Skip to content

Commit

Permalink
✨ Chip
Browse files Browse the repository at this point in the history
  • Loading branch information
simonwoerpel committed Mar 1, 2024
1 parent 07055af commit b94f654
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/theme/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { BACKGROUNDS, BLACK } from "./colors";
import { linkClasses } from "@mui/joy/Link";
import { TypographyOwnerState } from "@mui/joy/Typography";
import { CardOwnerState } from "@mui/joy/Card";
import { ChipOwnerState } from "@mui/joy/Chip";

const SIZES = {
lg: "35px",
Expand Down Expand Up @@ -177,4 +178,30 @@ export const components = {
},
},
},
JoyChip: {
defaultProps: {
size: "sm",
variant: "soft",
},
styleOverrides: {
root: ({ ownerState }: { ownerState: ChipOwnerState }) => ({
color: BLACK,
fontWeight: 400,
lineHeight: "130%",
...(ownerState.size === "sm" && {
borderRadius: "1rem",
fontSize: "1rem",
}),
...(ownerState.size === "md" && {
fontSize: "1.5rem",
borderRadius: "1.5rem",
}),
...(ownerState.size === "lg" && {
padding: "0.25rem 1rem",
fontSize: "2.0rem",
borderRadius: "2rem",
}),
}),
},
},
};
18 changes: 18 additions & 0 deletions stories/Chip.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import type { Meta, StoryObj } from "@storybook/react";

import { Chip } from "./MuiComponents";

const meta = {
title: "Atoms/Chip",
component: Chip,
tags: ["autodocs"],
} satisfies Meta<typeof Chip>;

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

export const Default: Story = {
args: {
children: "Chip text",
},
};
7 changes: 7 additions & 0 deletions stories/MuiComponents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import React from "react";
import MuiButton, { ButtonProps } from "@mui/joy/Button";
import MuiChip, { ChipProps } from "@mui/joy/Chip";

type TButton = Pick<
ButtonProps,
Expand All @@ -13,3 +14,9 @@ type TButton = Pick<
export function Button(props: React.PropsWithChildren<TButton>) {
return <MuiButton {...props} />;
}

type TChip = Pick<ChipProps, "color" | "size" | "variant">;

export function Chip(props: React.PropsWithChildren<TChip>) {
return <MuiChip {...props} />;
}

0 comments on commit b94f654

Please sign in to comment.