Skip to content

Commit

Permalink
feat: first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Barrior committed Jan 1, 2024
0 parents commit c22c0e9
Show file tree
Hide file tree
Showing 199 changed files with 33,447 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .commitlintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": ["@j-lints/commitlint-config"]
}
44 changes: 44 additions & 0 deletions .dumirc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { defineConfig } from 'dumi'
import sass from 'sass'
import path from 'path'

const globalStyles = sass.compile('./examples/global.scss')

export default defineConfig({
outputPath: 'docs-dist',
base: '/schema-render/',
publicPath: '/schema-render/',
resolve: {
docDirs: ['examples'],
},
styles: [globalStyles.css],
themeConfig: {
name: 'SchemaRender',
logo: false,
nav: [
{ title: '💎 Core', link: '/core-react/001-intro' },
{ title: '🚀 FormRender', link: '/form-render-react/001-intro' },
{ title: '⛵️ Search', link: '/search-react/001-intro' },
// { title: '🛳 SearchTable', link: '/search-table-react/001-intro' },
],
socialLinks: {
github: 'https://github.com/Barrior/schema-render',
},
rtl: true,
footer: false,
},
alias: {
// 根据精确程度按顺序声明
'@schema-render/core-react/dist/esm': path.resolve('packages/core-react/src'),
'@schema-render/form-render-react/dist/esm': path.resolve(
'packages/form-render-react/src'
),
'@schema-render/search-react/dist/esm': path.resolve('packages/search-react/src'),

'@examples': path.resolve('examples'),
'@schema-render/core-react': path.resolve('packages/core-react/src'),
'@schema-render/form-render-react': path.resolve('packages/form-render-react/src'),
'@schema-render/search-react': path.resolve('packages/search-react/src'),
},
mfsu: false,
})
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# http://editorconfig.org
root = true

[*]
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
3 changes: 3 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": ["@j-lints/eslint-config-ts-react"]
}
57 changes: 57 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Documentation Build

on:
push:
branches:
- master
- main

# allow actions to edit the project
permissions:
contents: write

jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Copy project to machine
uses: actions/checkout@v3

- name: Setup Node
uses: actions/setup-node@v3
with:
node: 18

- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 8.6

- name: Restore node_modules
id: restore-node-modules
uses: actions/cache/restore@v3
with:
path: node_modules
key: cache-${{ hashFiles('pnpm-lock.yaml') }}

- name: Install dependencies
if: steps.restore-node-modules.outputs.cache-hit != 'true'
run: pnpm install

- name: Cache node_modules
if: steps.restore-node-modules.outputs.cache-hit != 'true'
uses: actions/cache/save@v3
with:
path: node_modules
key: ${{ steps.restore-node-modules.outputs.cache-primary-key }}

- name: Build docs
run: pnpm docs:build

- name: Deploy
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: docs-dist
branch: gh-pages
clean: true
clean-exclude: CNAME
44 changes: 44 additions & 0 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Testing

on: push

jobs:
testing:
runs-on: ubuntu-latest
steps:
- name: Copy project to machine
uses: actions/checkout@v3

- name: Setup Node
uses: actions/setup-node@v3
with:
node: 18

- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 8.6

- name: Restore node_modules
id: restore-node-modules
uses: actions/cache/restore@v3
with:
path: node_modules
key: cache-${{ hashFiles('pnpm-lock.yaml') }}

- name: Install dependencies
if: steps.restore-node-modules.outputs.cache-hit != 'true'
run: pnpm install

- name: Cache node_modules
if: steps.restore-node-modules.outputs.cache-hit != 'true'
uses: actions/cache/save@v3
with:
path: node_modules
key: ${{ steps.restore-node-modules.outputs.cache-primary-key }}

- name: Run lint
run: pnpm lint

- name: Run testing
run: pnpm test
53 changes: 53 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# MacOS files
.DS_Store

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# Output of 'npm pack'
*.tgz

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

# node_modules
node_modules/

# Dumi
.dumi/

