2Depth active 수정
This commit is contained in:
@@ -14,6 +14,7 @@ const TabItemBase = ({
|
|||||||
icons,
|
icons,
|
||||||
title,
|
title,
|
||||||
expanded = false,
|
expanded = false,
|
||||||
|
mainSelected = false,
|
||||||
selected = false,
|
selected = false,
|
||||||
index = 0,
|
index = 0,
|
||||||
target,
|
target,
|
||||||
@@ -44,7 +45,6 @@ const TabItemBase = ({
|
|||||||
|
|
||||||
const _onFocus = useCallback(() => {
|
const _onFocus = useCallback(() => {
|
||||||
setFocused(true);
|
setFocused(true);
|
||||||
|
|
||||||
if (onFocus) {
|
if (onFocus) {
|
||||||
onFocus(index);
|
onFocus(index);
|
||||||
}
|
}
|
||||||
@@ -57,34 +57,44 @@ const TabItemBase = ({
|
|||||||
const onKeyDown = useCallback(
|
const onKeyDown = useCallback(
|
||||||
(event) => {
|
(event) => {
|
||||||
if (event.key === "ArrowRight") {
|
if (event.key === "ArrowRight") {
|
||||||
|
if (!showSubTab) {
|
||||||
_onClick();
|
_onClick();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
[deActivateTab]
|
[deActivateTab]
|
||||||
);
|
);
|
||||||
|
|
||||||
const renderIcon = useCallback(() => {
|
const renderIcon = useCallback(() => {
|
||||||
if (icons) {
|
if (!icons) {
|
||||||
const Component = icons;
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Component = icons;
|
||||||
|
let iconType = "normal";
|
||||||
|
|
||||||
let iconType;
|
|
||||||
if (expanded && index === mainSelectedIndex) {
|
if (expanded && index === mainSelectedIndex) {
|
||||||
iconType = "focused";
|
iconType = "focused";
|
||||||
} else {
|
} else if (selected) {
|
||||||
iconType = focused
|
iconType = "selected";
|
||||||
? "focused"
|
} else if (mainSelected) {
|
||||||
: selected
|
iconType = "selected";
|
||||||
? "selected"
|
} else if (focused) {
|
||||||
: expanded
|
iconType = "focused";
|
||||||
? "expanded"
|
} else if (expanded) {
|
||||||
: "normal";
|
iconType = "expanded";
|
||||||
}
|
}
|
||||||
|
|
||||||
return <Component iconType={iconType} />;
|
return <Component iconType={iconType} />;
|
||||||
} else {
|
}, [
|
||||||
return null;
|
focused,
|
||||||
}
|
expanded,
|
||||||
}, [focused, expanded, selected, mainSelectedIndex, index, icons]);
|
mainSelected,
|
||||||
|
mainSelectedIndex,
|
||||||
|
index,
|
||||||
|
icons,
|
||||||
|
selected,
|
||||||
|
]);
|
||||||
|
|
||||||
delete rest.hasChildren;
|
delete rest.hasChildren;
|
||||||
delete rest.getChildren;
|
delete rest.getChildren;
|
||||||
@@ -97,6 +107,7 @@ const TabItemBase = ({
|
|||||||
(focused || index === mainSelectedIndex) &&
|
(focused || index === mainSelectedIndex) &&
|
||||||
showSubTab &&
|
showSubTab &&
|
||||||
css.arrow,
|
css.arrow,
|
||||||
|
mainSelected && css.selected,
|
||||||
selected && css.selected
|
selected && css.selected
|
||||||
)}
|
)}
|
||||||
onKeyDown={onKeyDown}
|
onKeyDown={onKeyDown}
|
||||||
@@ -113,6 +124,7 @@ const TabItemBase = ({
|
|||||||
{icons && <div className={css.icon}>{renderIcon()}</div>}
|
{icons && <div className={css.icon}>{renderIcon()}</div>}
|
||||||
{expanded && title && (
|
{expanded && title && (
|
||||||
<Marquee
|
<Marquee
|
||||||
|
marqueeDisabled={!focused}
|
||||||
className={classNames(css.text, isSubItem && css.subItem)}
|
className={classNames(css.text, isSubItem && css.subItem)}
|
||||||
marqueeOn={"focus"}
|
marqueeOn={"focus"}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -3,6 +3,29 @@
|
|||||||
|
|
||||||
@ICON_SIZE: 48px;
|
@ICON_SIZE: 48px;
|
||||||
|
|
||||||
|
// @-webkit-keyframes textLoop {
|
||||||
|
// 0% {
|
||||||
|
// -webkit-transform: translate(50%);
|
||||||
|
// transform: translate(50%);
|
||||||
|
// }
|
||||||
|
// to {
|
||||||
|
// -webkit-transform: translate(calc(-100% - 189px));
|
||||||
|
// transform: translate(calc(-100% - 189px));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// @keyframes textLoop {
|
||||||
|
// 0% {
|
||||||
|
// -webkit-transform: translate(50%);
|
||||||
|
// transform: translate(50%);
|
||||||
|
// }
|
||||||
|
// to {
|
||||||
|
// -webkit-transform: translate(calc(-100% - 289px));
|
||||||
|
// transform: translate(calc(-100% - 189px));
|
||||||
|
// left: 100%; /* 끝 위치 */
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
.tabItem{
|
.tabItem{
|
||||||
font-size: 36px;
|
font-size: 36px;
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -69,15 +92,21 @@
|
|||||||
.text {
|
.text {
|
||||||
line-height: 1.2;
|
line-height: 1.2;
|
||||||
padding-left: 11px;
|
padding-left: 11px;
|
||||||
|
// .elip(@clamp: 1);
|
||||||
|
|
||||||
.font(@fontFamily:@baseFontBold, @fontSize:36px);
|
.font(@fontFamily:@baseFontBold, @fontSize:36px);
|
||||||
|
|
||||||
&.subItem {
|
&.subItem {
|
||||||
.font (@fontFamily:@baseFontBold, @fontSize:30px);
|
.font (@fontFamily:@baseFontBold, @fontSize:30px);
|
||||||
width: 245px;
|
width: 245px;
|
||||||
|
// word-break:break-all;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.marqueeWrap {
|
.marqueeWrap {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ const TabItemBase = ({
|
|||||||
<>
|
<>
|
||||||
{expanded && (
|
{expanded && (
|
||||||
<Marquee
|
<Marquee
|
||||||
|
marqueeDisabled={!focused}
|
||||||
marqueeOn={"focus"}
|
marqueeOn={"focus"}
|
||||||
className={classNames(css.text, isSubItem && css.subItem)}
|
className={classNames(css.text, isSubItem && css.subItem)}
|
||||||
>
|
>
|
||||||
@@ -92,7 +93,7 @@ const TabItemBase = ({
|
|||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}, [title]);
|
}, [title, focused]);
|
||||||
|
|
||||||
delete rest.hasChildren;
|
delete rest.hasChildren;
|
||||||
delete rest.getChildren;
|
delete rest.getChildren;
|
||||||
|
|||||||
@@ -89,11 +89,14 @@
|
|||||||
.text {
|
.text {
|
||||||
line-height: 1.2;
|
line-height: 1.2;
|
||||||
padding-left: 11px;
|
padding-left: 11px;
|
||||||
|
|
||||||
|
.elip(@clamp: 1);
|
||||||
.font(@fontFamily:@baseFontBold, @fontSize:36px);
|
.font(@fontFamily:@baseFontBold, @fontSize:36px);
|
||||||
|
|
||||||
&.subItem {
|
&.subItem {
|
||||||
.font (@fontFamily:@baseFontBold, @fontSize:30px);
|
.font (@fontFamily:@baseFontBold, @fontSize:30px);
|
||||||
width: 245px;
|
width: 248px;
|
||||||
|
word-break:break-all;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -114,7 +114,6 @@ export default function TabLayout({ topPanelName, onTabActivated }) {
|
|||||||
const [mainExpanded, setMainExpanded] = useState(false);
|
const [mainExpanded, setMainExpanded] = useState(false);
|
||||||
const [mainSelectedIndex, setMainSelectedIndex] = useState(-1);
|
const [mainSelectedIndex, setMainSelectedIndex] = useState(-1);
|
||||||
const [secondDepthReduce, setSecondDepthReduce] = useState(false);
|
const [secondDepthReduce, setSecondDepthReduce] = useState(false);
|
||||||
const [temp, setTemp] = useState(false);
|
|
||||||
const [tabs, setTabs] = useState([]);
|
const [tabs, setTabs] = useState([]);
|
||||||
const [tabFocused, setTabFocused] = useState([false, false, false]); //COLLABSED_MAIN, ACTIVATED_MAIN, ACTIVATED_SUB
|
const [tabFocused, setTabFocused] = useState([false, false, false]); //COLLABSED_MAIN, ACTIVATED_MAIN, ACTIVATED_SUB
|
||||||
const panelSwitching = useRef(null);
|
const panelSwitching = useRef(null);
|
||||||
@@ -126,9 +125,11 @@ export default function TabLayout({ topPanelName, onTabActivated }) {
|
|||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
icons: CategoryIcon,
|
icons: CategoryIcon,
|
||||||
|
// target: [{ name: panel_names.CATEGORY_PANEL }],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
icons: MyPageIcon,
|
icons: MyPageIcon,
|
||||||
|
// target: [{ name: panel_names.MY_PAGE_PANEL }],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
icons: SearchIcon,
|
icons: SearchIcon,
|
||||||
@@ -140,6 +141,7 @@ export default function TabLayout({ topPanelName, onTabActivated }) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
icons: FeaturedBrandIcon,
|
icons: FeaturedBrandIcon,
|
||||||
|
// target: [{ name: panel_names.FEATURED_BRANDS_PANEL }],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
icons: OnSaleIcon,
|
icons: OnSaleIcon,
|
||||||
@@ -201,9 +203,16 @@ export default function TabLayout({ topPanelName, onTabActivated }) {
|
|||||||
case "My Page":
|
case "My Page":
|
||||||
result = data?.mypage.map((item) => ({
|
result = data?.mypage.map((item) => ({
|
||||||
title: item.menuNm,
|
title: item.menuNm,
|
||||||
|
target: [
|
||||||
|
{
|
||||||
|
name: panel_names.MY_PAGE_PANEL,
|
||||||
|
panelInfo: item.menuOrd,
|
||||||
|
},
|
||||||
|
],
|
||||||
}));
|
}));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
//console.log("#data", data);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -306,7 +315,6 @@ export default function TabLayout({ topPanelName, onTabActivated }) {
|
|||||||
}
|
}
|
||||||
case EXTRA_AREA: {
|
case EXTRA_AREA: {
|
||||||
if (cursorVisible) {
|
if (cursorVisible) {
|
||||||
// deActivateTabJob.start(deActivateTab);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -351,19 +359,15 @@ export default function TabLayout({ topPanelName, onTabActivated }) {
|
|||||||
|
|
||||||
const onFocus = (index) => {
|
const onFocus = (index) => {
|
||||||
setMainSelectedIndex(index);
|
setMainSelectedIndex(index);
|
||||||
setTemp(false);
|
|
||||||
if (showSubTab) {
|
if (showSubTab) {
|
||||||
setSecondDepthReduce((prev) => !prev);
|
setSecondDepthReduce((prev) => !prev);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const onBlur = useCallback(() => {
|
|
||||||
setTemp(true);
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const handleNavigation = useCallback(
|
const handleNavigation = useCallback(
|
||||||
({ index, target }) => {
|
({ index, target }) => {
|
||||||
if (target) {
|
if (target && !showSubTab) {
|
||||||
dispatch(resetPanels(target));
|
dispatch(resetPanels(target));
|
||||||
deActivateTab();
|
deActivateTab();
|
||||||
panelSwitching.current = true;
|
panelSwitching.current = true;
|
||||||
@@ -441,6 +445,7 @@ export default function TabLayout({ topPanelName, onTabActivated }) {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setSecondDepthReduce(false);
|
setSecondDepthReduce(false);
|
||||||
|
|
||||||
if (showSubTab) {
|
if (showSubTab) {
|
||||||
tabs[mainSelectedIndex]?.children.map((item) => {
|
tabs[mainSelectedIndex]?.children.map((item) => {
|
||||||
if (item.path) {
|
if (item.path) {
|
||||||
@@ -506,12 +511,18 @@ export default function TabLayout({ topPanelName, onTabActivated }) {
|
|||||||
showSubTab={showSubTab}
|
showSubTab={showSubTab}
|
||||||
icons={item.icons}
|
icons={item.icons}
|
||||||
expanded={mainExpanded}
|
expanded={mainExpanded}
|
||||||
selected={
|
mainSelected={
|
||||||
(panels.length === 0 && index === 0) ||
|
(panels.length === 0 && index === 0) ||
|
||||||
(Array.isArray(item.target) &&
|
(Array.isArray(item.target) &&
|
||||||
item.target[0]?.name &&
|
item.target[0]?.name &&
|
||||||
panels[0]?.name === item.target[0]?.name)
|
panels[0]?.name === item.target[0]?.name)
|
||||||
}
|
}
|
||||||
|
selected={
|
||||||
|
(panels.length === 0 && index === 0) ||
|
||||||
|
(Array.isArray(item.children[0]?.target) &&
|
||||||
|
item.children[0]?.target[0]?.name &&
|
||||||
|
panels[0]?.name === item.children[0]?.target?.[0].name)
|
||||||
|
}
|
||||||
title={item.title}
|
title={item.title}
|
||||||
index={index}
|
index={index}
|
||||||
mainSelectedIndex={mainSelectedIndex}
|
mainSelectedIndex={mainSelectedIndex}
|
||||||
@@ -549,10 +560,9 @@ export default function TabLayout({ topPanelName, onTabActivated }) {
|
|||||||
path={item.path}
|
path={item.path}
|
||||||
showSubTab={showSubTab}
|
showSubTab={showSubTab}
|
||||||
selected={
|
selected={
|
||||||
(panels.length === 0 && index === 0) ||
|
Array.isArray(item.target) &&
|
||||||
(Array.isArray(item.target) &&
|
|
||||||
item.target[0]?.panelInfo &&
|
item.target[0]?.panelInfo &&
|
||||||
panels[0]?.panelInfo === item.target[0]?.panelInfo)
|
panels[0]?.panelInfo === item.target[0]?.panelInfo
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -39,9 +39,9 @@
|
|||||||
justify-content: center;
|
justify-content: center;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
flex-grow: 0;
|
flex-grow: 0;
|
||||||
|
|
||||||
// transition: width 0.5s ease;
|
// transition: width 0.5s ease;
|
||||||
|
|
||||||
|
|
||||||
> img {
|
> img {
|
||||||
width: 54px;
|
width: 54px;
|
||||||
height: 54px;
|
height: 54px;
|
||||||
|
|||||||
Reference in New Issue
Block a user