-
Notifications
You must be signed in to change notification settings - Fork 18
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
Refactor Dropdowns #125
Refactor Dropdowns #125
Conversation
return emptyText | ||
} | ||
|
||
private get menuOptions(): JSX.Element[] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be its own component?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Normally I'd say yes but in this case I like having the "composed" components as a single file
const {className} = this.props | ||
|
||
return classnames('dropdown', { | ||
className: className, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
className: className, | |
className, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah looks like I have to do [
${className}]: className
because that coerces className
to be of type string
. classnames
does not like that className
is of type string | undefined
. This might be a larger change since all clockface components handle className
this way.
I created an issue for this: #128
} | ||
|
||
export class DropdownDivider extends Component<Props> { | ||
public static defaultProps = { | ||
testID: 'dropdown--divider', | ||
testID: 'dropdown-divider', | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
newline
className={classnames('dropdown--divider', {line: !text})} | ||
className={classnames('dropdown-divider', { | ||
line: !text, | ||
[`${className}`]: className, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[`${className}`]: className, | |
[className]: className, |
|
||
if (checkbox) { | ||
if (type === DropdownItemType.Checkbox) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could be a good switch case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup yup good call
const {theme} = this.props | ||
|
||
switch (theme) { | ||
case DropdownMenuTheme.Malachite: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like this would be a good constant to extract where a theme enum key's a thumb colors object
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These menu "themes" might not live that much longer as we eventually plan to use the Gradients
enum instead
Closes #126
Overview
Dropdowns have been broken down into a set of components that are indepenent of each other and only worry about individual aspects of the dropdown's behavior. Rather than a super customizable
Dropdown
component we have exposed all the inner workings to be customized directly. In pursuit of theFamily / Composed
pattern found in some other Clockface components the Dropdown family is now completely transparent and composable. This unfortunately is a breaking change to Dropdowns and will cause some tech debt.Changes
Dropdown
has 2 render props (Button and Menu) and only handles opening/closing the dropdownDropdown
no longer cares about what its children areDropdownMenu
into own componentDropdownMenuColors
-->DropdownMenuTheme
DropdownItem
has atype
prop which controls appearance when selected and can beNone | Dot | Checkbox
DropdownItem
hasselected
andonClick
requiredDropdown
no longer passes down any props or functions toDropdownItems
so they must be manually wired upDropdownButton
can be whatever you wantSelectDropdown
that behaves like the HTML Select component as a composed variation of the DropdownMultiSelectDropdown
as another composed variation of DropdownDropdownLinkItem
for using<a>
or<Link>
as dropdown itemsFuture Work
#127
#61