mirror of
https://github.com/vercel/commerce.git
synced 2025-07-05 12:41:21 +00:00
fix: fix bug Components MenuFilter and MenuNavigation follow by review of Ly Tran
This commit is contained in:
parent
1954d8c266
commit
51d30bb9e4
@ -2,7 +2,33 @@
|
|||||||
import { Layout } from 'src/components/common';
|
import { Layout } from 'src/components/common';
|
||||||
import { MenuNavigation,MenuFilter} from 'src/components/common';
|
import { MenuNavigation,MenuFilter} from 'src/components/common';
|
||||||
import { HomeBanner, HomeCategories, HomeCTA, HomeSubscribe, HomeVideo } from 'src/components/modules/home';
|
import { HomeBanner, HomeCategories, HomeCTA, HomeSubscribe, HomeVideo } from 'src/components/modules/home';
|
||||||
|
import { OPTION_ALL, QUERY_KEY, ROUTE } from 'src/utils/constanst.utils'
|
||||||
|
const CATEGORY = [
|
||||||
|
{
|
||||||
|
name: 'All',
|
||||||
|
link: `${ROUTE.PRODUCTS}/?${QUERY_KEY.BRAND}=${OPTION_ALL}`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Veggie',
|
||||||
|
link: `${ROUTE.PRODUCTS}/?${QUERY_KEY.BRAND}=veggie`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Seafood',
|
||||||
|
link: `${ROUTE.PRODUCTS}/?${QUERY_KEY.BRAND}=seafood`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Frozen',
|
||||||
|
link: `${ROUTE.PRODUCTS}/?${QUERY_KEY.BRAND}=frozen`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Coffee Bean',
|
||||||
|
link: `${ROUTE.PRODUCTS}/?${QUERY_KEY.BRAND}=coffee-bean`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Sauce',
|
||||||
|
link: `${ROUTE.PRODUCTS}/?${QUERY_KEY.BRAND}=sauce`,
|
||||||
|
},
|
||||||
|
]
|
||||||
export default function Home() {
|
export default function Home() {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@ -11,8 +37,8 @@ export default function Home() {
|
|||||||
<HomeVideo />
|
<HomeVideo />
|
||||||
<HomeCTA />
|
<HomeCTA />
|
||||||
<HomeSubscribe /> */}
|
<HomeSubscribe /> */}
|
||||||
<MenuFilter heading="Categories"/>
|
<MenuFilter categories={CATEGORY} heading="Categories"/>
|
||||||
<MenuNavigation heading="Categories"/>
|
<MenuNavigation categories={CATEGORY} heading="Categories"/>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -20,9 +20,6 @@
|
|||||||
a{
|
a{
|
||||||
padding: 0.8rem 1.6rem;
|
padding: 0.8rem 1.6rem;
|
||||||
margin-right: 0.8rem;
|
margin-right: 0.8rem;
|
||||||
font-size: var(--font-size);
|
|
||||||
line-height: var(--line-height);
|
|
||||||
color:var(--text-base);
|
|
||||||
background-color: var(--gray);
|
background-color: var(--gray);
|
||||||
border-radius: 0.8rem;
|
border-radius: 0.8rem;
|
||||||
&:hover {
|
&:hover {
|
||||||
@ -40,7 +37,7 @@
|
|||||||
bottom: -20%;
|
bottom: -20%;
|
||||||
content: "";
|
content: "";
|
||||||
width: 100%;
|
width: 100%;
|
||||||
border-bottom: 1px solid #EBEBEB;
|
border-bottom: 1px solid var(--border-line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,41 +1,17 @@
|
|||||||
import classNames from 'classnames'
|
import classNames from 'classnames'
|
||||||
import Link from 'next/link'
|
import Link from 'next/link'
|
||||||
import { useRouter } from 'next/router'
|
import { useRouter } from 'next/router'
|
||||||
import { OPTION_ALL, QUERY_KEY, ROUTE } from 'src/utils/constanst.utils'
|
|
||||||
import s from './MenuFilter.module.scss'
|
import s from './MenuFilter.module.scss'
|
||||||
const CATEGORY = [
|
|
||||||
{
|
|
||||||
name: 'All',
|
|
||||||
link: `${ROUTE.PRODUCTS}/?${QUERY_KEY.BRAND}=${OPTION_ALL}`,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'Veggie',
|
|
||||||
link: `${ROUTE.PRODUCTS}/?${QUERY_KEY.BRAND}=veggie`,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'Seafood',
|
|
||||||
link: `${ROUTE.PRODUCTS}/?${QUERY_KEY.BRAND}=seafood`,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'Frozen',
|
|
||||||
link: `${ROUTE.PRODUCTS}/?${QUERY_KEY.BRAND}=frozen`,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'Coffee Bean',
|
|
||||||
link: `${ROUTE.PRODUCTS}/?${QUERY_KEY.BRAND}=coffee-bean`,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'Sauce',
|
|
||||||
link: `${ROUTE.PRODUCTS}/?${QUERY_KEY.BRAND}=sauce`,
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
children?: any,
|
children?: any,
|
||||||
heading:string,
|
heading:string,
|
||||||
|
categories:{name:string,link:string}[]
|
||||||
}
|
}
|
||||||
|
|
||||||
const MenuFilter = ({heading}:Props)=> {
|
const MenuFilter = ({heading,categories}:Props)=> {
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -43,7 +19,7 @@ const MenuFilter = ({heading}:Props)=> {
|
|||||||
<h2 className={classNames(s.menuFilterHeading)}>{heading}</h2>
|
<h2 className={classNames(s.menuFilterHeading)}>{heading}</h2>
|
||||||
<ul className={s.menuFilterList}>
|
<ul className={s.menuFilterList}>
|
||||||
{
|
{
|
||||||
CATEGORY.map(item => <li key={item.name}>
|
categories.map(item => <li key={item.name}>
|
||||||
<Link href={item.link}>
|
<Link href={item.link}>
|
||||||
<a className={classNames({ [s.active]: router.asPath === item.link})}>
|
<a className={classNames({ [s.active]: router.asPath === item.link})}>
|
||||||
{item.name}
|
{item.name}
|
||||||
|
@ -13,8 +13,6 @@
|
|||||||
li{
|
li{
|
||||||
margin: 0.8rem 0;
|
margin: 0.8rem 0;
|
||||||
a{
|
a{
|
||||||
font-size: var(--font-size);
|
|
||||||
line-height: var(--line-height);
|
|
||||||
color:var(--text-base);
|
color:var(--text-base);
|
||||||
&:hover {
|
&:hover {
|
||||||
@apply text-primary;
|
@apply text-primary;
|
||||||
|
@ -1,49 +1,23 @@
|
|||||||
import classNames from 'classnames'
|
import classNames from 'classnames'
|
||||||
import Link from 'next/link'
|
import Link from 'next/link'
|
||||||
import { useRouter } from 'next/router'
|
import { useRouter } from 'next/router'
|
||||||
import { OPTION_ALL, QUERY_KEY, ROUTE } from 'src/utils/constanst.utils'
|
|
||||||
import s from './MenuNavigation.module.scss'
|
import s from './MenuNavigation.module.scss'
|
||||||
const CATEGORY = [
|
|
||||||
{
|
|
||||||
name: 'All',
|
|
||||||
link: `${ROUTE.PRODUCTS}/?${QUERY_KEY.BRAND}=${OPTION_ALL}`,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'Veggie',
|
|
||||||
link: `${ROUTE.PRODUCTS}/?${QUERY_KEY.BRAND}=veggie`,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'Seafood',
|
|
||||||
link: `${ROUTE.PRODUCTS}/?${QUERY_KEY.BRAND}=seafood`,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'Frozen',
|
|
||||||
link: `${ROUTE.PRODUCTS}/?${QUERY_KEY.BRAND}=frozen`,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'Coffee Bean',
|
|
||||||
link: `${ROUTE.PRODUCTS}/?${QUERY_KEY.BRAND}=coffee-bean`,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'Sauce',
|
|
||||||
link: `${ROUTE.PRODUCTS}/?${QUERY_KEY.BRAND}=sauce`,
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
children?: any,
|
children?: any,
|
||||||
heading:string,
|
heading:string,
|
||||||
|
categories:{name:string,link:string}[]
|
||||||
}
|
}
|
||||||
|
|
||||||
const MenuNavigation = ({heading}:Props)=> {
|
const MenuNavigation = ({heading,categories}:Props)=> {
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section className={classNames(s.menuNavigationWrapper)}>
|
<section className={classNames(s.menuNavigationWrapper)}>
|
||||||
<h2 className={classNames(s.menuNavigationHeading)}>{heading}({CATEGORY.length})</h2>
|
<h2 className={classNames(s.menuNavigationHeading)}>{heading}({categories.length})</h2>
|
||||||
<ul className={s.menuNavigationList}>
|
<ul className={s.menuNavigationList}>
|
||||||
{
|
{
|
||||||
CATEGORY.map(item => <li key={item.name}
|
categories.map(item => <li key={item.name}
|
||||||
>
|
>
|
||||||
<Link href={item.link}>
|
<Link href={item.link}>
|
||||||
<a className={classNames({ [s.active]: router.asPath === item.link})}>
|
<a className={classNames({ [s.active]: router.asPath === item.link})}>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user