Skip to content
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
17 changes: 17 additions & 0 deletions site/src/components/DropdownArrow/DropdownArrow.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { type Meta, type StoryObj } from "@storybook/react";
import { chromatic } from "testHelpers/chromatic";
import { DropdownArrow } from "./DropdownArrow";

const meta: Meta<typeof DropdownArrow> = {
title: "components/DropdownArrow",
parameters: { chromatic },
component: DropdownArrow,
args: {},
};

export default meta;
type Story = StoryObj<typeof DropdownArrow>;

export const Open: Story = {};
export const Close: Story = { args: { close: true } };
export const WithColor: Story = { args: { color: "#f00" } };
30 changes: 20 additions & 10 deletions site/src/components/DropdownArrow/DropdownArrow.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,38 @@
import KeyboardArrowDown from "@mui/icons-material/KeyboardArrowDown";
import KeyboardArrowUp from "@mui/icons-material/KeyboardArrowUp";
import { type Interpolation, type Theme } from "@emotion/react";
import { type FC } from "react";
import { type Theme } from "@emotion/react";

interface ArrowProps {
margin?: boolean;
color?: string;
close?: boolean;
}

export const DropdownArrow: FC<ArrowProps> = (props) => {
const { margin = true, color, close } = props;

export const DropdownArrow: FC<ArrowProps> = ({
margin = true,
color,
close,
}) => {
const Arrow = close ? KeyboardArrowUp : KeyboardArrowDown;

return (
<Arrow
aria-label={close ? "close-dropdown" : "open-dropdown"}
css={(theme: Theme) => ({
color: color ?? theme.palette.primary.contrastText,
marginLeft: margin ? 8 : 0,
width: 16,
height: 16,
})}
css={[styles.base, margin && styles.withMargin]}
style={{ color }}
/>
);
};

const styles = {
base: (theme) => ({
color: theme.palette.primary.contrastText,
width: 16,
height: 16,
}),

withMargin: {
marginLeft: 8,
},
} satisfies Record<string, Interpolation<Theme>>;