Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Adds tokens to Navbar #142

Merged
merged 45 commits into from
Jul 1, 2022
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
9c9712c
Extracts Navbar related components and uses CSS Modules
eduardoformiga Jun 22, 2022
8410f28
Updates README navbar example
eduardoformiga Jun 22, 2022
3b6a348
Adds tokens to navbar
eduardoformiga Jun 22, 2022
f834400
Adds tokens to navlinks
eduardoformiga Jun 22, 2022
33394cd
Adds tokens to NavbarSlider
eduardoformiga Jun 22, 2022
67ea967
Tweaks navbar module comments
eduardoformiga Jun 22, 2022
5f71697
Adds CHANGELOG entry
eduardoformiga Jun 22, 2022
e2f04de
Tweaks tokens spaces
eduardoformiga Jun 22, 2022
0726fba
Creates Navbar stories
eduardoformiga Jun 23, 2022
3741123
Creates NavbarSlider stories
eduardoformiga Jun 23, 2022
8a37720
Creates NavLinks stories
eduardoformiga Jun 23, 2022
7da9fb0
Updates navbar related components links
eduardoformiga Jun 23, 2022
0a99d35
Merge branch 'main' into feat/theming-navbar-fsss-377
eduardoformiga Jun 23, 2022
fa73cc1
Merge branch 'main' into feat/theming-navbar-fsss-377
eduardoformiga Jun 28, 2022
ed88a3d
Update src/components/common/Navbar/Navbar.stories.mdx
eduardoformiga Jun 28, 2022
b8b5895
Removes logo img tokens
eduardoformiga Jun 28, 2022
b7b0eea
Merge branch 'feat/theming-navbar-fsss-377' of https://github.com/vte…
eduardoformiga Jun 28, 2022
e4170ad
Tweaks border color
eduardoformiga Jun 28, 2022
0d55c68
Tweaks token name
eduardoformiga Jun 28, 2022
9e560bb
Tweaks tokens names
eduardoformiga Jun 28, 2022
99083ad
Groups row token
eduardoformiga Jun 28, 2022
3bf9479
Tweaks transition tokens
eduardoformiga Jun 28, 2022
24a5441
Merge branch 'main' into feat/theming-navbar-fsss-377
eduardoformiga Jun 28, 2022
ff287eb
Merge branch 'main' into feat/theming-navbar-fsss-377
eduardoformiga Jun 29, 2022
668fb74
Tweaks storybook content width
eduardoformiga Jun 29, 2022
9b4bd25
Adjusts navbar tokens
eduardoformiga Jun 29, 2022
2aad36d
Tweaks Navlinks style
eduardoformiga Jun 29, 2022
ea056b2
Merge branch 'feat/theming-navbar-fsss-377' of https://github.com/vte…
eduardoformiga Jun 29, 2022
cde3ba3
Merge branch 'main' into feat/theming-navbar-fsss-377
eduardoformiga Jun 29, 2022
d4cadfa
Uses SectionList on navbar stories
eduardoformiga Jun 29, 2022
aa53761
Tweaks token stories
eduardoformiga Jun 29, 2022
f8e4aad
Applies token breakpoint name at the end
eduardoformiga Jun 29, 2022
1027d3c
Removes row width token
eduardoformiga Jun 30, 2022
9760ee3
Removes button collapse token
eduardoformiga Jun 30, 2022
773d5d3
Removes button cart token
eduardoformiga Jun 30, 2022
b76f179
Removes overflow token
eduardoformiga Jun 30, 2022
6c93620
Update src/components/common/Navbar/NavbarSlider.stories.mdx
eduardoformiga Jun 30, 2022
74a14e8
Tweaks navlinks tokens
eduardoformiga Jun 30, 2022
0723450
Merge branch 'feat/theming-navbar-fsss-377' of https://github.com/vte…
eduardoformiga Jun 30, 2022
aef0417
Merge branch 'main' into feat/theming-navbar-fsss-377
eduardoformiga Jun 30, 2022
041ef3a
Trigger CI
eduardoformiga Jun 30, 2022
9407bbb
Merge branch 'feat/theming-navbar-fsss-377' of https://github.com/vte…
eduardoformiga Jun 30, 2022
77e7c0e
Removes sign-in tokens
eduardoformiga Jun 30, 2022
20ea86a
Tweaks border color token
eduardoformiga Jul 1, 2022
9d1b6c7
Update src/components/common/Navbar/NavLinks.stories.mdx
eduardoformiga Jul 1, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .storybook/storybook.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/* General */

.sbdocs.sbdocs-content {
max-width: 1100px;
}

/* Text */

