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(Autocomplete): Convert Box usage to CSS modules behind feature flag #5451

Merged
merged 23 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
0a05161
test(AutoComplete): add e2e tests
francinelucca Dec 11, 2024
dcab809
test(vrt): update snapshots
francinelucca Dec 11, 2024
44f93b0
Merge branch 'main' into francinelucca/e2e-tests/autocomplete
francinelucca Dec 11, 2024
14b8035
Merge branch 'main' into francinelucca/e2e-tests/autocomplete
francinelucca Dec 12, 2024
328c4ac
Merge branch 'main' of github.com:primer/react into francinelucca/e2e…
francinelucca Dec 13, 2024
d886b2c
fix(Autocomplete): wait for full render before e2e testing
francinelucca Dec 13, 2024
a92ebf0
Merge branch 'main' into francinelucca/e2e-tests/autocomplete
francinelucca Dec 13, 2024
b48bd0a
test(vrt): update snapshots
francinelucca Dec 13, 2024
8797722
Merge branch 'main' into francinelucca/e2e-tests/autocomplete
randall-krauskopf Dec 16, 2024
06121c0
fix dev storybook accessibility
randall-krauskopf Dec 16, 2024
a9b653a
fix lint
randall-krauskopf Dec 16, 2024
3cf65ba
fix theme related a11y errors
randall-krauskopf Dec 16, 2024
e0aec57
test(vrt): update snapshots
randall-krauskopf Dec 16, 2024
1297e36
ignore color-contrast rule
randall-krauskopf Dec 16, 2024
184d90f
Merge branch 'francinelucca/e2e-tests/autocomplete' of https://github…
randall-krauskopf Dec 16, 2024
4f9a0d2
initial commit
randall-krauskopf Dec 16, 2024
9131ee9
Merge https://github.com/primer/react into auto-complete-css-modules
hussam-i-am Dec 18, 2024
aaaf4bc
remove unused snapshots
hussam-i-am Dec 18, 2024
b76cc0e
Merge branch 'main' of https://github.com/primer/react into auto-comp…
hussam-i-am Dec 18, 2024
cff9223
remove file
hussam-i-am Dec 18, 2024
620c9f2
revert file
hussam-i-am Dec 18, 2024
f6c9152
format fix
hussam-i-am Dec 18, 2024
69042e4
changeset
hussam-i-am Dec 18, 2024
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/purple-pants-sit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/react": minor
---

Convert Box usage in Autocomplete to CSS modules behind feature flag
9 changes: 9 additions & 0 deletions packages/react/src/Autocomplete/AutocompleteMenu.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.SpinnerWrapper {
display: flex;
justify-content: center;
padding: var(--base-size-16);
}

.EmptyStateWrapper {
padding: var(--base-size-16);
}
25 changes: 21 additions & 4 deletions packages/react/src/Autocomplete/AutocompleteMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import type {IconProps} from '@primer/octicons-react'
import {PlusIcon} from '@primer/octicons-react'
import VisuallyHidden from '../_VisuallyHidden'
import {isElement} from 'react-is'
import {useFeatureFlag} from '../FeatureFlags'

import classes from './AutocompleteMenu.module.css'

type OnSelectedChange<T> = (item: T | T[]) => void
export type AutocompleteMenuItem = MandateProps<ActionListItemProps, 'id'> & {
Expand Down Expand Up @@ -117,6 +120,8 @@ export type AutocompleteMenuInternalProps<T extends AutocompleteItemProps> = {
['aria-labelledby']: string
}

const CSS_MODULES_FEATURE_FLAG = 'primer_react_css_modules_team'

function AutocompleteMenu<T extends AutocompleteItemProps>(props: AutocompleteMenuInternalProps<T>) {
const autocompleteContext = useContext(AutocompleteContext)
if (autocompleteContext === null) {
Expand Down Expand Up @@ -324,12 +329,20 @@ function AutocompleteMenu<T extends AutocompleteItemProps>(props: AutocompleteMe
throw new Error('Autocomplete: selectionVariant "single" cannot be used with multiple selected items')
}

const enabled = useFeatureFlag(CSS_MODULES_FEATURE_FLAG)

return (
<VisuallyHidden isVisible={showMenu}>
{loading ? (
<Box p={3} display="flex" justifyContent="center">
<Spinner />
</Box>
enabled ? (
<Box className={classes.SpinnerWrapper}>
<Spinner />
</Box>
) : (
<Box p={3} display="flex" justifyContent="center">
<Spinner />
</Box>
)
) : (
<div ref={listContainerRef}>
{allItemsToRender.length ? (
Expand Down Expand Up @@ -367,7 +380,11 @@ function AutocompleteMenu<T extends AutocompleteItemProps>(props: AutocompleteMe
})}
</ActionList>
) : emptyStateText !== false && emptyStateText !== null ? (
<Box p={3}>{emptyStateText}</Box>
enabled ? (
<Box className={classes.EmptyStateWrapper}>{emptyStateText}</Box>
) : (
<Box p={3}>{emptyStateText}</Box>
)
) : null}
</div>
)}
Expand Down
Loading