Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[test] 서울콘 대응 #2966

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
40f429d
feat: Triple Document에서 prop으로 guestMode를 받을 수 있도록 타입 추가
seulgiyoon Oct 26, 2023
c03da40
feat: guestMode 값을 가지는 context 추가
seulgiyoon Oct 26, 2023
dd006d7
feat: Poi list에서 사용하는 엘리먼트들의 props 타입에 guestMode 추가
seulgiyoon Oct 26, 2023
c5c66ff
fix: Poi 엘리먼트들에서 guestMode인 경우 스크랩 버튼 숨김
seulgiyoon Oct 26, 2023
4d790d9
feat: Poi list에서 poi 엘리먼트에 guestMode 내려줌
seulgiyoon Oct 26, 2023
228a8a0
feat: Poi-detail image-carousel에서 prop으로 guestMode를 받을 수 있도록 타입 추가
seulgiyoon Oct 27, 2023
0fadc2c
feat: placeholder 컴포넌트에 guestMode를 prop으로 전달
seulgiyoon Oct 27, 2023
9fc0d6d
feat: guestMode가 true인 경우, 사진이 없을 때 사진 아이콘만 나타나게 함
seulgiyoon Oct 27, 2023
d08da25
feat: guestMode가 true인 경우, 사진이 5장 이상일 때 나타나는 앱으로 연결 overlay영역 미표시
seulgiyoon Oct 27, 2023
3664704
feat: guestMode가 true인 경우, 사진을 5장까지만 노출
seulgiyoon Oct 27, 2023
49d6f1b
feat: guestMode가 true일 때의 사진 인덱스 표기방식 수정
seulgiyoon Oct 27, 2023
bef7cc2
Merge branch 'feat/add-guestmode-on-image-carousel' into test/seoul-c…
seulgiyoon Oct 27, 2023
4df8861
feat: Poi list에 사용되는 엘리먼트의 이름과 리전명 영역에 대표어값(primary)이 가장 우선적으로 표기되도록 함
seulgiyoon Oct 30, 2023
4b62eab
fix: Poi 엘리먼트들에서 guestMode인 경우 스크랩 버튼 숨김
seulgiyoon Oct 30, 2023
b5ac589
fix: guestMode 타입을 Poi 엘리먼트 공통에서 제외하고 트리플 도큐먼트 Pois 에서 사용하는 엘리먼트들에만 정의
seulgiyoon Oct 30, 2023
29a336c
Merge branch 'feat/hide-scrap-poi-list' into test/seoul-con-and-i18n
seulgiyoon Oct 30, 2023
a6f1c13
Merge branch 'feat/set-primary-data' into test/seoul-con-and-i18n
seulgiyoon Oct 30, 2023
4905f4b
feat: Poi image-carousel에서 poi type도 받도록 함
seulgiyoon Nov 6, 2023
d5154dc
feat: 이미지 없을 때 표시하는 컴포넌트로 type prop 전달
seulgiyoon Nov 6, 2023
837219c
feat: guestmode이면서 대표사진이 없을 때, poi type별로 다른 아이콘 노출하도록 함
seulgiyoon Nov 6, 2023
f1ef37a
fix: guestmode용 디폴트 아이콘 너비 변경
seulgiyoon Nov 7, 2023
39ccf42
Merge branch 'feat/add-guestmode-on-image-carousel' into test/seoul-c…
seulgiyoon Nov 7, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions packages/poi-detail/src/image-carousel/carousel-section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import Carousel, { CarouselProps } from './carousel'
import Placeholder from './placeholder'
import { BusinessHoursNote, PermanentlyClosedNote } from './note'

export type PoiType = 'attraction' | 'hotel' | 'restaurant'

