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

Select icon transform #596

Merged
merged 3 commits into from
Mar 19, 2024
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
14 changes: 12 additions & 2 deletions ui/select/src/SelectTrigger.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,16 @@ const IconWrapper = styled("div", {
gridArea: "icon",
});

const AnimatedIcon = styled(Icon, {
transition: `transform ${theme.transitions.normal} ${theme.transitions.inOut}`,
"@reducedMotion": {
transition: "none",
},
'[aria-expanded="true"] &': {
transform: "rotate(180deg)",
},
});

type SelectTriggerVariants = WPDS.VariantProps<typeof StyledTrigger>;

type SelectTriggerProps = RadixAccordionTriggerProps &
Expand Down Expand Up @@ -127,9 +137,9 @@ export const SelectTrigger = React.forwardRef<
>
{children}
<IconWrapper isDisabled={disabled}>
<Icon label="">
<AnimatedIcon label="">
<ChevronDown />
</Icon>
</AnimatedIcon>
</IconWrapper>
</StyledTrigger>
<SubTextWrapper>
Expand Down
17 changes: 9 additions & 8 deletions ui/theme/src/play.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ const StyledBox = styled(Box, {
variants: {
breakpointActive: {
true: {
backgroundColor: theme.colors.success,
backgroundColor: theme.colors.green80,
color: theme.colors.secondary,
fontWeight: theme.fontWeights.bold,
},
false: {
backgroundColor: theme.colors.subtle,
backgroundColor: theme.colors.gray300,
},
},
},
Expand Down Expand Up @@ -243,7 +243,8 @@ function sleep(ms) {
}

const activeStyle = `background-color: ${theme.colors.green80.value}`;
const inactiveStyle = `background-color: ${theme.colors.alpha400.value}`;
const inactiveStyle = `background-color: ${theme.colors.gray300.value}`;
const transitionDelay = 500;

const allModes = {
sm: {
Expand Down Expand Up @@ -280,7 +281,7 @@ InteractionsSmall.parameters = {

InteractionsSmall.play = async ({ canvasElement }) => {
const canvas = within(canvasElement);
await sleep(500);
await sleep(transitionDelay);
await expect(canvas.getByText("@sm")).toHaveStyle(activeStyle);
await expect(canvas.getByText("@md")).toHaveStyle(inactiveStyle);
await expect(canvas.getByText("@maxSm")).toHaveStyle(activeStyle);
Expand All @@ -301,7 +302,7 @@ InteractionsMedium.parameters = {

InteractionsMedium.play = async ({ canvasElement }) => {
const canvas = within(canvasElement);
await sleep(500);
await sleep(transitionDelay);
await expect(canvas.getByText("@md")).toHaveStyle(activeStyle);
await expect(canvas.getByText("@lg")).toHaveStyle(inactiveStyle);
await expect(canvas.getByText("@notSm")).toHaveStyle(activeStyle);
Expand All @@ -323,7 +324,7 @@ InteractionsLarge.parameters = {

InteractionsLarge.play = async ({ canvasElement }) => {
const canvas = within(canvasElement);
await sleep(500);
await sleep(transitionDelay);
await expect(canvas.getByText("@lg")).toHaveStyle(activeStyle);
await expect(canvas.getByText("@xl")).toHaveStyle(inactiveStyle);
await expect(canvas.getByText("@notMd")).toHaveStyle(activeStyle);
Expand All @@ -345,7 +346,7 @@ InteractionsExtraLarge.parameters = {

InteractionsExtraLarge.play = async ({ canvasElement }) => {
const canvas = within(canvasElement);
await sleep(500);
await sleep(transitionDelay);
await expect(canvas.getByText("@xl")).toHaveStyle(activeStyle);
await expect(canvas.getByText("@xxl")).toHaveStyle(inactiveStyle);
await expect(canvas.getByText("@notLg")).toHaveStyle(activeStyle);
Expand All @@ -367,7 +368,7 @@ InteractionsExtraExtraLarge.parameters = {

InteractionsExtraExtraLarge.play = async ({ canvasElement }) => {
const canvas = within(canvasElement);
await sleep(500);
await sleep(transitionDelay);
await expect(canvas.getByText("@xxl")).toHaveStyle(activeStyle);
await expect(canvas.getByText("@notXxl")).toHaveStyle(inactiveStyle);
await expect(canvas.getByText("@maxXxl")).toHaveStyle(activeStyle);
Expand Down
Loading