alibaba / canvas-ui

UI Renderer runs on top of the HTML5 Canvas
https://alibaba.github.io/canvas-ui/
MIT License
162 stars 16 forks source link
canvas react typescript
canvas-ui-logo

Canvas UI 是一个运行在 HTML Canvas 上的通用 UI 渲染器。https://alibaba.github.io/canvas-ui/


他提供了一系列 React 组件,允许开发者利用已有知识快速构建基于 Canvas 的应用。

同时也具备类似 DOM 的场景树,开发者可以像操作 DOM 一样操作 Canvas 中绘制的元素。

import React from 'react'
import { Canvas, Text, Flex } from '@canvas-ui/react'

export default () => {
  const containerStyle = {
    width: 250,
    flexDirection: 'column'
  }
  const textStyle = {
    maxWidth: containerStyle.width,
    maxLines: 1,
  }
  return (
    <div style={{ height: '100px' }}>
      <Canvas>
        <Flex style={ containerStyle }>
          <Text style={ textStyle }>我能吞下玻璃而不伤身体。</Text>
          <Text style={ textStyle }>私はガラスを食べられます。それは私を傷つけません。</Text>
          <Text style={ textStyle }>The quick brown fox jumps over the lazy dog.</Text>
        </Flex>
      </Canvas>
    </div>
  )
}

Demo

https://alibaba.github.io/canvas-ui/examples/task

canvas-ui-kanban-demo

特性

目录结构

开始开发

# 启动 core 和 react 的开发模式
$ yarn dev

# 启动 Storybook
$ yarn dev:examples

# 运行单元测试
$ yarn test

# 构建 umd, esm 版本
$ yarn build

# 打版本
$ yarn lerna version

# 发布
$ sh ./tools/publish.sh