Skip to content

Commit

Permalink
breadcrums
Browse files Browse the repository at this point in the history
  • Loading branch information
soker90 committed Jul 8, 2024
1 parent 0cad82c commit 8582d97
Show file tree
Hide file tree
Showing 13 changed files with 116 additions and 59 deletions.
4 changes: 1 addition & 3 deletions src/components/DeliveryOrderExpand/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ import PropTypes from 'prop-types'
import {
Accordion,
AccordionContent, AccordionItem,
AccordionTrigger,
Paper
AccordionTrigger
} from 'components'
import ExpandMoreIcon from '@mui/icons-material/ExpandMore'

import ProductsOrderTable from './ProductsOrderTable'
import DeliveryOrderExpandHeader from './DeliveryOrderExpandHeader'
Expand Down
2 changes: 1 addition & 1 deletion src/components/Grid.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const Grid = ({ children, className, item, md, xs, lg }) => {
const type = item ? 'item' : 'container'

return (
<div className={cn(gridVariants({ className, type, xs, md, lg }), 'grid-cols-2')}>
<div className={cn(gridVariants({ className, type, xs, md, lg }))}>
{children}
</div>
)
Expand Down
56 changes: 18 additions & 38 deletions src/components/Header/Header.jsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
/* eslint-disable react/prop-types, no-shadow */

import { Link as RouterLink } from 'react-router-dom'
import PropTypes from 'prop-types'
import {
Breadcrumbs, Link, SvgIcon, Typography, Box
} from '@mui/material'
import { ChevronRight } from 'lucide-react'
import uniqId from 'uniqid'
import { Button, Grid } from 'components'
import { cn } from '../../utils/index.js'

import {
Button, Grid, Typography, Breadcrumb,
BreadcrumbLink,
BreadcrumbPage
} from 'components'

import { cn } from 'utils'

const Header = ({
className, routes = [], title, description, buttons, buttonsSecondary, ...rest
Expand All @@ -21,16 +20,12 @@ const Header = ({
* @private
*/
const _itemNav = (link, title) => (
<Link
<BreadcrumbLink
key={uniqId()}
variant='body1'
color='inherit'
to={link}
component={RouterLink}
underline='none'
>
{title}
</Link>
</BreadcrumbLink>
)

/**
Expand All @@ -53,16 +48,8 @@ const Header = ({
className='mb-2 ml-2'
{...rest}
>
{disableSvg
? <Icon className='mr-1' />
: (
<SvgIcon
fontSize='small'
className='mr-1'
>
<Icon />
</SvgIcon>
)}
<Icon className='mr-1 text-sm' />

{label}
</Button>
)
Expand All @@ -73,21 +60,14 @@ const Header = ({
{...rest}
>
<Grid item>
<Breadcrumbs
separator={<ChevronRight size={18} />}
aria-label='breadcrumb'
>
<Breadcrumb>
{_itemNav('/app', 'Inicio')}
{
routes.map(({ link, title }) => _itemNav(link, title))
}
<Typography
variant='body1'
color='textPrimary'
>
{title}
</Typography>
</Breadcrumbs>

<BreadcrumbPage>{title}</BreadcrumbPage>
</Breadcrumb>
<Typography
variant='h3'
color='textPrimary'
Expand All @@ -97,9 +77,9 @@ const Header = ({
{
buttonsSecondary &&
(
<Box mt={2}>
<div className='mt-4'>
{buttonsSecondary.map(_renderButton)}
</Box>
</div>
)
}
</Grid>
Expand Down
2 changes: 1 addition & 1 deletion src/components/ui/Alert.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const alertVariants = cva(
{
variants: {
severity: {
success: 'bg-success/10 dark:bg-success/20',
success: 'bg-success dark:bg-success/80 text-white',
error: 'bg-destructive text-destructive-foreground'
}
},
Expand Down
78 changes: 78 additions & 0 deletions src/components/ui/Breadcrumb.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import { ChevronRight } from 'lucide-react'
import { Children } from 'react'
import { Link } from 'react-router-dom'

import { cn } from 'utils'
import { Typography } from './index.js'

const Breadcrumb = ({ className, children }) => (
<nav aria-label='breadcrumb'>
<ol
className={cn(
'flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5',
className
)}
>
{Children.map(children, (child, index) => (
<>
{!!index && <BreadcrumbSeparator />}
{child}
</>
))}
</ol>
</nav>
)

const BreadcrumbItem = ({ children }) => (
<li
className='inline-flex items-center gap-1.5'
>
{children}
</li>
)

const BreadcrumbLink = ({ children, to }) => (
<BreadcrumbItem>
<Link to={to}>
<Typography
variant='body1'
className='transition-colors text-muted-foreground hover:text-foreground'
>
{children}
</Typography>
</Link>
</BreadcrumbItem>
)

const BreadcrumbPage = ({ children }) => (
<BreadcrumbItem>

<Typography
role='link'
aria-disabled='true'
aria-current='page'
variant='body1'
className='font-normal text-foreground'
>
{children}
</Typography>
</BreadcrumbItem>
)

const BreadcrumbSeparator = () => (
<li
role='presentation'
aria-hidden='true'
>
<ChevronRight className='size-3.5' strokeWidth={3.5} />
</li>
)

export {
Breadcrumb,

BreadcrumbItem,
BreadcrumbLink,
BreadcrumbPage,
BreadcrumbSeparator
}
2 changes: 1 addition & 1 deletion src/components/ui/Button.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const buttonVariants = cva(
outline:
'border border-input bg-background hover:bg-accent text-secondary',
outlined:
'border border-input bg-background hover:bg-accent text-secondary',
'border border-input bg-foreground/10 hover:bg-accent-foreground/20 text-secondary',
secondary:
'bg-secondary text-secondary-foreground hover:bg-secondary/80',
ghost: 'hover:bg-accent hover:text-accent-foreground text-default',
Expand Down
2 changes: 1 addition & 1 deletion src/components/ui/TextField.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const TextField = forwardRef(({ className, name, label, ...props }, ref) => (
<input
name={name}
className={cn(
'flex h-12 w-full rounded-md border px-3 py-2 text-white ring-offset-background bg-transparent placeholder:text-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50',
'flex h-12 w-full rounded-md border px-3 py-2 ring-offset-background bg-transparent placeholder:text-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50',
className
)}
ref={ref}
Expand Down
1 change: 1 addition & 0 deletions src/components/ui/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export * from './Alert'
export * from './Breadcrumb'
export * from './Card'
export * from './Checkbox'
export * from './Container'
Expand Down
6 changes: 2 additions & 4 deletions src/pages/Client/components/Header/Header.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import PropTypes from 'prop-types'
import ExpandLessIcon from '@mui/icons-material/ExpandLess'
import ExpandMoreIcon from '@mui/icons-material/ExpandMore'
import { ChevronDown, ChevronUp } from 'lucide-react'
import PostAddIcon from '@mui/icons-material/PostAdd'
import { useNavigate } from 'react-router'

Expand Down Expand Up @@ -31,8 +30,7 @@ const HeaderClient = ({
buttonsSecondary={[{
variant: 'text',
onClick: onExpand,
Icon: expanded ? ExpandLessIcon : ExpandMoreIcon,
disableSvg: true,
Icon: expanded ? ChevronUp : ChevronDown,
label: expanded ? 'Ocultar información' : 'Mostrar información'
}]}
buttons={[{
Expand Down
9 changes: 3 additions & 6 deletions src/pages/ClientInvoice/components/Header/index.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { useState } from 'react'
import CheckCircleOutlinedIcon from '@mui/icons-material/CheckCircleOutlined'
import PropTypes from 'prop-types'
import { PlusCircle as PlusCircleIcon, Trash2, ArrowDownToLine } from 'lucide-react'
import { PlusCircle, Trash2, ArrowDownToLine, CircleCheck } from 'lucide-react'

import { Header } from 'components'
import { downloadFile } from 'utils'
Expand Down Expand Up @@ -57,16 +56,14 @@ const HeaderClientInvoice = ({
variant: 'contained',
color: 'secondary',
onClick: () => setShowConfirmModal(true),
Icon: CheckCircleOutlinedIcon,
disableSvg: true,
Icon: CircleCheck,
label: 'Confirmar',
disabled: Boolean(nInvoice)
}, {
variant: 'contained',
color: 'primary',
onClick: _handleClickNewOrder,
Icon: PlusCircleIcon,
disableSvg: true,
Icon: PlusCircle,
label: 'Nuevo albarán',
disabled: Boolean(nInvoice)
}]}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Login/components/AuthLayout/TopBar/TopBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import PropTypes from 'prop-types'

const TopBar = () => {
return (
<div className='bg-background min-h-16 flex items-center'>
<div className='bg-header min-h-16 flex items-center'>
<nav className='px-6'>
<img
alt='Logo'
Expand Down
6 changes: 4 additions & 2 deletions src/theme/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
--card-foreground: 222.2 84% 4.9%;
--popover: 0 0% 100%;
--popover-foreground: 222.2 84% 4.9%;
--header: 231 50% 44%;
--primary: 221.2 83.2% 53.3%;
--primary-foreground: 210 40% 98%;
--secondary: 262.1 83.3% 57.8%;
Expand All @@ -20,7 +21,7 @@
--accent-foreground: 222.2 47.4% 11.2%;
--destructive: 0 84.2% 60.2%;
--destructive-foreground: 210 40% 98%;
--success: 123 46% 34%;
--success: 123 46% 33%;
--warning: 27 98% 47%;
--border: 0 0% 87%;
--input: 214.3 31.8% 91.4%;
Expand All @@ -36,6 +37,7 @@
--card-foreground: 210 40% 98%;
--popover: 222.2 84% 4.9%;
--popover-foreground: 210 40% 98%;
--header: 220 13% 18%;
--primary: 217.2 91.2% 59.8%;
--primary-foreground: 222.2 47.4% 11.2%;
--secondary: 242 100% 76%;
Expand All @@ -46,7 +48,7 @@
--accent-foreground: 210 40% 98%;
--destructive: 0 65% 51%;
--destructive-foreground: 240 9% 92%;
--success: 123 46% 34%;
--success: 123 46% 33%;
--warning: 27 98% 47%;
--border: 0 0% 32%;
--input: 217.2 32.6% 17.5%;
Expand Down
5 changes: 4 additions & 1 deletion tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ module.exports = {
DEFAULT: 'hsl(var(--success))'
},
warning: {
DEFAULT: 'hsl(var(--warning))',
DEFAULT: 'hsl(var(--warning))'
},
muted: {
DEFAULT: 'hsl(var(--muted))',
Expand All @@ -56,6 +56,9 @@ module.exports = {
card: {
DEFAULT: 'hsl(var(--card))',
foreground: 'hsl(var(--card-foreground))'
},
header: {
DEFAULT: 'hsl(var(--header))'
}
},
borderRadius: {
Expand Down

0 comments on commit 8582d97

Please sign in to comment.