export interface CarouselSectionProps extends CarouselProps {
loading: boolean
currentBusinessHours?:
Expand All @@ -18,6 +20,9 @@ export interface CarouselSectionProps extends CarouselProps {
onBusinessHoursClick?: () => void
onPlaceholderClick: () => void
height?: number
/** true인 경우, 로그인이 필요한 일부 동작을 막고, 트리플앱으로 연결되는 루트를 차단합니다 */
guestMode?: boolean
type?: PoiType
}

export default function CarouselSection({
Expand All @@ -29,6 +34,8 @@ export default function CarouselSection({
onPlaceholderClick,
onBusinessHoursClick,
borderRadius,
guestMode,
type,
...props
}: CarouselSectionProps) {
return (
Expand All @@ -43,9 +50,19 @@ export default function CarouselSection({
>
<Container position="relative">
{images.length > 0 ? (
<Carousel images={images} borderRadius={borderRadius} {...props} />
<Carousel
images={images}
borderRadius={borderRadius}
guestMode={guestMode}
{...props}
/>
) : (
<Placeholder onClick={onPlaceholderClick} noContent={loading} />
<Placeholder
onClick={onPlaceholderClick}
noContent={loading}
guestMode={guestMode}
type={type}
/>
)}
{!permanentlyClosed && onBusinessHoursClick ? (
<BusinessHoursNote
Expand Down
38 changes: 30 additions & 8 deletions packages/poi-detail/src/image-carousel/carousel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export interface CarouselProps {
optimized?: boolean
borderRadius?: number
height?: number
guestMode?: boolean
}

export default function Carousel({
Expand All @@ -50,11 +51,14 @@ export default function Carousel({
optimized,
borderRadius = 6,
height,
guestMode,
}: CarouselProps) {
const app = useTripleClientMetadata()
const { trackEvent, trackSimpleEvent } = useEventTrackingContext()
const [currentPage, setCurrentPage] = useState(0)
const visibleImages = app ? images : images.slice(0, SHOW_CTA_FROM_INDEX + 1)
const visibleImages = app
? images
: images.slice(0, guestMode ? SHOW_CTA_FROM_INDEX : SHOW_CTA_FROM_INDEX + 1)

const handleImageClick = useCallback(
(event?: MouseEvent, media?: ImageMeta) => {
Expand Down Expand Up @@ -125,15 +129,33 @@ export default function Carousel({
],
)

const ConditionalPageLabel = app
? undefined
: ({ currentIndex }: { currentIndex: number }) =>
!totalImagesCount || currentIndex === SHOW_CTA_FROM_INDEX ? null : (
<PageLabel currentIndex={currentPage} totalCount={totalImagesCount} />
)
const publicPageLabelRenderer = ({
currentIndex,
}: {
currentIndex: number
}) => {
if (!totalImagesCount) {
return null
}

if (guestMode || currentIndex !== SHOW_CTA_FROM_INDEX) {
const totalCount =
guestMode && totalImagesCount > SHOW_CTA_FROM_INDEX
? SHOW_CTA_FROM_INDEX
: totalImagesCount

return <PageLabel currentIndex={currentPage} totalCount={totalCount} />
}

return null
}

const ConditionalPageLabel = app ? undefined : publicPageLabelRenderer

const CTA = ({ currentIndex }: { currentIndex: number }) =>
!app && currentIndex === SHOW_CTA_FROM_INDEX ? <CtaOverlay /> : null
!app && !guestMode && currentIndex === SHOW_CTA_FROM_INDEX ? (
<CtaOverlay />
) : null

return (
<>
Expand Down
2 changes: 2 additions & 0 deletions packages/poi-detail/src/image-carousel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ type ImageCarouselProps = Pick<
| 'optimized'
| 'borderRadius'
| 'height'
| 'guestMode'
| 'type'
>

export default function ImageCarousel(props: ImageCarouselProps) {
Expand Down
54 changes: 41 additions & 13 deletions packages/poi-detail/src/image-carousel/placeholder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@ import { useTranslation } from '@titicaca/next-i18next'
import styled, { css } from 'styled-components'
import { Text, Responsive } from '@titicaca/core-elements'

import { PoiType } from './carousel-section'

const DEFAULT_ICON_URLS: Record<PoiType, string> = {
attraction: 'https://assets.triple.guide/images/seoulcon/default/ic_spot.svg',
hotel: 'https://assets.triple.guide/images/seoulcon/default/ic_hotel.svg',
restaurant:
'https://assets.triple.guide/images/seoulcon/default/ic_restaurant.svg',
}

const ImagePlaceholderContainer = styled.div<{ large?: boolean }>`
width: 100%;
overflow: hidden;
Expand All @@ -18,8 +27,6 @@ const ImagePlaceholderContainer = styled.div<{ large?: boolean }>`
`

const PlaceholderIcon = styled.img`
width: 60px;
height: 60px;
vertical-align: baseline;
`

Expand All @@ -39,22 +46,35 @@ const ImagePlaceholderContent = styled.div<{ large?: boolean }>`
interface ImagePlaceholderProps {
large?: boolean
noContent?: boolean
guestMode?: boolean
type?: PoiType
onClick: () => void
}

function ImagePlaceholder({
large,
noContent,
guestMode,
type,
onClick,
}: ImagePlaceholderProps) {
const { t } = useTranslation('common-web')

return (
<ImagePlaceholderContainer large={large} onClick={onClick}>
<ImagePlaceholderContent large={large}>
{noContent ? null : (
{noContent ? null : guestMode ? (
<PlaceholderIcon
src={DEFAULT_ICON_URLS[type || 'attraction']}
width={40}
css={{ opacity: 0.3 }}
/>
) : (
<>
<PlaceholderIcon src="https://assets.triple.guide/images/[email protected]" />
<PlaceholderIcon
src="https://assets.triple.guide/images/[email protected]"
width={60}
/>
<Text size="small" color="gray" alpha={0.3}>
{t([
'igosyi-ceos-beonjjae-sajineul-olryeojuseyo.',
Expand All @@ -68,22 +88,30 @@ function ImagePlaceholder({
)
}

interface ResponsiveImagePlaceholderProps {
onClick: () => void
noContent?: boolean
}

export default function ResponsiveImagePlaceholder({
onClick,
noContent,
}: ResponsiveImagePlaceholderProps) {
guestMode,
type,
onClick,
}: Omit<ImagePlaceholderProps, 'large'>) {
return (
<>
<Responsive maxWidth={706}>
<ImagePlaceholder noContent={noContent} onClick={onClick} />
<ImagePlaceholder
noContent={noContent}
guestMode={guestMode}
type={type}
onClick={onClick}
/>
</Responsive>
<Responsive minWidth={707}>
<ImagePlaceholder noContent={noContent} large onClick={onClick} />
<ImagePlaceholder
noContent={noContent}
guestMode={guestMode}
type={type}
large
onClick={onClick}
/>
</Responsive>
</>
)
Expand Down
34 changes: 21 additions & 13 deletions packages/poi-list-elements/src/carousel-element.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ function PoiCarouselElement<T extends PoiListElementType>({
imageFrame,
onImpress,
optimized,
guestMode,
}: PoiListElementBaseProps<T> & {
actionButtonElement?: ActionButtonElement
description?: ReactNode
Expand All @@ -43,15 +44,32 @@ function PoiCarouselElement<T extends PoiListElementType>({
imageFrame?: FrameRatioAndSizes
onImpress?: () => void
optimized?: boolean
guestMode?: boolean
}) {
if (!poi) {
return null
}

const { names: regionNames } = region?.source || {}

const name = nameOverride || names.ko || names.en || names.local
const regionName = regionNames?.ko || regionNames?.en || regionNames?.local
const name =
nameOverride || names.primary || names.ko || names.en || names.local
const regionName =
regionNames?.primary ||
regionNames?.ko ||
regionNames?.en ||
regionNames?.local
const ActionButton = actionButtonElement || (
<Container
position="absolute"
css={{
top: '3px',
right: '3px',
}}
>
<OverlayScrapButton resource={poi} size={36} />
</Container>
)

return (
<Carousel.Item
Expand Down Expand Up @@ -91,17 +109,7 @@ function PoiCarouselElement<T extends PoiListElementType>({
: vicinity}
</Text>

{actionButtonElement || (
<Container
position="absolute"
css={{
top: '3px',
right: '3px',
}}
>
<OverlayScrapButton resource={poi} size={36} />
</Container>
)}
{!guestMode ? ActionButton : null}

{additionalInfo}
</Carousel.Item>
Expand Down
38 changes: 23 additions & 15 deletions packages/poi-list-elements/src/compact-poi-list-element.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { getTypeNames } from './get-type-names'
interface CompactPoiListElementBaseProps<T extends PoiListElementType>
extends PoiListElementBaseProps<T> {
actionButtonElement?: ActionButtonElement
guestMode?: boolean
}

export type CompactPoiListElementProps<T extends PoiListElementType> =
Expand All @@ -41,6 +42,7 @@ export function CompactPoiListElement<T extends PoiListElementType>({
source: { names, image, areas, vicinity },
},
onClick,
guestMode,
}: CompactPoiListElementProps<T>) {
const [actionButtonWidth, setActionButtonWidth] = useState(0)
const actionButtonRef = useRef<HTMLDivElement & { width?: number }>(null)
Expand All @@ -53,8 +55,26 @@ export function CompactPoiListElement<T extends PoiListElementType>({

const { names: regionNames } = region?.source || {}

const name = nameOverride || names.ko || names.en || names.local
const regionName = regionNames?.ko || regionNames?.en || regionNames?.local
const name =
nameOverride || names.primary || names.ko || names.en || names.local
const regionName =
regionNames?.primary ||
regionNames?.ko ||
regionNames?.en ||
regionNames?.local
const ActionButton = actionButtonElement ? (
<div ref={actionButtonRef}>{actionButtonElement}</div>
) : (
<Container
position="absolute"
css={{
top: 0,
right: 0,
}}
>
<OutlineScrapButton resource={poi} size={34} />
</Container>
)

return (
<ResourceListItem onClick={onClick}>
Expand Down Expand Up @@ -86,19 +106,7 @@ export function CompactPoiListElement<T extends PoiListElementType>({
.join(' · ')}
</Text>

{actionButtonElement ? (
<div ref={actionButtonRef}>{actionButtonElement}</div>
) : (
<Container
position="absolute"
css={{
top: 0,
right: 0,
}}
>
<OutlineScrapButton resource={poi} size={34} />
</Container>
)}
{!guestMode ? ActionButton : null}
</ResourceListItem>
)
}
3 changes: 3 additions & 0 deletions packages/triple-document/src/elements/pois.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
import { Text } from '@titicaca/core-elements'

import { useResourceClickHandler } from '../prop-context/resource-click-handler'
import { useGuestMode } from '../prop-context/guest-mode'

import ResourceList from './shared/resource-list'
import DocumentCarousel from './shared/document-carousel'
Expand Down Expand Up @@ -43,6 +44,7 @@ export default function Pois<T extends ExtendedPoiListElementData>({
pois: T[]
}
}) {
const guestMode = useGuestMode()
const onResourceClick = useResourceClickHandler()

const Container = display === 'list' ? ResourceList : DocumentCarousel
Expand Down Expand Up @@ -74,6 +76,7 @@ export default function Pois<T extends ExtendedPoiListElementData>({
display,
poi,
})}
guestMode={guestMode}
/>
))}
</Container>
Expand Down
1 change: 1 addition & 0 deletions packages/triple-document/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export { Slot } from './elements/tna/slot'
export { PricePolicyCouponInfo } from './elements/tna/price-policy-coupon-info'

export { useDeepLink } from './prop-context/deep-link'
export { useGuestMode } from './prop-context/guest-mode'
export { useImageClickHandler } from './prop-context/image-click-handler'
export { useImageSource } from './prop-context/image-source'
export { useLinkClickHandler } from './prop-context/link-click-handler'
Expand Down
Loading
Loading