From 974c7ce9623fb60fa9ba37b3dd8b0843617e9263 Mon Sep 17 00:00:00 2001 From: dntzhang Date: Thu, 17 Jun 2021 10:47:28 +0800 Subject: [PATCH] docs: readme --- README.CN.md | 1 - README.md | 2 -- index.html | 84 ++++++++++++++++++++++++++++++++++++++-------------- 3 files changed, 61 insertions(+), 26 deletions(-) diff --git a/README.CN.md b/README.CN.md index 9cf06893b..937fa328a 100644 --- a/README.CN.md +++ b/README.CN.md @@ -1,7 +1,6 @@ [English](./README.md) | 简体中文

omi

-

omi

Omi - 前端跨框架跨平台框架

基于 Web Components 跨框架并支持小程序开发(omi-kbone)

diff --git a/README.md b/README.md index f75a608d1..8a3334612 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,7 @@ English | [简体中文](./README.CN.md)

omi

-

omi

Omi - Front End Cross-Frameworks Framework

-

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.

## With TypeScript diff --git a/index.html b/index.html index 53013de9b..2fac6cca6 100644 --- a/index.html +++ b/index.html @@ -320,32 +320,70 @@
       
-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)
-       
+  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>
+  }
+}
   
@@ -369,4 +407,4 @@ render(<my-counter />, 'body', new Store) - + \ No newline at end of file