# Output Dir
dist/
/docs-dist/
10 changes: 10 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

# https://github.com/typicode/husky/issues/912#issuecomment-817522060
# sets the correct PATH before running hook for use nvm
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm for general case
[ -s "/usr/local/opt/nvm/nvm.sh" ] && . "/usr/local/opt/nvm/nvm.sh" # This loads nvm for brew case

npx commitlint --edit $1
10 changes: 10 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

# https://typicode.github.io/husky/#/?id=command-not-found
# This loads nvm.sh and sets the correct PATH before running hook
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm for general case
[ -s "/usr/local/opt/nvm/nvm.sh" ] && . "/usr/local/opt/nvm/nvm.sh" # This loads nvm for brew case

npx lint-staged
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
registry=https://registry.npmjs.org/
7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"printWidth": 90,
"tabWidth": 2,
"semi": false,
"singleQuote": true,
"trailingComma": "es5"
}
3 changes: 3 additions & 0 deletions .stylelintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": ["@j-lints/stylelint-config-scss"]
}
14 changes: 14 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "attach",
"name": "AttachJestTest",
"port": 9229
}
]
}
15 changes: 15 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"cSpell.words": [
"antd",
"commitlint",
"cssinjs",
"dumi",
"execa",
"Immer",
"Popconfirm",
"shenzhen",
"stylelint"
],
"stylelint.validate": ["css", "less", "postcss", "scss"],
"editor.formatOnSave": true
}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024-present 花祁

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## SchemaRender

[![Documentation Build](https://github.com/Barrior/schema-render/actions/workflows/docs.yml/badge.svg)](https://github.com/Barrior/schema-render/actions/workflows/docs.yml)
[![Testing](https://github.com/Barrior/schema-render/actions/workflows/testing.yml/badge.svg)](https://github.com/Barrior/schema-render/actions/workflows/testing.yml)
[![Dependencies](https://img.shields.io/badge/dependencies-none-brightgreen.svg)](https://www.npmjs.com/package/@schema-render/core-react)

`SchemaRender` 是一套 `默认简单`,但又追求 `灵活``可高定``好用的` 表单渲染解决方案,旨在沉淀解决常见表单案例的渲染库,与相关的通用组件,以提升研发效率。

内容目录:

- `Core`: 表单渲染库内核,通过一套简易的 JSON Schema 构建出一套表单,内核主要处理 Schema 协议、渲染器编排、逻辑联动、校验能力等,支持 SSR(Server-Side Rendering)。
- 特点:协议驱动、简洁易用、高可定制、轻量级零依赖。
- `FormRender`: 基于 Core + [Antd](https://ant.design) 封装的开箱即用的表单渲染库。
- `Search`:基于 FormRender 封装的开箱即用的条件搜索组件。
- `SearchTable`:基于 Search + Antd Table 封装的条件搜索表格(建设中)。

更多详情请移步至官网:[中文官网](https://schema-render.js.org)
28 changes: 28 additions & 0 deletions examples/components/SyntaxHighlighter/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import './styles.less'

import type { CSSProperties } from 'react'
import SyntaxHighlighter from 'react-syntax-highlighter'
// @ts-ignore
import { stackoverflowLight } from 'react-syntax-highlighter/dist/esm/styles/hljs'

interface IProps {
value: object
language?: string
style?: CSSProperties
}

const ESyntaxHighlighter: React.FC<IProps> = ({ value, language, style }) => {
return (
<div style={style}>
<SyntaxHighlighter
className="example-hl"
language={language ?? 'json'}
style={stackoverflowLight}
>
{JSON.stringify(value, null, 2)}
</SyntaxHighlighter>
</div>
)
}

export default ESyntaxHighlighter
10 changes: 10 additions & 0 deletions examples/components/SyntaxHighlighter/styles.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.example-hl {
padding: 1.2em !important;
margin: 0;
border-radius: 6px;

code[class*="language-"],
pre[class*="language-"] {
background: none;
}
}
Loading

0 comments on commit c22c0e9

Please sign in to comment.