Skip to content

Commit

Permalink
docs(BottomNav): add BottomNav API (#2388)
Browse files Browse the repository at this point in the history
* docs(BottomNav): add BottomNav API

* feat: update title image

* feat: add examples of navitem

* fix: adjust image width

* feat: remove rel and target prop

* feat: add description
  • Loading branch information
saurabhdaware authored Oct 29, 2024
1 parent c4065e5 commit 99ab799
Show file tree
Hide file tree
Showing 4 changed files with 130 additions and 0 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
130 changes: 130 additions & 0 deletions packages/blade/src/components/BottomNav/_decisions/decisions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
# BottomNav

Bottom navigation component is a persistent user interface element at the bottom of a mobile app screen, providing quick access to core functionalities through icons and labels.

<img src="bottomnav-title.png" height="300px" />

## Links

- [Figma - Bottom Navigation](https://www.figma.com/design/jubmQL9Z8V7881ayUD95ps/Blade-DSL?node-id=96521-157514&node-type=instance&m=dev)

## API

<!-- prettier-ignore -->
```jsx
import { NavLink } from 'react-router-dom';

<BottomNav>
<BottomNavItem
as={NavLink}
isActive={true}
title="Payments"
icon={WalletIcon}
href="/payments"
/>
<BottomNavItem
as={NavLink}
title="Transactions"
icon={TransactionsIcon}
href="/transactions"
/>
<BottomNavItem
as={NavLink}
title="Links"
icon={PaymentLinksIcon}
href="/links"
/>
<BottomNavItem
title="More"
icon={MoreIcons}
onClick={() => {
// This can be used to open SideNav drawer
setIsSideNavOpen(true)
}}
/>
</BottomNav>
```

## Alternate APIs

- No alternate APIs were considered since this BottomNav API is consistent with our SideNav and TopNav API

## Props

### BottomNav

| **Props** | **Description** | **Type** | **Default Value** |
| --------- | ------------------------------------------------- | -------- | ----------------- |
| children | children slot of BottomNav, accepts BottomNavItem | JSX | |

```jsx
<BottomNav>{/* children */}</BottomNav>
```

### BottomNavItem

| **Props** | **Description** | **Type** | **Default Value** |
| --------- | -------------------------------------------------------------------------------------------------------------- | ----------------------------- | ----------------- |
| title | Title of BottomNavItem | string | |
| as | as prop for passing React Router's NavLink | NavLinkComponentType | |
| href | URL to navigate to. Internally links to `to` attribute of router (Also turns item into anchor tag when passed) | string | |
| isActive | Sets the link as selected / active | boolean | undefined |
| onClick | Click handler on item | (e: React.MouseEvent) => void | |
| icon | Blade's Icon Component | IconComponent | |

#### Examples

<table>

<tr>
<td>

<!-- prettier-ignore -->
```jsx
<BottomNavItem
title="Payments"
as={NavLink}
icon={AcceptPaymentsIcon}
href="/payments"
/>
```

</td>

<td>
<img src="navitem.png" width="100px" />
</td>
<tr>

<tr>
<td>

```jsx
<BottomNavItem
title="Payments"
as={NavLink}
icon={AcceptPaymentsIcon}
href="/payments"
// sets item as active
isActive
/>
```

</td>

<td>
<img src="navitem-selected.png" width="100px" />
</td>
<tr>

</table>

## Accessibility

1. All items should be accessible by `TAB`
2. It should have role navigation
3. Should have `aria-current="page"` on active item

## References

- [BottomNavigation - Base Web](https://baseweb.design/components/bottom-navigation/)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 99ab799

Please sign in to comment.