All Projects → Tencent → Omi

Tencent / Omi

Licence: other
Front End Cross-Frameworks Framework - 前端跨框架跨平台框架

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects
typescript
32286 projects
CSS
56736 projects
SCSS
7915 projects
Less
1899 projects

Projects that are alternatives of or similar to Omi

Preact
⚛️ Fast 3kB React alternative with the same modern API. Components & Virtual DOM.
Stars: ✭ 30,527 (+151.19%)
Mutual labels:  virtual-dom, vdom, jsx, preact
Virtual Dom
关于Vue,React,Preact和Omi等框架源码的解读
Stars: ✭ 139 (-98.86%)
Mutual labels:  virtual-dom, web-components, jsx, preact
Vhtml
Render JSX/Hyperscript to HTML strings, without VDOM 🌈
Stars: ✭ 556 (-95.42%)
Mutual labels:  virtual-dom, vdom, jsx, preact
Dataformsjs
🌟 DataFormsJS 🌟 A minimal JavaScript Framework and standalone React and Web Components for rapid development of high quality websites and single page applications.
Stars: ✭ 95 (-99.22%)
Mutual labels:  web-components, custom-elements, jsx, preact
Switzerland
🇨🇭Switzerland takes a functional approach to Web Components by applying middleware to your components. Supports Redux, attribute mutations, CSS variables, React-esque setState/state, etc… out-of-the-box, along with Shadow DOM for style encapsulation and Custom Elements for interoperability.
Stars: ✭ 261 (-97.85%)
Mutual labels:  virtual-dom, webcomponents, custom-elements, shadow-dom
element
Fast and simple custom elements.
Stars: ✭ 65 (-99.47%)
Mutual labels:  jsx, web-components, custom-elements, shadow-dom
Dna
Progressive Web Components.
Stars: ✭ 22 (-99.82%)
Mutual labels:  virtual-dom, webcomponents, custom-elements, shadow-dom
lego
🚀 Web-components made lightweight & Future-Proof.
Stars: ✭ 69 (-99.43%)
Mutual labels:  virtual-dom, webcomponents, web-components, custom-elements
Westore
更好的小程序项目架构
Stars: ✭ 3,897 (-67.93%)
Mutual labels:  weapp, webcomponents, mp, miniprogram
Nutmeg
Build, test, and publish vanilla Web Components with a little spice
Stars: ✭ 111 (-99.09%)
Mutual labels:  web-components, webcomponents, custom-elements, shadow-dom
Nerv
A blazing fast React alternative, compatible with IE8 and React 16.
Stars: ✭ 5,409 (-55.49%)
Mutual labels:  vdom, jsx, preact
Xy Ui
🎨面向未来的原生 web components UI组件库
Stars: ✭ 603 (-95.04%)
Mutual labels:  web-components, custom-elements, shadow-dom
Crab
JavaScript library for building user interfaces with Custom Elements, Shadow DOM and React like API
Stars: ✭ 22 (-99.82%)
Mutual labels:  webcomponents, custom-elements, shadow-dom
Redux React Starter
DEPRECATED use the new https://github.com/didierfranc/react-webpack-4
Stars: ✭ 137 (-98.87%)
Mutual labels:  virtual-dom, jsx, preact
Remount
Mount React components to the DOM using custom elements
Stars: ✭ 522 (-95.7%)
Mutual labels:  web-components, custom-elements, shadow-dom
Wux Weapp
🐶 一套组件化、可复用、易扩展的微信小程序 UI 组件库
Stars: ✭ 4,706 (-61.28%)
Mutual labels:  mini-program, weapp, miniprogram
Muve
Muve is a micro library for building interactive javascript applications.
Stars: ✭ 11 (-99.91%)
Mutual labels:  virtual-dom, vdom, jsx
Omil
📝Webpack loader for Omi.js React.js and Rax.js components 基于 Omi.js,React.js 和 Rax.js 单文件组件的webpack模块加载器
Stars: ✭ 140 (-98.85%)
Mutual labels:  jsx, preact, shadow-dom
Custom Element
A base class for Web Components (Custom Elements) which provides simple data binding.
Stars: ✭ 60 (-99.51%)
Mutual labels:  webcomponents, custom-elements, shadow-dom
Custom Elements Ts
Create native custom elements using Typescript
Stars: ✭ 52 (-99.57%)
Mutual labels:  web-components, custom-elements, shadow-dom

English | 简体中文

omi

Omi - Front End Cross-Frameworks Framework

Omiu - Cross-Frameworks and Cross-Themes UI Components powered by Omi

Define cross-frameworks button element with typescript:

import { tag, WeElement, h, extractClass } from 'omi'
import * as css from './index.scss'

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
}

