-
Notifications
You must be signed in to change notification settings - Fork 7
Badge 컴포넌트 마이그레이션 완료 #57
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
2867f58
conf: Install @svgr/webpack - Issue#24
hhhyyo 0dc88a2
conf: Set webpack config to use svgr in next.js - Issue#24
hhhyyo a822fc5
conf: Set webpack config to use svgr in storybook - Issue#24
hhhyyo e5f2ce9
feat: Add Badge.types.ts - Issue #24
hhhyyo ac36e2c
feat: Apply emotion to Badge - Issue #24
hhhyyo 58654bf
feat: Add style for badge size - Issue #24
hhhyyo 9c41b19
feat: Create Badge component - Issue #24
hhhyyo 2fb3a42
feat: Apply Storybook to Badge - Issue #24
hhhyyo 55f7636
Merge branch 'feature/migration-badge' into develop
hhhyyo 57a32b5
Merge branch 'develop' of https://github.com/TeamCooks/TwoSpoon into …
hhhyyo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,6 +1,15 @@ | ||
| /** @type {import('next').NextConfig} */ | ||
| const nextConfig = { | ||
| reactStrictMode: true, | ||
| } | ||
| webpack(config) { | ||
| config.module.rules.push({ | ||
| test: /\.svg$/i, | ||
| issuer: /\.[jt]sx?$/, | ||
| use: ['@svgr/webpack'], | ||
| }); | ||
|
|
||
| module.exports = nextConfig | ||
| return config; | ||
| }, | ||
| }; | ||
|
|
||
| module.exports = nextConfig; |
This file contains hidden or 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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,84 @@ | ||
| import { ComponentMeta, ComponentStory } from '@storybook/react'; | ||
| import { Badge } from './Badge'; | ||
|
|
||
| export default { | ||
| title: 'Badge', | ||
| component: Badge, | ||
| args: { | ||
| size: 'small', | ||
| }, | ||
| } as ComponentMeta<typeof Badge>; | ||
|
|
||
| const Template: ComponentStory<typeof Badge> = (args) => <Badge {...args} />; | ||
|
|
||
| export const dairyFree = Template.bind({}); | ||
|
|
||
| dairyFree.args = { | ||
| iconType: 'dairyFree', | ||
| }; | ||
|
|
||
| export const lactoOvo = Template.bind({}); | ||
|
|
||
| lactoOvo.args = { | ||
| iconType: 'lactoOvo', | ||
| }; | ||
|
|
||
| export const lactoOvoVegetarian = Template.bind({}); | ||
|
|
||
| lactoOvoVegetarian.args = { | ||
| iconType: 'lactoOvoVegetarian', | ||
| }; | ||
|
|
||
| export const vegetarian = Template.bind({}); | ||
|
|
||
| vegetarian.args = { | ||
| iconType: 'vegetarian', | ||
| }; | ||
|
|
||
| export const vegan = Template.bind({}); | ||
|
|
||
| vegan.args = { | ||
| iconType: 'vegan', | ||
| }; | ||
|
|
||
| export const glutenFree = Template.bind({}); | ||
|
|
||
| glutenFree.args = { | ||
| iconType: 'glutenFree', | ||
| }; | ||
|
|
||
| export const popular = Template.bind({}); | ||
|
|
||
| popular.args = { | ||
| iconType: 'popular', | ||
| }; | ||
|
|
||
| export const paleolithic = Template.bind({}); | ||
|
|
||
| paleolithic.args = { | ||
| iconType: 'paleolithic', | ||
| }; | ||
|
|
||
| export const paleo = Template.bind({}); | ||
|
|
||
| paleo.args = { | ||
| iconType: 'paleo', | ||
| }; | ||
|
|
||
| export const primal = Template.bind({}); | ||
|
|
||
| primal.args = { | ||
| iconType: 'primal', | ||
| }; | ||
|
|
||
| export const healthy = Template.bind({}); | ||
|
|
||
| healthy.args = { | ||
| iconType: 'healthy', | ||
| }; | ||
|
|
||
| export const pescatarian = Template.bind({}); | ||
|
|
||
| pescatarian.args = { | ||
| iconType: 'pescatarian', | ||
| }; |
This file contains hidden or 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,30 @@ | ||
| import styled from '@emotion/styled'; | ||
| import LactoOvo from 'assets/icons/lactoOvo.svg'; | ||
| import { StyledBadgeProps } from './Badge.types'; | ||
|
|
||
| const sizes = { | ||
| small: { | ||
| fontSize: '14px', | ||
| }, | ||
| large: { | ||
| fontSize: '16px', | ||
| }, | ||
| }; | ||
|
|
||
| export const StyledBadge = styled.div<StyledBadgeProps>` | ||
| display: inline-flex; | ||
| align-items: center; | ||
| justify-content: center; | ||
| gap: 10px; | ||
| border-radius: 30px; | ||
| padding: 1em; | ||
| color: ${({ theme }) => theme.color.white}; | ||
| background-color: ${({ $color, theme }) => theme.color[$color]}; | ||
| max-height: 2.5em; | ||
| text-transform: uppercase; | ||
| font-size: ${({ $size }) => sizes[$size].fontSize}; | ||
| `; | ||
|
|
||
| export const StyledLactoOvo = styled(LactoOvo)` | ||
| font-size: 20px; | ||
| `; |
This file contains hidden or 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,78 @@ | ||
| import DairyFree from 'assets/icons/dairyFree.svg'; | ||
| import { FaLeaf, FaFish } from 'react-icons/fa'; | ||
| import { GiThreeLeaves, GiGrain, GiMeat, GiMuscleUp } from 'react-icons/gi'; | ||
| import { BsStars } from 'react-icons/bs'; | ||
| import { StyledBadge, StyledLactoOvo } from './Badge.styled'; | ||
| import { BadgeProps, BadgeInfos } from './Badge.types'; | ||
|
|
||
| const BADGE: BadgeInfos = { | ||
| dairyFree: { | ||
| icon: <DairyFree />, | ||
| text: 'dairy-free', | ||
| color: 'badgePurple', | ||
| }, | ||
| lactoOvo: { | ||
| icon: <StyledLactoOvo />, | ||
| text: 'lacto-ovo', | ||
| color: 'badgePurple', | ||
| }, | ||
| lactoOvoVegetarian: { | ||
| icon: <StyledLactoOvo />, | ||
| text: 'lacto-ovo', | ||
| color: 'badgePurple', | ||
| }, | ||
| vegetarian: { | ||
| icon: <FaLeaf />, | ||
| text: 'vegetarian', | ||
| color: 'badgeGreen', | ||
| }, | ||
| vegan: { | ||
| icon: <GiThreeLeaves />, | ||
| text: 'vegan', | ||
| color: 'badgeGreen', | ||
| }, | ||
| glutenFree: { | ||
| icon: <GiGrain />, | ||
| text: 'gluten-free', | ||
| color: 'badgePink', | ||
| }, | ||
| popular: { | ||
| icon: <BsStars />, | ||
| text: 'popular', | ||
| color: 'badgePink', | ||
| }, | ||
| paleolithic: { | ||
| icon: <GiMeat />, | ||
| text: 'paleo', | ||
| color: 'badgePink', | ||
| }, | ||
| paleo: { | ||
| icon: <GiMeat />, | ||
| text: 'paleo', | ||
| color: 'badgePink', | ||
| }, | ||
| primal: { | ||
| icon: <GiMeat />, | ||
| text: 'primal', | ||
| color: 'badgePink', | ||
| }, | ||
| healthy: { | ||
| icon: <GiMuscleUp />, | ||
| text: 'healthy', | ||
| color: 'badgeNavy', | ||
| }, | ||
| pescatarian: { | ||
| icon: <FaFish />, | ||
| text: 'pescatarian', | ||
| color: 'badgeNavy', | ||
| }, | ||
| }; | ||
|
|
||
| export const Badge = ({ iconType, size }: BadgeProps) => { | ||
| return ( | ||
| <StyledBadge $color={BADGE[iconType].color} $size={size}> | ||
| {BADGE[iconType].icon} | ||
| <span>{BADGE[iconType].text}</span> | ||
| </StyledBadge> | ||
| ); | ||
| }; |
This file contains hidden or 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,49 @@ | ||
| type IconType = | ||
| | 'dairyFree' | ||
| | 'lactoOvo' | ||
| | 'lactoOvoVegetarian' | ||
| | 'vegetarian' | ||
| | 'vegan' | ||
| | 'glutenFree' | ||
| | 'popular' | ||
| | 'paleolithic' | ||
| | 'paleo' | ||
| | 'primal' | ||
| | 'healthy' | ||
| | 'pescatarian'; | ||
|
|
||
| type Size = 'small' | 'large'; | ||
|
|
||
| type Text = | ||
| | 'dairy-free' | ||
| | 'lacto-ovo' | ||
| | 'lacto-ovo' | ||
| | 'vegetarian' | ||
| | 'vegan' | ||
| | 'gluten-free' | ||
| | 'popular' | ||
| | 'paleo' | ||
| | 'paleo' | ||
| | 'primal' | ||
| | 'healthy' | ||
| | 'pescatarian'; | ||
|
|
||
| type Color = 'badgePink' | 'badgePurple' | 'badgeGreen' | 'badgeNavy'; | ||
|
|
||
| export interface BadgeProps { | ||
| iconType: IconType; | ||
| size: Size; | ||
| } | ||
|
|
||
| export interface StyledBadgeProps { | ||
| $color: Color; | ||
| $size: Size; | ||
| } | ||
|
|
||
| export type BadgeInfos = { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 오호 반복되는 타입의 객체를 이런 식으로 정의하는 방법이 있네요 굿굿 |
||
| [key in IconType]: { | ||
| icon: JSX.Element; | ||
| text: Text; | ||
| color: Color; | ||
| }; | ||
| }; | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
svgr로 svg를 컴포넌트화 했을 때의 장점이 궁금합니다!