-
Notifications
You must be signed in to change notification settings - Fork 492
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #323 from z2014/feature/weui_beta
Feature/weui beta
- Loading branch information
Showing
21 changed files
with
3,625 additions
and
2,068 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,17 @@ | ||
{ | ||
"ecmaFeatures": { | ||
"jsx": true, | ||
"modules": true | ||
}, | ||
"env": { | ||
"browser": true, | ||
"node": true | ||
}, | ||
"parser": "babel-eslint", | ||
"rules": { | ||
"quotes": [2, "single"], | ||
"strict": [2, "never"], | ||
"react/jsx-uses-react": 2, | ||
"react/jsx-uses-vars": 2, | ||
"react/react-in-jsx-scope": 2, | ||
"no-alert": 2, | ||
"no-array-constructor": 2, | ||
"no-caller": 2, | ||
"no-catch-shadow": 2, | ||
"no-labels": 2, | ||
"no-eval": 2, | ||
"no-extend-native": 2, | ||
"no-extra-bind": 2, | ||
"no-implied-eval": 2, | ||
"no-iterator": 2, | ||
"no-label-var": 2, | ||
"no-lone-blocks": 2, | ||
"no-loop-func": 2, | ||
"no-multi-spaces": 2, | ||
"no-multi-str": 2, | ||
"no-native-reassign": 2, | ||
"no-new": 2, | ||
"no-new-func": 2, | ||
"no-new-object": 2, | ||
"no-new-wrappers": 2, | ||
"no-octal-escape": 2, | ||
"no-process-exit": 2, | ||
"no-proto": 2, | ||
"no-return-assign": 2, | ||
"no-sequences": 2, | ||
"no-shadow": 2, | ||
"no-shadow-restricted-names": 2, | ||
"no-spaced-func": 2, | ||
"no-trailing-spaces": 2, | ||
"no-undef-init": 2, | ||
"no-unused-expressions": 2, | ||
"no-use-before-define": 2, | ||
"no-with": 2, | ||
"comma-spacing": 2, | ||
"consistent-return": 2, | ||
"no-extra-parens": [2, "functions"], | ||
"eqeqeq": 2, | ||
"key-spacing": [2, { "beforeColon": false, "afterColon": true }], | ||
"new-cap": 2, | ||
"new-parens": 2, | ||
"semi": 2, | ||
"semi-spacing": [2, {"before": false, "after": true}], | ||
"space-infix-ops": 1, | ||
"keyword-spacing": 2, | ||
"space-unary-ops": [2, { "words": true, "nonwords": false }], | ||
"yoda": [2, "never"] | ||
}, | ||
"plugins": [ | ||
"react" | ||
], | ||
"globals": { | ||
"it": true, | ||
"describe": true, | ||
} | ||
} | ||
"extends": [ | ||
"alloy", | ||
"alloy/react", | ||
"alloy/typescript" | ||
], | ||
"env": { | ||
"browser": true, | ||
"node": true | ||
}, | ||
"rules": { | ||
}, | ||
"globals": { | ||
"it": true, | ||
"describe": true | ||
} | ||
} |
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,6 @@ | ||
import Button from './src/button'; | ||
import ButtonArea from './src/buttonArea'; | ||
export { | ||
ButtonArea, | ||
Button | ||
}; |
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,54 @@ | ||
import * as React from 'react'; | ||
import { | ||
ButtonProps, | ||
buttonTypes, | ||
buttonSize | ||
} from './interface'; | ||
import classNames from '../../utils/classnames'; | ||
|
||
const InternalButton = (props: ButtonProps, ref) => { | ||
const { | ||
size, | ||
type, | ||
children, | ||
className, | ||
loading, | ||
disabled | ||
} = props; | ||
const handleClick = (e: React.MouseEvent<HTMLButtonElement | HTMLAnchorElement, MouseEvent>) => { | ||
const { onClick } = props; | ||
if (onClick && typeof onClick === 'function') { | ||
onClick(e); | ||
} | ||
}; | ||
const cls = classNames(className, { | ||
'weui-btn': true, | ||
'weui-btn_mini': size === 'small', | ||
'weui-btn_primary': type === 'primary', | ||
'weui-btn_default': type === 'default', | ||
'weui-btn_warn': type === 'warn', | ||
'weui-btn_disabled': disabled, | ||
'weui-btn_loading': loading | ||
}); | ||
const buttonRef = (ref as any) || React.createRef<HTMLElement>(); | ||
return (<a | ||
href='#' | ||
onClick={handleClick} | ||
className={cls} | ||
ref={buttonRef} | ||
> | ||
{ loading ? <i className='weui-loading'/> : null } | ||
{ children } | ||
</a>) | ||
} | ||
|
||
const Button = React.forwardRef(InternalButton); | ||
Button.displayName = 'Button'; | ||
Button.defaultProps = { | ||
disabled: false, | ||
type: buttonTypes.primary, | ||
size: buttonSize.normal, | ||
loading: false | ||
}; | ||
|
||
export default Button; |
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,23 @@ | ||
import * as React from 'react'; | ||
import classNames from '../../utils/classnames'; | ||
import { ButtonAreaProps, buttonAreaDirection } from './interface'; | ||
|
||
|
||
const InternalButtonArea = (props: ButtonAreaProps) => { | ||
const {direction, children, className} = props; | ||
const cls = classNames(className, { | ||
'weui-btn-area': true, | ||
'weui-btn-area_inline': direction === buttonAreaDirection.horizontal | ||
}); | ||
return (<div className={cls}> | ||
{children} | ||
</div>) | ||
} | ||
|
||
const ButtonArea = React.forwardRef(InternalButtonArea); | ||
ButtonArea.displayName = 'ButtonArea'; | ||
ButtonArea.defaultProps = { | ||
direction: buttonAreaDirection.vertical | ||
}; | ||
|
||
export default ButtonArea; |
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,31 @@ | ||
export interface ButtonProps { | ||
disabled?: boolean; | ||
type?: buttonTypes; | ||
size?: buttonSize; | ||
className?: String; | ||
loading?: boolean; | ||
children?: React.ReactNode; | ||
onClick?: (e) => void; | ||
} | ||
|
||
export interface ButtonAreaProps { | ||
direction?: String; | ||
className?: String; | ||
children?: React.ReactNode; | ||
} | ||
|
||
export enum buttonTypes { | ||
primary = 'primary', | ||
default = 'default', | ||
warn = 'warn' | ||
} | ||
|
||
export enum buttonSize { | ||
small = 'small', | ||
normal = 'normal' | ||
} | ||
|
||
export enum buttonAreaDirection { | ||
horizontal = 'horizontal', | ||
vertical = 'vertical' | ||
} |
Empty file.
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 @@ | ||
/* | ||
Copyright (c) 2017 Jed Watson. | ||
Licensed under the MIT License (MIT), see | ||
http://jedwatson.github.io/classnames | ||
with fix with es6 export default | ||
*/ | ||
|
||
const hasOwn = {}.hasOwnProperty; | ||
|
||
function classNames(...args: any[]): string { | ||
const classes = []; | ||
for (let arg of args) { | ||
if (!arg) continue; | ||
|
||
let argType = typeof arg; | ||
|
||
if (argType === 'string' || argType === 'number') { | ||
classes.push(arg); | ||
} else if (Array.isArray(arg)) { | ||
classes.push(classNames.apply(null, arg)); | ||
} else if (argType === 'object') { | ||
for (let key in arg) { | ||
if (hasOwn.call(arg, key) && arg[key]) { | ||
classes.push(key); | ||
} | ||
} | ||
} | ||
} | ||
|
||
return classes.join(' '); | ||
} | ||
|
||
export default classNames; |
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
Oops, something went wrong.