-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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
Showing
15 changed files
with
474 additions
and
122 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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.
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 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 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,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 |
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 |
---|---|---|
@@ -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' |
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,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 |
Oops, something went wrong.