Skip to content
This repository was archived by the owner on Mar 4, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
c2a6075
first implementation
silviuaavram Aug 14, 2019
7c2b8a8
shorthand on slots
silviuaavram Aug 15, 2019
2fa809b
fix the click handlers
silviuaavram Aug 15, 2019
5a0d4d9
addressed comments from PR
silviuaavram Aug 16, 2019
dae83d8
prevent default behavior
silviuaavram Aug 16, 2019
6efc1f4
address code review with ref
silviuaavram Aug 16, 2019
957bc85
moved it as a separate example
silviuaavram Aug 16, 2019
234cb99
changed the example content
silviuaavram Aug 16, 2019
961a1ec
replaced specification of behaviour
silviuaavram Aug 19, 2019
29e2ee9
address more code review
silviuaavram Aug 19, 2019
0af0dd3
add behavior in tests
silviuaavram Aug 19, 2019
9bb7324
moved behavior
silviuaavram Aug 19, 2019
a181fa6
add styles
silviuaavram Aug 19, 2019
7cbd2a1
focus button on select
silviuaavram Aug 19, 2019
8918159
some minor improvements
silviuaavram Aug 20, 2019
823df34
Merge branch 'master' into feat/split-button-component
silviuaavram Aug 20, 2019
9724971
Merge branch 'feat/split-button-component' of https://github.com/star…
silviuaavram Aug 20, 2019
e06b71e
updated styles
silviuaavram Aug 20, 2019
8da55ae
keep the Tab key handler
silviuaavram Aug 20, 2019
0fe1780
refactored buttons
silviuaavram Aug 22, 2019
1646922
Merge branch 'master' into feat/split-button-component
silviuaavram Aug 22, 2019
854c714
updates on styles and toggle close
silviuaavram Aug 22, 2019
e8247e0
Merge branch 'master' into feat/split-button-component
silviuaavram Aug 29, 2019
46d04c2
addressed code review
silviuaavram Aug 29, 2019
7004f13
fix behavior test
silviuaavram Aug 29, 2019
67276db
made component conformant
silviuaavram Aug 30, 2019
db03cda
defaultProp toggleButton
silviuaavram Aug 30, 2019
8967dd5
changelog
silviuaavram Aug 30, 2019
0e737a8
add more unit tests
silviuaavram Aug 30, 2019
96ea249
add more tests
silviuaavram Aug 30, 2019
79acfcb
fix focus style on toggle button
silviuaavram Aug 30, 2019
9c16898
more examples
silviuaavram Aug 30, 2019
036f844
changed the padding according to specs
silviuaavram Sep 2, 2019
a4edb37
Merge branch 'master' into feat/split-button-component
silviuaavram Sep 2, 2019
8d1623b
Merge branch 'feat/split-button-component' of https://github.com/star…
silviuaavram Sep 2, 2019
248f1b7
Merge branch 'master' into feat/split-button-component
silviuaavram Sep 5, 2019
b50c9df
code review integration
silviuaavram Sep 6, 2019
53f4986
use focus-visible in styles
silviuaavram Sep 6, 2019
3946e88
revert style slot rename
silviuaavram Sep 6, 2019
5de981c
add best practices
silviuaavram Sep 9, 2019
5b37e24
Merge branch 'master' into feat/split-button-component
silviuaavram Sep 9, 2019
4b04d21
Merge branch 'master' into feat/split-button-component
silviuaavram Sep 9, 2019
0b92870
Merge branch 'feat/split-button-component' of https://github.com/star…
silviuaavram Sep 10, 2019
59fb82e
fix variable name
silviuaavram Sep 10, 2019
ffc0d7d
update changelog
silviuaavram Sep 10, 2019
08bdb39
Merge branch 'master' into feat/split-button-component
silviuaavram Sep 10, 2019
e46250b
Merge branch 'feat/split-button-component' of https://github.com/star…
silviuaavram Sep 10, 2019
ea13424
call onOpenChange with this.props
silviuaavram Sep 12, 2019
d7f67e8
change onOpenChange prop type
silviuaavram Sep 12, 2019
56e38cf
Merge branch 'master' into feat/split-button-component
silviuaavram Sep 12, 2019
b7a4194
Merge branch 'feat/split-button-component' of https://github.com/star…
silviuaavram Sep 12, 2019
0e6ea21
changelog update
silviuaavram Sep 12, 2019
20b8fc0
integrate code review
silviuaavram Sep 12, 2019
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
### Features
- Add `TextArea` component @lucivpav ([#1897](https://github.com/stardust-ui/react/pull/1897))
- Export `bell-slash` and `bell-snooze` icon to Teams theme @musingh ([#1921](https://github.com/stardust-ui/react/pull/1921))
- Add the `SplitButton` component @silviuavram ([#1789](https://github.com/stardust-ui/react/pull/1798))

### Documentation
- Fix broken code editor in some doc site examples and improve error experience @levithomason ([#1906](https://github.com/stardust-ui/react/pull/1906))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const unsupportedComponents = [
'Portal',
'Provider',
'RadioGroup',
'SplitButton',
'Toolbar',
'Ref',
]
Expand Down
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
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
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
21 changes: 21 additions & 0 deletions docs/src/examples/components/SplitButton/Slots/index.tsx
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
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
15 changes: 15 additions & 0 deletions docs/src/examples/components/SplitButton/States/index.tsx
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
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
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
20 changes: 20 additions & 0 deletions docs/src/examples/components/SplitButton/Types/index.tsx
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
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
16 changes: 16 additions & 0 deletions docs/src/examples/components/SplitButton/Usage/index.tsx
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."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
description="A split button can have its main option changed based on last selection."
description="A SplitButton can have its main option changed based on last selection."

nit: to be consistent between sections

examplePath="components/SplitButton/Usage/SplitButtonMainOptionChangeExample"
/>
</ExampleSection>
)

export default Usage
15 changes: 15 additions & 0 deletions docs/src/examples/components/SplitButton/index.tsx
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
10 changes: 10 additions & 0 deletions packages/react/src/components/MenuButton/MenuButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ export interface MenuButtonProps extends StyledComponentProps<MenuButtonProps>,
/** Defines whether popup is displayed. */
open?: boolean

/**
* Called after user's click on a menu item.
*
* @param {SyntheticEvent} event - React's original SyntheticEvent.
* @param {object} data - All props.
*/
onMenuItemClick?: ComponentEventHandler<MenuItemProps>

/**
* Event for request to change 'open' value.
* @param {SyntheticEvent} event - React's original SyntheticEvent.
Expand Down Expand Up @@ -122,6 +130,7 @@ export default class MenuButton extends AutoControlledComponent<MenuButtonProps,
PropTypes.arrayOf(PropTypes.oneOf(['hover', 'focus', 'context'])),
]),
open: PropTypes.bool,
onMenuItemClick: PropTypes.func,
onOpenChange: PropTypes.func,
position: PropTypes.oneOf(POSITIONS),
target: PropTypes.any,
Expand Down Expand Up @@ -184,6 +193,7 @@ export default class MenuButton extends AutoControlledComponent<MenuButtonProps,
handleMenuOverrides = (predefinedProps?: MenuProps) => ({
onItemClick: (e: React.SyntheticEvent, itemProps: MenuItemProps) => {
_.invoke(predefinedProps, 'onItemClick', e, itemProps)
_.invoke(this.props, 'onMenuItemClick', e, itemProps)
if (!itemProps || !itemProps.menu) {
// do not close if clicked on item with submenu
this.setState({ open: false })
Expand Down
Loading