-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
649 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
@import '../../styles/variables'; | ||
.#{$prefix}-menu { | ||
display: flex; | ||
list-style: none; | ||
&-item{ | ||
padding: $menu-item-padding-y $menu-item-padding-x; | ||
cursor: pointer; | ||
transition: $menu-transition; | ||
&.disabled { | ||
color: $menu-item-disabled-color; | ||
cursor: $menu-item-disabled-cursor; | ||
} | ||
} | ||
} | ||
|
||
.#{$prefix}-menu-horizontal { | ||
border-bottom: $menu-border-width solid $menu-border-color; | ||
flex-direction: row; | ||
box-shadow: $menu-box-shadow; | ||
.#{$prefix}-menu-item{ | ||
border-bottom: $menu-item-active-border-width solid transparent; | ||
&.active{ | ||
color: $menu-item-active-color; | ||
border-bottom: $menu-item-active-border-width solid $menu-item-active-color; | ||
} | ||
&:not(.disabled):hover{ | ||
color: $menu-item-active-color; | ||
border-bottom: $menu-item-active-border-width solid $menu-item-active-color; | ||
} | ||
} | ||
} | ||
|
||
.#{$prefix}-menu-vertical { | ||
flex-direction: column; | ||
display: inline-flex; | ||
border-right: $menu-border-width solid $menu-border-color; | ||
.#{$prefix}-menu-item{ | ||
border-left: $menu-item-active-border-width solid transparent; | ||
&.active{ | ||
color: $menu-item-active-color; | ||
border-left: $menu-item-active-border-width solid $menu-item-active-color; | ||
} | ||
&:not(.disabled):hover{ | ||
color: $menu-item-active-color; | ||
border-left: $menu-item-active-border-width solid $menu-item-active-color; | ||
} | ||
} | ||
} | ||
|
||
.#{$prefix}-submenu{ | ||
position: relative; | ||
padding: $menu-item-padding-y $menu-item-padding-x; | ||
cursor: pointer; | ||
&-menu{ | ||
padding-left: 0; | ||
white-space: nowrap; | ||
list-style: none; | ||
transition: $menu-transition; | ||
color: $body-color; | ||
&-item{ | ||
padding: $menu-item-padding-y $menu-item-padding-x; | ||
} | ||
} | ||
} | ||
|
||
.#{$prefix}-submenu-menu{ | ||
display: none; | ||
&.open { | ||
display: block; | ||
} | ||
} | ||
.#{$prefix}-submenu-horizontal{ | ||
.#{$prefix}-submenu-menu{ | ||
position: absolute; | ||
background: $white; | ||
z-index: 100; | ||
top: calc(100% + $submenu-menu-offset); | ||
border: $menu-border-width solid $menu-border-color; | ||
left: 50%; | ||
transform: translateX(-50%); | ||
box-shadow: $submenu-box-shadow; | ||
.#{$prefix}-menu-item:not(.disabled):hover{ | ||
border-bottom: $menu-item-active-border-width solid transparent; | ||
} | ||
.#{$prefix}-menu-item.active{ | ||
border-bottom: $menu-item-active-border-width solid transparent; | ||
} | ||
} | ||
} | ||
|
||
.#{$prefix}-submenu-vertical{ | ||
.#{$prefix}-menu-item:not(.disabled):hover{ | ||
border-left: $menu-item-active-border-width solid transparent; | ||
} | ||
.#{$prefix}-menu-item.active{ | ||
border-left: $menu-item-active-border-width solid transparent; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
import { action } from '@storybook/addon-actions' | ||
import type { Meta, StoryObj } from '@storybook/react' | ||
import Menu from './menu' | ||
import MenuItem from './menuItem' | ||
import SubMenu from './subMenu' | ||
|
||
type Story = StoryObj<typeof Menu> | ||
|
||
|
||
// export const Playground: Story = { | ||
// args: { | ||
// } | ||
// } | ||
|
||
export const defaultMenu: Story = { | ||
render: ()=>( | ||
<Menu | ||
defaultActive={'0'} | ||
onSelect={action('selected!')} | ||
mode="horizontal" | ||
defaultOpenSubMenus={[]} | ||
> | ||
<MenuItem> | ||
cool link | ||
</MenuItem> | ||
<MenuItem> | ||
cool link 2 | ||
</MenuItem> | ||
<MenuItem disabled> | ||
disabled | ||
</MenuItem> | ||
<SubMenu title="下拉选项"> | ||
<MenuItem> | ||
下拉选项一 | ||
</MenuItem> | ||
<MenuItem> | ||
下拉选项二 | ||
</MenuItem> | ||
</SubMenu> | ||
</Menu> | ||
) | ||
} | ||
|
||
export const MenuWithVertical: Story = { | ||
render: ()=>( | ||
<Menu | ||
defaultActive={'0'} | ||
onSelect={action('selected!')} | ||
mode="vertical" | ||
defaultOpenSubMenus={[]} | ||
> | ||
<MenuItem> | ||
cool link | ||
</MenuItem> | ||
<MenuItem> | ||
cool link 2 | ||
</MenuItem> | ||
<SubMenu title="点击下拉选项"> | ||
<MenuItem> | ||
下拉选项一 | ||
</MenuItem> | ||
<MenuItem> | ||
下拉选项二 | ||
</MenuItem> | ||
</SubMenu> | ||
</Menu> | ||
) | ||
} | ||
|
||
export const MenuWithDefaultOpenSubMenus: Story = { | ||
render: ()=>( | ||
<Menu | ||
defaultActive={'0'} | ||
onSelect={action('selected!')} | ||
defaultOpenSubMenus={['2']} | ||
mode="vertical" | ||
> | ||
<MenuItem> | ||
cool link | ||
</MenuItem> | ||
<MenuItem> | ||
cool link 2 | ||
</MenuItem> | ||
<SubMenu title="默认展开下拉选项"> | ||
<MenuItem> | ||
下拉选项一 | ||
</MenuItem> | ||
<MenuItem> | ||
下拉选项二 | ||
</MenuItem> | ||
</SubMenu> | ||
</Menu> | ||
) | ||
} | ||
|
||
/** | ||
* ### How to import | ||
* ~~~js | ||
* import { Menu, MenuItem, SubMenu } from 'eizy-ui-react' | ||
* ~~~ | ||
*/ | ||
const meta:Meta<typeof Menu> = { | ||
title: 'Basic/Menu', | ||
component: Menu, | ||
tags: ['autodocs'], | ||
argTypes: { | ||
onSelect: { | ||
control: { | ||
type: 'function' | ||
}, | ||
description: 'description' | ||
} | ||
} | ||
}; | ||
|
||
export default meta |
Oops, something went wrong.