Skip to content

Commit

Permalink
fix: pr feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgemoya committed Jul 6, 2023
1 parent 84cc4e1 commit 393e7bc
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 31 deletions.
6 changes: 3 additions & 3 deletions packages/big-design/src/components/Form/Label/Label.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ import React, { LabelHTMLAttributes } from 'react';

import { StyledLabel } from './styled';

interface Localization {
export interface LabelLocalization {
optional: string;
}

const defaultLocalization: Localization = {
const defaultLocalization: LabelLocalization = {
optional: 'optional',
};

export interface LabelProps extends LabelHTMLAttributes<HTMLLabelElement> {
renderOptional?: boolean;
localization?: Localization;
localization?: LabelLocalization;
}

export const FormControlLabel: React.FC<LabelProps> = ({
Expand Down
7 changes: 4 additions & 3 deletions packages/big-design/src/components/Form/Label/styled.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import styled, { css, DefaultTheme, StyledComponent } from 'styled-components';
import { StyleableH4 } from '../../Typography/private';
import { HeadingProps } from '../../Typography/types';

import { LabelProps } from './Label';
import { LabelLocalization, LabelProps } from './Label';

interface StyledLabelArgument extends LabelProps {
interface StyledLabelArgument extends Omit<LabelProps, 'localization'> {
theme: DefaultTheme;
localization: LabelLocalization;
}

export const StyledLabel = styled<
Expand All @@ -24,7 +25,7 @@ export const StyledLabel = styled<
css`
&::after {
color: ${theme.colors.secondary60};
content: ' (${localization?.optional})';
content: ' (${localization.optional})';
font-weight: ${theme.typography.fontWeight.regular};
}
`}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ import {
StyledMessageItem,
} from './styled';

interface Localization {
export interface InlineMessageLocalization {
close: string;
}

const defaultLocalization: Localization = {
const defaultLocalization: InlineMessageLocalization = {
close: 'Close',
};

export type InlineMessageProps = SharedMessagingProps &
MarginProps & { localization?: Localization };
MarginProps & { localization?: InlineMessageLocalization };

export const InlineMessage: React.FC<InlineMessageProps> = memo(
({ className, style, header, localization = defaultLocalization, ...props }) => {
Expand Down
7 changes: 4 additions & 3 deletions packages/big-design/src/components/Message/Message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@ import {
StyledMessageItem,
} from './styled';

interface Localization {
export interface MessageLocalization {
close: string;
}

const defaultLocalization: Localization = {
const defaultLocalization: MessageLocalization = {
close: 'Close',
};

export type MessageProps = SharedMessagingProps & MarginProps & { localization?: Localization };
export type MessageProps = SharedMessagingProps &
MarginProps & { localization?: MessageLocalization };

export const Message: React.FC<MessageProps> = memo(
({ className, localization = defaultLocalization, style, header, ...props }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ const InternalStatefulTable = <T extends TableItem>({
itemName,
items = [],
keyField,
localization: localizationProp,
localization: localizationProp = defaultLocalization,
getRangeLabel,
onSelectionChange,
onRowDrop,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ interface Localization {
descendingOrder: string;
}

const defaultLocalization: Localization = {
ascendingOrder: 'Ascending order',
descendingOrder: 'Descending order',
};

export interface HeaderCellProps<T>
extends TableHTMLAttributes<HTMLTableCellElement>,
TableColumnDisplayProps {
Expand All @@ -33,7 +28,7 @@ export interface HeaderCellProps<T>
id: string;
hide?: boolean;
isSorted?: boolean;
localization?: Localization;
localization: Localization;
sortDirection?: 'ASC' | 'DESC';
stickyHeader?: boolean;
onSortClick?(column: TableColumn<T>): void;
Expand All @@ -57,7 +52,7 @@ const InternalHeaderCell = <T extends TableItem>({
hide = false,
id,
isSorted,
localization = defaultLocalization,
localization,
onSortClick,
sortDirection,
stickyHeader,
Expand Down
12 changes: 11 additions & 1 deletion packages/big-design/src/components/Table/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ import { Row } from './Row';
import { StyledTable, StyledTableFigure } from './styled';
import { TableColumn, TableItem, TableProps } from './types';

interface Localization {
ascendingOrder: string;
descendingOrder: string;
}

const defaultLocalization: Localization = {
ascendingOrder: 'Ascending order',
descendingOrder: 'Descending order',
};

const InternalTable = <T extends TableItem>(
props: TableProps<T>,
): React.ReactElement<TableProps<T>> => {
Expand All @@ -27,7 +37,7 @@ const InternalTable = <T extends TableItem>(
itemName,
items,
keyField = 'id',
localization,
localization = defaultLocalization,
onRowDrop,
pagination,
selectable,
Expand Down
1 change: 0 additions & 1 deletion packages/big-design/src/components/Table/spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,6 @@ test('renders a pagination component with custom button labels', async () => {
getRangeLabel,
label: '[Custom] Pagination',
localization: {
of: 'of',
previousPage: '[Custom] Previous page',
nextPage: '[Custom] Next page',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ interface Localization {
descendingOrder: string;
}

const defaultLocalization: Localization = {
ascendingOrder: 'Ascending order',
descendingOrder: 'Descending order',
};

export interface HeaderCellProps<T>
extends TableHTMLAttributes<HTMLTableCellElement>,
TableColumnDisplayProps {
Expand All @@ -33,7 +28,7 @@ export interface HeaderCellProps<T>
id: string;
hide?: boolean;
isSorted?: boolean;
localization?: Localization;
localization: Localization;
sortDirection?: 'ASC' | 'DESC';
stickyHeader?: boolean;
onSortClick?(column: TableColumn<T>): void;
Expand All @@ -57,7 +52,7 @@ const InternalHeaderCell = <T extends TableItem>({
hide = false,
id,
isSorted,
localization = defaultLocalization,
localization,
onSortClick,
sortDirection,
stickyHeader,
Expand Down
12 changes: 11 additions & 1 deletion packages/big-design/src/components/TableNext/TableNext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ import { RowContainer } from './RowContainer';
import { StyledTable, StyledTableFigure } from './styled';
import { TableColumn, TableItem, TableProps } from './types';

interface Localization {
ascendingOrder: string;
descendingOrder: string;
}

const defaultLocalization: Localization = {
ascendingOrder: 'Ascending order',
descendingOrder: 'Descending order',
};

const InternalTableNext = <T extends TableItem>(
props: TableProps<T>,
): React.ReactElement<TableProps<T>> => {
Expand All @@ -33,7 +43,7 @@ const InternalTableNext = <T extends TableItem>(
itemName,
items,
keyField = 'id',
localization,
localization = defaultLocalization,
pagination,
selectable,
sortable,
Expand Down
1 change: 0 additions & 1 deletion packages/big-design/src/components/TableNext/spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,6 @@ describe('pagination', () => {
onPageChange,
label: '[Custom] Pagination',
localization: {
of: 'of',
previousPage: '[Custom] Previous page',
nextPage: '[Custom] Next page',
},
Expand Down

0 comments on commit 393e7bc

Please sign in to comment.