@tag('o-button')
export default class Button extends WeElement<Props>{
  static css = css

  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>
  }
}

New Project by Omi

$ npm i omi-cli -g    # install cli
$ omi init my-app     # init project
$ cd my-app           
$ npm start           # develop
$ npm run build       # release

npx omi-cli init my-app is also supported(npm v5.2.0+).

New Component by Omi

$ npm i omi-cli -g    # install cli
$ omi init-component my-component     # init project
$ cd my-app           
$ npm start           # develop
$ npm run build       # release

npx omi-cli init-component my-component is also supported(npm v5.2.0+).

Ecosystem of Omi

💯Base

Project Description
omi-docs and codepen Omi official documents
omi-router Omi official router in 1KB js
omi-cli Project scaffolding. → Base Templates
CEE Fork from custom-elements-everywhere

🐍Snake MVP

Project Description
omi-snake & → Touch the demo The Snake-Eating Game Based on MVP Architecture Written by Omi
omi-kbone-snake omi-kbone 写的 MVP 架构的跨端贪吃蛇游戏,支持小程序和 H5
Preact-snake The Snake-Eating Game Based on MVP Architecture Written by Preact + Preact-CSS + Omis
[P]react-snake The Snake-Eating Game Based on MVP Architecture Written by React/Preact
omix-snake 小程序贪吃蛇

📚Other

Project Description
omi-piano Build piano with Omi and Omi Snippets, Enjoy now!
omi-devtools Browser DevTools extension
omi-chart Simple HTML5 Charts using chart-x tag.
md2site Static Site Generator with markdown powered by Omio.
omi-30-seconds Useful Omi snippets that you can understand in 30 seconds.
omi-canvas Perfect fusion of web components, jsx and canvas.
omi-swiper Omi + Swiper
omi-vscode VSCode extension for omi, Install now!
omi-ex Omi.js extension(TypeScript)
omi-transform Omi / css3transform integration. Made css3 transform super easy in your Omi project.
omi-finger Support touch and gesture events in your Omi project.
omi-touch Smooth scrolling, rotation, pull to refresh and any motion for the web.
omi-native Render web components to native
omi-i18n Internationalization solution for omi.js using i18next ecosystem
omie Build cross platform desktop apps with Omi.js and Electron.js
omi-cv Create a front-end engineer curriculum vitae, Get Started!
Soo Has same API as omi but is great alternative if you want to create custom elements without JSX, virtual DOM and store

Why Omi?

  • Tiny size and High performance
  • Cross frameworks(react, preact, vue, angular), components of omi are pure custom elements
  • One framework. Mobile & desktop & mini program
  • Stateless View Architecture Design
  • Be friendly to custom elements, you can pass false attributes to elements through string '0' or string 'false', you can pass object attributes to elements through : prefix and Omi.$
  • Easy two way binding by extend api
  • Enhanced CSS, rpx unit support base on 750 screen width
  • Compliance with browser trend and API design
  • Merge Web Components, JSX into one framework
  • Web Components can also be a data-driven view, UI = fn(data).
  • JSX is the best development experience (code intelligent completion and tip) UI Expression with least grammatical noise and it's turing complete(template engine is not, es template string is but grammatical noise is too loud)
  • Look at Facebook React vs Web Components,Omi combines their advantages and gives developers the freedom to choose the way they like
  • Shadow DOM or Light DOM merges with Virtual DOM, Omi uses both virtual DOM and real Shadow DOM to make view updates more accurate and faster
  • Scoped CSS's best solution is Shadow DOM, the community churning out frameworks and libraries for Scoped CSS (using JS or JSON writing styles such as Radium, jsxstyle, react-style; binding to webpack using generated unique className filename-classname-hash, such as CSS Modules, Vue), are hack technologies; and Shadow DOM Style is the perfect solution.

Compare TodoApp by Omi and React, Omi and React rendering DOM structure:

Omi React
Omi React

Omi uses Shadow DOM or Light DOM based style isolation and semantic structure.

Useful Resources

Title Name Other language Related
Web Components bookmarks
Snake-Eating Game Making with Web Components of Omi and MVP Architecture
Constructable Stylesheets: seamless reusable styles
Web Components specifications
Web Components in a Nutshell
Using Web Components with React in 2019
Using Web Components in React
Styling We Components Using A Shared Style Sheet
Developer Tools support for Web Components in Firefox 63
Develop W3C Web Components with WebAssembly
60FPS Animation In Omi 简体中文 한국어
Render Web Components To Native 简体中文 한국어
Shadow Dom In Depth 简体中文
Part Theme Explainer 求翻译
Web Components MDN 简体中文
Web Components Google
Web Components Org
Web Components: the Right Way
Proxy MDN 简体中文 한국어
CSS Variables 简体中文 한국어
CSS Shadow Parts
Platform HTML5
Using requestIdleCallback 简体中文 A polyfill
The Power Of Web Components 简体中文
ShadowRoot 简体中文

