Skip to content

Commit

Permalink
Merge pull request #19 from Findy-org/feat/#13-marker
Browse files Browse the repository at this point in the history
[FEAT] Marker 컴포넌트, 스토리북
  • Loading branch information
keemsebin authored Oct 23, 2024
2 parents 40851d0 + 9e98806 commit 72c6d4d
Show file tree
Hide file tree
Showing 7 changed files with 110 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/assets/icons/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import KakaoLogin from './kakao-login.svg?react';
import Link from './link.svg?react';
import Location from './location.svg?react';
import Map from './map.svg?react';
import Marker from './marker.svg?react';
import NaverLogin from './naver-login.svg?react';
import Other from './other.svg?react';
import Public from './public.svg?react';
Expand All @@ -38,6 +39,7 @@ export const Icons = {
link: Link,
map: Map,
location: Location,
marker: Marker,
kakaoLogin: KakaoLogin,
naverLogin: NaverLogin,
findy1: Findy1,
Expand Down
18 changes: 18 additions & 0 deletions src/assets/icons/marker.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file removed src/components/common/.gitkeep
Empty file.
39 changes: 39 additions & 0 deletions src/components/common/Marker/Marker.stories.tsx
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} />
))}
</>
);
},
};
10 changes: 10 additions & 0 deletions src/components/common/Marker/Marker.types.ts
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'>;
30 changes: 30 additions & 0 deletions src/components/common/Marker/index.tsx
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>
);
};
11 changes: 11 additions & 0 deletions src/constants/categories.ts
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];

0 comments on commit 72c6d4d

Please sign in to comment.