-
Notifications
You must be signed in to change notification settings - Fork 24
Improves Text component #170
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
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
c29dfad
feat: introduces `secondary`, deprecates `weak` prop
640e8cf
feat: makes disabled text color lighter
52d01e2
docs: adds props table
28b7ceb
fix: adjust the disabled color for inverted text
727197d
fix: adjust text tokens
9839961
refactor: applies semantic colors
ca23e71
docs: add usage guidelines
1a9d5f1
Merge branch 'main' into feat/improve-text-component
42cdd94
refactor: use semantic colors
f17cdba
docs: add more information about the props
bed464d
feat(text): show warning when deprecated `weak` prop is used
1d50fb5
test(text): update tests to use semantic colors
b622801
fix(text): use correct disabled inverted color
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,74 @@ | ||
import { render } from '@testing-library/react'; | ||
import * as React from 'react'; | ||
import { Colors } from '../../essentials'; | ||
import { SemanticColors } from '../../essentials/Colors/Colors'; | ||
|
||
import { Text } from './Text'; | ||
|
||
describe('Text', () => { | ||
it('renders a <span> by default', () => { | ||
expect(render(<Text />)).toMatchHtmlTag('span'); | ||
describe('default render', () => { | ||
it('renders a <span> by default', () => { | ||
expect(render(<Text />)).toMatchHtmlTag('span'); | ||
}); | ||
|
||
it('has a primary color by default', () => { | ||
expect(render(<Text />).container.firstChild).toHaveStyle(` | ||
color: ${SemanticColors.text.primary}; | ||
`); | ||
}); | ||
|
||
it('renders the children', () => { | ||
expect(render(<Text>Content</Text>).getByText('Content')).toBeInTheDocument(); | ||
}); | ||
}); | ||
|
||
it('respects the "as" prop', () => { | ||
expect(render(<Text as="b" />)).toMatchHtmlTag('b'); | ||
}); | ||
|
||
it('renders the children', () => { | ||
expect(render(<Text>Content</Text>).getByText('Content')).toBeInTheDocument(); | ||
it('has an inverted primary color if inverted property is set', () => { | ||
expect(render(<Text inverted />).container.firstChild).toHaveStyle(` | ||
color: ${SemanticColors.text.primaryInverted}; | ||
`); | ||
}); | ||
|
||
describe('if the weak property is set', () => { | ||
it('has a dim color', () => { | ||
expect(render(<Text weak />).container.firstChild).toHaveStyle(` | ||
color: ${Colors.AUTHENTIC_BLUE_550}; | ||
color: ${SemanticColors.text.secondary}; | ||
`); | ||
}); | ||
|
||
it('has a dimmer color if inverted', () => { | ||
expect(render(<Text weak inverted />).container.firstChild).toHaveStyle(` | ||
color: ${Colors.AUTHENTIC_BLUE_350}; | ||
color: ${SemanticColors.text.secondaryInverted}; | ||
`); | ||
}); | ||
}); | ||
|
||
describe('if the `secondary` property is set', () => { | ||
it('has a dim color', () => { | ||
expect(render(<Text secondary />).container.firstChild).toHaveStyle(` | ||
color: ${SemanticColors.text.secondary}; | ||
`); | ||
}); | ||
|
||
it('has a dimmer color if inverted', () => { | ||
expect(render(<Text secondary inverted />).container.firstChild).toHaveStyle(` | ||
color: ${SemanticColors.text.secondaryInverted}; | ||
`); | ||
}); | ||
}); | ||
|
||
describe('if the disabled property is set', () => { | ||
it('has the disabled color', () => { | ||
expect(render(<Text disabled />).container.firstChild).toHaveStyle(` | ||
color: ${Colors.AUTHENTIC_BLUE_350}; | ||
color: ${SemanticColors.text.disabled}; | ||
`); | ||
}); | ||
it('has a stronger disabled color if inverted', () => { | ||
expect(render(<Text disabled inverted />).container.firstChild).toHaveStyle(` | ||
color: ${Colors.AUTHENTIC_BLUE_550}; | ||
color: ${SemanticColors.text.disabledInverted}; | ||
`); | ||
}); | ||
}); | ||
|
||
it('has a bright color if inverted property is set', () => { | ||
expect(render(<Text inverted />).container.firstChild).toHaveStyle(` | ||
color: ${Colors.WHITE}; | ||
`); | ||
}); | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import * as React from 'react'; | ||
import { PropsTable } from '../../../docs/PropsTable'; | ||
|
||
export const TextPropsTable = () => { | ||
const props = [ | ||
nlopin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
name: 'fontWeight', | ||
type: '"normal" | "semibold" | "bold"', | ||
description: 'The font-weight property specifies the weight (or boldness) of the font', | ||
defaultValue: '"normal"' | ||
}, | ||
{ | ||
name: 'disabled', | ||
type: 'boolean', | ||
description: | ||
'Adjust color to display a disabled text element. Takes precedence over `inverted` and `secondary` props', | ||
defaultValue: 'false' | ||
}, | ||
{ | ||
name: 'inverted', | ||
type: 'boolean', | ||
description: 'Adjust color for display on a dark background', | ||
defaultValue: 'false' | ||
}, | ||
{ | ||
name: 'secondary', | ||
type: 'boolean', | ||
description: 'Adjust color to indicate secondary information', | ||
defaultValue: 'false' | ||
}, | ||
{ | ||
name: 'weak (deprecated)', | ||
type: 'boolean', | ||
description: 'Same as `secondary`', | ||
defaultValue: 'false' | ||
} | ||
]; | ||
return <PropsTable props={props} />; | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.