Skip to content

Adds disabled checkbox text color #97

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/components/Checkbox/Checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ const Checkbox: FC<CheckboxProps> = props => {
let dynamicLabel: ReactNode = label;

if (typeof label === 'string') {
dynamicLabel = <Text fontSize={size}>{label}</Text>;
dynamicLabel = (
<Text disabled={disabled} fontSize={size}>
{label}
</Text>
);
}

return (
Expand Down
29 changes: 25 additions & 4 deletions src/components/Text/Text.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,31 @@ describe('Text', () => {
expect(render(<Text>Content</Text>).getByText('Content')).toBeInTheDocument();
});

it('has a dim color if weak property is set', () => {
expect(render(<Text weak />).container.firstChild).toHaveStyle(`
color: ${Colors.AUTHENTIC_BLUE_550};
`);
describe('if the weak property is set', () => {
it('has a dim color', () => {
expect(render(<Text weak />).container.firstChild).toHaveStyle(`
color: ${Colors.AUTHENTIC_BLUE_550};
`);
});

it('has a dimmer color if inverted', () => {
expect(render(<Text weak inverted />).container.firstChild).toHaveStyle(`
color: ${Colors.AUTHENTIC_BLUE_350};
`);
});
});

describe('if the disabled property is set', () => {
it('has the disabled color', () => {
expect(render(<Text disabled />).container.firstChild).toHaveStyle(`
color: ${Colors.AUTHENTIC_BLUE_350};
`);
});
it('has a stronger disabled color if inverted', () => {
expect(render(<Text disabled inverted />).container.firstChild).toHaveStyle(`
color: ${Colors.AUTHENTIC_BLUE_550};
`);
});
});

it('has a bright color if inverted property is set', () => {
Expand Down
14 changes: 11 additions & 3 deletions src/components/Text/Text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,19 @@ interface TextProps
* Adjust color to indicate secondary information
*/
weak?: boolean;
/**
* Adjust color to display a disabled text element
*/
disabled?: boolean;
}

function determineTextColor({ weak, inverted }: TextProps) {
if (weak || (weak && inverted)) {
return Colors.AUTHENTIC_BLUE_550;
function determineTextColor({ weak, inverted, disabled }: TextProps) {
if (disabled) {
return inverted ? Colors.AUTHENTIC_BLUE_550 : Colors.AUTHENTIC_BLUE_350;
}

if (weak) {
return inverted ? Colors.AUTHENTIC_BLUE_350 : Colors.AUTHENTIC_BLUE_550;
}

if (inverted) {
Expand Down
10 changes: 10 additions & 0 deletions src/components/Text/docs/Text.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,13 @@ The Text component is a wrapper component that will apply typography styles to t
<Text as="p" weak fontSize={1} inverted>paragraph weak inverted medium</Text>
<Text as="p" weak fontSize={0} inverted>paragraph weak inverted small</Text>
</ItemWrapper>
<ItemWrapper>
<Text as="p" disabled>paragraph disabled large</Text>
<Text as="p" disabled fontSize={1}>paragraph disabled medium</Text>
<Text as="p" disabled fontSize={0}>paragraph disabled small</Text>
</ItemWrapper>
<ItemWrapper inverted>
<Text as="p" disabled inverted>paragraph disabled inverted large</Text>
<Text as="p" disabled fontSize={1} inverted>paragraph disabled inverted medium</Text>
<Text as="p" disabled fontSize={0} inverted>paragraph disabled inverted small</Text>
</ItemWrapper>