Skip to content

Commit 31a6a5d

Browse files
authored
chore: add stories for DropdownArrow (#11764)
1 parent 383eed9 commit 31a6a5d

File tree

2 files changed

+37
-10
lines changed

2 files changed

+37
-10
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { type Meta, type StoryObj } from "@storybook/react";
2+
import { chromatic } from "testHelpers/chromatic";
3+
import { DropdownArrow } from "./DropdownArrow";
4+
5+
const meta: Meta<typeof DropdownArrow> = {
6+
title: "components/DropdownArrow",
7+
parameters: { chromatic },
8+
component: DropdownArrow,
9+
args: {},
10+
};
11+
12+
export default meta;
13+
type Story = StoryObj<typeof DropdownArrow>;
14+
15+
export const Open: Story = {};
16+
export const Close: Story = { args: { close: true } };
17+
export const WithColor: Story = { args: { color: "#f00" } };
Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,38 @@
11
import KeyboardArrowDown from "@mui/icons-material/KeyboardArrowDown";
22
import KeyboardArrowUp from "@mui/icons-material/KeyboardArrowUp";
3+
import { type Interpolation, type Theme } from "@emotion/react";
34
import { type FC } from "react";
4-
import { type Theme } from "@emotion/react";
55

66
interface ArrowProps {
77
margin?: boolean;
88
color?: string;
99
close?: boolean;
1010
}
1111

12-
export const DropdownArrow: FC<ArrowProps> = (props) => {
13-
const { margin = true, color, close } = props;
14-
12+
export const DropdownArrow: FC<ArrowProps> = ({
13+
margin = true,
14+
color,
15+
close,
16+
}) => {
1517
const Arrow = close ? KeyboardArrowUp : KeyboardArrowDown;
1618

1719
return (
1820
<Arrow
1921
aria-label={close ? "close-dropdown" : "open-dropdown"}
20-
css={(theme: Theme) => ({
21-
color: color ?? theme.palette.primary.contrastText,
22-
marginLeft: margin ? 8 : 0,
23-
width: 16,
24-
height: 16,
25-
})}
22+
css={[styles.base, margin && styles.withMargin]}
23+
style={{ color }}
2624
/>
2725
);
2826
};
27+
28+
const styles = {
29+
base: (theme) => ({
30+
color: theme.palette.primary.contrastText,
31+
width: 16,
32+
height: 16,
33+
}),
34+
35+
withMargin: {
36+
marginLeft: 8,
37+
},
38+
} satisfies Record<string, Interpolation<Theme>>;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy