Skip to content

Commit

Permalink
Dang-1822 / TopNavDropdown (MegaMenu redesign) (#380)
Browse files Browse the repository at this point in the history
* TopNavDropdown

* more TopNavDropdown

* fix test

* nits

* add TopNavButton component

* nits & add active black bg

* nits & export TopNavButton

* story nits

* remove showmobilenav and cleanup of classes

* fix test

* change outline to dashed (not dotted)

* remove unused disabled class from item

* add one more item to top nav story

* update mdx docs and stories

* change topnav story to reflect current dashboard, with resources and username dropdowns

* remove old MegaMenu components

* nit: mainnav expand button centering

* focus visible nit

* nit

* fix

* package version & changelog
  • Loading branch information
Mrtly authored Jan 4, 2023
1 parent db8cd10 commit b0ffc6b
Show file tree
Hide file tree
Showing 21 changed files with 374 additions and 330 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# CHANGELOG

## v2.0.0-beta.21

### Features

Adds the `TopNavDropdown` component that replaces the `MegaMenu` component

### Breaking changes

- the `MegaMenu` component is removed from the library

## v2.0.0-beta.20

### Features
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@lob/ui-components",
"version": "2.0.0-beta.20",
"version": "2.0.0-beta.21",
"engines": {
"node": ">=14.18.2",
"npm": ">=8.3.0"
Expand Down
4 changes: 2 additions & 2 deletions src/components/MainNavigation/MainNavigation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
<nav class="xl:min-h-full p-4 relative bg-white border-r-2 border-white-300">
<button
v-if="collapsible"
:class="['hidden xl:block w-7 h-7 rounded-full absolute -right-3 mt-3 z-10',
:class="['hidden xl:block w-7 h-7 rounded-full absolute -right-3.5 mt-3 z-10',
'text-gray-500 bg-white border-2 border-white-300 transition-transform duration-100 ease-in',
{ 'transform -rotate-180': !expanded }]"
:aria-expanded="expanded"
@click="animateDrawer"
>
<ChevronLeft
size="s"
class="m-auto"
class="m-auto mr-1.5"
/>
</button>
<ul
Expand Down
57 changes: 0 additions & 57 deletions src/components/MegaMenu/MegaMenu.mdx

This file was deleted.

65 changes: 0 additions & 65 deletions src/components/MegaMenu/MegaMenu.stories.js

This file was deleted.

75 changes: 0 additions & 75 deletions src/components/MegaMenu/MegaMenuItem.vue

This file was deleted.

11 changes: 0 additions & 11 deletions src/components/MegaMenu/MegaMenuSubtitle.vue

This file was deleted.

20 changes: 0 additions & 20 deletions src/components/MegaMenu/__tests__/MegaMenuSubtitle.spec.js

This file was deleted.

23 changes: 23 additions & 0 deletions src/components/TopNavDropdown/TopNavButton.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<template>
<button class="type-small-700 text-gray-500 whitespace-nowrap h-[76px] px-8 hover:bg-gray-50 focus:outline-black focus:outline-dashed active:bg-black active:!text-white">
<div class="flex flex-col justify-center">
<div class="flex items-center">
<slot />
<div :class="{ 'ml-2': hasIcon }">
<slot name="icon" />
</div>
</div>
</div>
</button>
</template>

<script>
export default {
name: 'TopNavButton',
computed: {
hasIcon () {
return Boolean(this.$slots.icon);
}
}
};
</script>
57 changes: 57 additions & 0 deletions src/components/TopNavDropdown/TopNavDropdown.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import {
Preview,
Story,
ArgsTable,
PRIMARY_STORY,
} from "@storybook/addon-docs";
import TopNavDropdown from "./TopNavDropdown.vue";
import TopNavDropdownItem from "./TopNavDropdownItem.vue";

# TopNavDropdown

The TopNavDropdown component is used for displaying a big navigation menu with nested items displaying on hover.

<Preview>
<Story id="components-top-nav-dropdown--primary" />
</Preview>

## How to Use

The mega menu renders a semantic `nav` element. It is made to work with `TopNavDropdownItem` components. However, you can also write custom components for its slot.

Example of using this component in a template, with a TopNavDropdownItem

```html
<TopNavDropdown title="Resources" navKey="">
<TopNavDropdownItem to="/settings/main/account">
Settings
</TopNavDropdownItem>
</TopNavDropdown>
```

# TopNavDropdownItem

The TopNavDropdownItem component is used for displaying a single item in the nested submenu that's displayed on hover.

<Preview>
<Story id="components-top-nav-dropdown--item" />
</Preview>

## How to Use

The TopNavDropdownItem component can render as a traditional link (hooked up to your app's routing) or as an anchor tag depending on if the link is internal to your app's routing or external.

You can optionally provide an icon to display for the item in the `#icon` slot.

Example of using this component in a template

```html
<TopNavDropdownItem to="/overview" navKey="">
<template #icon> <Signal /> </template>
API Status
</TopNavDropdownItem>
```

## Props

<ArgsTable story={PRIMARY_STORY} />
Loading

0 comments on commit b0ffc6b

Please sign in to comment.