Coder Social home page Coder Social logo

jx3box-ui-react's Introduction

Jx3box-ui-react

为dps计算器等其它react前端业务线做准备

需要对公共组件生产一个react版本

首批只移植重要的几个模块

原vue2版本 https://github.com/JX3BOX/jx3box-common-ui

Install

npm install @jx3box/jx3box-ui-react
yarn add @jx3box/jx3box-ui-react

Usage

import { Layout } from '@jx3box/jx3box-ui-react';

const App = () => (
     <Layout>
        <Header />
        <Breadcrumb 
            name='频道名称' 
            slug='slug' 
            root='/slug' 
            logo={<Jx3Logo />}
        >
            bread info
        </Breadcrumb>

        <LeftSidebar>
            left sidebar content
        </LeftSidebar>

        <Main>
            <Thx 
                postType='tool'
                postId={31129} 
                userId={59236} 
            />
            <RightSidebar>
                RightSidebar content
            </RightSidebar>
            <Footer />
        </Main>
    </Layout>
);

Layout

请确保 Layout 组件在最外层

因为 LeftSidebar, RightSidebar, Main, BreadCrumb 等会影响

页面布局的组件需要被 Layout 组件包裹才能正确计算相应的 css

  • Layout: 总布局容器 内部实现Jx3BoxContext计算布局尽量放在最外层渲染

  • LeftSidebar: 左侧边栏 自带收放功能和默认样式 放在 Layout 内部才能正确计算

  • Main: 主显示区域 放在 Layout 内部才能正确计算

  • RightSidebar: 右侧边栏触发小屏时激活流式布局 放在 Layout 内部才能正确计算

代码演示

import { Layout, BreadCrumb } from '@jx3box/jx3box-ui-react';

const { LeftSidebar, RightSidebar, Main } = Layout;

export default () => (
    <Layout>
        <Breadcrumb name='频道名称' slug='slug' root='/slug'>
            bread content
        </Breadcrumb>

        <LeftSidebar>
            LeftSidebar content
        </LeftSidebar>

        <Main>
            <RightSidebar>
                RightSidebar content
            </RightSidebar>
        </Main>
    </Layout>
);

Breadcrumb

魔盒面包屑组件

请确保被 Layout 组件包裹

代码演示

import { Layout, Breadcrumb } from '@jx3box/jx3box-ui-react';

export default () => (
    <Layout>
        <Breadcrumb 
            name='频道名称'
            slug='slug' 
            root='/slug' 
            logo={<Jx3Logo />} 
        >
            custom breadcrumb info
        </Breadcrumb>
    </Layout>
);
props detail type default
name 面包屑标题 string -
root 点击面包屑标题跳转的链接 string -
slug 组装发布按钮的请求地址 string -
logo logo图片 ReactNode -
crumbEnable 是否显示 crumbBE 组件 boolean undefined
publishEnable 是否显示发布按钮 boolean true
feedbackEnable 是否显示反馈按钮 boolean true

Thx

功能区组件

代码演示

import { Layout, Header } from '@jx3box/jx3box-ui-react';

export default () => (
    <Thx postId={31129} postType='tool' userId={59236} />
);
props detail type default
postType 文章类型 string or number -
postId 文章id string or number -
userId 发布文章的作者id string or number -

Header

魔盒公共头部组件

请确保被 Layout 组件包裹

代码演示

import { Layout, Header } from '@jx3box/jx3box-ui-react';

export default () => (
    <Layout>
        <Header />
    </Layout>
);

Footer

魔盒公共底部组件

代码演示

import { Footer } from '@jx3box/jx3box-ui-react';

export default () => (
    <Layout>
        <Footer/>
    </Layout>
);

开发相关

StoryBook 查看组件库

npm run storybook

本地开发

npm run dev

jx3box-ui-react's People

Contributors

gaohan1994 avatar iruxu avatar

Stargazers

 avatar

Watchers

 avatar  avatar

jx3box-ui-react's Issues

魔盒前端公共组件

为dps计算器等其它react前端业务线做准备,需要对公共组件生产一个react版本。

首批只移植重要的几个模块
原vue2版本 https://github.com/JX3BOX/jx3box-common-ui

全局模块

其他cms栏目,会暂时继续沿用vue2,后续持续将vue3模块补齐。
而react项目只涉及应用类型,只移植应用需要用到的模块

[BUG]box与nav数据

目前将data/box.json 与 box/nav.json的初始数据已更新,保持和旧版vue2项目一致。
此外,vue2中的nav昨日也做了小修复。
即例如“竞技”栏目,status=1,但是仅在正式服展示(clients不包含origin),所以在怀旧服情况下,也需要隐藏对应项目。 JX3BOX/jx3box-common-ui@ee09ae9

目前从storybook看,nav数据异常。
image

[JBUR] Add storybook.

A story captures the rendered state of a UI component.
Supported react and typescript

[JBR] Improve entry

Use src/index.esm.ts for react project entry
So we need remove alias plugin and test for that

[JBR] Build layout main component

We should build layout module like this. So add a main component

<>
    <Header />
    <Layout>
      <LeftSidebar>
        <LeftSidebarContent />
      </LeftSidebar>

      <Main>
        <Footer />
      </Main>

      <RightSidebar>
        <RightSidebarContext />
      </RightSidebar>
    </Layout>
  </>

[JBUR] Add alias

It's better way to import component or less like this:

import Component from '@component/component-name'
import '@less/less-name'

[JBR] Rebuild Layout module.

Now the way we calculate the siderbar width is too sb. We need rebuild Layout module.

Except:

import {Layout} from 'jb-ui-react';

const { LeftSidebar, RightSidebar, Main } = Layout;

const Component = () => (
  <Layout>
    <LeftSidebar/>
    <Main>
      {children}
    </Main>
    <RightSidebar/>
  </Layout>
);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.