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(SelectPanel): Remove sxProp #5431

Open
wants to merge 4 commits into
base: main
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
5 changes: 5 additions & 0 deletions .changeset/long-swans-boil.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/react": major
---

Remove sxProp from SelectPanel
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
8 changes: 0 additions & 8 deletions e2e/components/SelectPanel.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,6 @@ const scenarios = matrix({
id: 'components-selectpanel-dev--with-css',
name: 'With Css',
},
{
id: 'components-selectpanel-dev--with-sx',
name: 'With Sx',
},
{
id: 'components-selectpanel-dev--with-sx-and-css',
name: 'With Sx and Css',
},
],
})

Expand Down
105 changes: 0 additions & 105 deletions packages/react/src/SelectPanel/SelectPanel.dev.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,108 +114,3 @@ export const WithCss = () => {
</FeatureFlags>
)
}

export const WithSx = () => {
const [selected, setSelected] = useState<ItemInput[]>(items.slice(1, 3))
const [filter, setFilter] = useState('')
const filteredItems = items.filter(
item =>
// design guidelines say to always show selected items in the list
selected.some(selectedItem => selectedItem.text === item.text) ||
// then filter the rest
item.text?.toLowerCase().startsWith(filter.toLowerCase()),
)
// design guidelines say to sort selected items first
const selectedItemsSortedFirst = filteredItems.sort((a, b) => {
const aIsSelected = selected.some(selectedItem => selectedItem.text === a.text)
const bIsSelected = selected.some(selectedItem => selectedItem.text === b.text)
if (aIsSelected && !bIsSelected) return -1
if (!aIsSelected && bIsSelected) return 1
return 0
})
const [open, setOpen] = useState(false)

return (
<FeatureFlags
flags={{
primer_react_css_modules_team: true,
primer_react_css_modules_staff: true,
primer_react_css_modules_ga: true,
}}
>
<FormControl>
<FormControl.Label>Labels</FormControl.Label>
<SelectPanel
title="Select labels"
placeholder="Select labels" // button text when no items are selected
subtitle="Use labels to organize issues and pull requests"
renderAnchor={({children, ...anchorProps}) => (
<Button trailingAction={TriangleDownIcon} {...anchorProps} aria-haspopup="dialog">
{children}
</Button>
)}
open={open}
onOpenChange={setOpen}
items={selectedItemsSortedFirst}
selected={selected}
onSelectedChange={setSelected}
onFilterChange={setFilter}
sx={{fontFamily: 'Times New Roman'}}
/>
</FormControl>
</FeatureFlags>
)
}

export const WithSxAndCSS = () => {
const [selected, setSelected] = useState<ItemInput[]>(items.slice(1, 3))
const [filter, setFilter] = useState('')
const filteredItems = items.filter(
item =>
// design guidelines say to always show selected items in the list
selected.some(selectedItem => selectedItem.text === item.text) ||
// then filter the rest
item.text?.toLowerCase().startsWith(filter.toLowerCase()),
)
// design guidelines say to sort selected items first
const selectedItemsSortedFirst = filteredItems.sort((a, b) => {
const aIsSelected = selected.some(selectedItem => selectedItem.text === a.text)
const bIsSelected = selected.some(selectedItem => selectedItem.text === b.text)
if (aIsSelected && !bIsSelected) return -1
if (!aIsSelected && bIsSelected) return 1
return 0
})
const [open, setOpen] = useState(false)

return (
<FeatureFlags
flags={{
primer_react_css_modules_team: true,
primer_react_css_modules_staff: true,
primer_react_css_modules_ga: true,
}}
>
<FormControl>
<FormControl.Label>Labels</FormControl.Label>
<SelectPanel
title="Select labels"
placeholder="Select labels" // button text when no items are selected
subtitle="Use labels to organize issues and pull requests"
renderAnchor={({children, ...anchorProps}) => (
<Button trailingAction={TriangleDownIcon} {...anchorProps} aria-haspopup="dialog">
{children}
</Button>
)}
open={open}
onOpenChange={setOpen}
items={selectedItemsSortedFirst}
selected={selected}
onSelectedChange={setSelected}
onFilterChange={setFilter}
sx={{fontFamily: 'Times New Roman'}}
className="testCustomClassnameMono"
/>
</FormControl>
</FeatureFlags>
)
}
5 changes: 2 additions & 3 deletions packages/react/src/SelectPanel/SelectPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ interface SelectPanelBaseProps {
}

export type SelectPanelProps = SelectPanelBaseProps &
Omit<FilteredActionListProps, 'selectionVariant'> &
Omit<FilteredActionListProps, 'selectionVariant' | 'sx'> &
Pick<AnchoredOverlayProps, 'open'> &
AnchoredOverlayWrapperAnchorProps &
(SelectPanelSingleSelection | SelectPanelMultiSelection)
Expand Down Expand Up @@ -100,7 +100,6 @@ export function SelectPanel({
footer,
textInputProps,
overlayProps,
sx,
className,
...listProps
}: SelectPanelProps): JSX.Element {
Expand Down Expand Up @@ -265,7 +264,7 @@ export function SelectPanel({
inputRef={inputRef}
// inheriting height and maxHeight ensures that the FilteredActionList is never taller
// than the Overlay (which would break scrolling the items)
sx={enabled ? sx : {...sx, height: 'inherit', maxHeight: 'inherit'}}
sx={enabled ? undefined : {height: 'inherit', maxHeight: 'inherit'}}
className={enabled ? clsx(className, classes.FilteredActionList) : className}
/>
{footer && (
Expand Down
Loading