-
Notifications
You must be signed in to change notification settings - Fork 1.3k
chore: add SelectBoxGroup to chromatic #8760
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 all commits
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,77 @@ | ||
| /* | ||
| * Copyright 2025 Adobe. All rights reserved. | ||
| * This file is licensed to you under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. You may obtain a copy | ||
| * of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software distributed under | ||
| * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS | ||
| * OF ANY KIND, either express or implied. See the License for the specific language | ||
| * governing permissions and limitations under the License. | ||
| */ | ||
|
|
||
| import {action} from '@storybook/addon-actions'; | ||
| import type {Meta, StoryObj} from '@storybook/react'; | ||
| import PaperAirplane from '../spectrum-illustrations/linear/Paperairplane'; | ||
| import React from 'react'; | ||
| import {SelectBox, SelectBoxGroup, Text} from '../src'; | ||
| import Server from '../spectrum-illustrations/linear/Server'; | ||
|
|
||
| const meta: Meta<typeof SelectBoxGroup> = { | ||
| component: SelectBoxGroup, | ||
| parameters: { | ||
| chromaticProvider: {disableAnimations: true} | ||
| }, | ||
| title: 'S2 Chromatic/SelectBoxGroup' | ||
| }; | ||
|
|
||
| export default meta; | ||
| type Story = StoryObj<typeof SelectBoxGroup>; | ||
|
|
||
| export const VerticalOrientation: Story = { | ||
| render: () => ( | ||
| <div style={{width: 600}}> | ||
| <SelectBoxGroup | ||
| orientation="vertical" | ||
| onSelectionChange={action('onSelectionChange')}> | ||
| <SelectBox value="text-only"> | ||
| <Text slot="label">V: Text Only</Text> | ||
| </SelectBox> | ||
| <SelectBox value="illustration-text"> | ||
| <Server /> | ||
| <Text slot="label">V: Illustration + Text</Text> | ||
| </SelectBox> | ||
| <SelectBox value="illustration-desc"> | ||
| <PaperAirplane /> | ||
| </SelectBox> | ||
| </SelectBoxGroup> | ||
| </div> | ||
| ) | ||
| }; | ||
|
|
||
| export const HorizontalOrientation: Story = { | ||
| render: () => ( | ||
| <div style={{width: 800}}> | ||
| <SelectBoxGroup | ||
| orientation="horizontal" | ||
| onSelectionChange={action('onSelectionChange')}> | ||
| <SelectBox value="text-only"> | ||
| <Text slot="label">Title Only</Text> | ||
| </SelectBox> | ||
| <SelectBox value="illustration-text"> | ||
| <Server /> | ||
| <Text slot="label">Illustration + Title</Text> | ||
| </SelectBox> | ||
| <SelectBox value="text-desc"> | ||
| <Text slot="label">Title + Description</Text> | ||
| <Text slot="description">Additional description</Text> | ||
| </SelectBox> | ||
| <SelectBox value="h-all"> | ||
| <Server /> | ||
| <Text slot="label">Illustration + Title + Description</Text> | ||
| <Text slot="description">Full horizontal layout with all elements</Text> | ||
| </SelectBox> | ||
| </SelectBoxGroup> | ||
| </div> | ||
| ) | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,22 +28,7 @@ import React, {createContext, forwardRef, ReactNode, useContext, useMemo, useRef | |
| import {TextContext} from './Content'; | ||
| import {useSpectrumContextProps} from './useSpectrumContextProps'; | ||
|
|
||
| type ExcludedListBoxProps = | ||
| | keyof GlobalDOMAttributes | ||
| | 'layout' | ||
| | 'dragAndDropHooks' | ||
| | 'renderEmptyState' | ||
| | 'dependencies' | ||
| | 'items' | ||
| | 'onAction' | ||
| | 'children' | ||
| | 'selectionMode' | ||
| | 'shouldSelectOnPress' | ||
| | 'shouldFocusWrap' | ||
| | 'selectionBehavior' | ||
| | 'shouldSelectOnFocus'; | ||
|
|
||
| export interface SelectBoxGroupProps<T> extends StyleProps, Omit<ListBoxProps<T>, ExcludedListBoxProps> { | ||
| export interface SelectBoxGroupProps<T> extends StyleProps, Omit<ListBoxProps<T>, keyof GlobalDOMAttributes | 'layout' | 'dragAndDropHooks' | 'dependencies' | 'renderEmptyState' | 'children' | 'onAction' | 'shouldFocusOnHover' | 'selectionBehavior' | 'style' | 'className'> { | ||
| /** | ||
| * The SelectBox elements contained within the SelectBoxGroup. | ||
| */ | ||
|
|
@@ -67,7 +52,7 @@ export interface SelectBoxProps extends StyleProps { | |
| /** | ||
| * The label for the element. | ||
| */ | ||
| children?: ReactNode, | ||
| children: ReactNode, | ||
| /** | ||
| * Whether the SelectBox is disabled. | ||
| */ | ||
|
|
@@ -320,7 +305,7 @@ export function SelectBox(props: SelectBoxProps): ReactNode { | |
| className={style({ | ||
| position: 'absolute', | ||
| top: 8, | ||
| left: 8, | ||
| insetStart: 8, | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. noticed that the checkbox was showing up on the wrong side when i added it to chromatic |
||
| pointerEvents: 'none' | ||
| })} | ||
| aria-hidden="true"> | ||
|
|
@@ -369,7 +354,7 @@ export function SelectBox(props: SelectBoxProps): ReactNode { | |
| /* | ||
| * SelectBoxGroup allows users to select one or more options from a list. | ||
| */ | ||
| export const SelectBoxGroup = /*#__PURE__*/ forwardRef(function SelectBoxGroup<T>(props: SelectBoxGroupProps<T>, ref: DOMRef<HTMLDivElement>) { | ||
| export const SelectBoxGroup = /*#__PURE__*/ forwardRef(function SelectBoxGroup<T extends object>(props: SelectBoxGroupProps<T>, ref: DOMRef<HTMLDivElement>) { | ||
| [props, ref] = useSpectrumContextProps(props, ref, SelectBoxGroupContext); | ||
|
|
||
| let { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,19 +1,14 @@ | ||
| /************************************************************************* | ||
| * ADOBE CONFIDENTIAL | ||
| * ___________________ | ||
| /* | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just changed this to match how our files do it |
||
| * Copyright 2025 Adobe. All rights reserved. | ||
| * This file is licensed to you under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. You may obtain a copy | ||
| * of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Copyright 2025 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. | ||
| **************************************************************************/ | ||
| * Unless required by applicable law or agreed to in writing, software distributed under | ||
| * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS | ||
| * OF ANY KIND, either express or implied. See the License for the specific language | ||
| * governing permissions and limitations under the License. | ||
| */ | ||
|
|
||
| import {action} from '@storybook/addon-actions'; | ||
| import AlertNotice from '../spectrum-illustrations/linear/AlertNotice'; | ||
|
|
@@ -312,5 +307,6 @@ export const AllSlotCombinations: Story = { | |
| </div> | ||
|
|
||
| </div> | ||
| ) | ||
| ), | ||
| tags: ['!autodocs'] | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we could either remove this and rely on chromatic or leave this in storybook and remove it from the docs |
||
| }; | ||
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.
it seems like we were excluding these but maybe they weren't picked up on the tsdiff? anyway, i decided to remove them and just add them directly to the Omit