-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 更新:`<Stepper />` 组件,支持主题切换; - 修复:重构 `<Select />` 支持自定义 option; - 文档:更新 README; - 文档:支持主题、语言切换。
- Loading branch information
Showing
103 changed files
with
2,080 additions
and
3,189 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,82 @@ | ||
# HIUI | ||
<div align="center"> | ||
|
||
[![HIUI Logo](https://raw.githubusercontent.com/XiaoMi/hiui/master/site/static/img/logo.png)](https://xiaomi.github.io/hiui/) | ||
|
||
<h1 align="center">HIUI</h1> | ||
|
||
[![JavaScript Style Guide](https://camo.githubusercontent.com/58fbab8bb63d069c1e4fb3fa37c2899c38ffcd18/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f64655f7374796c652d7374616e646172642d627269676874677265656e2e737667)](https://github.com/standard/standard) | ||
|
||
[English](https://github.com/XiaoMi/hiui/blob/master/README.md) | [中文](https://github.com/XiaoMi/hiui/blob/master/README-zh.md) | ||
</div> | ||
|
||
--- | ||
|
||
HIUI is a solution that is adequate for the fomulation and implementation of interaction and UI design standard for front, middle and backend . | ||
|
||
## Features | ||
|
||
- Highly minimize user perception of interaction costs and predictability of interactions | ||
- Build outstanding vitual style and get vitual design and interface specification for typical scenario | ||
- Highly refined design experience in OA, warehousing and after-sales systems, BI systems, and corporate mid-station projects | ||
|
||
## Setup | ||
## Install | ||
|
||
```sh | ||
npm install @hi-ui/hiui | ||
``` | ||
|
||
### Style Guide | ||
For components usage, see more at [HIUI Documents](https://xiaomi.github.io/hiui/#/en-US/components). | ||
|
||
## Contribute | ||
|
||
### Structure | ||
|
||
``` | ||
. | ||
├── build # build command | ||
├── components # component source | ||
├── docs # markdown docs | ||
│ ├── en-US | ||
│ └── zh-CN | ||
├── libs # third-party libraries | ||
├── locales # i18n config | ||
├── site # doc site source | ||
├── CHANGELOG.md | ||
├── commitlint.config.js | ||
├── gulpfile.js | ||
├── LICENSE | ||
├── README-zh.md | ||
├── README.md | ||
├── package.json | ||
└── postcss.config.js | ||
``` | ||
|
||
[![JavaScript Style Guide](https://cdn.rawgit.com/standard/standard/master/badge.svg)](https://github.com/standard/standard) | ||
### Setup | ||
|
||
```sh | ||
# install dependencies | ||
$ yarn | ||
|
||
# serve in dev mode, with hot reload at localhost:4200 | ||
$ yarn dev | ||
|
||
# compile for production | ||
$ yarn compile | ||
|
||
# build for production | ||
$ yarn build | ||
``` | ||
|
||
Open http://localhost:4200 | ||
|
||
### Style Guide | ||
|
||
- [BEM](https://en.bem.info/) | ||
- [git-flow (AVH Edition)](https://github.com/petervanderdoes/gitflow-avh) | ||
- [JavaScript Standard Style](https://github.com/standard/standard) | ||
- [Git Flow](https://nvie.com/posts/a-successful-git-branching-model/) | ||
|
||
## License | ||
|
||
MIT | ||
|
||
-- EOF -- |
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,88 @@ | ||
import React, { Component } from 'react' | ||
import { render } from 'react-dom' | ||
import classNames from 'classnames' | ||
import './index.scss' | ||
|
||
export default class Popper extends Component { | ||
container = undefined | ||
|
||
// static propTypes = { | ||
// attachEle: PropTypes.oneOfType([ | ||
// PropTypes.node | ||
// ]).isRequired, | ||
// className: PropTypes.string, | ||
// show: PropTypes.bool | ||
// } | ||
|
||
static defaultProps = { | ||
show: false, | ||
topGap: 2, | ||
leftGap: 0 | ||
} | ||
|
||
componentDidUpdate () { | ||
render(this.renderChildren(), this.container) | ||
} | ||
|
||
componentDidMount () { | ||
this.getContainer() | ||
} | ||
|
||
componentWillUnmount () { | ||
document.body.removeChild(this.container) | ||
} | ||
|
||
getOffset (ele) { | ||
let offset = { | ||
left: 0, | ||
top: 0 | ||
} | ||
while (ele && ele !== document.body) { | ||
offset.top += ele.offsetTop | ||
offset.left += ele.offsetLeft | ||
ele = ele.offsetParent | ||
} | ||
|
||
return offset | ||
} | ||
|
||
renderChildren () { | ||
const { | ||
children, | ||
className, | ||
show, | ||
attachEle, | ||
topGap, | ||
leftGap | ||
} = this.props | ||
const width = attachEle.offsetWidth | ||
const height = attachEle.offsetHeight | ||
const offset = this.getOffset(attachEle) | ||
const left = offset.left + leftGap + 'px' | ||
const top = offset.top + topGap + height + 'px' | ||
window.attachEle = attachEle | ||
|
||
return ( | ||
<div className={classNames(className, 'hi-popper__container', {hide: !show})} style={{left, top, width}}> | ||
{ children } | ||
</div> | ||
) | ||
} | ||
|
||
getContainer () { | ||
const container = document.createElement('div') | ||
container.style.position = 'absolute' | ||
container.style.top = '0' | ||
container.style.left = '0' | ||
container.style.width = '100%' | ||
// const child = React.Children.only(this.props.children) | ||
|
||
document.body.appendChild(container) | ||
|
||
this.container = container | ||
} | ||
|
||
render () { | ||
return null | ||
} | ||
} |
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,7 @@ | ||
|
||
.hi-popper__container { | ||
position: absolute; | ||
.hide { | ||
display: none; | ||
} | ||
} |
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,34 @@ | ||
/* @flow */ | ||
|
||
import { Component } from 'react' | ||
import PropTypes from 'prop-types' | ||
|
||
class Option extends Component { | ||
componentWillMount () { | ||
const { | ||
name, | ||
id, | ||
children | ||
} = this.props | ||
|
||
this.parent().addOption({ | ||
name, | ||
id, | ||
children | ||
}) | ||
} | ||
|
||
parent () { | ||
return this.context.component | ||
} | ||
|
||
render () { | ||
return null | ||
} | ||
} | ||
|
||
Option.contextTypes = { | ||
component: PropTypes.any | ||
} | ||
|
||
export default Option |
Oops, something went wrong.