Skip to content

Commit

Permalink
refactor: 버튼 스타일 수정, storybook global scss 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
sikkzz committed Jan 31, 2025
1 parent cca32f7 commit 2e6ed0d
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 10 deletions.
4 changes: 4 additions & 0 deletions .storybook/preview.module.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
body {
max-width: initial;
}

.Wrapper {
display: flex;
flex-flow: row wrap;
Expand Down
2 changes: 2 additions & 0 deletions .storybook/preview.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import type { Preview } from "@storybook/react";

import "@/styles/reset.scss";
import "@/styles/global.scss";
import styles from "./preview.module.scss";

const preview: Preview = {
Expand Down
2 changes: 1 addition & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const App = () => {
<div className={styles.Test}>
<Button variant="primary" text="정보가 맞아요" />
<Button variant="secondary" text="정보가 맞아요" />
<Button variant="disabled" text="다시 스캔하기" />
<Button variant="tertiary" text="다시 스캔하기" />
<div className={styles.Test2}>
<IconButton text="갤러리" iconName="gallery" />
<IconButton text="카메라" iconName="camera" />
Expand Down
1 change: 1 addition & 0 deletions src/components/ui/BaseButton/BaseButton.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
border-radius: 0.875rem;
width: 100%;
height: 3.25rem;
padding: 0.875rem;
}
14 changes: 10 additions & 4 deletions src/components/ui/Button/Button.module.scss
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
@use "@/styles/mixins" as *;

.Button {
@include buttonSecondary;

&.style-primary {
background-color: var(--color-text01);
color: var(--color-white);
@include buttonPrimary;
}

&.style-secondary {
background-color: var(--color-gray400);
color: var(--color-white);
@include buttonSecondary;
}

&.style-disabled {
&.style-tertiary {
background-color: var(--color-gray200);
color: var(--color-text02);
}

&:disabled {
background-color: var(--color-gray350);
color: var(--color-text03);
@include buttonSecondary;
cursor: not-allowed;
}
}

Expand All @@ -29,6 +34,7 @@
display: flex;
gap: 1rem;
justify-content: center;
align-items: center;
width: 300px;
}

Expand Down
4 changes: 2 additions & 2 deletions src/components/ui/Button/Button.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ export const VariantProps: StoryObj<typeof Button> = {
<Button variant="secondary" text="정보가 맞아요" />
</div>
<div className={styles.Wrapper}>
<p className={styles.Text}>disabled</p>
<Button variant="disabled" text="정보가 맞아요" />
<p className={styles.Text}>tertiary</p>
<Button variant="tertiary" text="정보가 맞아요" />
</div>
</div>
),
Expand Down
4 changes: 2 additions & 2 deletions src/components/ui/Button/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React, { useCallback } from "react";
import { forwardRef, useCallback } from "react";

import classNames from "classnames";

import BaseButton from "@/components/ui/BaseButton/BaseButton";
import styles from "@/components/ui/Button/Button.module.scss";
import type { ButtonProps } from "@/components/ui/Button/Button.types";

const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
const Button = forwardRef<HTMLButtonElement, ButtonProps>(
(
{ as = BaseButton, className, variant = "primary", text, disabled = false, onClick, ...props },
ref,
Expand Down
2 changes: 1 addition & 1 deletion src/components/ui/Button/Button.types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { ButtonOwnProps } from "@/components/ui/BaseButton/BaseButton.types";

type ButtonVariant = "primary" | "secondary" | "disabled";
type ButtonVariant = "primary" | "secondary" | "tertiary";

export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, ButtonOwnProps {
variant?: ButtonVariant;
Expand Down
1 change: 1 addition & 0 deletions src/components/ui/IconButton/IconButton.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
&.size-sm {
gap: 0.125rem;
height: 2.375rem;
padding: 0.5rem 0.875rem;
background-color: var(--color-text01);
color: var(--color-white);
border-radius: 0.75rem;
Expand Down

0 comments on commit 2e6ed0d

Please sign in to comment.