Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

공통 컴포넌트: Spacing #26

Merged
merged 4 commits into from
Jan 3, 2024
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
7 changes: 7 additions & 0 deletions .storybook/preview-head.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<style>
html,
body,
#storybook-root {
height: 100%;
}
</style>
1 change: 1 addition & 0 deletions .storybook/preview.ts
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 = {
Expand Down
46 changes: 34 additions & 12 deletions src/app/globals.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
:root {
--primary: #0075FF;
--secondary: #B2D6FF;
--red: #FF5247;
--gray-100: #CDCFD0;
--gray-200: #979C9E;
--gray-300: #72777A;
--gray-400: #404446;
--black: #090A0A;
--white: #EEE;
}

body {
margin: 0;
padding: 0;

html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
Expand All @@ -15,58 +30,65 @@ body {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
font-size: 100%;
vertical-align: baseline;
}

/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}

body {
line-height: 1;
}

ol, ul {
list-style: none;
}

blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {

blockquote::before, blockquote::after,
q::before, q::after {
content: '';
content: none;
}

table {
border-collapse: collapse;
border-spacing: 0;
border-collapse: collapse;
}

a {
color: inherit;
text-decoration: inherit; /* no underline */
}

button {
border: none;
width: auto;
margin: 0;
padding: 0;
width: auto;
overflow: visible;

border: none;
background: transparent;

/* inherit font & color from ancestor */
color: inherit;
font: inherit;

/* Normalize `line-height`. Cannot be changed from `normal` in Firefox 4+. */
line-height: normal;

/* Corrects font smoothing for webkit */
-webkit-font-smoothing: inherit;
-moz-osx-font-smoothing: inherit;

/* Normalize `line-height`. Cannot be changed from `normal` in Firefox 4+. */
line-height: normal;

/* Corrects inability to style clickable `input` types in iOS */
-webkit-appearance: none;
appearance: none;
}
}
}
32 changes: 32 additions & 0 deletions src/components/query/shared/spacing/Spacing.stories.ts
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',
},
};
24 changes: 24 additions & 0 deletions src/components/query/shared/spacing/Spacing.tsx
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;
13 changes: 13 additions & 0 deletions src/styles/colorPalette.ts
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;
3 changes: 3 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
"@/*": [
"src/*"
],
"@app/*": [
"src/app/*"
],
"@components/*": [
"src/components/*"
],
Expand Down
Loading