-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(menu): initial implement menu component
- Loading branch information
1 parent
659e369
commit 33a29c7
Showing
10 changed files
with
190 additions
and
34 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,4 +60,3 @@ module.exports = { | |
}, | ||
}; | ||
|
||
|
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 |
---|---|---|
@@ -1,44 +1,60 @@ | ||
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). | ||
# bigbear-ui | ||
bigbear-ui是个人制作的拟物化小型轻量级ui库 | ||
|
||
## Available Scripts | ||
 | ||
 | ||
 | ||
[](https://travis-ci.com/yehuozhili/bigbear-ui) | ||
[](https://coveralls.io/github/yehuozhili/bigbear-ui?branch=master) | ||
|
||
In the project directory, you can run: | ||
✨ 特性 | ||
|
||
### `npm start` | ||
|
||
Runs the app in the development mode.<br /> | ||
Open [http://localhost:3000](http://localhost:3000) to view it in the browser. | ||
- 📕 详细的文档与介绍 | ||
- 🎨 使用富有特色的Neumorphism拟物化风格 | ||
- 📦 开箱即用的高质量 React 组件 | ||
- 🔥 使用 TypeScript 开发,提供完整的类型定义文件 | ||
|
||
The page will reload if you make edits.<br /> | ||
You will also see any lint errors in the console. | ||
|
||
### `npm test` | ||
<br/> | ||
|
||
Launches the test runner in the interactive watch mode.<br /> | ||
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. | ||
## 安装 | ||
使用 npm 或 yarn 安装 | ||
|
||
### `npm run build` | ||
``` | ||
$ npm install bigbear-ui --save | ||
``` | ||
|
||
Builds the app for production to the `build` folder.<br /> | ||
It correctly bundles React in production mode and optimizes the build for the best performance. | ||
## 引入样式 | ||
|
||
The build is minified and the filenames include the hashes.<br /> | ||
Your app is ready to be deployed! | ||
``` | ||
import 'bigbear-ui/dist/index.css'; | ||
``` | ||
|
||
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. | ||
## 在线文档 | ||
|
||
### `npm run eject` | ||
https://yehuozhili.github.io/bigbear-ui/ | ||
|
||
**Note: this is a one-way operation. Once you `eject`, you can’t go back!** | ||
<br/> | ||
|
||
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. | ||
|
||
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. | ||
## 本地文档 | ||
|
||
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. | ||
下载代码,npm安装,使用`npm run storybook`即可获得本地文档。 | ||
``` | ||
git clone https://github.com/yehuozhili/bigbear-ui.git | ||
npm install | ||
npm run storybook | ||
``` | ||
|
||
## Learn More | ||
## 制作初衷 | ||
|
||
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). | ||
制作一个属于自己的组件库应该是每个前端人员都有的梦想,有时候自己写出某些好的组件也想记录下来。 | ||
|
||
To learn React, check out the [React documentation](https://reactjs.org/). | ||
|
||
## 仍在开发中 | ||
|
||
<br/> | ||
|
||
|
||
组件库仍不完善,处于初级阶段。 |
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,26 @@ | ||
.bigbear-menu{ | ||
display: flex; | ||
flex-wrap: wrap; | ||
padding-left: 0; | ||
list-style: none; | ||
border-bottom:$menu-border-width solid $menu-border-color; | ||
box-shadow: $menu-box-shadow; | ||
.bigbear-menuitem{ | ||
padding:$menu-item-padding-y $menu-item-padding-x; | ||
cursor: pointer; | ||
transition: $menu-transition; | ||
&:hover,&:focus{ | ||
text-decoration: none; | ||
} | ||
&.isdisabled{ | ||
color:$menu-item-disabled-color; | ||
pointer-events: none; | ||
cursor: default; | ||
} | ||
&.isactive,&:hover{ | ||
color:$menu-item-active-color; | ||
border-bottom: $menu-item-active-border-width solid $menu-item-active-color; | ||
} | ||
} | ||
|
||
} |
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,27 @@ | ||
import { Meta, Story, Props ,Preview } from '@storybook/addon-docs/blocks'; | ||
import Menu from './menu'; | ||
import MenuItem from './menuitem' | ||
|
||
<Meta title='Component|Menu 菜单' component={Menu} /> | ||
|
||
<br/> | ||
|
||
# Menu 菜单 | ||
<br/> | ||
|
||
|
||
<Preview> | ||
<Story name='default' > | ||
<Menu defaultIndex={0} onSelect={(index)=>{console.log(index)}}> | ||
<MenuItem index={0}>item1</MenuItem> | ||
<MenuItem index={1}>item2</MenuItem> | ||
<MenuItem index={2}>item3</MenuItem> | ||
</Menu> | ||
|
||
</Story> | ||
</Preview> | ||
|
||
<br/> | ||
|
||
## 菜单类型 btnType | ||
<br/> |
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,35 @@ | ||
import React, { useContext } from 'react' | ||
import {MenuContext} from './menu' | ||
import classNames from 'classnames' | ||
|
||
|
||
export interface MenuItemProps{ | ||
index:number; | ||
disabled?:boolean; | ||
className?:string; | ||
style?:React.CSSProperties | ||
} | ||
|
||
|
||
|
||
|
||
|
||
const MenuItem : React.FC<MenuItemProps> =(props)=>{ | ||
const {index ,disabled,className,style,children}= props; | ||
const context =useContext(MenuContext) | ||
const classes = classNames('bigbear-menuitem',className,{ | ||
'isdisabled':disabled, | ||
'isactive':context.index===index | ||
}) | ||
const handleClick=()=>{ | ||
if(context.onSelect&&!disabled){ | ||
context.onSelect(index) | ||
} | ||
} | ||
return ( | ||
<li className={classes} style={style} onClick={handleClick}> | ||
{children} | ||
</li> | ||
) | ||
} | ||
export default MenuItem |
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