Skip to content

Commit

Permalink
feat: different alignements for navmenu contents (left center right)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sasha committed Apr 22, 2024
1 parent 4e7e4f3 commit 62d6e1a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/lib/components/organisms/navmenu/NavMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export interface NavMenuProps {
links: NavMenuEntry[]
headerLeft?: ReactNode
headerRight?: ReactNode
positionItems?: 'center' | 'left' | 'right'
fillScreen?: 'always' | 'mobile' | 'never'
}

Expand Down Expand Up @@ -58,13 +59,19 @@ const Gap: FC<{ type: 'always' | 'mobile' | 'never' }> = ({ type }) => {
return null
}

export const NavMenu: FC<NavMenuProps> = ({ links, headerLeft, headerRight, fillScreen = 'mobile' }) => {
export const NavMenu: FC<NavMenuProps> = ({
links,
headerLeft,
headerRight,
fillScreen = 'mobile',
positionItems = 'left',
}) => {
return (
<nav className={styles.nav_menu}>
<div className={styles.nav_menu_header}>
{headerLeft} {headerRight}
</div>
<ul className={styles.nav_menu_list}>
<ul className={[styles.nav_menu_list, styles[`nav_menu_list_${positionItems}`]].join(' ')}>
{links.map((link, index) => {
if ('category' in link) {
return (
Expand Down Expand Up @@ -113,6 +120,7 @@ export const ToggleNavMenu: FC<ToggleNavMenuProps> = ({
headerItem,
headerItemPosition,
fillScreen = 'mobile',
positionItems = 'left',
}) => {
return (
<nav className={styles.nav_menu_toggleable}>
Expand Down Expand Up @@ -140,7 +148,7 @@ export const ToggleNavMenu: FC<ToggleNavMenuProps> = ({
</label>
</span>
</div>
<ul className={styles.nav_menu_list}>
<ul className={[styles.nav_menu_list, styles[`nav_menu_list_${positionItems}`]].join(' ')}>
{links.map((link, index) => {
if ('category' in link) {
return (
Expand Down Expand Up @@ -181,6 +189,7 @@ export const ResponsiveNavMenu: FC<ToggleNavMenuProps> = ({
headerItem,
headerItemPosition,
fillScreen = 'mobile',
positionItems = 'left',
}) => {
const getRectY = (index: number) => index * (18 / 2) + 2
return (
Expand Down Expand Up @@ -227,7 +236,7 @@ export const ResponsiveNavMenu: FC<ToggleNavMenuProps> = ({
</span>
</span>
</div>
<ul className={styles.nav_menu_list}>
<ul className={[styles.nav_menu_list, styles[`nav_menu_list_${positionItems}`]].join(' ')}>
{links.map((link, index) => {
if ('category' in link) {
return (
Expand Down
13 changes: 13 additions & 0 deletions src/lib/components/organisms/navmenu/navmenu.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -405,3 +405,16 @@
width: max-content;
margin-top: var(--space-10);
}


.nav_menu_list_left {
align-items: left;
}

.nav_menu_list_center {
align-items: center;
}

.nav_menu_list_right {
align-items: right;
}

0 comments on commit 62d6e1a

Please sign in to comment.