업데이트
This commit is contained in:
@@ -16,5 +16,6 @@ export interface MenuCategoryProps {
|
|||||||
setMenuOn?: (menuOn: boolean) => void;
|
setMenuOn?: (menuOn: boolean) => void;
|
||||||
editMode?: boolean;
|
editMode?: boolean;
|
||||||
setChangeMenuId: (menuId?: string) => void;
|
setChangeMenuId: (menuId?: string) => void;
|
||||||
buttonRefs: RefObject<Array<HTMLLIElement | null>>;
|
buttonRef: any
|
||||||
|
btnRef?: any;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ export const MenuCategory = ({
|
|||||||
setMenuOn,
|
setMenuOn,
|
||||||
editMode,
|
editMode,
|
||||||
setChangeMenuId,
|
setChangeMenuId,
|
||||||
buttonRefs
|
buttonRef,btnRef
|
||||||
}: MenuCategoryProps) => {
|
}: MenuCategoryProps) => {
|
||||||
const { navigate } = useNavigate();
|
const { navigate } = useNavigate();
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ export const MenuCategory = ({
|
|||||||
menuId?: string
|
menuId?: string
|
||||||
) => {
|
) => {
|
||||||
let userFavorite = useStore.getState().UserStore.userFavorite;
|
let userFavorite = useStore.getState().UserStore.userFavorite;
|
||||||
let randomNum = Math.floor(Math.random() * 5) + 1;
|
let randomNum = Math.floor(Math.random() * 3) + 1;
|
||||||
if(checked){
|
if(checked){
|
||||||
userFavorite = [
|
userFavorite = [
|
||||||
...userFavorite,
|
...userFavorite,
|
||||||
@@ -78,7 +78,6 @@ export const MenuCategory = ({
|
|||||||
<li
|
<li
|
||||||
key={ `menu-item-key-${menuId}-${i}` }
|
key={ `menu-item-key-${menuId}-${i}` }
|
||||||
onClick={ () => onClickToNavigate(subMenu[i]?.path) }
|
onClick={ () => onClickToNavigate(subMenu[i]?.path) }
|
||||||
ref={ (element) => { buttonRefs.current[i] = element }}
|
|
||||||
>
|
>
|
||||||
<span>{ subMenu[i]?.menuName }</span>
|
<span>{ subMenu[i]?.menuName }</span>
|
||||||
<div className="check_box_scrap">
|
<div className="check_box_scrap">
|
||||||
@@ -107,7 +106,7 @@ export const MenuCategory = ({
|
|||||||
<li
|
<li
|
||||||
key={ `menu-item-key-${i}` }
|
key={ `menu-item-key-${i}` }
|
||||||
onClick={ () => onClickToNavigate(subMenu[i]?.path) }
|
onClick={ () => onClickToNavigate(subMenu[i]?.path) }
|
||||||
ref={ (element) => { buttonRefs.current[i] = element }}
|
|
||||||
>{ subMenu[i]?.menuName }</li>
|
>{ subMenu[i]?.menuName }</li>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -120,8 +119,13 @@ export const MenuCategory = ({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="menu-category">
|
<div
|
||||||
<div className="category-header">
|
className={`menu-category ${btnRef? 'ok': 'no'}`}
|
||||||
|
|
||||||
|
>
|
||||||
|
<div className="category-header"
|
||||||
|
ref={ btnRef || null }
|
||||||
|
>
|
||||||
<div className={ 'category-icon ' + menuIcon }></div>
|
<div className={ 'category-icon ' + menuIcon }></div>
|
||||||
<span>{ menuName }</span>
|
<span>{ menuName }</span>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -121,4 +121,7 @@ main {
|
|||||||
top: 234px;
|
top: 234px;
|
||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
}
|
||||||
|
.menu-category{
|
||||||
|
position: relative;
|
||||||
}
|
}
|
||||||
@@ -27,16 +27,36 @@ export const Menu = ({
|
|||||||
const [editMode, setEditMode] = useState<boolean>(false);
|
const [editMode, setEditMode] = useState<boolean>(false);
|
||||||
const [changeMenuId, setChangeMenuId] = useState<string | undefined>();
|
const [changeMenuId, setChangeMenuId] = useState<string | undefined>();
|
||||||
|
|
||||||
const buttonRefs = useRef<Array<HTMLLIElement>>([]);
|
const buttonRefs = useRef<Array<HTMLDivElement>>([]);
|
||||||
|
const btnRef = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
const onClickToNavigate = (path: string) => {
|
const onClickToNavigate = (path: string) => {
|
||||||
onClickToMenuClose();
|
onClickToMenuClose();
|
||||||
navigate(path);
|
navigate(path);
|
||||||
};
|
};
|
||||||
const onClickToMenuNavigate = (menuId: string, index: number) => {
|
const onClickToMenuNavigate = (menuId: string, index: number) => {
|
||||||
|
//let rect = buttonRefs.current[index]?.getBoundingClientRect();
|
||||||
|
//console.log(rect?.top)
|
||||||
|
/*
|
||||||
buttonRefs.current[index]?.scrollIntoView({
|
buttonRefs.current[index]?.scrollIntoView({
|
||||||
behavior: 'smooth'
|
behavior: 'smooth'
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
|
if(index === 1){
|
||||||
|
/*
|
||||||
|
btnRef.current?.scrollTo({
|
||||||
|
top: 300,
|
||||||
|
behavior: "smooth"
|
||||||
|
});
|
||||||
|
*/
|
||||||
|
btnRef.current?.scrollIntoView({
|
||||||
|
block: 'start',
|
||||||
|
behavior: 'smooth'
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
const onClickToMenuClose = () => {
|
const onClickToMenuClose = () => {
|
||||||
if(editMode){
|
if(editMode){
|
||||||
@@ -50,7 +70,8 @@ export const Menu = ({
|
|||||||
const getMenuCategory = () => {
|
const getMenuCategory = () => {
|
||||||
let rs = [];
|
let rs = [];
|
||||||
for(let i=0;i<MenuItems.length;i++){
|
for(let i=0;i<MenuItems.length;i++){
|
||||||
rs.push(
|
if(i===1){
|
||||||
|
rs.push(
|
||||||
<MenuCategory
|
<MenuCategory
|
||||||
key={ `menu-category-${i}` }
|
key={ `menu-category-${i}` }
|
||||||
menuId={ MenuItems[i]?.menuId }
|
menuId={ MenuItems[i]?.menuId }
|
||||||
@@ -60,9 +81,28 @@ export const Menu = ({
|
|||||||
setMenuOn={ setMenuOn }
|
setMenuOn={ setMenuOn }
|
||||||
editMode={ editMode }
|
editMode={ editMode }
|
||||||
setChangeMenuId= { setChangeMenuId }
|
setChangeMenuId= { setChangeMenuId }
|
||||||
buttonRefs={ buttonRefs }
|
buttonRef={ buttonRefs.current[i] }
|
||||||
|
btnRef={ btnRef }
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
rs.push(
|
||||||
|
<MenuCategory
|
||||||
|
key={ `menu-category-${i}` }
|
||||||
|
menuId={ MenuItems[i]?.menuId }
|
||||||
|
menuIcon={ MenuItems[i]?.menuIcon }
|
||||||
|
menuName={ MenuItems[i]?.menuName }
|
||||||
|
subMenu={ MenuItems[i]?.subMenu }
|
||||||
|
setMenuOn={ setMenuOn }
|
||||||
|
editMode={ editMode }
|
||||||
|
setChangeMenuId= { setChangeMenuId }
|
||||||
|
buttonRef={ buttonRefs.current[i] }
|
||||||
|
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return rs;
|
return rs;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -76,7 +76,10 @@ export const HeaderNavigation = ({
|
|||||||
<select className="heading-select">
|
<select className="heading-select">
|
||||||
{ selectOptions && selectOptions.length > 0 &&
|
{ selectOptions && selectOptions.length > 0 &&
|
||||||
selectOptions.map((value, index) => (
|
selectOptions.map((value, index) => (
|
||||||
<option value={ value.value }>{ value.name }</option>
|
<option
|
||||||
|
key={ value.value }
|
||||||
|
value={ value.value }
|
||||||
|
>{ value.name }</option>
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
</select>
|
</select>
|
||||||
|
|||||||
Reference in New Issue
Block a user