diff --git a/src/components/Common/MarkedText/MarkedText.tsx b/src/components/Common/MarkedText/MarkedText.tsx index 341b3c92b..80bc5566d 100644 --- a/src/components/Common/MarkedText/MarkedText.tsx +++ b/src/components/Common/MarkedText/MarkedText.tsx @@ -1,5 +1,8 @@ import { Fragment } from 'react'; -import styled from 'styled-components'; + +import { markText } from './markedText.css'; + +import { Text } from '@/components/Common'; interface MarkedTextProps { text: string; @@ -13,7 +16,13 @@ const MarkedText = ({ text, mark }: MarkedTextProps) => { <> {textFragments.map((fragment, index) => ( - {fragment.toLowerCase() === mark.toLowerCase() ? {fragment} : <>{fragment}} + {fragment.toLowerCase() === mark.toLowerCase() ? ( + {fragment} + ) : ( + + {fragment} + + )} ))} @@ -21,8 +30,3 @@ const MarkedText = ({ text, mark }: MarkedTextProps) => { }; export default MarkedText; - -const Mark = styled.mark` - font-weight: ${({ theme }) => theme.fontWeights.bold}; - background-color: ${({ theme }) => theme.backgroundColors.default}; -`; diff --git a/src/components/Common/MarkedText/markedText.css.ts b/src/components/Common/MarkedText/markedText.css.ts new file mode 100644 index 000000000..ee911d543 --- /dev/null +++ b/src/components/Common/MarkedText/markedText.css.ts @@ -0,0 +1,8 @@ +import { vars } from '@/styles/theme.css'; +import { style } from '@vanilla-extract/css'; + +export const markText = style({ + color: vars.colors.primary, + fontWeight: 700, + background: vars.colors.background.default, +}); diff --git a/src/components/Search/RecommendList/RecommendList.stories.tsx b/src/components/Search/RecommendList/RecommendList.stories.tsx new file mode 100644 index 000000000..e3dc399fa --- /dev/null +++ b/src/components/Search/RecommendList/RecommendList.stories.tsx @@ -0,0 +1,17 @@ +import type { Meta, StoryObj } from '@storybook/react'; + +import RecommendList from './RecommendList'; + +const meta: Meta = { + title: 'search/RecommendList', + component: RecommendList, +}; + +export default meta; +type Story = StoryObj; + +export const Default: Story = { + args: { + searchQuery: '꼬북칩', + }, +}; diff --git a/src/components/Search/RecommendList/RecommendList.tsx b/src/components/Search/RecommendList/RecommendList.tsx index b43ccf9e1..e0d328ff5 100644 --- a/src/components/Search/RecommendList/RecommendList.tsx +++ b/src/components/Search/RecommendList/RecommendList.tsx @@ -1,11 +1,12 @@ -import { Button, Text } from '@fun-eat/design-system'; import type { MouseEventHandler } from 'react'; import { useRef } from 'react'; -import styled from 'styled-components'; -import { MarkedText } from '@/components/Common'; +import { backdrop, container, productButton, wrapper } from './recommendList.css'; + +import { MarkedText, Text } from '@/components/Common'; import { useIntersectionObserver } from '@/hooks/common'; import { useInfiniteProductSearchAutocompleteQuery } from '@/hooks/queries/search'; +import { vars } from '@/styles/theme.css'; interface RecommendListProps { searchQuery: string; @@ -21,72 +22,29 @@ const RecommendList = ({ searchQuery, handleSearchClick, handleAutocompleteClose const products = searchResponse.pages.flatMap((page) => page.products); if (products.length === 0) { - return 검색어가 포함된 상품을 찾지 못했어요; + return 검색어가 포함된 상품을 찾지 못했어요; } return ( - - - +
+
+
    {products.map(({ id, name }) => (
  • - + +
  • ))} - +
- +
); }; export default RecommendList; - -const Backdrop = styled.div` - position: fixed; - top: 0; - left: 0; - bottom: 0; - right: 0; -`; - -const RecommendListContainer = styled.div` - position: absolute; - top: 100%; - left: 0; - right: 0; - max-height: 150px; - padding: 10px 0; - border: 1px solid ${({ theme }) => theme.borderColors.default}; - background-color: ${({ theme }) => theme.backgroundColors.default}; - overflow-y: auto; -`; - -const RecommendListWrapper = styled.ul` - position: relative; - width: 100%; - - & > li { - height: 36px; - padding: 0 10px; - line-height: 36px; - } -`; - -const ProductButton = styled(Button)` - text-align: left; -`; - -const ErrorText = styled(Text)` - height: 36px; - padding: 0 10px; - line-height: 36px; -`; diff --git a/src/components/Search/RecommendList/recommendList.css.ts b/src/components/Search/RecommendList/recommendList.css.ts new file mode 100644 index 000000000..cd89faa4e --- /dev/null +++ b/src/components/Search/RecommendList/recommendList.css.ts @@ -0,0 +1,34 @@ +import { vars } from '@/styles/theme.css'; +import { style } from '@vanilla-extract/css'; + +export const container = style({ + position: 'absolute', + minWidth: 360, + maxHeight: 150, + padding: '10px 0', + background: vars.colors.background.default, + overflowY: 'auto', +}); + +export const backdrop = style({ + position: 'fixed', + top: 0, + left: 0, + bottom: 0, + right: 0, +}); + +export const wrapper = style({ + position: 'relative', + width: '100%', +}); + +export const productButton = style({ + display: 'flex', + alignItems: 'center', + padding: '14px 0', + color: '#232527', + fontSize: '1.6rem', + fontWeight: 400, + textAlign: 'left', +});