Skip to content

Commit

Permalink
feat: set place component (#43)
Browse files Browse the repository at this point in the history
* feat: set PickChip component

* feat: set PlaceMapPopup

* chore: fix lint error

* chore: fix lint error

* feat: set PlaceListItem

* chore: change icon size

* feat: set auto search item component

* refactor: refactor place component:

* feat: set highlight when equal word

* style: fix width

* feat: add placeId props"

* feat: set filtering logic

* chore: change key

* feat: set Place component props type

* eslint: fix lint error

* chore: change like name

* chore: change hashtag optional

* chore: change onClick name

* fix: add key

* chore: remove scroll

* feat: add useLayoutEffect

* chore: extends ClassName

* chore: rename review

* chore: rename rate

* refactor: seperate getFitContainerWidthHashtag function

* chore: rename: numOfLikes.......

* eslint: fix lint error

* chore: rename numOfReviews....

* refactor: set util

* fix: fix build error"
  • Loading branch information
Pridesd authored Jul 4, 2024
1 parent 4bf9003 commit 3c26260
Show file tree
Hide file tree
Showing 15 changed files with 474 additions and 122 deletions.
120 changes: 0 additions & 120 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

75 changes: 75 additions & 0 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
'use client'

import BoardingInfoPass from '@/components/boarding-pass/boarding-info-pass'
import PlaceAutoSearchItem from '@/components/place/place-auto-search-item'
import PlaceListItem from '@/components/place/place-list-item'
import PlaceMapPopup from '@/components/place/place-map-popup'

const Home = () => {
return (
Expand All @@ -20,6 +23,78 @@ const Home = () => {
]}
numOfPins={19339}
/>
<PlaceAutoSearchItem
placeId="dasdas"
query="존라"
address="서울시 성동구 장터5길"
name="존라멘"
numOfReviews={324}
category="일본식 라멘"
distance="234m"
/>
<PlaceListItem
placeId="sdfsgasf"
name="존라멘"
address="서울시 성동구 장터5길"
rating={0.5}
images={[
'https://images.unsplash.com/photo-1551782450-a2132b4ba21d?w=164&h=164&fit=crop&auto=format',
'https://images.unsplash.com/photo-1551782450-a2132b4ba21d?w=164&h=164&fit=crop&auto=format',
'https://images.unsplash.com/photo-1551782450-a2132b4ba21d?w=164&h=164&fit=crop&auto=format',
]}
pick={{
hashtags: [
'존맛탱구리',
'존존맛탱구리',
'존맛존맛탱구리',
'존맛탱존맛탱구리',
'존맛탱구리',
],
isLiked: false,
isMyPick: false,
numOfLikes: 122,
onClickLike: () => null,
}}
/>
<PlaceListItem
placeId="fasfasfas"
name="존라멘"
address="서울시 성동구 장터5길"
rating={0.5}
pick={{
hashtags: [
'존존맛탱구리',
'존맛',
'존맛탱',
'존맛탱구',
'존맛탱구리',
],
isLiked: false,
isMyPick: false,
numOfLikes: 122,
onClickLike: () => null,
}}
/>
<PlaceMapPopup
placeId="dsd3egg"
name="존라멘"
address="서울시 성동구 장터5길"
distance="3km"
image="https://images.unsplash.com/photo-1551782450-a2132b4ba21d?w=164&h=164&fit=crop&auto=format"
pick={{
hashtags: [
'존맛탱구리',
'존존맛탱구리',
'존맛존맛탱구리',
'존맛탱존맛탱구리',
'존맛탱구리',
],
isLiked: false,
isMyPick: false,
numOfLikes: 122,
onClickLike: () => null,
}}
/>
</main>
)
}
Expand Down
17 changes: 15 additions & 2 deletions src/components/common/chip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ import Typography, { type FontKey } from './typography'

