-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Components: improve vertical and RTL support for Divider
#36579
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
16 commits
Select commit
Hold shift + click to select a range
7d38d63
Divider: add styles for `vertical` orientation
ciampo 69aea2e
Divider: depracate top/bottom margin props in favour of logical start…
ciampo 013188f
Divider: add Horizontal and Vertical storybook examples
ciampo e99640b
Divider: update example code snippets
ciampo aa56b5d
Divider: add Props section to README
ciampo c626dbd
CHANGELOG
ciampo 78c558c
Update snapshots
ciampo e299b20
Remove black border-color override in Storybook
ciampo 39a2b0a
Use `currentColor` for the border color
ciampo 1e42420
Update snapshots
ciampo 0851665
Update changelog
ciampo 748d2cc
Fix comments
ciampo 43780d3
Delete deprecated marginTop|Bottom props
ciampo d2e80b2
Divider: rewrite storybook examples using controls
ciampo 8d77fc6
Divider: add back `border: 0` reset
ciampo b160690
Update snapshots
ciampo 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
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
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,38 +1,64 @@ | ||
| /** | ||
| * External dependencies | ||
| */ | ||
| import { number } from '@storybook/addon-knobs'; | ||
| import { css } from '@emotion/react'; | ||
|
|
||
| /** | ||
| * Internal dependencies | ||
| */ | ||
| import { useCx } from '../../utils'; | ||
| import { Text } from '../../text'; | ||
| import { Divider } from '..'; | ||
|
|
||
| export default { | ||
| component: Divider, | ||
| title: 'Components (Experimental)/Divider', | ||
| parameters: { | ||
| knobs: { disabled: false }, | ||
| argTypes: { | ||
| margin: { | ||
| control: { type: 'number' }, | ||
| }, | ||
| marginStart: { | ||
| control: { type: 'number' }, | ||
| }, | ||
| marginEnd: { | ||
| control: { type: 'number' }, | ||
| }, | ||
| }, | ||
| }; | ||
|
|
||
| const BlackDivider = ( props ) => ( | ||
| <Divider { ...props } style={ { borderColor: 'black' } } /> | ||
| const HorizontalTemplate = ( args ) => ( | ||
| <div> | ||
| <Text>Some text before the divider</Text> | ||
| <Divider { ...args } /> | ||
| <Text>Some text after the divider</Text> | ||
| </div> | ||
| ); | ||
|
|
||
| export const _default = () => { | ||
| const props = { | ||
| margin: number( 'margin', 0 ), | ||
| }; | ||
| // make the border color black to give higher contrast and help it appear in storybook better | ||
| return <BlackDivider { ...props } />; | ||
| const VerticalTemplate = ( args ) => { | ||
| const cx = useCx(); | ||
| const wrapperClassName = cx( css` | ||
| display: flex; | ||
| align-items: stretch; | ||
| justify-content: start; | ||
| ` ); | ||
|
|
||
| return ( | ||
| <div className={ wrapperClassName }> | ||
| <Text>Some text before the divider</Text> | ||
| <Divider orientation="vertical" { ...args } /> | ||
| <Text>Some text after the divider</Text> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export const splitMargins = () => { | ||
| const props = { | ||
| marginTop: number( 'marginTop', 0 ), | ||
| marginBottom: number( 'marginBottom', 0 ), | ||
| }; | ||
| export const Horizontal = HorizontalTemplate.bind( {} ); | ||
| Horizontal.args = { | ||
| margin: 2, | ||
| marginStart: undefined, | ||
| marginEnd: undefined, | ||
| }; | ||
|
|
||
| return <BlackDivider { ...props } />; | ||
| export const Vertical = VerticalTemplate.bind( {} ); | ||
| Vertical.args = { | ||
| ...Horizontal.args, | ||
| }; |
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
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.