Skip to content

Commit 4101f8d

Browse files
committed
style(ui-select,ui-options,shared-types): add new color to selected and at the same time highlighted options
INSTUI-4537
1 parent e69f4ae commit 4101f8d

File tree

5 files changed

+21
-11
lines changed

5 files changed

+21
-11
lines changed

packages/shared-types/src/ComponentThemeVariables.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -943,12 +943,13 @@ export type OptionsItemTheme = {
943943
fontFamily: Typography['fontFamily']
944944
fontWeight: Typography['fontWeightNormal']
945945
lineHeight: Typography['lineHeightCondensed']
946-
color: Colors['contrasts']['grey125125']
947-
background: Colors['contrasts']['white1010']
948-
highlightedLabelColor: Colors['contrasts']['white1010']
949-
highlightedBackground: Colors['contrasts']['blue4570']
950-
selectedLabelColor: Colors['contrasts']['white1010']
951-
selectedBackground: Colors['contrasts']['grey4570']
946+
color: string
947+
background: string
948+
highlightedLabelColor: string
949+
highlightedBackground: string
950+
selectedLabelColor: string
951+
selectedBackground: string
952+
selectedHighlightedBackground: string
952953
padding: string | 0
953954
iconPadding: Spacing['small']
954955
nestedPadding: Spacing['medium']
@@ -958,7 +959,7 @@ export type OptionsItemTheme = {
958959
descriptionFontWeight: Typography['fontWeightNormal']
959960
descriptionLineHeight: Typography['lineHeight']
960961
descriptionPaddingStart: string | 0
961-
descriptionColor: Colors['contrasts']['grey4570']
962+
descriptionColor: string
962963
fontWeightSelected: Typography['fontWeightNormal']
963964
}
964965

packages/ui-options/src/Options/Item/props.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ type OptionsItemRenderProps = {
4949
| 'selected'
5050
| 'disabled'
5151
| 'highlighted-disabled'
52+
| 'selected-highlighted'
5253
/**
5354
* The ARIA role of the element
5455
*/
@@ -125,7 +126,8 @@ const propTypes: PropValidators<PropKeys> = {
125126
'highlighted',
126127
'selected',
127128
'disabled',
128-
'highlighted-disabled'
129+
'highlighted-disabled',
130+
'selected-highlighted'
129131
]),
130132
role: PropTypes.string,
131133
renderBeforeLabel: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),

packages/ui-options/src/Options/Item/styles.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,16 @@ const generateStyle = (
6464
color: componentTheme.highlightedLabelColor
6565
},
6666
disabled: { cursor: 'not-allowed', opacity: 0.5 },
67-
['highlighted-disabled']: {
67+
'highlighted-disabled': {
6868
background: componentTheme.highlightedBackground,
6969
color: componentTheme.highlightedLabelColor,
7070
cursor: 'not-allowed',
7171
opacity: 0.5
7272
},
73+
'selected-highlighted': {
74+
background: componentTheme.selectedHighlightedBackground,
75+
color: componentTheme.highlightedLabelColor
76+
},
7377
default: {
7478
transition: 'background 200ms'
7579
}

packages/ui-options/src/Options/Item/theme.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ const generateComponentTheme = (theme: Theme): OptionsItemTheme => {
5353
highlightedBackground: colors?.contrasts?.blue4570,
5454
selectedLabelColor: colors?.contrasts?.white1010,
5555
selectedBackground: colors?.contrasts?.grey4570,
56+
selectedHighlightedBackground: colors?.contrasts?.blue5782,
5657

5758
padding: `${spacing?.xSmall} ${spacing?.small}`,
5859
iconPadding: spacing?.small,

packages/ui-select/src/Select/index.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
* SOFTWARE.
2323
*/
2424

25-
2625
import { ComponentElement, Children, Component, memo, ReactNode } from 'react'
2726

2827
import * as utils from '@instructure/ui-utils'
@@ -429,7 +428,10 @@ class Select extends Component<SelectProps> {
429428
renderAfterLabel: getRenderOptionLabel(renderAfterLabel)
430429
}
431430
// should option be treated as highlighted or selected
432-
if (isSelected) {
431+
if (isSelected && isHighlighted) {
432+
optionProps.variant = 'selected-highlighted'
433+
optionProps.isSelected = true
434+
} else if (isSelected) {
433435
optionProps.variant = 'selected'
434436
optionProps.isSelected = true
435437
} else if (isHighlighted) {

0 commit comments

Comments
 (0)