-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from Kernel360/common-component-spacing
�공통 컴포넌트 제작: Spacing
- Loading branch information
Showing
7 changed files
with
114 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<style> | ||
html, | ||
body, | ||
#storybook-root { | ||
height: 100%; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import '../src/app/globals.css' | ||
import type { Preview } from "@storybook/react"; | ||
|
||
const preview: Preview = { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
|
||
import Spacing from './Spacing'; | ||
|
||
const meta = { | ||
title: 'Shared/Spacing', | ||
component: Spacing, | ||
parameters: { | ||
}, | ||
tags: ['autodocs'], | ||
argTypes: { | ||
backgroundColor: { control: 'color' }, | ||
}, | ||
} satisfies Meta<typeof Spacing>; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Horizontal: Story = { | ||
args: { | ||
size: 10, | ||
backgroundColor: 'primary', | ||
}, | ||
}; | ||
|
||
export const Vertical: Story = { | ||
args: { | ||
size: 100, | ||
direction: 'vertical', | ||
backgroundColor: 'secondary', | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { useMemo } from 'react'; | ||
|
||
import { Colors, colors } from '@styles/colorPalette'; | ||
|
||
interface SpacingProps { | ||
size: number | ||
direction?: 'vertical' | 'horizontal' | ||
backgroundColor?: Colors | ||
} | ||
|
||
function Spacing({ size = 10, direction = 'horizontal', backgroundColor }: SpacingProps) { | ||
const styles = useMemo(() => { | ||
return { | ||
width: direction === 'horizontal' ? '100%' : `${size}px`, | ||
height: direction === 'vertical' ? '100%' : `${size}px`, | ||
backgroundColor: backgroundColor && colors[backgroundColor], | ||
}; | ||
}, [size, direction, backgroundColor]); | ||
return ( | ||
<div style={styles} /> | ||
); | ||
} | ||
|
||
export default Spacing; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
export const colors = { | ||
primary: 'var(--primary)', | ||
secondary: 'var(--secondary)', | ||
red: 'var(--red)', | ||
gray100: 'var(--gray-100)', | ||
gray200: 'var(--gray-200) ', | ||
gray300: 'var(--gray-300)', | ||
gray400: 'var(--gray-400)', | ||
black: 'var(--black)', | ||
white: 'var(--white)', | ||
}; | ||
|
||
export type Colors = keyof typeof colors; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,9 @@ | |
"@/*": [ | ||
"src/*" | ||
], | ||
"@app/*": [ | ||
"src/app/*" | ||
], | ||
"@components/*": [ | ||
"src/components/*" | ||
], | ||
|