.sbdocs-content > header h1 {
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Applies new local tokens to `Navbar` ([#142](https://github.com/vtex-sites/nextjs.store/pull/142))
- Applies new local tokens to `Tiles` ([#134](https://github.com/vtex-sites/nextjs.store/pull/134))
- Applies new local tokens to `ProductGrid` ([#144](https://github.com/vtex-sites/nextjs.store/pull/144))
- Applies new local tokens to `Accordion` ([#130](https://github.com/vtex-sites/nextjs.store/pull/130))
Expand Down
21 changes: 0 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -287,27 +287,6 @@ function Button({ variant, ...props }: Props) {
```

Now we have a styled Button component that accepts different variants!! 🎉
The aforementioned guide works well for UI components. However, components like `Navbar` and `Footer` are more complex and usually don't have variants, since they usually serve a single responsibility on the page. For these cases, you can use [BEM-Style CSS Syntax in SCSS](https://en.bem.info/methodology/) like:
eduardoformiga marked this conversation as resolved.
Show resolved Hide resolved

```tsx
// components/common/Navbar/Navbar.tsx
...
function Navbar {
return (
<header className="navbar">
<div className="navbar__header">
<section className="navbar__row">
<Button
className="navbar__menu"
aria-label="Open Menu"
>
<ListIcon size={32} />
</Button>
</section>
</div>
</header>
)
```

### Managing SVG Icons
Icons help build web pages by illustrating concepts and improving website navigation. However, using icons can decrease the page's performance. One option to avoid the decrease of the page's performance is to use SVGs from a single SVG file, located in `/static/icons.svg`, and load them with the `ui/Icon` component.
Expand Down
105 changes: 105 additions & 0 deletions src/components/common/Navbar/NavLinks.stories.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
import { Meta, Canvas, Story, ArgsTable } from '@storybook/addon-docs'

import { CartProvider, SessionProvider } from '@faststore/sdk'
import UIProvider from 'src/sdk/ui/Provider'

import { NavLinks } from '.'

import {
TokenTable,
TokenRow,
TokenDivider,
} from 'src/../.storybook/components'

<Meta component={NavLinks} title="Organisms/Navbar/NavLinks" />

export const TemplateProvider = () => {
return (
<SessionProvider initialState={{}}>
<CartProvider>
<UIProvider>
<NavLinks />
</UIProvider>
</CartProvider>
</SessionProvider>
)
}

<header>

# NavLinks

Displays a set navigation links and self adapts on mobile <code>NavbarSlider</code> or desktop screens.

</header>

## Usage

`import { NavLinks } from 'src/components/common/Navbar'`

<Canvas>
<Story name="overview-default">{TemplateProvider.bind({})}</Story>
</Canvas>

<TokenTable>
<TokenRow
token="--fs-navlinks-notebook-padding-top"
value="var(--fs-spacing-1)"
/>
<TokenDivider />
<TokenRow
token="--fs-navlinks-mobile-border-top-width"
value="var(--fs-border-width)"
/>
<TokenRow
token="--fs-navlinks-mobile-border-top-color"
value="var(--fs-color-neutral-2)"
eduardoformiga marked this conversation as resolved.
Show resolved Hide resolved
isColor
/>
<TokenDivider />
<TokenRow
token="--fs-navlinks-mobile-border-bottom-width"
value="var(--fs-border-width)"
/>
<TokenRow
token="--fs-navlinks-mobile-border-bottom-color"
value="var(--fs-color-neutral-2)"
isColor
/>
</TokenTable>

---

## Nested Elements

### Link

<TokenTable>
<TokenRow token="--fs-navlinks-link-mobile-width" value="100%" />
<TokenDivider />
<TokenRow
token="--fs-navlinks-link-notebook-padding"
value="0 var(--fs-spacing-0)"
/>
</TokenTable>

### List

<TokenTable>
<TokenRow
token="--fs-navlinks-list-notebook-padding-left"
value="var(--fs-spacing-3)"
/>
<TokenRow
token="--fs-navlinks-list-notebook-margin-left"
value="var(--fs-spacing-2)"
/>
<TokenRow
token="--fs-navlinks-list-notebook-border-left-width"
value="var(--fs-border-width)"
/>
<TokenRow
token="--fs-navlinks-list-notebook-border-left-color"
value="var(--fs-border-color-light)"
/>
</TokenTable>
56 changes: 56 additions & 0 deletions src/components/common/Navbar/NavLinks.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { List as UIList } from '@faststore/ui'
import type { AnchorHTMLAttributes } from 'react'

import RegionalizationButton from 'src/components/regionalization/RegionalizationButton'
import Link from 'src/components/ui/Link'
import { mark } from 'src/sdk/tests/mark'

import styles from './navlinks.module.scss'

interface NavLinksProps {
onClickLink?: AnchorHTMLAttributes<HTMLAnchorElement>['onClick']
classes?: string
}

const collections = [
{
name: 'Office',
href: '/office',
},
{
name: 'Home Appliances',
href: '/kitchen---home-appliances',
},
{
name: 'Computer and Software',
href: '/computer---software',
},
{
name: 'Technology',
href: '/technology',
},
]

function NavLinks({ onClickLink, classes = '' }: NavLinksProps) {
return (
<nav className={`${styles.fsNavlinks} ${classes}`}>
<RegionalizationButton />
<UIList data-fs-navlinks-list>
{collections.map(({ href, name }) => (
<li key={name} data-fs-navlinks-list-item>
<Link
data-fs-navlinks-link
variant="display"
href={href}
onClick={onClickLink}
>
{name}
</Link>
</li>
))}
</UIList>
</nav>
)
}

export default mark(NavLinks)
Loading