From 6507e8000aeb1671b4fbfbfb41269e79fcfbc95e Mon Sep 17 00:00:00 2001 From: liushaozhen <804199994@qq.com> Date: Thu, 13 Aug 2020 14:02:44 +0800 Subject: [PATCH 1/6] =?UTF-8?q?feat(message):=20=E6=96=B0=E5=A2=9Emessage?= =?UTF-8?q?=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/ui/message/.storybook/main.js | 73 +++++++++++++++++++ packages/ui/message/.storybook/preview.js | 18 +++++ packages/ui/message/CHANGELOG.md | 0 packages/ui/message/babel.config.js | 11 +++ packages/ui/message/package.json | 56 ++++++++++++++ packages/ui/message/scripts/build.sh | 18 +++++ packages/ui/message/src/index.less | 8 ++ packages/ui/message/src/index.tsx | 27 +++++++ packages/ui/message/stories/index.stories.mdx | 20 +++++ packages/ui/message/stories/index.stories.tsx | 39 ++++++++++ packages/ui/message/tsconfig.json | 8 ++ 11 files changed, 278 insertions(+) create mode 100644 packages/ui/message/.storybook/main.js create mode 100644 packages/ui/message/.storybook/preview.js create mode 100644 packages/ui/message/CHANGELOG.md create mode 100644 packages/ui/message/babel.config.js create mode 100644 packages/ui/message/package.json create mode 100644 packages/ui/message/scripts/build.sh create mode 100644 packages/ui/message/src/index.less create mode 100644 packages/ui/message/src/index.tsx create mode 100644 packages/ui/message/stories/index.stories.mdx create mode 100644 packages/ui/message/stories/index.stories.tsx create mode 100644 packages/ui/message/tsconfig.json diff --git a/packages/ui/message/.storybook/main.js b/packages/ui/message/.storybook/main.js new file mode 100644 index 00000000..34ac8402 --- /dev/null +++ b/packages/ui/message/.storybook/main.js @@ -0,0 +1,73 @@ +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)$/, + 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/message/.storybook/preview.js b/packages/ui/message/.storybook/preview.js new file mode 100644 index 00000000..faeb11a4 --- /dev/null +++ b/packages/ui/message/.storybook/preview.js @@ -0,0 +1,18 @@ +import {addParameters} 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 + } + }, +}); diff --git a/packages/ui/message/CHANGELOG.md b/packages/ui/message/CHANGELOG.md new file mode 100644 index 00000000..e69de29b diff --git a/packages/ui/message/babel.config.js b/packages/ui/message/babel.config.js new file mode 100644 index 00000000..d222841d --- /dev/null +++ b/packages/ui/message/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/message/package.json b/packages/ui/message/package.json new file mode 100644 index 00000000..1b666f0a --- /dev/null +++ b/packages/ui/message/package.json @@ -0,0 +1,56 @@ +{ + "name": "@osui/message", + "version": "0.0.1", + "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": "huoyuxuan", + "license": "MIT", + "dependencies": { + "classnames": "^2.2.6" + } +} diff --git a/packages/ui/message/scripts/build.sh b/packages/ui/message/scripts/build.sh new file mode 100644 index 00000000..f1cf5724 --- /dev/null +++ b/packages/ui/message/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/message/src/index.less b/packages/ui/message/src/index.less new file mode 100644 index 00000000..d290f5d9 --- /dev/null +++ b/packages/ui/message/src/index.less @@ -0,0 +1,8 @@ +@osui-message-class-prefix: osui-message; + +.@{osui-message-class-prefix} { + .ant-message-notice-content { + box-shadow: 0 4 8px -2px rgba(9, 30, 66, .25), 0 0 1px 0 rgba(9, 30, 66, .31); + border-radius: 4px; + } +} diff --git a/packages/ui/message/src/index.tsx b/packages/ui/message/src/index.tsx new file mode 100644 index 00000000..c461ee13 --- /dev/null +++ b/packages/ui/message/src/index.tsx @@ -0,0 +1,27 @@ +import { message as AntdMessage } from 'antd'; +import { MessageInstance as AntdMessageInstance, MessageApi as AntdMessageApi } from 'antd/lib/Message'; +import './index.less'; + +const clsPrefix = 'osui-message'; + +export type MessageInstance = AntdMessageInstance; +export type MessageApi = AntdMessageApi; + +const types = ['success', 'error', 'info', 'warning', 'warn', 'loading', 'config', 'destroy', 'useMessage']; + +enum message { } + +types.forEach(item => { + message[item] = props => { + const defaultProps = { className: '' }; + if (typeof props === 'object') { + defaultProps.className = clsPrefix + ` ${props.className ? props.className : ''}`; + } else if (typeof props === 'string') { + defaultProps.className = clsPrefix; + defaultProps.content = props; + } + AntdMessage[item](props); + }; +}); + +export default message; diff --git a/packages/ui/message/stories/index.stories.mdx b/packages/ui/message/stories/index.stories.mdx new file mode 100644 index 00000000..b0560e8a --- /dev/null +++ b/packages/ui/message/stories/index.stories.mdx @@ -0,0 +1,20 @@ +import {Meta, Story, Preview} from '@storybook/addon-docs/blocks'; +import {Demo} from './index.stories' + + + +# OSUI Progress + +## API + +### 基本属性 + +支持所有antd属性:见[antd文档](https://ant.design/components/progress-cn/#API) + + + + + + {Demo()} + + diff --git a/packages/ui/message/stories/index.stories.tsx b/packages/ui/message/stories/index.stories.tsx new file mode 100644 index 00000000..6319b21f --- /dev/null +++ b/packages/ui/message/stories/index.stories.tsx @@ -0,0 +1,39 @@ +import * as React from 'react'; +import { Button, Space } from 'antd'; +import message from '../src'; + +export default { + title: 'OSUI-Message', +}; + +export const Demo = () => { + const success = () => { + message.success('This is a success message'); + }; + const error = () => { + message.error('This is an error message'); + }; + const info = () => { + message.info('This is an info message'); + }; + const warning = () => { + message.warning('This is a warning message'); + }; + const warn = () => { + message.warn('This is a warn message'); + }; + const loading = () => { + message.loading('This is a loading message'); + }; + return ( +
+ + + + + + + + +
); +}; diff --git a/packages/ui/message/tsconfig.json b/packages/ui/message/tsconfig.json new file mode 100644 index 00000000..3a24a511 --- /dev/null +++ b/packages/ui/message/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../../../tsconfig.json", + "compilerOptions": { + "rootDir": "./src", + "outDir": "./tmp" + }, + "include": ["src"] +} -- Gitee From 258658e64c477371216f8d01e114eb632b3a7f2d Mon Sep 17 00:00:00 2001 From: liushaozhen <804199994@qq.com> Date: Thu, 13 Aug 2020 14:03:43 +0800 Subject: [PATCH 2/6] =?UTF-8?q?fix(message):=20message=E7=BB=84=E4=BB=B6pr?= =?UTF-8?q?ops=E9=BB=98=E8=AE=A4=E5=80=BC=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/ui/message/src/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/ui/message/src/index.tsx b/packages/ui/message/src/index.tsx index c461ee13..30c712f5 100644 --- a/packages/ui/message/src/index.tsx +++ b/packages/ui/message/src/index.tsx @@ -20,7 +20,7 @@ types.forEach(item => { defaultProps.className = clsPrefix; defaultProps.content = props; } - AntdMessage[item](props); + AntdMessage[item](defaultProps); }; }); -- Gitee From 83a0be073d749bc97b88b778a412f3406989762b Mon Sep 17 00:00:00 2001 From: liushaozhen <804199994@qq.com> Date: Thu, 13 Aug 2020 14:10:32 +0800 Subject: [PATCH 3/6] =?UTF-8?q?docs(docs):=20=E6=96=87=E6=A1=A3=E6=A0=87?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/ui/message/stories/index.stories.mdx | 6 +++--- packages/ui/modal/stories/index.stories.mdx | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/ui/message/stories/index.stories.mdx b/packages/ui/message/stories/index.stories.mdx index b0560e8a..0b2b2e4b 100644 --- a/packages/ui/message/stories/index.stories.mdx +++ b/packages/ui/message/stories/index.stories.mdx @@ -1,15 +1,15 @@ import {Meta, Story, Preview} from '@storybook/addon-docs/blocks'; import {Demo} from './index.stories' - + -# OSUI Progress +# OSUI Message ## API ### 基本属性 -支持所有antd属性:见[antd文档](https://ant.design/components/progress-cn/#API) +支持所有antd属性:见[antd文档](https://ant.design/components/message-cn/#API) diff --git a/packages/ui/modal/stories/index.stories.mdx b/packages/ui/modal/stories/index.stories.mdx index b9d6f726..237c8f9d 100644 --- a/packages/ui/modal/stories/index.stories.mdx +++ b/packages/ui/modal/stories/index.stories.mdx @@ -1,7 +1,7 @@ import {Meta, Story, Preview} from '@storybook/addon-docs/blocks'; import {Demo} from './index.stories' - + # OSUI Modal -- Gitee From a62ed4120967c10d1c15ec0775ac2ffc68f810fd Mon Sep 17 00:00:00 2001 From: liushaozhen <804199994@qq.com> Date: Thu, 13 Aug 2020 15:36:21 +0800 Subject: [PATCH 4/6] =?UTF-8?q?feat(checkbox):=20=E6=96=B0=E5=A2=9Echeckbo?= =?UTF-8?q?x=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/ui/checkbox/.storybook/main.js | 73 +++++++++++++++++++ packages/ui/checkbox/.storybook/preview.js | 18 +++++ packages/ui/checkbox/CHANGELOG.md | 0 packages/ui/checkbox/babel.config.js | 11 +++ packages/ui/checkbox/package.json | 56 ++++++++++++++ packages/ui/checkbox/scripts/build.sh | 18 +++++ packages/ui/checkbox/src/index.less | 23 ++++++ packages/ui/checkbox/src/index.tsx | 22 ++++++ .../ui/checkbox/stories/index.stories.mdx | 20 +++++ .../ui/checkbox/stories/index.stories.tsx | 48 ++++++++++++ packages/ui/checkbox/tsconfig.json | 8 ++ 11 files changed, 297 insertions(+) create mode 100644 packages/ui/checkbox/.storybook/main.js create mode 100644 packages/ui/checkbox/.storybook/preview.js create mode 100644 packages/ui/checkbox/CHANGELOG.md create mode 100644 packages/ui/checkbox/babel.config.js create mode 100644 packages/ui/checkbox/package.json create mode 100644 packages/ui/checkbox/scripts/build.sh create mode 100644 packages/ui/checkbox/src/index.less create mode 100644 packages/ui/checkbox/src/index.tsx create mode 100644 packages/ui/checkbox/stories/index.stories.mdx create mode 100644 packages/ui/checkbox/stories/index.stories.tsx create mode 100644 packages/ui/checkbox/tsconfig.json diff --git a/packages/ui/checkbox/.storybook/main.js b/packages/ui/checkbox/.storybook/main.js new file mode 100644 index 00000000..34ac8402 --- /dev/null +++ b/packages/ui/checkbox/.storybook/main.js @@ -0,0 +1,73 @@ +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)$/, + 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/checkbox/.storybook/preview.js b/packages/ui/checkbox/.storybook/preview.js new file mode 100644 index 00000000..faeb11a4 --- /dev/null +++ b/packages/ui/checkbox/.storybook/preview.js @@ -0,0 +1,18 @@ +import {addParameters} 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 + } + }, +}); diff --git a/packages/ui/checkbox/CHANGELOG.md b/packages/ui/checkbox/CHANGELOG.md new file mode 100644 index 00000000..e69de29b diff --git a/packages/ui/checkbox/babel.config.js b/packages/ui/checkbox/babel.config.js new file mode 100644 index 00000000..d222841d --- /dev/null +++ b/packages/ui/checkbox/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/checkbox/package.json b/packages/ui/checkbox/package.json new file mode 100644 index 00000000..9071acbc --- /dev/null +++ b/packages/ui/checkbox/package.json @@ -0,0 +1,56 @@ +{ + "name": "@osui/checkbox", + "version": "0.0.1", + "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": "huoyuxuan", + "license": "MIT", + "dependencies": { + "classnames": "^2.2.6" + } +} diff --git a/packages/ui/checkbox/scripts/build.sh b/packages/ui/checkbox/scripts/build.sh new file mode 100644 index 00000000..f1cf5724 --- /dev/null +++ b/packages/ui/checkbox/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/checkbox/src/index.less b/packages/ui/checkbox/src/index.less new file mode 100644 index 00000000..fc97c702 --- /dev/null +++ b/packages/ui/checkbox/src/index.less @@ -0,0 +1,23 @@ +@osui-checkbox-class-prefix: osui-checkbox; + +.@{osui-checkbox-class-prefix} { + .ant-checkbox-inner, + .ant-checkbox-checked::after { + border-radius: 4px; + } + + .ant-checkbox-disabled .ant-checkbox-inner { + background-color: #fff; + } + + &-group { + .ant-checkbox-inner, + .ant-checkbox-checked::after { + border-radius: 4px; + } + + .ant-checkbox-disabled .ant-checkbox-inner { + background-color: #fff; + } + } +} diff --git a/packages/ui/checkbox/src/index.tsx b/packages/ui/checkbox/src/index.tsx new file mode 100644 index 00000000..9a231d97 --- /dev/null +++ b/packages/ui/checkbox/src/index.tsx @@ -0,0 +1,22 @@ +import * as React from 'react'; +import { Checkbox as AntdCheckbox } from 'antd'; +import { CheckboxProps as AntdCheckboxProps, CheckboxGroupProps as AntdCheckboxGroupProps } from 'antd/lib/Checkbox'; +import classNames from 'classnames'; +import './index.less'; + +const AntdCheckboxGroup = AntdCheckbox.Group; + +const clsPrefix = 'osui-checkbox'; + +export type CheckboxProps = AntdCheckboxProps; + +const CheckboxGroup: React.FC = ({ className, ...restProps }) => { + return ; +}; +const Checkbox: React.FC = ({ className, ...restProps }) => { + return ; +}; + +Checkbox.Group = CheckboxGroup; + +export default Checkbox; diff --git a/packages/ui/checkbox/stories/index.stories.mdx b/packages/ui/checkbox/stories/index.stories.mdx new file mode 100644 index 00000000..e3d432d4 --- /dev/null +++ b/packages/ui/checkbox/stories/index.stories.mdx @@ -0,0 +1,20 @@ +import {Meta, Story, Preview} from '@storybook/addon-docs/blocks'; +import {Demo} from './index.stories' + + + +# OSUI Checkbox + +## API + +### 基本属性 + +支持所有antd属性:见[antd文档](https://ant.design/components/checkbox-cn/#API) + + + + + + {Demo()} + + diff --git a/packages/ui/checkbox/stories/index.stories.tsx b/packages/ui/checkbox/stories/index.stories.tsx new file mode 100644 index 00000000..84d60282 --- /dev/null +++ b/packages/ui/checkbox/stories/index.stories.tsx @@ -0,0 +1,48 @@ +import * as React from 'react'; +import Checkbox from '../src'; + +const Group = Checkbox.Group; + +export default { + title: 'OSUI-Checkbox', +}; + +export const Demo = () => { + function onChange(checkedValues) { + console.log('checked = ', checkedValues); + } + + const plainOptions = ['Apple', 'Pear', 'Orange']; + const options = [ + { label: 'Apple', value: 'Apple' }, + { label: 'Pear', value: 'Pear' }, + { label: 'Orange', value: 'Orange' }, + ]; + const optionsWithDisabled = [ + { label: 'Apple', value: 'Apple' }, + { label: 'Pear', value: 'Pear' }, + { label: 'Orange', value: 'Orange', disabled: false }, + ]; + return ( +
+

