-
Notifications
You must be signed in to change notification settings - Fork 1.4k
feat: initial commit for select-box component #7287
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
Changes from 1 commit
242f405
154722e
4dd6750
71e3403
e3c516a
075dd91
a374a3e
fb1832c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -0,0 +1,308 @@ | ||||
| /************************************************************************* | ||||
| * ADOBE CONFIDENTIAL | ||||
| * ___________________ | ||||
| * | ||||
| * Copyright 2024 Adobe | ||||
| * All Rights Reserved. | ||||
| * | ||||
| * NOTICE: All information contained herein is, and remains | ||||
| * the property of Adobe and its suppliers, if any. The intellectual | ||||
| * and technical concepts contained herein are proprietary to Adobe | ||||
| * and its suppliers and are protected by all applicable intellectual | ||||
| * property laws, including trade secret and copyright laws. | ||||
| * Dissemination of this information or reproduction of this material | ||||
| * is strictly forbidden unless prior written permission is obtained | ||||
| * from Adobe. | ||||
| **************************************************************************/ | ||||
|
|
||||
| import { | ||||
| Checkbox as AriaCheckbox, | ||||
| Radio as AriaRadio, | ||||
| Provider, | ||||
| TextContext | ||||
| } from 'react-aria-components'; | ||||
| import {Checkbox, IconContext, Radio} from '@react-spectrum/s2'; | ||||
| import {FocusableRef} from '@react-types/shared'; | ||||
| import {focusRing, size, style} from '../style' with {type: 'macro'}; | ||||
| import React, {forwardRef, useRef} from 'react'; | ||||
|
|
||||
| import {useFocusableRef} from '@react-spectrum/utils'; | ||||
| import {useSelectBoxGroupProvider} from './SelectBoxGroup'; | ||||
|
|
||||
| export interface SelectBoxProps { | ||||
| children?: React.ReactNode, | ||||
| isDisabled?: boolean, | ||||
| value: string | ||||
| } | ||||
|
|
||||
| const selectBoxStyle = style({ | ||||
| ...focusRing(), | ||||
| aspectRatio: { | ||||
| orientation: { | ||||
| vertical: 'square' | ||||
| } | ||||
| }, | ||||
| backgroundColor: { | ||||
| default: 'white', | ||||
| isDisabled: 'disabled' | ||||
| }, | ||||
| borderWidth: 2, | ||||
| borderStyle: { | ||||
| default: 'solid', | ||||
| isDisabled: 'none' | ||||
| }, | ||||
| borderColor: { | ||||
| default: 'gray-25', | ||||
| isSelected: 'black' | ||||
| }, | ||||
| borderRadius: 'lg', | ||||
| boxShadow: 'elevated', | ||||
| boxSizing: 'border-box', | ||||
| color: { | ||||
| default: 'neutral', | ||||
| isDisabled: 'disabled' | ||||
| }, | ||||
| display: 'flex', | ||||
| flexDirection: 'column', | ||||
| justifyContent: 'center', | ||||
| maxHeight: { | ||||
| orientation: { | ||||
| horizontal: { | ||||
| size: { | ||||
| S: size(72), | ||||
| M: size(106) | ||||
| } | ||||
| }, | ||||
| vertical: { | ||||
| size: { | ||||
| XS: size(168), | ||||
| S: size(184), | ||||
| M: size(200), | ||||
| L: size(216), | ||||
| XL: size(232) | ||||
| } | ||||
| } | ||||
| } | ||||
| }, | ||||
| minHeight: { | ||||
| orientation: { | ||||
| horizontal: { | ||||
| size: { | ||||
| S: size(72), | ||||
| M: size(106) | ||||
| } | ||||
| }, | ||||
| vertical: { | ||||
| size: { | ||||
| XS: size(100), | ||||
| S: size(128), | ||||
| M: size(144), | ||||
| L: size(160), | ||||
| XL: size(192) | ||||
| } | ||||
| } | ||||
| } | ||||
| }, | ||||
| maxWidth: { | ||||
| orientation: { | ||||
| horizontal: { | ||||
| size: { | ||||
| S: size(312), | ||||
| M: size(368) | ||||
| } | ||||
| }, | ||||
| vertical: { | ||||
| size: { | ||||
| XS: size(168), | ||||
| S: size(184), | ||||
| M: size(200), | ||||
| L: size(216), | ||||
| XL: size(232) | ||||
| } | ||||
| } | ||||
| } | ||||
| }, | ||||
| minWidth: { | ||||
| orientation: { | ||||
| horizontal: { | ||||
| size: { | ||||
| S: size(312), | ||||
| M: size(368) | ||||
| } | ||||
| }, | ||||
| vertical: { | ||||
| size: { | ||||
| XS: size(100), | ||||
| S: size(128), | ||||
| M: size(144), | ||||
| L: size(160), | ||||
| XL: size(192) | ||||
| } | ||||
| } | ||||
| } | ||||
| }, | ||||
| outlineColor: { | ||||
| default: 'focus-ring', | ||||
| forcedColors: 'Highlight' | ||||
| }, | ||||
| padding: { | ||||
| orientation: { | ||||
| horizontal: { | ||||
| default: 16 | ||||
| } | ||||
| } | ||||
| }, | ||||
| position: 'relative' | ||||
| }); | ||||
|
|
||||
| const selectBoxContentStyle = style({ | ||||
| alignContent: 'center', | ||||
| alignItems: 'center', | ||||
| display: 'grid', | ||||
| gap: { | ||||
| orientation: { | ||||
| horizontal: { | ||||
| size: { | ||||
| S: 0, | ||||
| M: size(2) | ||||
| }, | ||||
| vertical: size(8) | ||||
| } | ||||
| } | ||||
| }, | ||||
| gridTemplateAreas: { | ||||
| orientation: { | ||||
| horizontal: ['icon label', 'icon description'], | ||||
| vertical: ['. icon .', '. label .'] | ||||
| } | ||||
| }, | ||||
| gridTemplateColumns: { | ||||
| orientation: { | ||||
| horizontal: '48px 1fr' | ||||
|
||||
| } | ||||
| }, | ||||
| height: 'full', | ||||
| justifyItems: { | ||||
| orientation: { | ||||
| horizontal: 'flex-start', | ||||
| vertical: 'center' | ||||
| } | ||||
| }, | ||||
| paddingStart: { | ||||
| orientation: { | ||||
| horizontal: size(12), | ||||
| vertical: 0 | ||||
| } | ||||
| }, | ||||
| width: 'auto' | ||||
| }); | ||||
|
|
||||
| const selectBoxIconStyle = style({ | ||||
| color: { | ||||
|
||||
| const icon = style<InlineStylesProps>({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a heads up, i think this is getting moved to top left following how cards looks
https://github.com/adobe/react-spectrum/blob/main/packages/%40react-spectrum/s2/src/Card.tsx#L202
may also be worthwhile to compare styles from cards to this, I suspect there's a fair amount of overlap
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about when focused?
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to include UNSAFE classname/style and style overrides, see
| let {density = 'regular', size = 'M', variant = 'primary', UNSAFE_className = '', UNSAFE_style, styles, id, ...otherProps} = props; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 and 8 should not need
sizeI think I saw some other values above which you should be able to just pass along
https://github.com/adobe/react-spectrum/blob/main/packages/%40react-spectrum/s2/style/spectrum-theme.ts#L121