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

[docs] Improve Multiselect demo styling #37120

Merged
merged 2 commits into from
May 2, 2023
Merged
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
15 changes: 15 additions & 0 deletions docs/data/base/components/select/UnstyledSelectMultiple.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ const StyledOption = styled(Option)(
padding: 8px;
border-radius: 8px;
cursor: default;
transition: border-radius 300ms ease;

&:last-of-type {
border-bottom: none;
Expand All @@ -144,6 +145,20 @@ const StyledOption = styled(Option)(
color: ${theme.palette.mode === 'dark' ? grey[300] : grey[900]};
}

@supports selector(:has(*)) {
&.${optionClasses.selected} {
& + .${optionClasses.selected} {
border-top-left-radius: 0;
border-top-right-radius: 0;
}

&:has(+ .${optionClasses.selected}) {
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
}
}
}

&.${optionClasses.highlighted}.${optionClasses.selected} {
background-color: ${theme.palette.mode === 'dark' ? blue[900] : blue[100]};
color: ${theme.palette.mode === 'dark' ? blue[100] : blue[900]};
Expand Down
15 changes: 15 additions & 0 deletions docs/data/base/components/select/UnstyledSelectMultiple.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ const StyledOption = styled(Option)(
padding: 8px;
border-radius: 8px;
cursor: default;
transition: border-radius 300ms ease;

&:last-of-type {
border-bottom: none;
Expand All @@ -133,6 +134,20 @@ const StyledOption = styled(Option)(
color: ${theme.palette.mode === 'dark' ? grey[300] : grey[900]};
}

@supports selector(:has(*)) {
&.${optionClasses.selected} {
& + .${optionClasses.selected} {
border-top-left-radius: 0;
border-top-right-radius: 0;
}

&:has(+ .${optionClasses.selected}) {
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
}
}
}

&.${optionClasses.highlighted}.${optionClasses.selected} {
background-color: ${theme.palette.mode === 'dark' ? blue[900] : blue[100]};
color: ${theme.palette.mode === 'dark' ? blue[100] : blue[900]};
Expand Down
4 changes: 2 additions & 2 deletions docs/src/createEmotionCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ function globalSelector(element: Element) {
switch (element.type) {
case RULESET:
element.props = (element.props as string[]).map((value: any) => {
if (value.match(/(:where|:has)\(/)) {
value = value.replace(/\.[^:]+(:where|:has)/, '$1');
if (value.match(/(:where|:is)\(/)) {
value = value.replace(/\.[^:]+(:where|:is)/, '$1');
return value;
}
return value;
Expand Down