基础示例

+ Checkbox + Checkbox + Checkbox + Checkbox +

+

Checkbox组

+ +
+
+ +
+
+ +
); +}; diff --git a/packages/ui/checkbox/tsconfig.json b/packages/ui/checkbox/tsconfig.json new file mode 100644 index 00000000..3a24a511 --- /dev/null +++ b/packages/ui/checkbox/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../../../tsconfig.json", + "compilerOptions": { + "rootDir": "./src", + "outDir": "./tmp" + }, + "include": ["src"] +} -- Gitee From 1a76fd801d2d10b496e65d5229bfb7530c49a9e9 Mon Sep 17 00:00:00 2001 From: liushaozhen <804199994@qq.com> Date: Thu, 13 Aug 2020 15:41:34 +0800 Subject: [PATCH 5/6] =?UTF-8?q?fix(checkbox):=20=E5=AF=BC=E5=87=BAcheckbox?= =?UTF-8?q?Group?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/ui/checkbox/src/index.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/ui/checkbox/src/index.tsx b/packages/ui/checkbox/src/index.tsx index 9a231d97..49492d80 100644 --- a/packages/ui/checkbox/src/index.tsx +++ b/packages/ui/checkbox/src/index.tsx @@ -9,8 +9,9 @@ const AntdCheckboxGroup = AntdCheckbox.Group; const clsPrefix = 'osui-checkbox'; export type CheckboxProps = AntdCheckboxProps; +export type CheckboxGroupProps = AntdCheckboxProps; -const CheckboxGroup: React.FC = ({ className, ...restProps }) => { +const CheckboxGroup: React.FC = ({ className, ...restProps }) => { return ; }; const Checkbox: React.FC = ({ className, ...restProps }) => { -- Gitee From cce680f7ee1fa9570e690b2e457b49424f769e4a Mon Sep 17 00:00:00 2001 From: liushaozhen <804199994@qq.com> Date: Thu, 13 Aug 2020 15:45:06 +0800 Subject: [PATCH 6/6] =?UTF-8?q?fix(checkbox):=20=E5=AF=BC=E5=87=BAcheckbox?= =?UTF-8?q?Group?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/ui/checkbox/src/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/ui/checkbox/src/index.tsx b/packages/ui/checkbox/src/index.tsx index 49492d80..583135bd 100644 --- a/packages/ui/checkbox/src/index.tsx +++ b/packages/ui/checkbox/src/index.tsx @@ -9,7 +9,7 @@ const AntdCheckboxGroup = AntdCheckbox.Group; const clsPrefix = 'osui-checkbox'; export type CheckboxProps = AntdCheckboxProps; -export type CheckboxGroupProps = AntdCheckboxProps; +export type CheckboxGroupProps = AntdCheckboxGroupProps; const CheckboxGroup: React.FC = ({ className, ...restProps }) => { return ; -- Gitee