Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

chore: add stories forDropdownArrow#11764

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
aslilac merged 1 commit intomainfromdda-story
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes fromall 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 deletionssite/src/components/DropdownArrow/DropdownArrow.stories.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff 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 deletionssite/src/components/DropdownArrow/DropdownArrow.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff 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>>;

[8]ページ先頭

©2009-2025 Movatter.jp