From 113733c7476d6c81ef0c88fd6945ff7bad0c2afc Mon Sep 17 00:00:00 2001 From: "hyunwoo93.cha" Date: Tue, 13 Feb 2024 22:01:24 +0900 Subject: [PATCH] =?UTF-8?q?[TButtonTab]=20=EA=B3=B5=ED=86=B5=20=EC=BB=B4?= =?UTF-8?q?=ED=8F=AC=EB=84=8C=ED=8A=B8=20-=20TButtonTab=20(=ED=83=AD?= =?UTF-8?q?=EB=B0=94)=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/TButtonTab/TButtonTab.jsx | 66 +++++++++++++ .../TButtonTab/TButtonTab.module.less | 17 ++++ .../components/TButtonTab/TButtonTabItem.jsx | 95 +++++++++++++++++++ .../TButtonTab/TButtonTabItem.module.less | 49 ++++++++++ 4 files changed, 227 insertions(+) create mode 100644 com.twin.app.shoptime/src/components/TButtonTab/TButtonTab.jsx create mode 100644 com.twin.app.shoptime/src/components/TButtonTab/TButtonTab.module.less create mode 100644 com.twin.app.shoptime/src/components/TButtonTab/TButtonTabItem.jsx create mode 100644 com.twin.app.shoptime/src/components/TButtonTab/TButtonTabItem.module.less diff --git a/com.twin.app.shoptime/src/components/TButtonTab/TButtonTab.jsx b/com.twin.app.shoptime/src/components/TButtonTab/TButtonTab.jsx new file mode 100644 index 00000000..8de77442 --- /dev/null +++ b/com.twin.app.shoptime/src/components/TButtonTab/TButtonTab.jsx @@ -0,0 +1,66 @@ +import React, { useCallback } from "react"; + +import classNames from "classnames"; + +import SpotlightContainerDecorator from "@enact/spotlight/SpotlightContainerDecorator"; + +import css from "./TButtonTab.module.less"; +import TButtonTabItem from "./TButtonTabItem"; + +const Container = SpotlightContainerDecorator( + { enterTo: "last-focused" }, + "div" +); + +export const LIST_TYPE = { + large: "large", + medium: "medium", + small: "small", +}; + +export const RIGHT_BUTTON_TYPE = { + sort: "sort", +}; + +export default function TButtonTab({ + className, + selectedIndex, + onItemClick, + contents = [], + noMarquee = false, + listType = LIST_TYPE.medium, + spotlightId, + ...rest +}) { + const onClick = useCallback( + (index) => (e) => { + if (onItemClick) { + onItemClick({ index, e }); + } + }, + [selectedIndex] + ); + + return ( + + {contents.map((item, index) => { + return ( + + {item} + + ); + })} + + ); +} diff --git a/com.twin.app.shoptime/src/components/TButtonTab/TButtonTab.module.less b/com.twin.app.shoptime/src/components/TButtonTab/TButtonTab.module.less new file mode 100644 index 00000000..99ef1ad9 --- /dev/null +++ b/com.twin.app.shoptime/src/components/TButtonTab/TButtonTab.module.less @@ -0,0 +1,17 @@ +@import "../../style/CommonStyle.module.less"; +@import "../../style/utils.module.less"; + +.tabs { + .size(@w: 1680px, @h: 67px); + display: flex; + position: relative; + + &::after { + content: ""; + position: absolute; + .size(@w: 100%, @h: 1px); + background-color: @COLOR_DARK_RED; + left: 0; + bottom: 0; + } +} diff --git a/com.twin.app.shoptime/src/components/TButtonTab/TButtonTabItem.jsx b/com.twin.app.shoptime/src/components/TButtonTab/TButtonTabItem.jsx new file mode 100644 index 00000000..41321ffb --- /dev/null +++ b/com.twin.app.shoptime/src/components/TButtonTab/TButtonTabItem.jsx @@ -0,0 +1,95 @@ +import React, { useCallback, useRef, useState } from "react"; + +import classNames from "classnames"; +import compose from "ramda/src/compose"; + +import { Job } from "@enact/core/util"; +import Marquee, { MarqueeController } from "@enact/sandstone/Marquee"; +import Spottable from "@enact/spotlight/Spottable"; + +import * as Config from "../../utils/Config"; +import { convertNewlinesToBr } from "../../utils/helperMethods"; +import css from "./TButtonTabItem.module.less"; + +const SpottableComponent = Spottable("div"); + +const ItemBase = ({ + panelInfo, + selected, + onClick, + index, + selectedTabIndex, + spotlightDisabled = false, + noMarquee, + children, + listType, + ...rest +}) => { + const [pressed, setPressed] = useState(false); + const [blur, setBlur] = useState(true); + + const _onClick = useCallback( + (e) => { + if (onClick) { + onClick(e); + setPressed(true); + clearPressedJob.current.start(); + } + }, + [onClick] + ); + + const clearPressedJob = useRef( + new Job((func) => { + setPressed(false); + setTimeout(func, Config.TBUTTON_PRESS_DELAY); + }, Config.TBUTTON_PRESS_DELAY) + ); + + const _onBlur = useCallback(() => { + setPressed(false); + clearPressedJob.current.stop(); + setBlur(true); + }, [pressed]); + + const _onFocus = useCallback(() => { + setBlur(false); + }, [blur]); + + return ( + + {noMarquee ? ( +
{convertNewlinesToBr(children)}
+ ) : ( + + {children} + + )} +
+ ); +}; + +const ImageItemDecorator = compose( + MarqueeController({ mmarqueeOnFocus: true }) +); + +const TButtonTabItem = ImageItemDecorator(ItemBase); + +export default TButtonTabItem; diff --git a/com.twin.app.shoptime/src/components/TButtonTab/TButtonTabItem.module.less b/com.twin.app.shoptime/src/components/TButtonTab/TButtonTabItem.module.less new file mode 100644 index 00000000..fd2e00ba --- /dev/null +++ b/com.twin.app.shoptime/src/components/TButtonTab/TButtonTabItem.module.less @@ -0,0 +1,49 @@ +@import "../../style/CommonStyle.module.less"; +@import "../../style/utils.module.less"; + +@BORDER_WIDTH: 1px; + +.tItem { + min-width: 100px; + max-width: 500px; + height: calc(100% - @BORDER_WIDTH); + background-color: @COLOR_WHITE; + border-top-right-radius: 12px; + border-top-left-radius: 12px; + border: 1px solid @COLOR_GRAY02; + border-bottom: none; + box-sizing: border-box; + padding: 0 12px; + + .title { + .font(@fontFamily: @baseFontBold, @fontSize: 24px); + color: @COLOR_GRAY03; + width: 100%; + height: 100%; + display: flex; + justify-content: center; + align-items: center; + } + + &.selected { + background-color: @COLOR_DARK_RED; + border-color: @COLOR_DARK_RED; + + .title { + color: @COLOR_WHITE; + } + } + + &:focus-within { + background-color: @PRIMARY_COLOR_RED; + border-color: @PRIMARY_COLOR_RED; + + .title { + color: @COLOR_WHITE; + } + } + + &.medium { + min-width: 330px; + } +}