@abiser/railwind 中文文档教程

发布于 3年前 浏览 33 项目主页 更新于 3年前

Railwind

Rails 上的 React 组件

使用 TypeScript 在 tailwind css 之上构建的 React 组件库。

Goal

这个库的目的是生成一组核心的 React 组件,这些组件是使用 tailwind 配置选项静态类型化的。

What is the point?

使用 tailwind css 的一个好处是您无需编写 css,而是从现有的预构建类中选择它。 如果这些类型随后被映射到 TypeScript 类型并分配给 props,我们现在可以在代码级别控制组件的样式,因为编译器将不允许任何在生成的类型中不存在的 props。 然后,我们可以在可视化编辑器中公开这些类型,以在构建 ui 组件时通过在编辑器中显示选项来简化 ui 工作流程。

May-19-2021 06-27-13

Using Railwind

Railwind 应该导入到项目中,以便为特定用例生成设计系统。 示例:用于特定组织的 ui 库,用于样式和主题一致的多个应用程序。

Editing railwind core components

  • 运行 yarn run build-watch

  • 运行 playground 脚本以直观地测试更改

Using the playground

cdplayground 目录,运行 yarn install 然后运行 ​​yarn run start 启动示例游乐场以测试 railwind 组件

Updating Railwind Options

示例:添加新颜色

  • Add new color to tailwind.config.js

  • 运行 yarn run scripts:generateTailwindTypes 以生成更新类型

  • 运行 yarn run build:railwind 以生成新的样式表

Build for deployment

  • package.json

  • 运行 yarn run build 构建生产包

  • 运行 npm publish

TODO

Railwind

React components on rails

A React component library built on top of tailwind css using TypeScript.

Goal

The purpose of this library is to generate a core set of React components that are statically typed using tailwind configuration options.

What is the point?

A benefit of using tailwind css is that you don't write css, you select it from existing prebuilt classes. If these types are then mapped to TypeScript types and assigned to props we now can control the styling of components at the code level as the compiler will not allow for any props that do not exist in the generated types. We can then expose these types in a visual editor to streamline the ui workflow by presenting the options in the editor when building ui components.

May-19-2021 06-27-13

Using Railwind

Railwind should be imported into a project in order to generate a design system for a specific use case. Example: A ui library for a specific organization that is used in several applications where the styling and theme are consistent.

Editing railwind core components

  • Run yarn run build-watch

  • run the playground script to visually test changes

Using the playground

cd to playground directory, run yarn install and then run yarn run start to start up the example playground to test railwind components

Updating Railwind Options

Example: Adding a new color

  • Add new color to tailwind.config.js

  • Run yarn run scripts:generateTailwindTypes to generate updates types

  • Run yarn run build:railwind to generate new stylesheet

Build for deployment

  • Bump the version in package.json

  • Run yarn run build to build a production package

  • Run npm publish

TODO

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文