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

New SelectMenu component #2665

Merged
merged 160 commits into from
Mar 21, 2023
Merged
Show file tree
Hide file tree
Changes from 146 commits
Commits
Show all changes
160 commits
Select commit Hold shift + click to select a range
194a848
Component draft
domidomi Jan 23, 2023
47fbcbe
Add @floating-ui/react
domidomi Jan 23, 2023
6f456ca
Use combobox and listbox role html elements to render selected value …
domidomi Jan 24, 2023
0e67c5c
Allow expanding and collapsing options list
domidomi Jan 25, 2023
23dd595
Use floating-ui wrapper for options list
domidomi Jan 26, 2023
83064fb
Import Select scss file
domidomi Jan 26, 2023
90f167b
Handle expanded state and option change on controlled and uncontrolle…
domidomi Jan 27, 2023
f1cb79d
Create useSelect hook
domidomi Jan 27, 2023
b474b1c
Add placeholder
domidomi Jan 27, 2023
540701c
Handle defaultExpanded
domidomi Jan 27, 2023
7cbf391
Create useFloatingSelect hook
domidomi Jan 30, 2023
d4ca7f6
Add listeners that dismiss (close) the floating element
domidomi Jan 30, 2023
0126289
Merge branch 'master' into new-select-component
domidomi Jan 30, 2023
ee51511
Display subject icons
domidomi Jan 30, 2023
2d49e78
Add multiple options select
domidomi Jan 31, 2023
f6307bf
Remove expanded controlled story, as clicking outside of select close…
domidomi Feb 1, 2023
cd4c403
Remove option groups support
domidomi Feb 1, 2023
255228d
Create SelectOption component. Use useListNavigation
domidomi Feb 1, 2023
1234084
Layout improvements
domidomi Feb 2, 2023
a8d792f
Display caret up on the select when expanded
domidomi Feb 2, 2023
769e53f
Style select element, add story with long label, add support for full…
domidomi Feb 3, 2023
a65dd9e
Add spacing between icon and label in the select element
domidomi Feb 3, 2023
2db23a9
Adjust popup position when no space available
domidomi Feb 6, 2023
7498ea5
Add fallback placement for the popup position
domidomi Feb 6, 2023
c9f5799
Add popup offset
domidomi Feb 6, 2023
42b0684
Make select popup scroll when not enough space
domidomi Feb 7, 2023
2639200
Fix border radius on the select popup
domidomi Feb 7, 2023
e89af31
Add more items to the story
domidomi Feb 7, 2023
bf36118
Remove unused import
domidomi Feb 7, 2023
f658c56
Handle size change, move select display value declaration to the Sele…
domidomi Feb 8, 2023
b5c5465
Select element sizing. Fix 'defaultExpanded' and 'size' story arg types
domidomi Feb 9, 2023
40a2ea3
Use custom text sizes, so they match other form elements
domidomi Feb 9, 2023
73a480e
Add isTouchScreen util. Do not allow interactions with outside elemen…
domidomi Feb 14, 2023
5e4b9a2
Add disabled state
domidomi Feb 14, 2023
ecd5b1c
Create variants story in mdx
domidomi Feb 14, 2023
e900193
Add missing aria attribute
domidomi Feb 14, 2023
b5287a1
Add valid and invalid states
domidomi Feb 14, 2023
dddff9f
Add invariant, cleanup imports order
domidomi Feb 14, 2023
941a880
Change active border color on valid and invalid states
domidomi Feb 14, 2023
8818207
Change option padding when multiselect
domidomi Feb 15, 2023
c96ebe7
Create options floating container so border radius can be applied to …
domidomi Feb 15, 2023
9026524
Add white color type
domidomi Feb 15, 2023
c36fc9c
Add props documentation. Attach onClick event to the component
domidomi Feb 15, 2023
80be91e
Merge branch 'master' into new-select-component
domidomi Feb 16, 2023
860960b
Delete redundant mergeRefs function
domidomi Feb 16, 2023
55e0a1f
Fix variants story select color
domidomi Feb 16, 2023
48b3282
Fix Select colors for hover and expanded states
domidomi Feb 16, 2023
b2a2fa7
Prevent focusing disabled element
domidomi Feb 16, 2023
3b543d7
Remove unnecessary import
domidomi Feb 16, 2023
0518c67
Tests
domidomi Feb 17, 2023
fd39311
Do not require onToggle to be defined
domidomi Feb 17, 2023
a3c1c3e
Ensure floating container preserves margins from the screen sides
domidomi Feb 17, 2023
be6d4f2
Fix popup positioning, add story with different positions
domidomi Feb 17, 2023
073540c
Add missing fullscreen param
domidomi Feb 20, 2023
5cd52cc
Add expand and close height transition
domidomi Feb 21, 2023
48136e9
Apply expand and close height animation based on the popup position
domidomi Feb 22, 2023
60b5150
Fix preventing isExpanded change before transition is finished
domidomi Feb 22, 2023
78e7fb5
Create hook for select animations
domidomi Feb 22, 2023
5eeacbb
Add scroll only, when options list is bigger than the container
domidomi Feb 22, 2023
e1e19c3
Do not use default expanded on the positions story
domidomi Feb 22, 2023
6da6d3c
Use UX motion tokens
domidomi Feb 22, 2023
a3d9b30
Size popup accordingly to the select element size
domidomi Feb 22, 2023
09a633d
Add story representing different select element and popup widths
domidomi Feb 22, 2023
61ad67c
Allow options to fill the whole popup width
domidomi Feb 22, 2023
552be47
Fix transform origins for another positions
domidomi Feb 22, 2023
b1a57f8
Animate floating container position
domidomi Feb 23, 2023
cf514d9
Animate select icon
domidomi Feb 23, 2023
ed8041b
Animate opacity
domidomi Feb 23, 2023
2523875
Add transition on the select background and border
domidomi Feb 23, 2023
7989e52
Add transition on the option background change
domidomi Feb 23, 2023
6dbca17
Fix icon rotation
domidomi Feb 23, 2023
4cf4f8b
Disable scroll when component is animating
domidomi Feb 24, 2023
de12f47
Alter opacity exit animation
domidomi Feb 24, 2023
821205c
Fix unmounting component delay
domidomi Feb 24, 2023
b5c36dc
Handle reduce-motion
domidomi Feb 24, 2023
98044ba
Fix small select input paddings
domidomi Feb 24, 2023
465716a
Do not move popup content on the popup animation
domidomi Feb 27, 2023
3c51c28
Preserve space for tick
domidomi Feb 28, 2023
c71cee8
Fix invariant
domidomi Feb 28, 2023
df7fedd
Always make Select to fill the available space, adjust stories. Handl…
domidomi Feb 28, 2023
295df6b
Merge branch 'master' into new-select-component
domidomi Feb 28, 2023
ec34d35
Extend options API so it supports regular icons
domidomi Mar 1, 2023
ecef38f
Add press feedback to the option
domidomi Mar 1, 2023
d19556e
Add appear animation to subject input label icon
domidomi Mar 1, 2023
e96dca4
Fix popup positon when the option list is scrollable
domidomi Mar 2, 2023
518f17d
Add keyboard navigation
domidomi Mar 3, 2023
741a39c
Change animation name
domidomi Mar 3, 2023
8fa04fd
Add aria label to the select element
domidomi Mar 3, 2023
2db81cd
Remove padding, so the container doesn't flip if the select is at the…
domidomi Mar 3, 2023
6fffdb7
Scroll to selected element
domidomi Mar 3, 2023
0bbb40d
Add tests and apply fixes
domidomi Mar 7, 2023
bbefaf3
Fix icon size
domidomi Mar 7, 2023
cb693d5
Fix checkboxes flickering
domidomi Mar 8, 2023
7a62a32
Fix scrollbar appearance
domidomi Mar 8, 2023
2682191
Hide checkbox input so it doesn't mess up the layout animation
domidomi Mar 8, 2023
e7db88b
Merge branch 'master' into new-select-component
domidomi Mar 8, 2023
79c64e7
Fix icon size
domidomi Mar 9, 2023
e422ceb
Fix popup expanding over max width
domidomi Mar 9, 2023
b4ecadf
Do not enable focus on hover
domidomi Mar 9, 2023
a994822
add accessibility rules
katarzynatobis Mar 9, 2023
264f6b6
Change placeholder color
domidomi Mar 9, 2023
8cf1251
add status to rules
katarzynatobis Mar 9, 2023
98440d5
open listbox on Space press
katarzynatobis Mar 9, 2023
54ee1d0
add test about label and description
katarzynatobis Mar 9, 2023
c3f9e29
Fix scrolled content width issue. Fix popup shadow on reduced motion
domidomi Mar 10, 2023
e36a259
Fix focusing items when the popup is opened by click
domidomi Mar 10, 2023
f74888a
Allow escaping focus out of the popup. Fix roles
domidomi Mar 10, 2023
fa88f4b
add Windows High Contrast Mode
katarzynatobis Mar 10, 2023
167df0d
add test for listbox
katarzynatobis Mar 10, 2023
b902d25
add Select test for Enter
katarzynatobis Mar 10, 2023
798bd37
darken input placeholder color to increase contrast
katarzynatobis Mar 10, 2023
762d7d8
update accessibility rules after fixes
katarzynatobis Mar 10, 2023
95b2845
add aria-multiselectable
katarzynatobis Mar 10, 2023
a2d1980
improve tests for SelectOption
katarzynatobis Mar 13, 2023
729b5b6
add test: selecting option by pressing enter
katarzynatobis Mar 13, 2023
d1c00c6
Tests improvements, fixes
domidomi Mar 13, 2023
d7461cb
Change funcion
domidomi Mar 13, 2023
b4620ab
Tests improvements
domidomi Mar 13, 2023
09b73a0
Darken invalid state colors
domidomi Mar 13, 2023
7c7cde9
Fix caret icon not animating on first click
domidomi Mar 13, 2023
f32fba6
Fix select element states styles
domidomi Mar 14, 2023
48469e1
Change story
domidomi Mar 14, 2023
8e7ea49
Do not use zindex to change overlay display
domidomi Mar 14, 2023
33e58e0
Do not block clicking outside of the overlay and hovering elements, w…
domidomi Mar 14, 2023
29b99ca
Fix stories height
domidomi Mar 14, 2023
2799d83
Rename SelectNew to SelectMenu
domidomi Mar 14, 2023
d6c730f
Change placeholder
domidomi Mar 14, 2023
7348f24
Add snippet with selecting items
domidomi Mar 14, 2023
dbe5e21
Merge branch 'master' into new-select-component
domidomi Mar 14, 2023
b08e5c6
Add chromatic stories
domidomi Mar 15, 2023
3759f15
omit rules with `:not(:hover)` in generating hover styles
katarzynatobis Mar 15, 2023
06ac9f6
Add hovers and expanded popups chromatic stories
domidomi Mar 15, 2023
3c08e24
Merge branch 'master' into new-select-component
domidomi Mar 15, 2023
5805561
Merge branch 'master' into new-select-component
domidomi Mar 15, 2023
b144991
Fix types in chromatic stories
domidomi Mar 15, 2023
7b39295
Enable disabling chromatic snapshots in a story
domidomi Mar 16, 2023
3f66ec5
Create chromatic stories for SelectMenu
domidomi Mar 16, 2023
addaa03
Merge branch 'master' into new-select-component
domidomi Mar 16, 2023
0b171b3
Merge branch 'master' into new-select-component
domidomi Mar 16, 2023
b7f6f4e
Change SelectMenu options in chromatic story, mock function
domidomi Mar 17, 2023
634ac46
Disable user select
domidomi Mar 17, 2023
0fe6418
Ensure there's enough space for the popup to display (story)
domidomi Mar 17, 2023
ef6ed50
Reset popup height to 0 on the animation start
domidomi Mar 17, 2023
707c13d
Parameterise value
domidomi Mar 17, 2023
68e6cd9
Add sg-* prefix to animate-on-transforms class
domidomi Mar 17, 2023
5c786a2
Remove redundant story
domidomi Mar 17, 2023
8c99d66
Use English labels
domidomi Mar 17, 2023
cdaafff
Cleanup
domidomi Mar 17, 2023
e00a405
Use English labels in chromatic stories
domidomi Mar 17, 2023
34247e2
Upgrade @floating-ui to v0.22.0
domidomi Mar 20, 2023
a1894d7
Use CSS variables
domidomi Mar 20, 2023
861f79c
Downgrade @floating-ui/react version as there's a bug with handling k…
domidomi Mar 20, 2023
0a60fbf
Improve handling keyboard events
domidomi Mar 20, 2023
b271be1
Use waitForElementToBeRemoved() for popup disappearance
domidomi Mar 20, 2023
6160be3
Tests fixes
domidomi Mar 20, 2023
0dd3386
Tests fixes
domidomi Mar 20, 2023
58da544
Merge branch 'master' into new-select-component
domidomi Mar 20, 2023
e4f6441
Chromatic test visual fix
domidomi Mar 20, 2023
54910dc
Fix chromatic story layout
domidomi Mar 20, 2023
3ae12de
Cleanup hovers chromatic story
domidomi Mar 21, 2023
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 package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"@aws-sdk/client-lambda": "^3.210.0",
"@codesandbox/sandpack-react": "^1.17.0",
"@codesandbox/sandpack-themes": "^1.17.0",
"@floating-ui/react": "^0.18.1",
domidomi marked this conversation as resolved.
Show resolved Hide resolved
"@types/react": "^16.2.0",
"chalk": "4.1.2",
"classnames": "^2.3.2",
Expand Down
6 changes: 5 additions & 1 deletion src/chromatic/HoverStyle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ const generateUnhoveredSelector = (

const hoverSelectorText = selectorText
.split(', ')
.filter(text => text.includes(':hover') || text.includes('--hover'))
.filter(
text =>
(text.includes(':hover') || text.includes('--hover')) &&
!text.includes(':not(:hover)')
)
.map(selector =>
`#${hoverContainerId} ${selector}`
.replace(/:hover/i, '')
Expand Down
6 changes: 5 additions & 1 deletion src/chromatic/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ export const generateChromaticStory: any = (

const mergeStories: any = module => {
const stories = Object.keys(module)
.filter(moduleExports => moduleExports !== 'default')
.filter(
moduleExports =>
moduleExports !== 'default' &&
!module[moduleExports].parameters?.chromatic?.disableSnapshot
)
.map(moduleExportName => {
return {
name: moduleExportName,
Expand Down
152 changes: 152 additions & 0 deletions src/components/select-menu/SelectMenu.chromatic.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
import * as React from 'react';
import * as SelectMenuStories from './SelectMenu.stories.mdx';
import {generateChromaticStory} from '../../chromatic/utils';
import SelectMenu, {SIZE as SELECT_SIZE} from './SelectMenu';

import Text from '../text/Text';
import Flex from '../flex/Flex';

const onOptionChange = () => null;

export const Sizes = args => {
return (
<div style={{display: 'flex', flexDirection: 'row'}}>
{Object.values(SELECT_SIZE).map(size => (
<div style={{width: '200px'}} key={size}>
<SelectMenu
{...args}
defaultExpanded
size={size}
onOptionChange={onOptionChange}
/>
</div>
))}
</div>
);
};

export const DifferentPopupLenghts = args => {
return (
<Flex direction="row" style={{gap: '40px'}}>
<div style={{width: '200px'}}>
<Text>Popup with wide content:</Text>
<SelectMenu
options={[
{
value: 'tv',
label: 'Usłyszałem o Brainly w reklamie telewizyjnej w telewizji',
domidomi marked this conversation as resolved.
Show resolved Hide resolved
icon: {
name: 'physics',
isSubjectIcon: true,
},
},
{
value: 'fb',
label: 'Media społecznościowe',
icon: {
name: 'history',
isSubjectIcon: true,
},
},
{
value: 'search',
label: 'Wyszukiwarka internetowa',
icon: {
name: 'science',
isSubjectIcon: true,
},
},
]}
defaultExpanded
onOptionChange={onOptionChange}
/>
</div>
<div style={{width: '400px'}}>
<Text>
Popup with short content that stretches to 70% of the input:
</Text>
<SelectMenu
{...args}
withIcons={false}
defaultExpanded
options={[
{
value: 'tv',
label: '1',
},
{value: 'fb', label: '2'},
{
value: 'search',
label: '3',
},
]}
placeholder="Select something from the list"
onOptionChange={onOptionChange}
/>
</div>
<div>
<Text>Popup with short content and short input:</Text>
<div style={{width: '120px'}}>
<SelectMenu
{...args}
withIcons={false}
defaultExpanded
options={[
{
value: 'tv',
label: '1',
},
{value: 'fb', label: '2'},
{
value: 'search',
label: '3',
},
]}
placeholder="Age"
onOptionChange={onOptionChange}
/>
</div>
</div>
</Flex>
);
};

const Hovers = args => {
const types = [{name: 'default'}, {disabled: true, name: 'disabled'}];

return (
<div>
{types.map(t => (
<div key={t.name}>
{t.name}
<SelectMenu {...args} {...t} onOptionChange={onOptionChange} />
</div>
))}
<div style={{background: 'black'}}>
{types.map(t => (
<div key={t.name}>
<span style={{color: 'white'}}>White: {t.name}</span>
<SelectMenu
{...args}
{...t}
color="white"
onOptionChange={onOptionChange}
/>
</div>
))}
</div>
</div>
);
};

export const Default = generateChromaticStory(
{
...SelectMenuStories,
},
{
storiesToHover: [Hovers],
}
);
const {includeStories, ...meta} = SelectMenuStories.default;

export default meta;
Loading