Overview of the Readme

Getting Started

Project Template

Template Type Command Describe
Base Template omi init my-app Basic omi project template.
Kbone Template omi init-kbone my-app Developing mini program or web using omi.

Hello Element

Define a custom element by extending WeElement base class:

import { define, WeElement } from 'omi'

define('hello-element', class extends WeElement {
  onClick = evt => {
    // trigger CustomEvent
    this.fire('Abc', { name: 'dntzhang', age: 12 })
    evt.stopPropagation()
  }

  //If you need to use <hello-element></hello-element> directly in html, you must declare propTypes
  static propTypes = {
    msg: String
  }

  static css = `
      div {
        color: red;
        cursor: pointer;
      }`

  render(props) {
    return (
      <div onClick={this.onClick}>
        Hello {props.msg}
        <div>Click Me!</div>
      </div>
    )
  }
})

Using hello-element:

import { define, render, WeElement } from 'omi'
import './hello-element'

define('my-app', class extends WeElement {
  data = { abc: 'abc' }

  // define CustomEvent Handler
  onAbc = evt => {
    // get evt data by evt.detail
    this.data.abc = ' by ' + evt.detail.name
    this.update()
  }

  static css = `
      div{
          color: green;
      }`

  render(props) {
    return (
      <div>
        Hello {this.data.abc}
        <hello-element
          onAbc={this.onAbc}
          msg="WeElement"
        />
      </div>
    )
  }
})

render(<my-app name="Omi v4.0" />, 'body')

Tell Babel to transform JSX into Omi.h() call:

{
  "presets": ["env", "omi"]
}

The following two NPM packages need to be installed to support the above configuration:

"babel-preset-env": "^1.6.0",
"babel-preset-omi": "^0.1.1",

If you use babel7, you can also use the following packages and configuration:

npm install --save-dev @babel/preset-env
npm install --save-dev @babel/preset-react
{
  "presets": [
    "@babel/preset-env",
    [
      "@babel/preset-react",
      {
        "pragma": "Omi.h",
        "pragmaFrag": "Omi.h.f"
      }
    ]
  ]
}

If you don't want to write CSS in JS, you can use to-string-loader of webpack. For example, the following configuration:

{
  test: /[\\|\/]_[\S]*\.css$/,
  use: [
    'to-string-loader',
    'css-loader'
  ]
}

If your CSS file starts with "_", CSS will use to-string-loader, such as:

import { tag, WeElement render } from 'omi'

define('my-app', class extends WeElement {

  css = require('./_index.css')
  ...
  ...
  ...

You can also forget the tedious configuration and use omi-cli directly, no need to configure anything.

TypeScript Auto Complete

import { h, WeElement, tag, classNames } from 'omi';
import * as styles from './_index.less';

interface ButtonProps {
  href?: string,
  disabled?: boolean,
  type?: 'default' | 'primary' | 'danger',
  htmltype?: 'submit' | 'button' | 'reset',
  onClick?: (e: any) => void
}

const TAG = 'o-button'

declare global {
  namespace JSX {
    interface IntrinsicElements {
      [TAG]: Omi.Props & ButtonProps
    }
  }
}

@tag(TAG)
export default class oButton extends WeElement<ButtonProps> {
...
...
...

omi

Lifecycle

Lifecycle method When it gets called
install before the component gets mounted to the DOM
installed after the component gets mounted to the DOM
uninstall prior to removal from the DOM
beforeUpdate before update
updated after update
beforeRender before render()
receiveProps parent element re-render will trigger it, return false will prevent update action

View registered elements

console.log(Omi.elements)

Browsers Support

Omi works in the latest two versions of all major browsers: Safari 10+, IE 11+, and the evergreen Chrome, Firefox, and Edge.

→ Browsers Support

→ Polyfills

<script src="https://unpkg.com/@webcomponents/[email protected]/webcomponents-bundle.js"></script>

Contribution

Build a example:

npm start example_name

Build omi:

npm run build

Unit testing

npm run test

Contributors

Any form of contribution is welcome. The above contributors have been officially released by Tencent.

We very much welcome developers to contribute to Tencent's open source, and we will also give them incentives to acknowledge and thank them. Here we provide an official description of Tencent's open source contribution. Specific contribution rules for each project are formulated by the project team. Developers can choose the appropriate project and participate according to the corresponding rules. The Tencent Project Management Committee will report regularly to qualified contributors and awards will be issued by the official contact.

Core Maintainers

Please contact us for any questions.

Thanks

License

MIT © Tencent

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].