-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[FEAT] Marker 컴포넌트, 스토리북
- Loading branch information
Showing
7 changed files
with
110 additions
and
0 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
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,39 @@ | ||
/* eslint-disable no-restricted-exports */ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
|
||
import { MARKER_CATEGORIES } from '@/constants/categories'; | ||
|
||
import { Marker } from '.'; | ||
|
||
const meta = { | ||
title: 'components/common/Marker', | ||
component: Marker, | ||
tags: ['autodocs'], | ||
} satisfies Meta<typeof Marker>; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof Marker>; | ||
|
||
export const Basic: Story = { | ||
args: { | ||
categoryName: 'restaurant', | ||
}, | ||
argTypes: { | ||
categoryName: { control: { type: 'select' }, options: MARKER_CATEGORIES }, | ||
}, | ||
render: (args) => { | ||
return <Marker {...args} />; | ||
}, | ||
}; | ||
|
||
export const ALL: Story = { | ||
render: () => { | ||
return ( | ||
<> | ||
{MARKER_CATEGORIES.map((item) => ( | ||
<Marker key={item} categoryName={item} /> | ||
))} | ||
</> | ||
); | ||
}, | ||
}; |
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,10 @@ | ||
import { ComponentPropsWithoutRef } from 'react'; | ||
|
||
import { MarkerCategory } from '@/constants/categories'; | ||
|
||
export type Props = { | ||
/** | ||
* category name to be displayed. | ||
*/ | ||
categoryName: MarkerCategory; | ||
} & ComponentPropsWithoutRef<'button'>; |
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,30 @@ | ||
import MarkerIcon from '@/assets/icons/marker.svg'; | ||
|
||
import { Props } from './Marker.types'; | ||
|
||
import { Icon } from '../Icon'; | ||
|
||
export const Marker = ({ categoryName, ...props }: Props) => { | ||
const ICON_SIZE = 35; | ||
const ICON_POSITIONS = { | ||
default: { left: '51%', top: '1/2' }, | ||
restaurant: { left: '51%', top: '[55%]' }, | ||
}; | ||
|
||
const position = | ||
categoryName === 'restaurant' ? ICON_POSITIONS.restaurant : ICON_POSITIONS.default; | ||
return ( | ||
<button | ||
aria-label={`${categoryName} location marker`} | ||
className="relative inline-block" | ||
{...props} | ||
> | ||
<MarkerIcon /> | ||
<Icon | ||
name={categoryName} | ||
size={ICON_SIZE} | ||
className={`absolute left-[${position.left}] top-${position.top} -translate-x-1/2 -translate-y-1/2`} | ||
/> | ||
</button> | ||
); | ||
}; |
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,11 @@ | ||
export const MARKER_CATEGORIES = [ | ||
'restaurant', | ||
'cafe', | ||
'bar', | ||
'shopping', | ||
'travel', | ||
'public', | ||
'hospital', | ||
'other', | ||
] as const; | ||
export type MarkerCategory = (typeof MARKER_CATEGORIES)[number]; |