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(Dropdown): add checkable and checkableIndicator prop #1738
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
f6e526b
-added selectedIndicator prop
3aaaf96
Merge branch 'master' into feat/dropdown-selected-checkmark
7e0c835
-updated changelog
1fc5d25
-reverted description changes
e177ca7
-fixed height issues
0f690f0
-changed API
a2e3d68
-updated changelog
4497fa8
-added new props in the prop types
c6ef338
-fixed aria selected for single selection
7c72c3e
Merge branch 'master' into feat/dropdown-selected-checkmark
mnajdova fd7b00e
Update CHANGELOG.md
mnajdova 6da3e7c
Merge branch 'master' into feat/dropdown-selected-checkmark
mnajdova ab89e28
Merge branch 'master' into feat/dropdown-selected-checkmark
mnajdova 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,13 +7,15 @@ import { UIComponent, RenderResultConfig, createShorthandFactory, commonPropType | |
| import { ShorthandValue, ComponentEventHandler, WithAsProp, withSafeTypeForAs } from '../../types' | ||
| import { UIComponentProps } from '../../lib/commonPropInterfaces' | ||
| import ListItem from '../List/ListItem' | ||
| import Icon, { IconProps } from '../Icon/Icon' | ||
| import Image, { ImageProps } from '../Image/Image' | ||
| import Box, { BoxProps } from '../Box/Box' | ||
|
|
||
| export interface DropdownItemSlotClassNames { | ||
| content: string | ||
| header: string | ||
| image: string | ||
| checkableIndicator: string | ||
| } | ||
|
|
||
| export interface DropdownItemProps extends UIComponentProps<DropdownItemProps> { | ||
|
|
@@ -26,6 +28,12 @@ export interface DropdownItemProps extends UIComponentProps<DropdownItemProps> { | |
| /** Item's content. */ | ||
| content?: ShorthandValue<BoxProps> | ||
|
|
||
| /** Item can show check indicator if selected. */ | ||
| checkable?: boolean | ||
|
|
||
| /** A slot for a checkable indicator. */ | ||
| checkableIndicator?: ShorthandValue<IconProps> | ||
|
|
||
| /** Item's header. */ | ||
| header?: ShorthandValue<BoxProps> | ||
|
|
||
|
|
@@ -65,6 +73,8 @@ class DropdownItem extends UIComponent<WithAsProp<DropdownItemProps>> { | |
| accessibilityItemProps: PropTypes.object, | ||
| active: PropTypes.bool, | ||
| content: customPropTypes.itemShorthand, | ||
| checkable: PropTypes.bool, | ||
| checkableIndicator: customPropTypes.itemShorthandWithoutJSX, | ||
| header: customPropTypes.itemShorthand, | ||
| image: customPropTypes.itemShorthandWithoutJSX, | ||
| onClick: PropTypes.func, | ||
|
|
@@ -77,7 +87,15 @@ class DropdownItem extends UIComponent<WithAsProp<DropdownItemProps>> { | |
| } | ||
|
|
||
| renderComponent({ classes, styles, unhandledProps }: RenderResultConfig<DropdownItemProps>) { | ||
| const { content, header, image, accessibilityItemProps } = this.props | ||
| const { | ||
| content, | ||
| header, | ||
| image, | ||
| accessibilityItemProps, | ||
| selected, | ||
| checkable, | ||
| checkableIndicator, | ||
| } = this.props | ||
| return ( | ||
| <ListItem | ||
| className={DropdownItem.className} | ||
|
|
@@ -102,6 +120,18 @@ class DropdownItem extends UIComponent<WithAsProp<DropdownItemProps>> { | |
| styles: styles.content, | ||
| }, | ||
| })} | ||
| endMedia={ | ||
|
Contributor
Author
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. This is different then how the rest of the elements are created and where the styles are applied, but there are issues with the height if we don't provide these styles.. I am open for other ideas...
Contributor
Author
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. |
||
| selected && | ||
| checkable && { | ||
| content: Icon.create(checkableIndicator, { | ||
| defaultProps: { | ||
| className: DropdownItem.slotClassNames.checkableIndicator, | ||
| styles: styles.checkableIndicator, | ||
| }, | ||
| }), | ||
| styles: styles.endMedia, | ||
| } | ||
| } | ||
| truncateContent | ||
| truncateHeader | ||
| {...accessibilityItemProps} | ||
|
|
@@ -115,6 +145,7 @@ DropdownItem.slotClassNames = { | |
| content: `${DropdownItem.className}__content`, | ||
| header: `${DropdownItem.className}__header`, | ||
| image: `${DropdownItem.className}__image`, | ||
| checkableIndicator: `${DropdownItem.className}__checkable-indicator`, | ||
| } | ||
|
|
||
| DropdownItem.create = createShorthandFactory({ Component: DropdownItem, mappedProp: 'header' }) | ||
|
|
||
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 |
|---|---|---|
|
|
@@ -59,6 +59,13 @@ const dropdownItemStyles: ComponentSlotStylesInput<DropdownItemProps, DropdownVa | |
| fontSize: v.listItemContentFontSize, | ||
| color: v.listItemContentColor, | ||
| }), | ||
| checkableIndicator: ({ variables: v }) => ({ | ||
| position: 'relative', | ||
| left: pxToRem(3), | ||
|
Contributor
Author
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. The padding on the |
||
| }), | ||
| endMedia: () => ({ | ||
| lineHeight: pxToRem(16), | ||
| }), | ||
| } | ||
|
|
||
| export default dropdownItemStyles | ||
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.
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.
fixed prop type