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(ui-popover, ui-select): allow overriding Select's dropdown border #1862

Open
wants to merge 2 commits 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
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
16 changes: 13 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,14 @@ type PopoverOwnProps = {
* Provides a reference to the underlying HTML root element
*/
elementRef?: (element: Element | null) => void
/**
* Allowed values: 0, 'none', 'small', 'medium', 'large'.
*
* Accepts the familiar CSS shorthand to designate border widths corresponding to edges. (e.g. 'none large none large).
*
* Only applies to a Popover without an arrow.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I inserted this about the no arrow version, because the arrow version uses ContextView which would result in having to rewrite ContextView too unfortunately.

*/
borderWidth?: BorderWidth
}

type PopoverProps = PopoverOwnProps &
Expand Down Expand Up @@ -344,7 +352,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 +398,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 @@ -713,6 +713,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
Loading