Skip to content

Commit

Permalink
Merge pull request #757 from gympass/feat/navigation-menu-v3
Browse files Browse the repository at this point in the history
🚀 feat (DS-797): revamp navigation menu to v3 theme
  • Loading branch information
MicaelRodrigues authored Mar 13, 2024
2 parents d32dd00 + 6f5eca3 commit 5030492
Show file tree
Hide file tree
Showing 11 changed files with 512 additions and 421 deletions.
14 changes: 11 additions & 3 deletions packages/doc/content/components/components/navigationmenu/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const NavigationMenuProps = [
defaultValue: { value: 'true' },
},
{
name: '$zIndex',
name: 'zIndex',
description: { text: `Value of z-index of the menu` },
type: { name: 'number' },
required: false,
Expand Down Expand Up @@ -57,6 +57,14 @@ export const MenuProps = [
type: { name: 'func' },
required: false,
},
{
name: 'icon',
description: {
text: 'Custom action icon',
},
type: { name: 'node' },
required: false,
},
];

export const SwitcherActionProps = [
Expand Down Expand Up @@ -85,7 +93,7 @@ export const SwitcherActionProps = [
required: true,
},
{
name: '$zIndex',
name: 'zIndex',
description: { text: `Value of z-index of the switcher actions menu` },
type: { name: 'number' },
required: false,
Expand Down Expand Up @@ -239,7 +247,7 @@ export const BottomItemsProps = [
required: true,
},
{
name: '$zIndex',
name: 'zIndex',
description: { text: `Value of z-index of the bottom items menu` },
type: { name: 'number' },
required: false,
Expand Down
169 changes: 129 additions & 40 deletions packages/yoga/src/NavigationMenu/NavigationMenu.theme.ts
Original file line number Diff line number Diff line change
@@ -1,58 +1,147 @@
const NavigationMenu = ({ colors, fontWeights, radii, spacing }) => ({
avatar: {
height: spacing.xlarge,
width: spacing.xlarge,
},
import { css } from 'styled-components';
import { merge } from '@gympass/yoga-common';

const sandy = '#F6EDDF';

const navigationMenuV3 = ({ colors, fontWeights, fontSizes, radii }) => ({
backgroundColor: {
default: colors.clear,
hover: colors.light,
stamina: colors.stamina,
yoga: colors.yoga,
white: colors.white,
contextMenu: colors.sand,
default: colors.sand,
hover: sandy,
active: sandy,
},
border: {
color: {
default: colors.light,
white: colors.white,
},
radius: {
default: radii.small,
circle: radii.circle,
tag: radii.small,
contextMenu: radii.small,
},
},
font: {
color: {
default: colors.deep,
active: colors.vibin,
hover: colors.stamina,
default: colors.text.secondary,
active: colors.text.primary,
hover: colors.text.secondary,
},
weight: {
bold: fontWeights.bold,
medium: fontWeights.regular,
},
size: {
contextMenu: {
title: fontSizes.xlarge,
},
},
weight: { medium: fontWeights.medium },
},
gap: {
xxxsmall: spacing.xxxsmall,
xxsmall: spacing.xxsmall,
medium: spacing.medium,
hover: {
contextMenu: css`
background-color: ${sandy};
`,
},
height: { xxlarge: spacing.xxlarge, xlarge: spacing.xlarge },
icon: {
height: spacing.medium,
width: spacing.medium,
fill: {
default: colors.deep,
active: colors.vibin,
hover: colors.stamina,
default: colors.text.secondary,
actions: colors.text.secondary,
active: colors.text.primary,
hover: colors.text.secondary,
},
},
padding: {
xxxsmall: spacing.xxxsmall,
xxsmall: spacing.xxsmall,
xsmall: spacing.xsmall,
small: spacing.small,
},
tag: {
color: { default: colors.white },
},
width: { xxlarge: spacing.xxlarge, xlarge: spacing.xlarge },
});

const NavigationMenu = theme => {
const {
colors,
elevations,
fontWeights,
fontSizes,
radii,
spacing,
v3theme,
} = theme;

const baseTheme = {
avatar: {
height: spacing.xlarge,
width: spacing.xlarge,
},
backgroundColor: {
contextMenu: colors.white,
default: colors.clear,
hover: colors.light,
active: colors.yoga,
tag: colors.stamina,
bottomMenu: colors.white,
},
border: {
color: {
default: colors.light,
},
radius: {
default: radii.small,
circle: radii.circle,
tag: v3theme ? radii.small : radii.circle,
action: radii.circle,
contextMenu: v3theme ? radii.small : radii.circle,
},
},
font: {
color: {
default: colors.deep,
active: colors.vibin,
hover: colors.stamina,
},
weight: {
bold: fontWeights.medium,
medium: fontWeights.regular,
},
size: {
contextMenu: {
title: fontSizes.small,
},
},
},
gap: {
xxxsmall: spacing.xxxsmall,
xxsmall: spacing.xxsmall,
medium: spacing.medium,
},
height: {
xxlarge: spacing.xxlarge,
xlarge: spacing.xlarge,
contextMenu: spacing.xlarge * 2,
bottomMenu: spacing.xxxlarge,
},
hover: {
contextMenu: css`
box-shadow: ${elevations.small};
`,
},
icon: {
height: spacing.medium,
width: spacing.medium,
fill: {
default: colors.deep,
actions: colors.primary,
active: colors.vibin,
hover: colors.stamina,
},
},
padding: {
xxxsmall: spacing.xxxsmall,
xxsmall: spacing.xxsmall,
xsmall: spacing.xsmall,
small: spacing.small,
},
tag: {
color: { default: colors.white },
},
width: { xxlarge: spacing.xxlarge, xlarge: spacing.xlarge },
};

if (!v3theme) {
return baseTheme;
}

return merge(baseTheme, navigationMenuV3(theme));
};

export default NavigationMenu;
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,22 @@ const Active = css`
theme: {
yoga: {
components: {
navigationmenu: { icon, font },
navigationmenu: { backgroundColor, icon, font },
},
},
},
}) =>
css`
background-color: ${backgroundColor.active};
:not(:last-child) {
pointer-events: none;
}
div {
${StyledText} {
color: ${font.color.active};
font-weight: ${font.weight.bold};
}
svg {
Expand All @@ -56,7 +59,7 @@ const StyledItem = styled.li<{ isActive: boolean; children: React.ReactNode }>`
theme: {
yoga: {
components: {
navigationmenu: { border, icon, font },
navigationmenu: { backgroundColor, border, icon, font },
},
},
},
Expand All @@ -78,6 +81,8 @@ const StyledItem = styled.li<{ isActive: boolean; children: React.ReactNode }>`
&:focus {
${!isActive &&
css`
background-color: ${backgroundColor.hover};
${StyledText} {
color: ${font.color.hover};
}
Expand Down
20 changes: 11 additions & 9 deletions packages/yoga/src/NavigationMenu/web/BottomItems/BottomItems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,23 @@ import React from 'react';
import styled, { css } from 'styled-components';
import { media } from '@gympass/yoga-helpers';

type BottomItemsStyledProps = React.HTMLAttributes<HTMLUListElement> & {
$zIndex?: number;
};

const StyledItemsContainer = styled.nav`
position: relative;
${media.lg`display: none`}
`;
type BottomItemsStyledProps = React.HTMLAttributes<HTMLUListElement> & {
$zIndex?: number;
}
z-index: ${({ $zIndex }: BottomItemsStyledProps) => $zIndex ?? 2};
`;

const StyledItems = styled.ul`
${({
theme: {
yoga: {
components: {
navigationmenu: { backgroundColor, border, gap },
navigationmenu: { backgroundColor, border, gap, height },
},
},
},
Expand All @@ -28,18 +30,18 @@ const StyledItems = styled.ul`
grid-auto-flow: column;
align-items: center;
width: 100%;
height: 56px;
background-color: ${backgroundColor.white};
height: ${height.bottomMenu}px;
background-color: ${backgroundColor.bottomMenu};
margin: 0;
padding: 0;
border: 1px solid ${border.color.default};
gap: ${gap.xxxsmall}px;
z-index: ${({ $zIndex }: BottomItemsStyledProps) => $zIndex ?? 2};
`}
`;

type BottomItemsProps = BottomItemsStyledProps & {
type BottomItemsProps = Omit<BottomItemsStyledProps, '$zIndex'> & {
children: React.ReactNode;
zIndex: number;
};

const BottomItems = ({ children, ...containerProps }: BottomItemsProps) => {
Expand Down
28 changes: 7 additions & 21 deletions packages/yoga/src/NavigationMenu/web/Item/styles.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import styled, { css } from 'styled-components';
import { media } from '@gympass/yoga-helpers';
import Box from '../../../Box';
import Tag from '../../../Tag';
import Text from '../../../Text';

export const StyledTextContainer = styled(Box)<{
export const StyledTextContainer = styled.div<{
isSubItem?: boolean;
children: React.ReactNode;
}>`
Expand Down Expand Up @@ -39,9 +37,9 @@ export const StyledTag = styled(Tag)`
},
}) => css`
text-transform: uppercase;
background-color: ${backgroundColor.stamina};
background-color: ${backgroundColor.tag};
color: ${tag.color.default};
border-radius: ${border.radius.circle}px;
border-radius: ${border.radius.tag}px;
`}
`;

Expand All @@ -63,9 +61,8 @@ export const StyledText = styled(Text)`
`}
`;

const Active = css<{ isResponsive?: boolean }>`
const Active = css`
${({
isResponsive,
theme: {
yoga: {
components: {
Expand All @@ -77,30 +74,19 @@ const Active = css<{ isResponsive?: boolean }>`
cursor: auto;
> ${StyledTextContainer} {
background-color: ${backgroundColor.default};
${isResponsive
? media.lg`background-color: ${backgroundColor.yoga}`
: css`
background-color: ${backgroundColor.yoga};
`}
background-color: ${backgroundColor.active};
${StyledText} {
color: ${font.color.active};
${isResponsive
? media.lg`font-weight: ${font.weight.medium}`
: css`
font-weight: ${font.weight.medium};
`}
font-weight: ${font.weight.bold};
}
svg {
fill: ${icon.fill.active};
}
> ${StyledTag} {
background-color: ${backgroundColor.stamina};
background-color: ${backgroundColor.tag};
}
}
`}
Expand Down
Loading

0 comments on commit 5030492

Please sign in to comment.