File tree 2 files changed +37
-10
lines changed
site/src/components/DropdownArrow
2 files changed +37
-10
lines changed Original file line number Diff line number Diff line change
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" } } ;
Original file line number Diff line number Diff line change 1
1
import KeyboardArrowDown from "@mui/icons-material/KeyboardArrowDown" ;
2
2
import KeyboardArrowUp from "@mui/icons-material/KeyboardArrowUp" ;
3
+ import { type Interpolation , type Theme } from "@emotion/react" ;
3
4
import { type FC } from "react" ;
4
- import { type Theme } from "@emotion/react" ;
5
5
6
6
interface ArrowProps {
7
7
margin ?: boolean ;
8
8
color ?: string ;
9
9
close ?: boolean ;
10
10
}
11
11
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
+ } ) => {
15
17
const Arrow = close ? KeyboardArrowUp : KeyboardArrowDown ;
16
18
17
19
return (
18
20
< Arrow
19
21
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 } }
26
24
/>
27
25
) ;
28
26
} ;
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 > > ;
You can’t perform that action at this time.
0 commit comments