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

fix(many): border colors are adjusted to meet a11y contrast standards #1743

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions packages/shared-types/src/Colors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type Primitives = {
grey12: string
grey14: string
grey24: string
grey30: string
grey45: string
grey57: string
grey70: string
Expand Down Expand Up @@ -195,6 +196,7 @@ type Contrasts = {
grey1214: Primitives['grey12'] | Primitives['grey14']
grey1424: Primitives['grey14'] | Primitives['grey24']
grey2424: Primitives['grey24']
grey3045: Primitives['grey30'] | Primitives['grey45']
grey4570: Primitives['grey45'] | Primitives['grey70']
grey5782: Primitives['grey57'] | Primitives['grey82']
grey100100: Primitives['grey100']
Expand Down
16 changes: 16 additions & 0 deletions packages/shared-types/src/ComponentThemeVariables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,8 @@ export type ToggleFacadeTheme = {
labelFontSizeSmall: Typography['fontSizeSmall']
labelFontSizeMedium: Typography['fontSizeMedium']
labelFontSizeLarge: Typography['fontSizeLarge']
uncheckedIconBorderColor: Colors['contrasts']['grey3045']
checkedIconBorderColor: Colors['contrasts']['green5782']
}

export type CodeEditorTheme = {
Expand Down Expand Up @@ -534,6 +536,8 @@ export type DrilldownTheme = {
headerTitleFontWeight: Typography['fontWeightBold']
headerActionColor: Colors['contrasts']['blue4570']
labelInfoPadding: Spacing['small']
labelInfoColor: Colors['contrasts']['grey5782']
borderColor: Colors['contrasts']['grey3045']
}

export type FileDropTheme = {
Expand Down Expand Up @@ -960,6 +964,10 @@ export type PillTheme = {
borderRadius: string | 0
}

export type PopoverTheme = {
borderColor: Colors['contrasts']['grey3045']
}

export type PositionTheme = {
zIndex: Stacking['topmost']
}
Expand Down Expand Up @@ -1417,6 +1425,10 @@ export type ToggleDetailsTheme = {
filledPadding: Spacing['small']
}

export type ToggleGroupTheme = {
borderColor: Colors['contrasts']['grey3045']
}

export type TooltipTheme = {
fontFamily: Typography['fontFamily']
fontWeight: Typography['fontWeightNormal']
Expand Down Expand Up @@ -1586,6 +1598,7 @@ export type ContextViewTheme = {
arrowBorderColor: Colors['contrasts']['grey1214']
arrowBackgroundColorInverse: Colors['contrasts']['grey125125']
arrowBorderColorInverse: string
borderColorForView: string
}

export type ViewTheme = {
Expand Down Expand Up @@ -1739,6 +1752,7 @@ export interface ThemeVariables {
Pages: PagesTheme
PaginationPageInput: PaginationPageInputTheme
'Pagination.PageInput': PaginationPageInputTheme
Popover: PopoverTheme
Position: PositionTheme
Pill: PillTheme
ProgressBar: ProgressBarTheme
Expand Down Expand Up @@ -1775,6 +1789,8 @@ export interface ThemeVariables {
TextArea: TextAreaTheme
TextInput: TextInputTheme
ToggleDetails: ToggleDetailsTheme
ToggleGroup: ToggleGroupTheme
'ToggleDetails.ToggleGroup': ToggleGroupTheme
Tooltip: TooltipTheme
TopNavBarBrand: TopNavBarBrandTheme
'TopNavBar.Brand': TopNavBarBrandTheme
Expand Down
2 changes: 1 addition & 1 deletion packages/ui-avatar/src/Avatar/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const generateComponentTheme = (theme: Theme): AvatarTheme => {
background: colors?.contrasts?.white1010,
borderWidthSmall: borders?.widthSmall,
borderWidthMedium: borders?.widthMedium,
borderColor: colors?.contrasts?.grey1214,
borderColor: colors?.contrasts?.grey3045,
boxShadowColor: alpha('#2d3b45', 12),
boxShadowBlur: '1rem',
fontFamily: typography?.fontFamily,
Expand Down
6 changes: 3 additions & 3 deletions packages/ui-buttons/src/BaseButton/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ const generateComponentTheme = (theme: Theme): BaseButtonTheme => {
primaryHoverBackground: colors?.contrasts?.blue5782,
primaryActiveBackground: colors?.contrasts?.blue5782,
primaryActiveBoxShadow: `${activeShadow} ${colors?.contrasts?.white1010}`,
primaryGhostColor: colors?.contrasts?.blue4570,
primaryGhostColor: colors?.contrasts?.blue5782,
primaryGhostBorderColor: colors?.contrasts?.blue4570,
primaryGhostBackground: 'transparent',
primaryGhostHoverBackground: alpha(colors?.contrasts?.blue4570, 10),
primaryGhostHoverBackground: colors?.contrasts?.blue1212,
primaryGhostActiveBackground: 'transparent',
primaryGhostActiveBoxShadow: `${activeShadow} ${alpha(
colors?.contrasts?.blue1212,
Expand All @@ -98,7 +98,7 @@ const generateComponentTheme = (theme: Theme): BaseButtonTheme => {
secondaryGhostColor: colors?.contrasts?.grey125125,
secondaryGhostBorderColor: colors?.contrasts?.grey125125,
secondaryGhostBackground: 'transparent',
secondaryGhostHoverBackground: alpha(colors?.contrasts?.grey125125, 10),
secondaryGhostHoverBackground: colors?.contrasts?.grey1111,
secondaryGhostActiveBackground: 'transparent',
secondaryGhostActiveBoxShadow: `${activeShadow} ${alpha(
colors?.contrasts?.grey125125,
Expand Down
2 changes: 1 addition & 1 deletion packages/ui-checkbox/src/Checkbox/CheckboxFacade/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const generateComponentTheme = (theme: Theme): CheckboxFacadeTheme => {
const componentVariables: CheckboxFacadeTheme = {
color: colors?.contrasts?.white1010,
borderWidth: borders?.widthSmall,
borderColor: colors?.contrasts?.grey1214,
borderColor: colors?.contrasts?.grey3045,
borderRadius: borders?.radiusMedium,
background: colors?.contrasts?.white1010,
marginRight: spacing?.xSmall,
Expand Down
13 changes: 8 additions & 5 deletions packages/ui-checkbox/src/Checkbox/ToggleFacade/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,16 @@ const generateStyle = (
'&::before': {
content: '""',
position: 'absolute',
top: componentTheme.borderWidth,
left: componentTheme.borderWidth,
height: `calc(100% - (${componentTheme.borderWidth} * 2))`,
width: `calc(100% - (${componentTheme.borderWidth} * 2))`,
height: `calc(100% - (${componentTheme.borderWidth} * 6))`,
width: `calc(100% - (${componentTheme.borderWidth} * 6))`,
background: componentTheme.toggleBackground,
boxShadow: componentTheme.toggleShadow,
borderRadius: '100%'
borderRadius: '100%',
border: `${componentTheme.borderWidth} solid ${
checked
? componentTheme.checkedIconBorderColor
: componentTheme.uncheckedIconBorderColor
}`
}
},

Expand Down
8 changes: 5 additions & 3 deletions packages/ui-checkbox/src/Checkbox/ToggleFacade/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ const generateComponentTheme = (theme: Theme): ToggleFacadeTheme => {
const componentVariables: ToggleFacadeTheme = {
color: colors?.contrasts?.white1010,
background: colors?.contrasts?.grey1111,
borderColor: colors?.contrasts?.grey1214,
borderColor: colors?.contrasts?.grey3045,
borderWidth: borders?.widthSmall,
borderRadius: '4rem',
marginEnd: spacing?.small,
marginStart: spacing?.small,
marginVertical: spacing?.xSmall,
checkedBackground: colors?.contrasts?.green4570,
uncheckedIconColor: colors?.contrasts?.grey125125,
checkedIconColor: colors?.contrasts?.green4570,
checkedIconColor: colors?.contrasts?.green5782,
focusOutlineColor: colors?.contrasts?.blue4570,
focusBorderWidth: borders?.widthMedium,
focusBorderStyle: borders?.style,
Expand All @@ -76,7 +76,9 @@ const generateComponentTheme = (theme: Theme): ToggleFacadeTheme => {
labelLineHeight: typography?.lineHeightCondensed,
labelFontSizeSmall: typography?.fontSizeSmall,
labelFontSizeMedium: typography?.fontSizeMedium,
labelFontSizeLarge: typography?.fontSizeLarge
labelFontSizeLarge: typography?.fontSizeLarge,
uncheckedIconBorderColor: colors?.contrasts?.grey5782,
checkedIconBorderColor: colors?.contrasts?.green5782
}

return {
Expand Down
1 change: 1 addition & 0 deletions packages/ui-drilldown/src/Drilldown/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1377,6 +1377,7 @@ class Drilldown extends Component<DrilldownProps, DrilldownState> {
getDisabledOptionProps
}) => (
<View
borderWidth="small"
as="div"
elementRef={this.handleDrilldownRef}
tabIndex={0}
Expand Down
4 changes: 3 additions & 1 deletion packages/ui-drilldown/src/Drilldown/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const generateStyle = (
drilldown: {
label: 'drilldown',
overflow: 'visible', // needed for focus ring!
borderColor: componentTheme.borderColor,

...(hasHighlightedOption && {
'&:focus::before': {
Expand Down Expand Up @@ -80,7 +81,8 @@ const generateStyle = (
flexShrink: 0,
height: '100%',
alignItems: 'center',
paddingInlineStart: componentTheme.labelInfoPadding
paddingInlineStart: componentTheme.labelInfoPadding,
color: componentTheme.labelInfoColor
},
optionContent: {
label: 'drilldown__optionContent',
Expand Down
4 changes: 3 additions & 1 deletion packages/ui-drilldown/src/Drilldown/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ const generateComponentTheme = (theme: Theme): DrilldownTheme => {
const componentVariables: DrilldownTheme = {
headerTitleFontWeight: typography.fontWeightBold,
headerActionColor: colors?.contrasts?.blue4570,
labelInfoPadding: spacing?.small
labelInfoPadding: spacing?.small,
labelInfoColor: colors?.contrasts?.grey3045,
borderColor: colors?.contrasts?.grey3045
}

return {
Expand Down
5 changes: 2 additions & 3 deletions packages/ui-menu/src/Menu/MenuItem/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ const generateComponentTheme = (theme: Theme): MenuItemTheme => {
const themeSpecificStyle: ThemeSpecificStyle<MenuItemTheme> = {
canvas: {
labelColor: theme['ic-brand-font-color-dark'],
iconColor: theme['ic-brand-font-color-dark'],
activeBackground: theme['ic-brand-primary']
iconColor: theme['ic-brand-font-color-dark']
}
}

Expand All @@ -56,7 +55,7 @@ const generateComponentTheme = (theme: Theme): MenuItemTheme => {
iconColor: colors?.contrasts?.grey125125,
iconPadding: spacing?.small,

activeBackground: colors?.contrasts?.blue4570,
activeBackground: colors?.contrasts?.grey4570,
activeLabelColor: colors?.contrasts?.white1010,
activeIconColor: colors?.contrasts?.white1010
}
Expand Down
2 changes: 1 addition & 1 deletion packages/ui-number-input/src/NumberInput/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const generateComponentTheme = (theme: Theme): NumberInputTheme => {

borderWidth: borders?.widthSmall,
borderStyle: borders?.style,
borderColor: colors?.contrasts?.grey1214,
borderColor: colors?.contrasts?.grey3045,
borderRadius: borders?.radiusMedium,

color: colors?.contrasts?.grey125125,
Expand Down
2 changes: 1 addition & 1 deletion packages/ui-options/src/Options/Item/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const generateComponentTheme = (theme: Theme): OptionsItemTheme => {
descriptionFontWeight: typography.fontWeightNormal,
descriptionLineHeight: typography.lineHeight,
descriptionPaddingStart: '0.25em',
descriptionColor: colors?.contrasts?.grey4570
descriptionColor: colors?.contrasts?.grey5782
}

return {
Expand Down
29 changes: 26 additions & 3 deletions packages/ui-popover/src/Popover/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,14 @@ import type { ViewProps, ContextViewProps } from '@instructure/ui-view'
import type { PositionProps } from '@instructure/ui-position'
import type { DialogProps } from '@instructure/ui-dialog'

import { withStyle } from '@instructure/emotion'

import generateStyle from './styles'
import generateComponentTheme from './theme'

import type { PopoverProps, PopoverState } from './props'
import { allowedProps, propTypes } from './props'
import type { Renderable } from '@instructure/shared-types'

/**
---
category: components
Expand All @@ -67,6 +71,7 @@ tags: overlay, portal, dialog
**/
@withDeterministicId()
@textDirectionContextConsumer()
@withStyle(generateStyle, generateComponentTheme)
@testable()
class Popover extends Component<PopoverProps, PopoverState> {
static readonly componentId = 'Popover'
Expand Down Expand Up @@ -558,6 +563,7 @@ class Popover extends Component<PopoverProps, PopoverState> {
}

const { placement } = this.state
const { styles } = this.props

if (this.props.withArrow) {
viewProps = {
Expand All @@ -570,7 +576,17 @@ class Popover extends Component<PopoverProps, PopoverState> {
: placement
} as Partial<ContextViewProps> & { ref: any }

return <ContextView {...viewProps}>{content}</ContextView>
return (
<ContextView
{...viewProps}
themeOverride={{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we shouldn't use themeOverride for our own components

borderColorForView: styles?.borderColor,
arrowBorderColor: styles?.borderColor
}}
>
{content}
</ContextView>
)
} else {
viewProps = {
...viewProps,
Expand All @@ -579,7 +595,14 @@ class Popover extends Component<PopoverProps, PopoverState> {
...(color === 'primary-inverse' && { borderColor: 'transparent' })
} as Partial<ViewProps> & { ref: any }

return <View {...viewProps}>{content}</View>
return (
<View
{...viewProps}
themeOverride={{ borderColorPrimary: styles?.borderColor }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we shouldn't use themeOverride for our own components

>
{content}
</View>
)
}
} else {
return null
Expand Down
12 changes: 8 additions & 4 deletions packages/ui-popover/src/Popover/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { element } from '@instructure/ui-prop-types'
import { ThemeablePropTypes } from '@instructure/emotion'
import { PositionPropTypes } from '@instructure/ui-position'

import type { Shadow, Stacking } from '@instructure/emotion'
import type { Shadow, Stacking, WithStyleProps } from '@instructure/emotion'

import type {
PlacementPropValues,
Expand All @@ -41,7 +41,8 @@ import type {
PropValidators,
LiveRegion,
UIElement,
Renderable
Renderable,
PopoverTheme
} from '@instructure/shared-types'
import type { WithDeterministicIdProps } from '@instructure/ui-react-utils'

Expand Down Expand Up @@ -278,7 +279,8 @@ type PopoverOwnProps = {

type PopoverProps = PopoverOwnProps &
TextDirectionContextConsumerProps &
WithDeterministicIdProps
WithDeterministicIdProps &
WithStyleProps<PopoverTheme, PopoverStyle>

type PopoverState = {
placement: PopoverOwnProps['placement']
Expand All @@ -291,6 +293,8 @@ type PropKeys = keyof PopoverOwnProps

type AllowedPropKeys = Readonly<Array<PropKeys>>

type PopoverStyle = { borderColor: string }

const propTypes: PropValidators<PropKeys> = {
isShowingContent: PropTypes.bool,
defaultIsShowingContent: PropTypes.bool,
Expand Down Expand Up @@ -388,5 +392,5 @@ const allowedProps: AllowedPropKeys = [
'elementRef'
]

export type { PopoverOwnProps, PopoverProps, PopoverState }
export type { PopoverOwnProps, PopoverProps, PopoverState, PopoverStyle }
export { propTypes, allowedProps }
Loading
Loading