-
Notifications
You must be signed in to change notification settings - Fork 109
feat(ui-options,ui-select,ui-simple-select,ui-time-select): rework Select, SimpleSelect and TimeSelect #2465
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -71,7 +71,7 @@ const generateStyle = ( | |
| }, | ||
| 'selected-highlighted': { | ||
| background: componentTheme.selectedHighlightedBackground, | ||
| color: componentTheme.highlightedLabelColor | ||
| color: componentTheme.selectedLabelColor | ||
|
Comment on lines
73
to
+74
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 worked in the two old canvas themes, but in the new light theme, the label would be black on a dark background (bad visibility) and in the new dark theme it would be white on a white background (bad visibilty). So I changed this. You can check this on the first example of in Select. |
||
| }, | ||
| default: { | ||
| transition: 'background 200ms' | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| /* | ||
| * The MIT License (MIT) | ||
| * | ||
| * Copyright (c) 2015 - present Instructure, Inc. | ||
| * | ||
| * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| * of this software and associated documentation files (the "Software"), to deal | ||
| * in the Software without restriction, including without limitation the rights | ||
| * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| * copies of the Software, and to permit persons to whom the Software is | ||
| * furnished to do so, subject to the following conditions: | ||
| * | ||
| * The above copyright notice and this permission notice shall be included in all | ||
| * copies or substantial portions of the Software. | ||
| * | ||
| * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| * SOFTWARE. | ||
| */ | ||
|
|
||
| import { Component } from 'react' | ||
| import type { SelectGroupProps } from './props' | ||
| import { allowedProps } from './props' | ||
|
|
||
| /** | ||
| --- | ||
| parent: Select | ||
| id: Select.Group | ||
| --- | ||
| @module Group | ||
| **/ | ||
| class Group extends Component<SelectGroupProps> { | ||
| static readonly componentId = 'Select.Group' | ||
|
|
||
| static allowedProps = allowedProps | ||
|
|
||
| static defaultProps = {} | ||
|
|
||
| /* istanbul ignore next */ | ||
| render() { | ||
| // this component is only used for prop validation. Select.Group children | ||
| // are parsed in Select and rendered as Options components | ||
| return null | ||
| } | ||
| } | ||
|
|
||
| export default Group | ||
| export { Group } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| /* | ||
| * The MIT License (MIT) | ||
| * | ||
| * Copyright (c) 2015 - present Instructure, Inc. | ||
| * | ||
| * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| * of this software and associated documentation files (the "Software"), to deal | ||
| * in the Software without restriction, including without limitation the rights | ||
| * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| * copies of the Software, and to permit persons to whom the Software is | ||
| * furnished to do so, subject to the following conditions: | ||
| * | ||
| * The above copyright notice and this permission notice shall be included in all | ||
| * copies or substantial portions of the Software. | ||
| * | ||
| * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| * SOFTWARE. | ||
| */ | ||
| import React from 'react' | ||
|
|
||
| import type { OtherHTMLAttributes, Renderable } from '@instructure/shared-types' | ||
|
|
||
| type SelectGroupOwnProps = { | ||
| /** | ||
| * The label associated with the group options. | ||
| */ | ||
| renderLabel: Renderable | ||
| /** | ||
| * Children of type `<SimpleSelect.Option />` that will be considered part of the group. | ||
| */ | ||
| children?: React.ReactNode // TODO: ChildrenPropTypes.oneOf([Option]) | ||
| } | ||
|
|
||
| type PropKeys = keyof SelectGroupOwnProps | ||
|
|
||
| type AllowedPropKeys = Readonly<Array<PropKeys>> | ||
|
|
||
| type SelectGroupProps = SelectGroupOwnProps & | ||
| OtherHTMLAttributes<SelectGroupOwnProps> | ||
| const allowedProps: AllowedPropKeys = ['renderLabel', 'children'] | ||
|
|
||
| export type { SelectGroupProps } | ||
| export { allowedProps } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| /* | ||
| * The MIT License (MIT) | ||
| * | ||
| * Copyright (c) 2015 - present Instructure, Inc. | ||
| * | ||
| * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| * of this software and associated documentation files (the "Software"), to deal | ||
| * in the Software without restriction, including without limitation the rights | ||
| * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| * copies of the Software, and to permit persons to whom the Software is | ||
| * furnished to do so, subject to the following conditions: | ||
| * | ||
| * The above copyright notice and this permission notice shall be included in all | ||
| * copies or substantial portions of the Software. | ||
| * | ||
| * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| * SOFTWARE. | ||
| */ | ||
|
|
||
| import { Component } from 'react' | ||
| import type { SelectOptionProps } from './props' | ||
| import { allowedProps } from './props' | ||
|
|
||
| /** | ||
| --- | ||
| parent: Select | ||
| id: Select.Option | ||
| --- | ||
| @module Option | ||
| **/ | ||
| class Option extends Component<SelectOptionProps> { | ||
| static readonly componentId = 'Select.Option' | ||
|
|
||
| static allowedProps = allowedProps | ||
|
|
||
| static defaultProps = { | ||
| isHighlighted: false, | ||
| isSelected: false, | ||
| isDisabled: false | ||
| } | ||
|
|
||
| /* istanbul ignore next */ | ||
| render() { | ||
| // this component is only used for prop validation. Select.Option children | ||
| // are parsed in Select and rendered as Options.Item components | ||
| return null | ||
| } | ||
| } | ||
|
|
||
| export default Option | ||
| export { Option } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| /* | ||
| * The MIT License (MIT) | ||
| * | ||
| * Copyright (c) 2015 - present Instructure, Inc. | ||
| * | ||
| * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| * of this software and associated documentation files (the "Software"), to deal | ||
| * in the Software without restriction, including without limitation the rights | ||
| * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| * copies of the Software, and to permit persons to whom the Software is | ||
| * furnished to do so, subject to the following conditions: | ||
| * | ||
| * The above copyright notice and this permission notice shall be included in all | ||
| * copies or substantial portions of the Software. | ||
| * | ||
| * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| * SOFTWARE. | ||
| */ | ||
|
|
||
| import React from 'react' | ||
| import type { OtherHTMLAttributes, Renderable } from '@instructure/shared-types' | ||
|
|
||
| type OptionProps = { | ||
| /** | ||
| * The id for the option. **Must be globally unique**, it will be translated | ||
| * to an `id` prop in the DOM. | ||
| */ | ||
| id: string | ||
| /** | ||
| * Whether or not this option is highlighted. | ||
| */ | ||
| isHighlighted?: boolean | ||
| /** | ||
| * Whether or not this option is selected. | ||
| */ | ||
| isSelected?: boolean | ||
| /** | ||
| * Whether or not this option is disabled. | ||
| */ | ||
| isDisabled?: boolean | ||
| /** | ||
| * Content to display as the option label. | ||
| */ | ||
| children?: React.ReactNode | ||
| } | ||
|
|
||
| type RenderSelectOptionLabel = Renderable<OptionProps> | ||
|
|
||
| type SelectOptionOwnProps = OptionProps & { | ||
| /** | ||
| * Content to display before the option label, such as an icon. | ||
| */ | ||
| renderBeforeLabel?: RenderSelectOptionLabel | ||
| /** | ||
| * Content to display after the option label, such as an icon. | ||
| */ | ||
| renderAfterLabel?: RenderSelectOptionLabel | ||
| } | ||
|
|
||
| type PropKeys = keyof SelectOptionOwnProps | ||
|
|
||
| type AllowedPropKeys = Readonly<Array<PropKeys>> | ||
|
|
||
| type SelectOptionProps = SelectOptionOwnProps & | ||
| OtherHTMLAttributes<SelectOptionOwnProps> | ||
| const allowedProps: AllowedPropKeys = [ | ||
| 'id', | ||
| 'isHighlighted', | ||
| 'isSelected', | ||
| 'isDisabled', | ||
| 'renderBeforeLabel', | ||
| 'renderAfterLabel', | ||
| 'children' | ||
| ] | ||
|
|
||
| export type { SelectOptionProps, RenderSelectOptionLabel } | ||
| export { allowedProps } |
Uh oh!
There was an error while loading. Please reload this page.
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.
Paddig token was removed from TextInput so changing TextInputTheme to NewComponentTypes['TextInput'] in TextInput's props.ts resulted an error here so I fixed this.