Skip to content
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

feat(shared-types,ui-options,ui-select): allow to change font weight … #1824

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 packages/shared-types/src/ComponentThemeVariables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -911,6 +911,7 @@ export type OptionsItemTheme = {
descriptionLineHeight: Typography['lineHeight']
descriptionPaddingStart: string | 0
descriptionColor: Colors['contrasts']['grey4570']
fontWeightSelected: Typography['fontWeightNormal']
}

export type OptionsSeparatorTheme = {
Expand Down
3 changes: 2 additions & 1 deletion packages/ui-options/src/Options/Item/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ class Item extends Component<OptionsItemProps> {
role: 'listitem',
voiceoverRoleBugWorkaround: false,
beforeLabelContentVAlign: 'center',
afterLabelContentVAlign: 'center'
afterLabelContentVAlign: 'center',
isSelected: false
} as const

ref: Element | null = null
Expand Down
10 changes: 8 additions & 2 deletions packages/ui-options/src/Options/Item/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ type OptionsItemOwnProps = OptionsItemRenderProps & {
* provides a reference to the underlying html root element
*/
elementRef?: (element: Element | null) => void
/**
* Whether or not this option is selected
*/
isSelected?: boolean
}

type PropKeys = keyof OptionsItemOwnProps
Expand Down Expand Up @@ -133,7 +137,8 @@ const propTypes: PropValidators<PropKeys> = {
href: PropTypes.string,
voiceoverRoleBugWorkaround: PropTypes.bool,
elementRef: PropTypes.func,
children: PropTypes.oneOfType([PropTypes.node, PropTypes.func])
children: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
isSelected: PropTypes.bool
}

const allowedProps: AllowedPropKeys = [
Expand All @@ -149,7 +154,8 @@ const allowedProps: AllowedPropKeys = [
'voiceoverRoleBugWorkaround',
'href',
'elementRef',
'children'
'children',
'isSelected'
]

export type { OptionsItemProps, OptionsItemStyle, OptionsItemRenderProps }
Expand Down
4 changes: 3 additions & 1 deletion packages/ui-options/src/Options/Item/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ const generateStyle = (
display: 'block',
fontSize: componentTheme.fontSize,
fontFamily: componentTheme.fontFamily,
fontWeight: componentTheme.fontWeight,
fontWeight: props.isSelected
? componentTheme.fontWeightSelected
: componentTheme.fontWeight,
lineHeight: componentTheme.lineHeight,
outline: 'none',
position: 'relative',
Expand Down
1 change: 1 addition & 0 deletions packages/ui-options/src/Options/Item/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const generateComponentTheme = (theme: Theme): OptionsItemTheme => {
fontFamily: typography?.fontFamily,
fontWeight: typography?.fontWeightNormal,
lineHeight: typography?.lineHeightCondensed,
fontWeightSelected: typography?.fontWeightNormal,

color: colors?.contrasts?.grey125125,
background: colors?.contrasts?.white1010,
Expand Down
1 change: 1 addition & 0 deletions packages/ui-select/src/Select/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ class Select extends Component<SelectProps> {
// should option be treated as highlighted or selected
if (isSelected) {
optionProps.variant = 'selected'
optionProps.isSelected = true
} else if (isHighlighted) {
optionProps.variant = 'highlighted'
}
Expand Down
Loading