const ChipVariants = cva<{
colorScheme: Record<
'neutral-400' | 'neutral-500' | 'neutral-800' | 'orange',
| 'neutral-400'
| 'neutral-500'
| 'neutral-600'
| 'neutral-800'
| 'orange'
| 'purple',
string
>
size: Record<'sm' | 'md' | 'lg', string>
Expand All @@ -16,8 +21,10 @@ const ChipVariants = cva<{
colorScheme: {
'neutral-400': 'bg-neutral-400 text-neutral-000',
'neutral-500': 'bg-neutral-500 text-neutral-400',
'neutral-600': 'bg-neutral-600 text-neutral-300',
'neutral-800': 'bg-neutral-800 text-orange-400',
orange: 'bg-orange-400 text-neutral-000',
purple: 'bg-purple-300 text-neutral-000',
},
size: {
sm: 'px-2 py-1',
Expand All @@ -32,7 +39,13 @@ const ChipVariants = cva<{
})

interface ChipProps extends HTMLAttributes<HTMLSpanElement> {
colorScheme?: 'neutral-400' | 'neutral-500' | 'neutral-800' | 'orange'
colorScheme?:
| 'neutral-400'
| 'neutral-500'
| 'neutral-600'
| 'neutral-800'
| 'orange'
| 'purple'
size?: 'sm' | 'md' | 'lg'
fontSize?: FontKey
children: ReactNode
Expand Down
7 changes: 7 additions & 0 deletions src/components/common/icons/Star.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/components/common/icons/Subtract.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions src/components/common/icons/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import RoundedTriangle from './RoundedTriangle.svg'
import Search from './Search.svg'
import ShareNetwork from './ShareNetwork.svg'
import SignOut from './SignOut.svg'
import Star from './Star.svg'
import Subtract from './Subtract.svg'
import UploadSimple from './UploadSimple.svg'

export const icons = {
Expand All @@ -33,5 +35,7 @@ export const icons = {
search: Search,
shareNetwork: ShareNetwork,
signOut: SignOut,
star: Star,
subtract: Subtract,
uploadSimple: UploadSimple,
}
52 changes: 52 additions & 0 deletions src/components/hashtag-list.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { useEffect, useLayoutEffect, useRef, useState } from 'react'

import { Chip } from '@/components'
import cn from '@/utils/cn'
import { ClassName } from '@/models/interface'
import { getFitContainerWidthHashtag } from '@/utils/hashtag'

interface HashtagListProps extends ClassName {
placeId: string
hashtags: string[]
}

const HashtagList = ({ placeId, hashtags, className }: HashtagListProps) => {
const [visibleHashtags, setVisibleHashtags] = useState(hashtags)
const containerRef = useRef<HTMLDivElement>(null)

const useIsomorphicLayoutEffect =
typeof window !== 'undefined' ? useLayoutEffect : useEffect

useIsomorphicLayoutEffect(() => {
const editHashtag = () => {
if (!containerRef.current) return

const containerWidth = containerRef.current.offsetWidth

setVisibleHashtags(
getFitContainerWidthHashtag(placeId, hashtags, containerWidth),
)
}
editHashtag()
}, [hashtags])

return (
<div
ref={containerRef}
className={cn('w-full max-w-[380px] flex items-center gap-2', className)}
>
{visibleHashtags.map((hashtag) => (
<Chip
id={`${placeId}-hashtag-${hashtag}`}
className="whitespace-nowrap"
colorScheme="neutral-600"
key={`${placeId}-${hashtag}`}
>{`#${hashtag}`}</Chip>
))}
</div>
)
}

HashtagList.displayName = 'HashtagList'

export default HashtagList
3 changes: 3 additions & 0 deletions src/components/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
export * from './common'
export { default as AccessibleIconButton } from './accessible-icon-button'
export { default as ConfirmCancelButton } from './confirm-cancel-button'
export { default as HashtagList } from './hashtag-list'
export { default as LikeButton } from './like-button'
export { default as PickChip } from './pick-chip'
37 changes: 37 additions & 0 deletions src/components/like-button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
'use client'

import { forwardRef } from 'react'
import { AccessibleIconButton, Typography } from '@/components'

interface LikeButtonProps {
numOfLikes: number
isLiked: boolean
onClick: () => void
}

const LikeButton = forwardRef<HTMLDivElement, LikeButtonProps>(
({ isLiked, numOfLikes, onClick }, ref) => {
return (
<div ref={ref} className="flex items-center gap-0.5">
<AccessibleIconButton
label={isLiked ? '좋아요 취소' : '좋아요'}
onClick={onClick}
icon={{
type: 'heartStraightOutlined',
stroke: isLiked ? 'orange-400' : 'neutral-200',
fill: isLiked ? 'orange-400' : undefined,
'aria-hidden': true,
className: 'w-4 h-4',
}}
/>
<Typography size="body1" color="neutral-200" className="font-medium">
{numOfLikes}
</Typography>
</div>
)
},
)

LikeButton.displayName = 'LikeButton'

export default LikeButton
Loading

0 comments on commit 3c26260

Please sign in to comment.