This repository was archived by the owner on Mar 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 51
feat: SplitButton component #1798
Merged
Merged
Changes from all commits
Commits
Show all changes
53 commits
Select commit
Hold shift + click to select a range
c2a6075
first implementation
silviuaavram 7c2b8a8
shorthand on slots
silviuaavram 2fa809b
fix the click handlers
silviuaavram 5a0d4d9
addressed comments from PR
silviuaavram dae83d8
prevent default behavior
silviuaavram 6efc1f4
address code review with ref
silviuaavram 957bc85
moved it as a separate example
silviuaavram 234cb99
changed the example content
silviuaavram 961a1ec
replaced specification of behaviour
silviuaavram 29e2ee9
address more code review
silviuaavram 0af0dd3
add behavior in tests
silviuaavram 9bb7324
moved behavior
silviuaavram a181fa6
add styles
silviuaavram 7cbd2a1
focus button on select
silviuaavram 8918159
some minor improvements
silviuaavram 823df34
Merge branch 'master' into feat/split-button-component
silviuaavram 9724971
Merge branch 'feat/split-button-component' of https://github.com/star…
silviuaavram e06b71e
updated styles
silviuaavram 8da55ae
keep the Tab key handler
silviuaavram 0fe1780
refactored buttons
silviuaavram 1646922
Merge branch 'master' into feat/split-button-component
silviuaavram 854c714
updates on styles and toggle close
silviuaavram e8247e0
Merge branch 'master' into feat/split-button-component
silviuaavram 46d04c2
addressed code review
silviuaavram 7004f13
fix behavior test
silviuaavram 67276db
made component conformant
silviuaavram db03cda
defaultProp toggleButton
silviuaavram 8967dd5
changelog
silviuaavram 0e737a8
add more unit tests
silviuaavram 96ea249
add more tests
silviuaavram 79acfcb
fix focus style on toggle button
silviuaavram 9c16898
more examples
silviuaavram 036f844
changed the padding according to specs
silviuaavram a4edb37
Merge branch 'master' into feat/split-button-component
silviuaavram 8d1623b
Merge branch 'feat/split-button-component' of https://github.com/star…
silviuaavram 248f1b7
Merge branch 'master' into feat/split-button-component
silviuaavram b50c9df
code review integration
silviuaavram 53f4986
use focus-visible in styles
silviuaavram 3946e88
revert style slot rename
silviuaavram 5de981c
add best practices
silviuaavram 5b37e24
Merge branch 'master' into feat/split-button-component
silviuaavram 4b04d21
Merge branch 'master' into feat/split-button-component
silviuaavram 0b92870
Merge branch 'feat/split-button-component' of https://github.com/star…
silviuaavram 59fb82e
fix variable name
silviuaavram ffc0d7d
update changelog
silviuaavram 08bdb39
Merge branch 'master' into feat/split-button-component
silviuaavram e46250b
Merge branch 'feat/split-button-component' of https://github.com/star…
silviuaavram ea13424
call onOpenChange with this.props
silviuaavram d7f67e8
change onOpenChange prop type
silviuaavram 56e38cf
Merge branch 'master' into feat/split-button-component
silviuaavram b7a4194
Merge branch 'feat/split-button-component' of https://github.com/star…
silviuaavram 0e6ea21
changelog update
silviuaavram 20b8fc0
integrate code review
silviuaavram 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
16 changes: 16 additions & 0 deletions
16
docs/src/examples/components/SplitButton/BestPractices/SplitButtonBestPractices.tsx
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,16 @@ | ||
| import * as React from 'react' | ||
|
|
||
| import ComponentBestPractices from 'docs/src/components/ComponentBestPractices' | ||
|
|
||
| const doList = [ | ||
| 'Use `aria-roledescription` with the value of `splitbutton` on the `button` slot to announce the proper semantics of the component.', | ||
| 'Use `aria-describedby` on the `button` slot and an invisible text element to announce that the split button can be opened by Alt+ArrowDown.', | ||
| ] | ||
|
|
||
| const dontList = [] | ||
|
|
||
| const SplitButtonBestPractices: React.FunctionComponent<{}> = () => { | ||
| return <ComponentBestPractices doList={doList} dontList={dontList} /> | ||
| } | ||
|
|
||
| export default SplitButtonBestPractices |
32 changes: 32 additions & 0 deletions
32
.../src/examples/components/SplitButton/Slots/SplitButtonIconAndContentExample.shorthand.tsx
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,32 @@ | ||
| import * as React from 'react' | ||
| import { SplitButton } from '@stardust-ui/react' | ||
|
|
||
| const items = [ | ||
| { | ||
| key: 'pdf', | ||
| content: 'Export to PDF', | ||
| icon: 'files-pdf', | ||
| }, | ||
| { | ||
| key: 'pds', | ||
| content: 'Export to PDS', | ||
| icon: 'files-photoshop', | ||
| }, | ||
| { | ||
| key: 'gif', | ||
| content: 'Export as GIF', | ||
| icon: 'files-gif', | ||
| disabled: true, | ||
| }, | ||
| { | ||
| key: 'eps', | ||
| content: 'Export to EPS', | ||
| icon: 'files-illustrator', | ||
| }, | ||
| ] | ||
|
|
||
| const SplitButtonIconAndContentExampleShorthand = () => ( | ||
| <SplitButton menu={items} button={items[0]} /> | ||
| ) | ||
|
|
||
| export default SplitButtonIconAndContentExampleShorthand |
21 changes: 21 additions & 0 deletions
21
docs/src/examples/components/SplitButton/Slots/SplitButtonToggleButtonExample.shorthand.tsx
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,21 @@ | ||
| import { useBooleanKnob } from '@stardust-ui/docs-components' | ||
| import { SplitButton } from '@stardust-ui/react' | ||
| import * as React from 'react' | ||
|
|
||
| const SplitButtonExampleToggleButtonShorthand = () => { | ||
| const [open, setOpen] = useBooleanKnob({ name: 'open' }) | ||
|
|
||
| return ( | ||
| <SplitButton | ||
| menu={[ | ||
| { key: 'group', content: 'New group message' }, | ||
| { key: 'channel', content: 'New channel message' }, | ||
| ]} | ||
| button="New conversation" | ||
| toggleButton={{ icon: open ? 'triangle-up' : 'triangle-down' }} | ||
| onOpenChange={(e, { open }) => setOpen(open)} | ||
| /> | ||
| ) | ||
| } | ||
|
|
||
| export default SplitButtonExampleToggleButtonShorthand |
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,21 @@ | ||
| import * as React from 'react' | ||
|
|
||
| import ComponentExample from 'docs/src/components/ComponentDoc/ComponentExample' | ||
| import ExampleSection from 'docs/src/components/ComponentDoc/ExampleSection' | ||
|
|
||
| const Slots = () => ( | ||
| <ExampleSection title="Slots"> | ||
| <ComponentExample | ||
| title="Icon and Content" | ||
| description="A Split Button can have icon next to content." | ||
| examplePath="components/SplitButton/Slots/SplitButtonIconAndContentExample" | ||
| /> | ||
| <ComponentExample | ||
| title="Toggle Button" | ||
| description="A Split Button can have its toggle button customized." | ||
| examplePath="components/SplitButton/Slots/SplitButtonToggleButtonExample" | ||
| /> | ||
| </ExampleSection> | ||
| ) | ||
|
|
||
| export default Slots |
15 changes: 15 additions & 0 deletions
15
docs/src/examples/components/SplitButton/States/SplitButtonExampleDisabled.shorthand.tsx
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,15 @@ | ||
| import * as React from 'react' | ||
| import { SplitButton } from '@stardust-ui/react' | ||
|
|
||
| const SplitButtonExampleDisabledShorthand = () => ( | ||
| <SplitButton | ||
| disabled | ||
| menu={[ | ||
| { key: 'group', content: 'New group message' }, | ||
| { key: 'channel', content: 'New channel message' }, | ||
| ]} | ||
| button="New conversation" | ||
| /> | ||
| ) | ||
|
|
||
| export default SplitButtonExampleDisabledShorthand |
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,15 @@ | ||
| import * as React from 'react' | ||
| import ComponentExample from 'docs/src/components/ComponentDoc/ComponentExample' | ||
| import ExampleSection from 'docs/src/components/ComponentDoc/ExampleSection' | ||
|
|
||
| const States = () => ( | ||
| <ExampleSection title="States"> | ||
| <ComponentExample | ||
| title="Disabled" | ||
| description="A SplitButton can be disabled." | ||
| examplePath="components/SplitButton/States/SplitButtonExampleDisabled" | ||
| /> | ||
| </ExampleSection> | ||
| ) | ||
|
|
||
| export default States |
14 changes: 14 additions & 0 deletions
14
docs/src/examples/components/SplitButton/Types/SplitButtonExample.shorthand.tsx
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,14 @@ | ||
| import * as React from 'react' | ||
| import { SplitButton } from '@stardust-ui/react' | ||
|
|
||
| const SplitButtonExampleShorthand = () => ( | ||
| <SplitButton | ||
| menu={[ | ||
| { key: 'group', content: 'New group message' }, | ||
| { key: 'channel', content: 'New channel message' }, | ||
| ]} | ||
| button="New conversation" | ||
| /> | ||
| ) | ||
|
|
||
| export default SplitButtonExampleShorthand | ||
15 changes: 15 additions & 0 deletions
15
docs/src/examples/components/SplitButton/Types/SplitButtonExamplePrimary.shorthand.tsx
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,15 @@ | ||
| import * as React from 'react' | ||
| import { SplitButton } from '@stardust-ui/react' | ||
|
|
||
| const SplitButtonExamplePrimaryShorthand = () => ( | ||
| <SplitButton | ||
| menu={[ | ||
| { key: 'group', content: 'New group message' }, | ||
| { key: 'channel', content: 'New channel message' }, | ||
| ]} | ||
| button="New conversation" | ||
| primary | ||
| /> | ||
| ) | ||
|
|
||
| export default SplitButtonExamplePrimaryShorthand |
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,20 @@ | ||
| import * as React from 'react' | ||
| import ComponentExample from 'docs/src/components/ComponentDoc/ComponentExample' | ||
| import ExampleSection from 'docs/src/components/ComponentDoc/ExampleSection' | ||
|
|
||
| const SplitButton = () => ( | ||
| <ExampleSection title="Split Button"> | ||
| <ComponentExample | ||
| title="Split Button" | ||
| description="Buttons can be split into action and toggle." | ||
| examplePath="components/SplitButton/Types/SplitButtonExample" | ||
| /> | ||
| <ComponentExample | ||
| title="Emphasis" | ||
| description="A SplitButton can be formatted to show primary level of emphasis." | ||
| examplePath="components/SplitButton/Types/SplitButtonExamplePrimary" | ||
| /> | ||
| </ExampleSection> | ||
| ) | ||
|
|
||
| export default SplitButton |
27 changes: 27 additions & 0 deletions
27
...rc/examples/components/SplitButton/Usage/SplitButtonMainOptionChangeExample.shorthand.tsx
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,27 @@ | ||
| import { useNumberKnob } from '@stardust-ui/docs-components' | ||
| import { SplitButton } from '@stardust-ui/react' | ||
| import * as React from 'react' | ||
|
|
||
| const items = [ | ||
| { key: 'group', content: 'New group message' }, | ||
| { key: 'channel', content: 'New channel message' }, | ||
| { key: 'conversation', content: 'New conversation' }, | ||
| ] | ||
|
|
||
| const SplitButtonExampleMenuShorthand = () => { | ||
| const [activeIndex, setActiveIndex] = useNumberKnob({ name: 'activeIndex' }) | ||
| const activeItem = items[activeIndex] | ||
|
|
||
| return ( | ||
| <SplitButton | ||
| button={activeItem} | ||
| menu={{ | ||
| activeIndex, | ||
| items, | ||
| }} | ||
| onMenuItemClick={(e, { index }) => setActiveIndex(index)} | ||
| /> | ||
| ) | ||
| } | ||
|
|
||
| export default SplitButtonExampleMenuShorthand |
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,16 @@ | ||||||
| import * as React from 'react' | ||||||
|
|
||||||
| import ComponentExample from 'docs/src/components/ComponentDoc/ComponentExample' | ||||||
| import ExampleSection from 'docs/src/components/ComponentDoc/ExampleSection' | ||||||
|
|
||||||
| const Usage = () => ( | ||||||
| <ExampleSection title="Usage"> | ||||||
| <ComponentExample | ||||||
| title="Main option change" | ||||||
| description="A split button can have its main option changed based on last selection." | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
nit: to be consistent between sections |
||||||
| examplePath="components/SplitButton/Usage/SplitButtonMainOptionChangeExample" | ||||||
| /> | ||||||
| </ExampleSection> | ||||||
| ) | ||||||
|
|
||||||
| export default Usage | ||||||
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,15 @@ | ||
| import * as React from 'react' | ||
|
|
||
| import Types from './Types' | ||
| import States from './States' | ||
| import Slots from './Slots' | ||
|
|
||
| const SplitButtonExamples = () => ( | ||
| <> | ||
| <Types /> | ||
| <States /> | ||
| <Slots /> | ||
| </> | ||
| ) | ||
|
|
||
| export default SplitButtonExamples |
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
Oops, something went wrong.
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.