Files
shoptime/com.twin.app.shoptime/src/views/HomePanel/PopularShow/PopularShow.jsx
junghoon86.park d5f4dc30f2 [TItemCard] videoshow 부분 이미지 가로형 세로형 관련 추가.
- TItemCard imgType 추가.
 - getTop20Show topinfos 값중 vtctpYn값이 Y가 아닐시 가로형 이미지.
2024-03-05 11:29:31 +09:00

93 lines
2.8 KiB
JavaScript

import React, { useCallback, useEffect, useState } from "react";
import { useDispatch, useSelector } from "react-redux";
import { SpotlightContainerDecorator } from "@enact/spotlight/SpotlightContainerDecorator";
import Spottable from "@enact/spotlight/Spottable";
import { pushPanel } from "../../../actions/panelActions";
import SectionTitle from "../../../components/SectionTitle/SectionTitle";
import TItemCard, {
IMAGETYPES,
TYPES,
} from "../../../components/TItemCard/TItemCard";
import TScroller from "../../../components/TScroller/TScroller";
import useScrollReset from "../../../hooks/useScrollReset";
import useScrollTo from "../../../hooks/useScrollTo";
import { panel_names } from "../../../utils/Config";
import { $L } from "../../../utils/helperMethods";
import css from "../PopularShow/PopularShow.module.less";
const SpottableComponent = Spottable("div");
const Container = SpotlightContainerDecorator(
{ enterTo: "last-focused" },
"div"
);
const PopularShow = ({ ...rest }) => {
const dispatch = useDispatch();
const topInfos = useSelector((state) => state.main.top20ShowData.topInfos);
const [drawChk, setDrawChk] = useState(false);
const { getScrollTo, scrollLeft } = useScrollTo();
const { handleScrollReset, handleStopScrolling } = useScrollReset(
scrollLeft,
true
);
useEffect(() => {
setDrawChk(true);
}, [topInfos]);
const handleCardClick = useCallback(() => {
dispatch(
pushPanel(
{
name: panel_names.TRENDING_NOW_PANEL,
},
[dispatch]
)
);
});
return (
<Container className={css.popularShow}>
<SectionTitle className={css.subTitle} title={$L(`POPULAR SHOW`)} />
<TScroller
className={css.showList}
direction="horizontal"
cbScrollTo={getScrollTo}
noScrollByWheel
>
{topInfos &&
topInfos.map((item, index) => {
return (
<TItemCard
key={item.showId}
imageSource={
item.thumbnailUrl !== item.thumbnailUrl960
? item.thumbnailUrl960
: item.thumbnailUrl
}
imageAlt={item.showNm}
productName={item.showNm}
nonPosition={true}
type={TYPES.videoShow}
imgType={
item.vtctpYn !== "Y"
? IMAGETYPES.imgHorizontal
: IMAGETYPES.imgVertical
}
onFocus={index === 0 ? handleScrollReset : null}
onBlur={handleStopScrolling}
onClick={handleCardClick}
/>
);
})}
{drawChk && (
<SpottableComponent className={css.addItem}></SpottableComponent>
)}
</TScroller>
</Container>
);
};
export default PopularShow;