Skip to content

Commit

Permalink
feat(ui-popover, ui-select): allow overriding Select's dropdown border
Browse files Browse the repository at this point in the history
  • Loading branch information
ToMESSKa committed Feb 6, 2025
1 parent 6c85b31 commit 9c06820
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 8 deletions.
1 change: 1 addition & 0 deletions packages/shared-types/src/ComponentThemeVariables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1175,6 +1175,7 @@ export type SelectTheme = {
largeIconSize: Typography['fontSizeMedium']
color: Colors['contrasts']['grey125125']
background: Colors['contrasts']['white1010']
popoverBorderWidth: Border['widthSmall']
}

export type SourceCodeEditorTheme = {
Expand Down
2 changes: 1 addition & 1 deletion packages/ui-popover/src/Popover/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ class Popover extends Component<PopoverProps, PopoverState> {
} else {
viewProps = {
...viewProps,
borderWidth: 'small',
borderWidth: this.props.borderWidth || 'small',
borderRadius: 'medium',
...(color === 'primary-inverse' && { borderColor: 'transparent' })
} as Partial<ViewProps> & { ref: any }
Expand Down
13 changes: 10 additions & 3 deletions packages/ui-popover/src/Popover/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import React from 'react'
import PropTypes from 'prop-types'

import { element } from '@instructure/ui-prop-types'
import { ThemeablePropTypes } from '@instructure/emotion'
import { ThemeablePropTypes, BorderWidth } from '@instructure/emotion'
import { PositionPropTypes } from '@instructure/ui-position'

import type { Shadow, Stacking, WithStyleProps } from '@instructure/emotion'
Expand Down Expand Up @@ -275,6 +275,11 @@ type PopoverOwnProps = {
* Provides a reference to the underlying HTML root element
*/
elementRef?: (element: Element | null) => void
/**
* Accepts the familiar CSS shorthand to designate border widths corresponding to edges with the following values: 'none', 'small', 'medium','large'(e.g. 'none large none large).
* Only applies to a Popover without an arrow.
*/
borderWidth?: BorderWidth
}

type PopoverProps = PopoverOwnProps &
Expand Down Expand Up @@ -344,7 +349,8 @@ const propTypes: PropValidators<PropKeys> = {
onMouseOut: PropTypes.func,
renderTrigger: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
children: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
elementRef: PropTypes.func
elementRef: PropTypes.func,
borderWidth: ThemeablePropTypes.borderWidth
}

const allowedProps: AllowedPropKeys = [
Expand Down Expand Up @@ -389,7 +395,8 @@ const allowedProps: AllowedPropKeys = [
'onMouseOut',
'renderTrigger',
'children',
'elementRef'
'elementRef',
'borderWidth'
]

export type { PopoverOwnProps, PopoverProps, PopoverState, PopoverStyle }
Expand Down
3 changes: 2 additions & 1 deletion packages/ui-select/src/Select/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ import type {
SelectableRender
} from '@instructure/ui-selectable'

import { withStyle, jsx } from '@instructure/emotion'
import { withStyle, jsx, BorderWidth } from '@instructure/emotion'

import generateStyle from './styles'
import generateComponentTheme from './theme'
Expand Down Expand Up @@ -712,6 +712,7 @@ class Select extends Component<SelectProps> {
isShowingContent={isShowingOptions}
shouldReturnFocus={false}
withArrow={false}
borderWidth={styles?.popoverBorderWidth as BorderWidth}
>
{this.renderList({
getListProps,
Expand Down
4 changes: 3 additions & 1 deletion packages/ui-select/src/Select/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,9 @@ type SelectProps = SelectOwnProps &
> &
WithDeterministicIdProps

type SelectStyle = ComponentStyle<'select' | 'icon' | 'assistiveText'>
type SelectStyle = ComponentStyle<
'select' | 'icon' | 'assistiveText' | 'popoverBorderWidth'
>

const propTypes: PropValidators<PropKeys> = {
renderLabel: PropTypes.oneOfType([PropTypes.node, PropTypes.func]).isRequired,
Expand Down
3 changes: 2 additions & 1 deletion packages/ui-select/src/Select/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ const generateStyle = (
assistiveText: {
label: 'select__assistiveText',
display: 'none'
}
},
popoverBorderWidth: componentTheme.popoverBorderWidth
}
}

Expand Down
3 changes: 2 additions & 1 deletion packages/ui-select/src/Select/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ const generateComponentTheme = (theme: Theme): SelectTheme => {
largeIconSize: typography?.fontSizeMedium,

color: colors?.contrasts?.grey125125,
background: colors?.contrasts?.white1010
background: colors?.contrasts?.white1010,
popoverBorderWidth: 'small'
}

return {
Expand Down

0 comments on commit 9c06820

Please sign in to comment.