diff --git a/packages/ui-theme/src/antd-vars-patch.less b/packages/ui-theme/src/antd-vars-patch.less index bf85dd8e1bf16880c01f3ba8e99d34363a739409..009922a9542d02a6ac2e0a83168f67b787e9f23d 100644 --- a/packages/ui-theme/src/antd-vars-patch.less +++ b/packages/ui-theme/src/antd-vars-patch.less @@ -157,3 +157,7 @@ @tag-default-color: @text-color; @tag-font-size: @font-size-base; @tag-line-height: 22px; + +// Table +//-- +@table-row-hover-bg: var(--color-gray-3); diff --git a/packages/ui/table/.storybook/main.js b/packages/ui/table/.storybook/main.js new file mode 100644 index 0000000000000000000000000000000000000000..8a1cb9e5e8113819c7c2f17a1af726b1c04ef3e6 --- /dev/null +++ b/packages/ui/table/.storybook/main.js @@ -0,0 +1,74 @@ +const {getBabelConfig} = require('@reskript/config-babel'); +const {loaders} = require('@reskript/config-webpack'); +const path = require('path'); + +const loaderOptions = { + cwd: process.cwd(), + srcDirectory: 'src', + projectSettings: { + build: { + extractCSS: false, + styleResources: [ + require.resolve('@osui/theme/dist/antd-vars-patch.less'), + require.resolve('@osui/theme/dist/less-functions-overrides.less'), + ], + }, + }, +}; + +module.exports = { + stories: [ + '../stories/**/*.stories.[tj]s{,x}', + '../stories/**/*.stories.mdx' + ], + addons: [ + { + name: '@storybook/addon-docs', + options: { + configureJSX: true, + babelOptions: {}, + sourceLoaderOptions: null, + }, + }, + '@storybook/addon-storysource', // https://github.com/storybookjs/storybook/tree/master/addons/storysource + '@storybook/addon-a11y/register', // https://github.com/storybookjs/storybook/tree/master/addons/a11y + '@storybook/addon-viewport/register', // https://github.com/storybookjs/storybook/tree/master/addons/viewport + ], + webpackFinal: async (config) => { + config.module.rules.push({ + test: /\.(js|jsx|ts|tsx)$/, + exclude: /node_modules/, + use: [ + { + loader: 'babel-loader', + options: getBabelConfig(), + }, + ], + }); + config.module.rules.push({ + test: /\.less$/, + loaders: [ + loaders.style(loaderOptions), + loaders.css(loaderOptions), + loaders.less(loaderOptions), + loaders.styleResources(loaderOptions), + ], + }); + // 如果使用css modules 请打开这个,并按需匹配css modules 文件 + // 这个同时打开了classnames loader, 可以用 import c from 'xxx.less' + // config.module.rules.push({ + // test: /\.less$/, + // loaders: [ + // loaders.classNames(), + // loaders.style(loaderOptions), + // loaders.cssModules(loaderOptions), + // loaders.less(loaderOptions), + // loaders.styleResources(loaderOptions), + // ], + // }); + + config.resolve.extensions.push('.ts', '.tsx'); + config.resolve.alias['@'] = path.resolve(__dirname, '../src'); + return config; + }, +}; diff --git a/packages/ui/table/.storybook/preview.js b/packages/ui/table/.storybook/preview.js new file mode 100644 index 0000000000000000000000000000000000000000..07034b2817a7c283b61bafd08c2e684db9ccbd08 --- /dev/null +++ b/packages/ui/table/.storybook/preview.js @@ -0,0 +1,20 @@ +import {addParameters, addDecorator} from '@storybook/react'; +import {DocsPage, DocsContainer} from '@storybook/addon-docs/blocks'; +import { + INITIAL_VIEWPORTS, + } from '@storybook/addon-viewport'; +import '@osui/theme/dist/theme/vars.css'; + +addParameters({ + docs: { + container: DocsContainer, + page: DocsPage, + }, + viewport: { + viewports: { + ...INITIAL_VIEWPORTS + } + }, +}); + +addDecorator(storyFn =>
{storyFn()}
); diff --git a/packages/ui/table/README.md b/packages/ui/table/README.md new file mode 100644 index 0000000000000000000000000000000000000000..6d8a5b99d68fc92acf1afd739d46738b33667f0e --- /dev/null +++ b/packages/ui/table/README.md @@ -0,0 +1,30 @@ +# @osui/table + +## 安装说明 + +### 方式一 + +单包使用 + +``` +yarn install @osui/table +``` + +``` +import Table from '@osui/table' +``` + +### 方式二 + +从 `@osui/ui` 统一引入 + +``` +yarn install @osui/ui +``` + +``` +import {Table} from '@osui/ui'; +``` + + + diff --git a/packages/ui/table/babel.config.js b/packages/ui/table/babel.config.js new file mode 100644 index 0000000000000000000000000000000000000000..d222841daa0815ccea18188ceb097da34d13aad9 --- /dev/null +++ b/packages/ui/table/babel.config.js @@ -0,0 +1,11 @@ +const {getTransformBabelConfig} = require('@reskript/config-babel'); + +const options = { + browserSupport: {}, + usage: 'build', + mode: 'production', + polyfill: false, + hostType: 'library', +}; + +module.exports = getTransformBabelConfig(options); diff --git a/packages/ui/table/package.json b/packages/ui/table/package.json new file mode 100644 index 0000000000000000000000000000000000000000..db6f8530dff50766cdcce8fe130ea593b37fd18b --- /dev/null +++ b/packages/ui/table/package.json @@ -0,0 +1,60 @@ +{ + "name": "@osui/table", + "version": "0.1.0", + "description": "", + "main": "dist/index.js", + "scripts": { + "lint": "skr lint", + "build": "sh scripts/build.sh", + "storybook": "start-storybook -p 8700", + "clean": "rm -rf node_modules && rm -rf dist", + "test": "echo \"Error: no test specified\" && exit 1" + }, + "sideEffects": [ + "dist/*.less" + ], + "devDependencies": { + "@babel/cli": "^7.10.5", + "@reskript/cli": "^0.9.0", + "@reskript/cli-lint": "^0.9.9", + "@reskript/config-babel": "^0.9.0", + "@reskript/config-lint": "^0.12.3", + "@reskript/config-webpack": "^0.11.2", + "@storybook/addon-a11y": "^5.3.19", + "@storybook/addon-docs": "^5.3.19", + "@storybook/addon-storysource": "^5.3.19", + "@storybook/addon-viewport": "^5.3.19", + "@storybook/addons": "^5.3.19", + "@storybook/client-api": "^5.3.19", + "@storybook/react": "^5.3.19", + "@types/classnames": "^2.2.10", + "@types/react-dom": "^16.9.8", + "antd": "^4.4.0", + "babel-loader": "^8.1.0", + "cpy-cli": "^3.1.1", + "husky": "^4.2.5", + "prop-types": "^15.7.2", + "react": "^16.13.1", + "react-dom": "^16.13.1", + "react-is": "^16.13.1", + "typescript": "^3.9.6" + }, + "peerDependencies": { + "antd": ">=4.4.0", + "react": ">=16.9.0", + "react-dom": ">=16.9.0" + }, + "repository": { + "type": "git", + "url": "https://gitee.com/yuxuanhuo/osui/tree/master" + }, + "author": "zhangxingchang", + "license": "MIT", + "husky": { + "hooks": { + "pre-commit": "skr lint ./src" + } + }, + "dependencies": { + } +} diff --git a/packages/ui/table/scripts/build.sh b/packages/ui/table/scripts/build.sh new file mode 100644 index 0000000000000000000000000000000000000000..f1cf5724ccdec601e43fab14da4e8f9f80d5765c --- /dev/null +++ b/packages/ui/table/scripts/build.sh @@ -0,0 +1,18 @@ +# export PATH=$NODEJS_BIN_LATEST:$YARN_BIN_LATEST:$PATH + +echo "node $(node -v)" +echo "npm $(npm -v)" +echo "yarn $(yarn -v)" + +rm -rf dist + +yarn install --production=false +# yarn test + +$(npm bin)/cpy '**/*' '!**/*.ts' '!**/*.tsx' '!**/*.js' '!**/*.jsx' ../tmp/ --cwd=src/ --parents +$(npm bin)/tsc +$(npm bin)/babel tmp --out-dir dist --ignore "src/**/*.test.js" --copy-files --source-maps + +rm -rf tmp + +echo "build success" diff --git a/packages/ui/table/stories/index.stories.mdx b/packages/ui/table/stories/index.stories.mdx new file mode 100644 index 0000000000000000000000000000000000000000..de38b4d5f110569cb3d48f4d6489835c2ec5f97f --- /dev/null +++ b/packages/ui/table/stories/index.stories.mdx @@ -0,0 +1,14 @@ +import {Meta, Story, Preview} from '@storybook/addon-docs/blocks'; +import {Demo} from './index.stories' + + + +# OSUI Alert + +一些给UE看的文档说明,可以放在这里 + + + + {Demo()} + + diff --git a/packages/ui/table/stories/index.stories.tsx b/packages/ui/table/stories/index.stories.tsx new file mode 100644 index 0000000000000000000000000000000000000000..a6dcac149c62e5d9e0b3e7c5a2329d12f229e719 --- /dev/null +++ b/packages/ui/table/stories/index.stories.tsx @@ -0,0 +1,54 @@ +import * as React from 'react'; +import { Table, Tag, Space } from 'antd'; + +export default { + title: 'OSUI-Table', +}; + +export const Demo = () => { + + const columns = [ + { + title: 'Name', + dataIndex: 'name', + key: 'name', + }, + { + title: 'Age', + dataIndex: 'age', + key: 'age', + }, + { + title: 'Address', + dataIndex: 'address', + key: 'address', + }, + ]; + + const data = [ + { + key: '1', + name: 'John Brown', + age: 32, + address: 'New York No. 1 Lake Park', + }, + { + key: '2', + name: 'Jim Green', + age: 42, + address: 'London No. 1 Lake Park', + }, + { + key: '3', + name: 'Joe Black', + age: 32, + address: 'Sidney No. 1 Lake Park', + }, + ]; + + + return ( +
+ + ); +}; diff --git a/packages/ui/table/tsconfig.json b/packages/ui/table/tsconfig.json new file mode 100644 index 0000000000000000000000000000000000000000..3a24a511df9639581444c76e59ea1b775c5d8ea6 --- /dev/null +++ b/packages/ui/table/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../../../tsconfig.json", + "compilerOptions": { + "rootDir": "./src", + "outDir": "./tmp" + }, + "include": ["src"] +}