From 2f1b2606df4219bb8c5f22c46ab551b1aaecf813 Mon Sep 17 00:00:00 2001 From: "younghoon100.park" Date: Tue, 6 Feb 2024 14:43:40 +0900 Subject: [PATCH] =?UTF-8?q?[FeaturedBrandsPanel]=20=20QuickMenu,=20compone?= =?UTF-8?q?nt=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Detail Notes : 1. QuickMenu, Scroller → VirtualGridList 변경 2. QuickMenuItem 생성 및 css 수정 --- .../FeaturedBrandsPanel.jsx | 68 +++++++++------ .../QuickMenu/QuickMenu.jsx | 87 +++++++++---------- .../QuickMenu/QuickMenu.module.less | 61 ++----------- .../QuickMenuItem/QuickMenuItem.jsx | 45 ++++++++++ .../QuickMenuItem/QuickMenuItem.module.less | 73 ++++++++++++++++ .../QuickMenuItem/package.json | 6 ++ 6 files changed, 214 insertions(+), 126 deletions(-) create mode 100644 com.twin.app.shoptime/src/views/FeaturedBrandsPanel/QuickMenuItem/QuickMenuItem.jsx create mode 100644 com.twin.app.shoptime/src/views/FeaturedBrandsPanel/QuickMenuItem/QuickMenuItem.module.less create mode 100644 com.twin.app.shoptime/src/views/FeaturedBrandsPanel/QuickMenuItem/package.json diff --git a/com.twin.app.shoptime/src/views/FeaturedBrandsPanel/FeaturedBrandsPanel.jsx b/com.twin.app.shoptime/src/views/FeaturedBrandsPanel/FeaturedBrandsPanel.jsx index bc69cc93..435e451b 100644 --- a/com.twin.app.shoptime/src/views/FeaturedBrandsPanel/FeaturedBrandsPanel.jsx +++ b/com.twin.app.shoptime/src/views/FeaturedBrandsPanel/FeaturedBrandsPanel.jsx @@ -1,11 +1,14 @@ -import React, { useEffect, useState } from "react"; +import React, { useCallback, useEffect, useState } from "react"; import { useDispatch, useSelector } from "react-redux"; +import Spotlight from "@enact/spotlight"; + import { getBrandLayoutInfo, getBrandLiveChannelInfo, } from "../../actions/brandActions"; +import TBody from "../../components/TBody/TBody"; import TPanel from "../../components/TPanel/TPanel"; import Banner from "./Banner/Banner"; import css from "./FeaturedBrandsPanel.module.less"; @@ -37,9 +40,16 @@ export default function FeaturedBrandsPanel() { // @@pyh Todo, provided by GNB as props or global state const [selectedPatnrId, setSelectedPatnrId] = useState("1"); - const handleQuickMenu = (patnrId) => { - setSelectedPatnrId(patnrId); - }; + const handleQuickMenuClick = useCallback( + (patnrId) => { + if (selectedPatnrId === patnrId) { + return; + } + + setSelectedPatnrId(patnrId); + }, + [selectedPatnrId] + ); useEffect(() => { if (brandInfo) { @@ -50,32 +60,40 @@ export default function FeaturedBrandsPanel() { dispatch(getBrandLiveChannelInfo({ patnrId: selectedPatnrId })); }, [selectedPatnrId]); + useEffect(() => { + if (selectedPatnrId) { + Spotlight.focus("spotlight" + selectedPatnrId); + } + }, [selectedPatnrId]); + return ( /* scenario page 98 */ - {brandInfo && brandInfo.length > 1 && ( - - )} - - {selectedBrandInfo && ( - - )} - -
- {brandChanInfo && ( - + {brandInfo && brandInfo.length > 1 && ( + )} -
+ + {selectedBrandInfo && brandTopImgInfo && ( + + )} + +
+ {brandChanInfo && ( + + )} +
+
); } diff --git a/com.twin.app.shoptime/src/views/FeaturedBrandsPanel/QuickMenu/QuickMenu.jsx b/com.twin.app.shoptime/src/views/FeaturedBrandsPanel/QuickMenu/QuickMenu.jsx index 0884bc77..4e14ce4d 100644 --- a/com.twin.app.shoptime/src/views/FeaturedBrandsPanel/QuickMenu/QuickMenu.jsx +++ b/com.twin.app.shoptime/src/views/FeaturedBrandsPanel/QuickMenu/QuickMenu.jsx @@ -1,64 +1,61 @@ -import React, { useEffect } from 'react'; +import React, { useCallback, useEffect } from "react"; -import Spotlight from '@enact/spotlight'; -import SpotlightContainerDecorator - from '@enact/spotlight/SpotlightContainerDecorator'; -import Spottable from '@enact/spotlight/Spottable'; +import { VirtualGridList } from "@enact/sandstone/VirtualList"; +import SpotlightContainerDecorator from "@enact/spotlight/SpotlightContainerDecorator"; +import ri from "@enact/ui/resolution"; -import { $L } from '../../../utils/helperMethods'; -import css from './QuickMenu.module.less'; +import QuickMenuItem from "../QuickMenuItem/QuickMenuItem"; +import css from "./QuickMenu.module.less"; + +const LIST_ITEM_CONF = { + ITEM_WIDTH: 138 * 2, + ITEM_HEIGHT: 138 * 2, +}; const Container = SpotlightContainerDecorator( { leaveFor: { right: "" }, enterTo: "last-focused" }, "nav" ); -const SpottableComponent = Spottable("li"); - export default function QuickMenu({ brandInfo, selectedPatnrId, onQuickMenuClick, ...rest }) { - const handleClick = (patnrId) => { - if (selectedPatnrId === patnrId) { - return; - } - - onQuickMenuClick(patnrId); - }; - - useEffect(() => { - console.log("@@ brandInfo", brandInfo); - // @@pyh Todo, change to logic - // const element = document.getElementById(selectedPatnrId); - - Spotlight.focus("spotlight" + selectedPatnrId); - }, []); + const renderItem = useCallback( + ({ index, ...rest }) => { + return ( + + ); + }, + [brandInfo, selectedPatnrId, onQuickMenuClick] + ); return ( - -
    - {brandInfo && - brandInfo.map(({ logoImgAlt, logoImgPath, newFlag, patnrId }) => { - return ( - handleClick(patnrId)} - spotlightId={"spotlight" + patnrId} - > - {newFlag === "Y" && ( - {$L("NEW")} - )} - - {logoImgAlt} - - ); - })} -
+ + {brandInfo && ( + + )} ); } diff --git a/com.twin.app.shoptime/src/views/FeaturedBrandsPanel/QuickMenu/QuickMenu.module.less b/com.twin.app.shoptime/src/views/FeaturedBrandsPanel/QuickMenu/QuickMenu.module.less index 08ddf19e..32c4b75e 100644 --- a/com.twin.app.shoptime/src/views/FeaturedBrandsPanel/QuickMenu/QuickMenu.module.less +++ b/com.twin.app.shoptime/src/views/FeaturedBrandsPanel/QuickMenu/QuickMenu.module.less @@ -2,66 +2,15 @@ @import "../../../style/utils.module.less"; .container { - .flex(@justifyCenter:flex start); .size(@w: 100%, @h: 180px); - padding: 30px 60px; + padding: 18px 60px; background-color: #e7e7e7; - ul { - .flex(@justifyCenter: flex-start); - gap: 18px; + .virtualGridList { + overflow: unset; - /* normal */ - li { - position: relative; - - .newBagde { - .position(@position: absolute, @top: 0, @right: 0, @bottom: auto, @left: auto); - z-index: 10; - .size(@w: 60px, @h: 30px); - background-color: #f00; - color: #fff; - border-radius: 6px; - font-family: Arial; - font-weight: 600; - font-size: 18px; - text-align: center; - } - - .outline { - .position(@position: absolute, @top: 0, @right: auto, @bottom: auto, @left: 0); - .size(@w: 138px, @h:138px); - background-position: center; - background-size: cover; - } - - img { - .size(@w: 120px, @h: 120px); - } - - /* focused */ - &:focus { - border-radius: 60px; - .focusDropShadow(); - - .outline { - background-image: url("../../../../assets/images/partners/ic-tab-partners-focus@3x.png"); - } - - img { - .size(@w: 138px, @h: 138px); - } - } - - /* selected */ - &.selected { - img { - .size(@w: 138px, @h: 138px); - } - .outline { - background-image: url("../../../../assets/images/partners/ic-tab-partners-selected@3x.png"); - } - } + > div { + overflow: unset !important; } } } diff --git a/com.twin.app.shoptime/src/views/FeaturedBrandsPanel/QuickMenuItem/QuickMenuItem.jsx b/com.twin.app.shoptime/src/views/FeaturedBrandsPanel/QuickMenuItem/QuickMenuItem.jsx new file mode 100644 index 00000000..14c474ca --- /dev/null +++ b/com.twin.app.shoptime/src/views/FeaturedBrandsPanel/QuickMenuItem/QuickMenuItem.jsx @@ -0,0 +1,45 @@ +import React, { memo, useCallback } from "react"; + +import classNames from "classnames"; + +import Spottable from "@enact/spotlight/Spottable"; + +import { $L } from "../../../utils/helperMethods"; +import css from "./QuickMenuItem.module.less"; + +const SpottableComponent = Spottable("div"); + +export default memo(function QuickMenuItem({ + brandInfo, + index, + onQuickMenuClick, + selectedPatnrId, + ...rest +}) { + const { logoImgAlt, logoImgPath, newFlag, patnrId } = brandInfo[index]; + + const handleClick = useCallback( + (patnrId) => { + onQuickMenuClick && onQuickMenuClick(patnrId); + }, + [selectedPatnrId] + ); + + return ( + handleClick(patnrId)} + {...rest} + spotlightId={"spotlight" + patnrId} + > + {logoImgAlt} + {newFlag === "Y" &&
{$L("NEW")}
} + +
+ ); +}); diff --git a/com.twin.app.shoptime/src/views/FeaturedBrandsPanel/QuickMenuItem/QuickMenuItem.module.less b/com.twin.app.shoptime/src/views/FeaturedBrandsPanel/QuickMenuItem/QuickMenuItem.module.less new file mode 100644 index 00000000..810028cd --- /dev/null +++ b/com.twin.app.shoptime/src/views/FeaturedBrandsPanel/QuickMenuItem/QuickMenuItem.module.less @@ -0,0 +1,73 @@ +@import "../../../style/CommonStyle.module.less"; +@import "../../../style/utils.module.less"; + +.item { + /* normal */ + position: relative; + .size(@w: 138px, @h: 138px); + .flex(); + + // partner logo + img { + .size(@w: 120px, @h: 120px); + } + + // newBadge + > div { + .position(@position: absolute, @top: 0, @right: 18px); + z-index: 10; + .size(@w: 60px, @h: 30px); + border-radius: 6px; + background-color: #f00; + .font(@fontFamily: @arialFontBold, @fontSize: 18px); + color: @COLOR_WHITE; + text-align: center; + } + + // outline + > span { + .position(@position: absolute, @top: 0, @right: 0, @bottom: 0, @left: 0); + .size(@w: 138px, @h:138px); + background-position: center; + background-size: cover; + } + + /* focused */ + &:focus-within { + border-radius: 100%; + .focusDropShadow(); + + // partner logo + img { + .size(@w: 138px, @h: 138px); + } + + // newBadge + > div { + right: 0; + } + + // outline + > span { + background-image: url("../../../../assets/images/partners/ic-tab-partners-focus@3x.png"); + } + } + + /* selected */ + &.selected { + // partner logo + img { + .size(@w: 138px, @h: 138px); + } + + // newBadge + > div { + right: 0; + } + + // outline + > span { + background-image: url("../../../../assets/images/partners/ic-tab-partners-selected@3x.png"); + } + } +} diff --git a/com.twin.app.shoptime/src/views/FeaturedBrandsPanel/QuickMenuItem/package.json b/com.twin.app.shoptime/src/views/FeaturedBrandsPanel/QuickMenuItem/package.json new file mode 100644 index 00000000..6ba12e64 --- /dev/null +++ b/com.twin.app.shoptime/src/views/FeaturedBrandsPanel/QuickMenuItem/package.json @@ -0,0 +1,6 @@ +{ + "main": "QuickMenuItem.jsx", + "styles": [ + "QuickMenuItem.module.less" + ] +}