docs: readme
This commit is contained in:
parent
254a4d3f9f
commit
974c7ce962
|
@ -1,7 +1,6 @@
|
|||
[English](./README.md) | 简体中文
|
||||
|
||||
<p align="center"><img src="https://tencent.github.io/omi/assets/logo.svg" alt="omi" width="100"/></p>
|
||||
<p align="center"><img src="https://tencent.github.io/omi/assets/omi-v6.jpg" alt="omi" width="1000"/></p>
|
||||
<h2 align="center">Omi - 前端跨框架跨平台框架</h2>
|
||||
<p align="center"><b>基于 Web Components 跨框架并支持小程序开发(omi-kbone)</b></p>
|
||||
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
English | [简体中文](./README.CN.md)
|
||||
|
||||
<p align="center"><img src="https://tencent.github.io/omi/assets/logo.svg" alt="omi" width="100"/></p>
|
||||
<p align="center"><img src="https://tencent.github.io/omi/assets/omi-v6.jpg" alt="omi" width="1000"/></p>
|
||||
<h2 align="center">Omi - Front End Cross-Frameworks Framework</h2>
|
||||
<p align="center">Merge Web Components, JSX, Virtual DOM, Functional style, observe or Proxy into one framework with tiny size and high performance. Write components once, using in everywhere, such as Omi, React, Preact, Vue or Angular.</p>
|
||||
|
||||
## With TypeScript
|
||||
|
||||
|
|
84
index.html
84
index.html
|
@ -320,32 +320,70 @@
|
|||
</div>
|
||||
<pre style="position:absolute;left:40px;top:40px;transform:rotateZ(5deg);pointer-events: none;text-transform:none;">
|
||||
<code>
|
||||
import { define, render } from 'omi'
|
||||
import { tag, WeElement, h, extractClass } from 'omi'
|
||||
import * as css from './index.scss'
|
||||
|
||||
class Store {
|
||||
data = {
|
||||
count: 1
|
||||
}
|
||||
sub = () => {
|
||||
this.data.count--
|
||||
}
|
||||
add = () => {
|
||||
this.data.count++
|
||||
}
|
||||
interface Props {
|
||||
size?: 'medium' | 'small' | 'mini',
|
||||
type?: 'primary' | 'success' | 'warning' | 'danger' | 'info' | 'text'
|
||||
plain?: boolean,
|
||||
round?: boolean,
|
||||
circle?: boolean,
|
||||
loading?: boolean,
|
||||
disabled?: boolean,
|
||||
icon?: string,
|
||||
autofocus?: boolean,
|
||||
nativeType?: 'button' | 'submit' | 'reset',
|
||||
block?: boolean
|
||||
text?: string
|
||||
}
|
||||
|
||||
define('my-counter', _ =>
|
||||
<>
|
||||
<button onClick={_.store.sub}>-</button>
|
||||
<span>{_.store.data.count}</span>
|
||||
<button onClick={_.store.add}>+</button>
|
||||
</>, {
|
||||
use: ['count']
|
||||
}
|
||||
))
|
||||
@tag('o-button')
|
||||
export default class Button extends WeElement<Props>{
|
||||
static css = css
|
||||
|
||||
render(<my-counter />, 'body', new Store)
|
||||
</code>
|
||||
static defaultProps = {
|
||||
plain: false,
|
||||
round: false,
|
||||
circle: false,
|
||||
loading: false,
|
||||
disabled: false,
|
||||
autofocus: false,
|
||||
nativeType: 'button',
|
||||
block: false
|
||||
}
|
||||
|
||||
static propTypes = {
|
||||
size: String,
|
||||
type: String,
|
||||
plain: Boolean,
|
||||
round: Boolean,
|
||||
circle: Boolean,
|
||||
loading: Boolean,
|
||||
disabled: Boolean,
|
||||
icon: String,
|
||||
autofocus: Boolean,
|
||||
nativeType: String,
|
||||
block: Boolean,
|
||||
text: String
|
||||
}
|
||||
|
||||
render(props) {
|
||||
return <button disabled={props.disabled} {...extractClass(props, 'o-button', {
|
||||
['o-button-' + props.type]: props.type,
|
||||
['o-button-' + props.size]: props.size,
|
||||
'is-plain': props.plain,
|
||||
'is-round': props.round,
|
||||
'is-circle': props.circle,
|
||||
'is-disabled': props.disabled,
|
||||
'is-block': props.block
|
||||
})} type={props.nativeType} >
|
||||
{props.loading && <i class='icon-loading'></i>}
|
||||
{props.text}
|
||||
<slot></slot>
|
||||
</button>
|
||||
}
|
||||
}</code>
|
||||
</pre>
|
||||
|
||||
|
||||
|
@ -369,4 +407,4 @@ render(<my-counter />, 'body', new Store)
|
|||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
</html>
|
Loading…
Reference in New Issue