diff --git a/.commitlintrc.js b/.commitlintrc.js new file mode 100644 index 000000000..77a6b15c5 --- /dev/null +++ b/.commitlintrc.js @@ -0,0 +1,7 @@ +// https://github.com/conventional-changelog/commitlint/blob/master/@commitlint/config-conventional/index.js +const { cloneDeep, last } = require('lodash'); +const config = cloneDeep(require('@1stg/commitlint-config')); + +last(config.rules['type-enum']).push('icon'); + +module.exports = config; diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 000000000..3c35535a2 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,23 @@ +name: Deploy stories + +on: + push: + branches: [master] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install dependencies + run: yarn install + - name: Build stories + run: yarn storybook:build + - name: Deploy + if: success() + uses: crazy-max/ghaction-github-pages@v1 + with: + build_dir: dist + fqdn: aui.js.org + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 000000000..abbfa96f1 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,21 @@ +name: Publish package + +on: + release: + types: [published] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Install dependencies + run: yarn install + - name: Build package + run: yarn build + - name: Publish + run: | + npm set //registry.npmjs.org/:_authToken "$NPM_TOKEN" + npm publish release + env: + NPM_TOKEN: ${{secrets.NPM_TOKEN}} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 000000000..b51709e1f --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,13 @@ +name: Run unit test + +on: push + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install dependencies + run: yarn install + - name: Run test + run: yarn test:ci diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..314c1fad7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +.*cache +*.log +coverage +dist +node_modules +release +reports +/report.*.json diff --git a/.huskyrc.js b/.huskyrc.js new file mode 100644 index 000000000..dce9687a4 --- /dev/null +++ b/.huskyrc.js @@ -0,0 +1 @@ +module.exports = require('@1stg/husky-config'); diff --git a/.lintstagedrc.js b/.lintstagedrc.js new file mode 100644 index 000000000..50f4c95c3 --- /dev/null +++ b/.lintstagedrc.js @@ -0,0 +1 @@ +module.exports = require('@1stg/lint-staged'); diff --git a/.storybook/addons.js b/.storybook/addons.js new file mode 100644 index 000000000..3938cbb87 --- /dev/null +++ b/.storybook/addons.js @@ -0,0 +1,4 @@ +import '@storybook/addon-options/register'; +import '@storybook/addon-knobs/register'; +import '@storybook/addon-actions/register'; +import '@storybook/addon-storysource/register'; diff --git a/.storybook/config.js b/.storybook/config.js new file mode 100644 index 000000000..e8c0d44d6 --- /dev/null +++ b/.storybook/config.js @@ -0,0 +1,12 @@ +import { addParameters, configure } from '@storybook/angular'; + +addParameters({ + options: { + panelPosition: 'right', + theme: { + brandTitle: 'Alauda UI', + }, + }, +}); + +configure(() => require('../stories'), module); diff --git a/.storybook/preview-head.html b/.storybook/preview-head.html new file mode 100644 index 000000000..b2b0b8002 --- /dev/null +++ b/.storybook/preview-head.html @@ -0,0 +1,62 @@ + diff --git a/.storybook/tsconfig.json b/.storybook/tsconfig.json new file mode 100644 index 000000000..26bb171cc --- /dev/null +++ b/.storybook/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "../tsconfig", + "include": ["../src", "../stories"] +} diff --git a/.storybook/webpack.config.js b/.storybook/webpack.config.js new file mode 100644 index 000000000..f9344ece8 --- /dev/null +++ b/.storybook/webpack.config.js @@ -0,0 +1,19 @@ +const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin'); + +module.exports = ({ config }) => { + config.resolve.plugins = [new TsconfigPathsPlugin()]; + config.module.rules.push({ + test: /stories\/\S+\/index.ts$/, + loaders: [ + { + loader: '@storybook/source-loader', + options: { + parser: 'typescript', + }, + }, + ], + enforce: 'pre', + }); + + return config; +}; diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 000000000..c743b68ef --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,267 @@ +# Changelog + +All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. + +### [5.1.3](https://bitbucket.org/mathildetech/alauda-ui/branches/compare/v5.1.3..v5.1.2#diff) (2020-04-08) + + +### Bug Fixes + +* placeholder rely on value of hasSelected changes ([d448ba1](https://bitbucket.org/mathildetech/alauda-ui/commits/d448ba1e561f74ab022eb99177f396ce2afd6cbc)) +* style for class names includes aui- ([217fdc4](https://bitbucket.org/mathildetech/alauda-ui/commits/217fdc40bc136651a1e900ffbddd4e8a9d341d32)) + +### [5.1.2](https://bitbucket.org/mathildetech/alauda-ui/branches/compare/v5.1.2..v5.1.1#diff) (2020-03-26) + + +### Features + +* optimize taginput ([e3e549d](https://bitbucket.org/mathildetech/alauda-ui/commits/e3e549dd9e1dbd17617955726f95d7cd9b9696ea)) + + +### Bug Fixes + +* ivy compatibility ([8fcc012](https://bitbucket.org/mathildetech/alauda-ui/commits/8fcc01291087ac7174a13bd0368cc0fab8e1330b)) + +### [5.1.1](https://bitbucket.org/mathildetech/alauda-ui/branches/compare/v5.1.1..v5.1.0#diff) (2020-03-16) + + +### Bug Fixes + +* using unique spinner mask id ([b7b58ac](https://bitbucket.org/mathildetech/alauda-ui/commits/b7b58acdc516be5e9b2fc417d2c483f2e276742e)) + +## [5.1.0](https://bitbucket.org/mathildetech/alauda-ui/branches/compare/v5.1.0..v5.0.2#diff) (2020-03-09) + + +### ⚠ BREAKING CHANGES + +* basic icons are removed, and some aui icons are renamed + +### Features + +* change the color of info type notification/message to blue ([b99f941](https://bitbucket.org/mathildetech/alauda-ui/commits/b99f941ae4c494326682f9a4bc245b5bf8442b1d)) +* include cdk scrolling module ([bdabaa3](https://bitbucket.org/mathildetech/alauda-ui/commits/bdabaa35d7c99bbce5d7883cf7ab8eba8083704c)) +* remove basic icons ([697ee60](https://bitbucket.org/mathildetech/alauda-ui/commits/697ee60a346f7cbb08de08e7b69b425053be6a12)) +* replace spinner icon ([579a3fb](https://bitbucket.org/mathildetech/alauda-ui/commits/579a3fb593c7afa231e0e0eac7d3fdc76b14b00c)) + +### [5.0.2](https://bitbucket.org/mathildetech/alauda-ui/branches/compare/v5.0.2..v5.0.1#diff) (2020-02-18) + + +### Bug Fixes + +* add debounce to toc container scroll event handler ([00b3f6a](https://bitbucket.org/mathildetech/alauda-ui/commits/00b3f6a82801a5cc7dfd222ee66297685c280383)) + +### [5.0.1](https://bitbucket.org/mathildetech/alauda-ui/branches/compare/v5.0.1..v5.0.0#diff) (2020-02-14) + +## [5.0.0](https://bitbucket.org/mathildetech/alauda-ui/branches/compare/v5.0.0..v4.3.3#diff) (2020-02-07) + + +### ⚠ BREAKING CHANGES + +* upgrade angular to 9.0, remove deprecated modules + +### Features + +* upgrade angular to 9.0, remove deprecated modules ([9f5c81c](https://bitbucket.org/mathildetech/alauda-ui/commits/9f5c81cde219c9a613e960fc4deb4b423cd8a4c3)) + +### [4.3.3](https://bitbucket.org/mathildetech/alauda-ui/branches/compare/v4.3.3..v4.3.2#diff) (2020-02-03) + + +### Bug Fixes + +* can't resolve 'clipboard-polyfill' ([940221f](https://bitbucket.org/mathildetech/alauda-ui/commits/940221f16f2aec4904f595794a0e70f8cee0383e)) +* num-aui-input min max ui bug #PT-263 ([3d0a06b](https://bitbucket.org/mathildetech/alauda-ui/commits/3d0a06bcb8cc4c9192be76ab7fcc87814cf62eb9)), closes [#PT-263](http://jira.alaudatech.com/browse/PT-263) +* storybook build error ([eb605be](https://bitbucket.org/mathildetech/alauda-ui/commits/eb605befbd81220fcdc738412a857f65abb19abe)) + +### [4.3.2](https://bitbucket.org/mathildetech/alauda-ui/branches/compare/v4.3.2..v4.3.1#diff) (2019-12-11) + + +### Features + +* use union [@1st](https://bitbucket.org/mathildetech/alauda-ui)G configs, bump all (dev)Dependencies ([355a814](https://bitbucket.org/mathildetech/alauda-ui/commits/355a81464c8c583e805301433141a828a38ecc46)) + +### [4.3.1](https://bitbucket.org/mathildetech/alauda-ui/branches/compare/v4.3.1..v4.3.0#diff) (2019-12-10) + + +### Features + +* support to disable table row ([6108ab4](https://bitbucket.org/mathildetech/alauda-ui/commits/6108ab490212aeb73adf7541fd959eb466c57cab)) + +## [4.3.0](https://bitbucket.org/mathildetech/alauda-ui/branches/compare/v4.3.0..v4.2.12#diff) (2019-12-05) + + +### Features + +* support muilt select options label use template ([a6d895d](https://bitbucket.org/mathildetech/alauda-ui/commits/a6d895d43644d98658a330d9d07deb12b8fd3cc6)) + + +### Bug Fixes + +* form item content should align to the center of container ([b4757d3](https://bitbucket.org/mathildetech/alauda-ui/commits/b4757d3b16b0fd93a1ab14c2eb49dcdf7e0cc481)) + +## [1.5.0](https://bitbucket.org/mathildetech/alauda-ui/branches/compare/v1.5.0..v4.2.12#diff) (2019-12-05) + + +### Features + +* support muilt select options label use template ([a6d895d](https://bitbucket.org/mathildetech/alauda-ui/commits/a6d895d43644d98658a330d9d07deb12b8fd3cc6)) + + +### Bug Fixes + +* form item content should align to the center of container ([b4757d3](https://bitbucket.org/mathildetech/alauda-ui/commits/b4757d3b16b0fd93a1ab14c2eb49dcdf7e0cc481)) + +### [4.2.12](https://bitbucket.org/mathildetech/alauda-ui/branches/compare/v4.2.12..v4.2.11#diff) (2019-12-03) + + +### Bug Fixes + +* form-item-addon should align to the top of the container ([0907081](https://bitbucket.org/mathildetech/alauda-ui/commits/09070819ed7089385f2ec9364b3f2bfa6b0f4278)) + +### [4.2.11](https://bitbucket.org/mathildetech/alauda-ui/branches/compare/v4.2.11..v4.2.10#diff) (2019-11-28) + + +### Bug Fixes + +* add fill color for tree select icon ([f062006](https://bitbucket.org/mathildetech/alauda-ui/commits/f06200669affe69e265c1a67c7b36b0de2ad23da)) +* optimize the postion of the close button in dialog header ([f1d1129](https://bitbucket.org/mathildetech/alauda-ui/commits/f1d11297a8a5bfdcf9ce69bb16e6c77480216a7f)) + +### [4.2.10](https://bitbucket.org/mathildetech/alauda-ui/branches/compare/v4.2.10..v4.2.9#diff) (2019-11-14) + + +### Icon + +* update basic icon v0.75 ([026dd69](https://bitbucket.org/mathildetech/alauda-ui/commits/026dd693cdc29224063427102895203fbd524a5f)) + +### [4.2.9](https://bitbucket.org/mathildetech/alauda-ui/branches/compare/v4.2.9..v4.2.8#diff) (2019-10-21) + + +### Bug Fixes + +* number input add type attribute ([c60dae1](https://bitbucket.org/mathildetech/alauda-ui/commits/c60dae1053cade76a70768e37a6ffc1b49be9593)) + +### [4.2.8](https://bitbucket.org/mathildetech/alauda-ui/branches/compare/v4.2.8..v4.2.7#diff) (2019-10-17) + + +### Bug Fixes + +* multi select custom create value bug ([db908ce](https://bitbucket.org/mathildetech/alauda-ui/commits/db908ce71537bda9f6f68a5ff44ca4c451e3b448)) + +### [4.2.7](https://bitbucket.org/mathildetech/alauda-ui/branches/compare/v4.2.7..v4.2.6#diff) (2019-10-16) + + +### Bug Fixes + +* icon doc url ([396e186](https://bitbucket.org/mathildetech/alauda-ui/commits/396e1867b78b39eb6413a41ac1f0dee4cf45eb0f)) + + +### Icon + +* update basic icon v0.73 ([be43888](https://bitbucket.org/mathildetech/alauda-ui/commits/be438888c71d48821abdccf8ccd406e535fabaee)) + +### [4.2.6](https://bitbucket.org/mathildetech/alauda-ui/branches/compare/v4.2.6..v4.2.5#diff) (2019-10-15) + + +### Bug Fixes + +* select allow create bug ([e816a2f](https://bitbucket.org/mathildetech/alauda-ui/commits/e816a2f6c77a133c21e93625cca3d5d4e7d85440)) + +### [4.2.5](https://bitbucket.org/mathildetech/alauda-ui/branches/compare/v4.2.5..v4.2.4#diff) (2019-09-18) + + +### Bug Fixes + +* confirm dialog type error ([e376a1b](https://bitbucket.org/mathildetech/alauda-ui/commits/e376a1b)) + +### [4.2.4](https://bitbucket.org/mathildetech/alauda-ui/branches/compare/v4.2.4..v4.2.3#diff) (2019-09-18) + + +### Bug Fixes + +* dialog confirm method return type ([113a4ea](https://bitbucket.org/mathildetech/alauda-ui/commits/113a4ea)) + + +### Icon + +* update v0.72, fix viewBox ([c06729a](https://bitbucket.org/mathildetech/alauda-ui/commits/c06729a)) + +### [4.2.3](https://bitbucket.org/mathildetech/alauda-ui/branches/compare/v4.2.3..v4.2.2#diff) (2019-09-18) + +### [4.2.2](https://bitbucket.org/mathildetech/alauda-ui/branches/compare/v4.2.2..v4.2.1#diff) (2019-09-16) + + +### Bug Fixes + +* bitbucket pipeline ([c349be9](https://bitbucket.org/mathildetech/alauda-ui/commits/c349be9)) +* update dev readme ([f88e232](https://bitbucket.org/mathildetech/alauda-ui/commits/f88e232)) + + +### Icon + +* update basic icon v0.71 ([87794c0](https://bitbucket.org/mathildetech/alauda-ui/commits/87794c0)) + +### [4.2.1](https://bitbucket.org/mathildetech/alauda-ui/compare/v4.2.0...v4.2.1) (2019-08-27) + + +### Bug Fixes + +* change all similar codes ([7edf3a6](https://bitbucket.org/mathildetech/alauda-ui/commit/7edf3a6)) +* workaround for fesm2015 package building error ([d4701e6](https://bitbucket.org/mathildetech/alauda-ui/commit/d4701e6)), closes [/github.com/angular/angular-cli/issues/14247#issuecomment-486582423](https://bitbucket.org/mathildetech/alauda-ui/issues/issuecomment-486582423) + + + +## [4.2.0](https://bitbucket.org/mathildetech/alauda-ui/branches/compare/v4.2.0..v4.1.2#diff) (2019-08-18) + + +### Features + +* confirm dialog return result ([839e0b0](https://bitbucket.org/mathildetech/alauda-ui/commits/839e0b0)) + +### [4.1.2](https://bitbucket.org/mathildetech/alauda-ui/branches/compare/v4.1.2..v4.1.1#diff) (2019-08-15) + + +### Bug Fixes + +* add icon 0.70 ([6f619d9](https://bitbucket.org/mathildetech/alauda-ui/commits/6f619d9)) +* menu-group-title margin bottom ([c43b8da](https://bitbucket.org/mathildetech/alauda-ui/commits/c43b8da)) + +### [4.1.1](https://bitbucket.org/mathildetech/alauda-ui/branches/compare/v4.1.1..v4.1.0#diff) (2019-08-05) + + +### Bug Fixes + +* menu item add icon margin ([7e56525](https://bitbucket.org/mathildetech/alauda-ui/commits/7e56525)), closes [#PT-220](http://jira.alaudatech.com/browse/PT-220) + + +### Icon + +* update basic icon 0.69 ([5437436](https://bitbucket.org/mathildetech/alauda-ui/commits/5437436)) + +## [4.1.0](https://bitbucket.org/mathildetech/alauda-ui/branches/compare/v4.1.0..v4.0.5#diff) (2019-07-26) + + +### Bug Fixes + +* call _changeActivatedTabs on selectedIndex changes ([c73a46e](https://bitbucket.org/mathildetech/alauda-ui/commits/c73a46e)) +* change tab component static metadata ([8f3b7a6](https://bitbucket.org/mathildetech/alauda-ui/commits/8f3b7a6)) +* input group addon support dynamic render ([8556bf1](https://bitbucket.org/mathildetech/alauda-ui/commits/8556bf1)) +* story should declare used component ([0572490](https://bitbucket.org/mathildetech/alauda-ui/commits/0572490)) + + +### Refactor + +* remove unused layout component ([578c016](https://bitbucket.org/mathildetech/alauda-ui/commits/578c016)) + + +### BREAKING CHANGES + +* aui-layout has been removed + + + +### [4.0.5](https://bitbucket.org/mathildetech/alauda-ui/branches/compare/v4.0.5..v4.0.4#diff) (2019-07-10) + + +### Bug Fixes + +* aui header addon not show error ([d96a1b9](https://bitbucket.org/mathildetech/alauda-ui/commits/d96a1b9)) +* ContentChild static false for form-item ([a85139a](https://bitbucket.org/mathildetech/alauda-ui/commits/a85139a)) diff --git a/README.md b/README.md new file mode 100644 index 000000000..97dc1d7b9 --- /dev/null +++ b/README.md @@ -0,0 +1,88 @@ +# Alauda UI + +> Internal Angular UI framework for Alauda Frontend Team. + +## TOC + +- [Online Demo](#online-demo) +- [Getting Started](#getting-started) + - [Install](#install) + - [Usage](#usage) +- [Development](#development) +- [Test](#test) +- [Build Storybook](#build-storybook) +- [Build Library](#build-library) +- [LICENCE](#licence) +- [Read More](#read-more) + +## Online Demo + +[Storybook Demo](http://k8s-cn-alauda-ui.nolimited.haproxy-internet-alaudacn.myalauda.cn) + +## Getting Started + +### Install + +```sh +# npm +npm i @alauda/ui + +# yarn +yarn add @alauda/ui +``` + +### Usage + +```ts +import { ButtonModule } from '@alauda/ui'; + +@NgModule({ + imports: [ButtonModule], +}) +export class AppModule {} +``` + +## Development + +```sh +git clone git@bitbucket.org:mathildetech/alauda-ui.git +cd alauda-ui +yarn install +yarn start +``` + +开发环境基于 [Storybook](https://storybook.js.org/) 运行, 查看 [文档](https://storybook.js.org/basics/guide-angular/)。 + +## Test + +```sh +yarn test +``` + +or + +```sh +yarn test:watch +``` + +## Build Storybook + +```sh +yarn storybook:build +``` + +## Build Library + +```sh +yarn build +``` + +## LICENCE + +[MIT](LICENCE) © [Alauda](http://www.alauda.io) + +## Read More + +- [coding standards](./docs/CODING_STANDARDS.md) +- [contributing](./docs/CONTRIBUTING.md) +- [AOT notes](./docs/AOT_NOTES.md) diff --git a/docs/ALAUDA_UI_INTRODUCTION.md b/docs/ALAUDA_UI_INTRODUCTION.md new file mode 100644 index 000000000..d88e8b13d --- /dev/null +++ b/docs/ALAUDA_UI_INTRODUCTION.md @@ -0,0 +1,72 @@ +# Alauda UI 介绍 + +当前目标是满足发行版和 DevOps 需求,长远目标是要移植进大平台并且开源。以后大平台会使用新的设计规范。 + +## Overview + +- 开发、demo => storybook:The UI Development Environment +- 单元测试 => jest: 命令行运行、更快的测试速度、支持 snapshot 对比 +- 编译 => ngc/rollup: 参照 google [APF](https://docs.google.com/document/d/1CZC2rcpxffTDfRDs6p1cfbmKNLA6x5O-NtkJglDaBVs/preview#),支持 AOT。编译过程: + - 复制源码并 inline template 和样式 + - ngc 将 ts 编译为 js 并生成 metadata 供 AOT 使用 + - rollup 将代码 打包成 es2015/es5/umd 模块 + - 复制 package.json 等 +- 项目结构 => + - config: jest/storybook 配置 + - tasks: 编译脚本 + - release: 编译产出物 + - coverage: 测试覆盖率报告 + - dist:storybook build + - src: 源码 + - stories: demo app + +## Workflow + +1. 按规范提交代码并 PR,触发 bitbucket ci 测试。成员 approve 且测试通过后 merge 进 master +2. master 分支触发 cn [构建项目](https://enterprise.alauda.cn/console/build/config/detail/215bf840-160c-4714-800a-85bfe47e8a38),构建的新镜像触发 [Jenkins 流水线](https://enterprise.alauda.cn/console/jenkins/pipelines/5c857f05-a706-4bc4-97e1-496c6c44b053)自动更新[服务](https://enterprise.alaudatech.cn/console/app_service/service/service_detail/k8s-cn-alauda-UI) +3. 发版:需要手动修改 `package.json` 中的 `version` 的版本,并提交 `PR` 合并到 `master` 中,流水线检测到 `version` 发生变化会在 UI 规范群中发送通知确认是否确定发版。 + +## Coding Standards + +### Angular + +- 组件的配置 + +```ts +@Component({ + encapsulation: ViewEncapsulation.None, + changeDetection: ChangeDetectionStrategy.OnPush, + preserveWhitespaces: false, +}) +export class XComponent {} +``` + +- 原则上如果修改元素内容或样式使用 `Component`,如果是对元素功能的增强使用 `Directive` +- 组件 `selector` 使用中划线命名,指令使用驼峰命名 +- 组件参数名不带组件名前缀,指令使用指令名作为前缀 + +### CSS + +- 严格遵守 BEM 规范 +- 组件颜色、边框等可配置参数统一放在 `var.scss` 中,并根据设计意图决定是否引用基础变量 +- 公用 `mixin` 等放在 `common.scss` 中 + +### Test + +- 测试覆盖率以 80% 为目标,但测试覆盖率不能表明测试代码的质量 +- 避免使用 Angular 提供的异步测试工具,推荐 `async` 和 `sleep` 函数 +- AOT 打包会检查模板语法,有错误时会导致编译失败。在完成新组件后应运行 `yarn run test:aot` 进行 AOT 编译测试。bitbucket pipeline 为 master 分支配置了 AOT 编译测试,在发布新版本前应等待测试通过 + +## 需要注意的点 + +- aui 目前没有提供一次性导入全部组件的模块,需要单独导入 要用的组件模块 +- 当 `import` 路径为文件夹时,ngc 无法正确生成 `metadata`,所以导出模块的文件全部命名为 `public-api.ts` +- 运行 jest 测试前组件模板已被预编译为 `inline template`,因此不需要再异步编译 +- 通过 `pipe` 方法组合操作符 +- 多行注释会保留在 编译后的文件中,所以写注释时要考虑下是不是应该用单行注释(比如 `TODO`) + +## Contributing + +1. 与产品和设计讨论、制定组件样式规范,或从已确定的设计中领取任务 +2. 调研实现方案、接口设计,与其他组员讨论,讨论通过后明确 deadline +3. 开始开发 diff --git a/docs/AOT_NOTES.md b/docs/AOT_NOTES.md new file mode 100644 index 000000000..ce0424efe --- /dev/null +++ b/docs/AOT_NOTES.md @@ -0,0 +1,69 @@ +# AOT Notes + +## About barred latin O(ɵ) + + + + + + + +> The prefixed symbols are indeed private (see documentation). The must be exported because they are being used by the code generated by the AOT compiler. + +### Bad + +`/x-module/index.ts` + +```ts +export * from './x-module'; +``` + +`/x-module/x-module.ts` + +```ts +export class XModule {} +``` + +`/index.ts` + +```ts +export * from './root-module'; +export * from './x-module'; +``` + +`/root-module.ts` + +```ts +//bad +import { XModule } from './x-module/x-module'; +export class RootModule {} +``` + +### Good + +`/x-module/index.ts` + +```ts +export * from './x-module'; +``` + +`/x-module/x-module.ts` + +```ts +export class XModule {} +``` + +`/index.ts` + +```ts +export * from './root-module'; +export * from './x-module'; +``` + +`/root-module.ts` + +```ts +//good +import { XModule } from './x-module'; +export class RootModule {} +``` diff --git a/docs/CODING_STANDARDS.md b/docs/CODING_STANDARDS.md new file mode 100644 index 000000000..743a2ed68 --- /dev/null +++ b/docs/CODING_STANDARDS.md @@ -0,0 +1,65 @@ +# Coding Standards + +首先阅读 [Angular 风格指南](https://angular.cn/guide/styleguide)、[Material2 Coding Standards](https://github.com/angular/material2/blob/master/CODING_STANDARDS.md) ,Alauda UI 代码规范以此为基础。 + +## TypeScript + +尽可能少的引入第三方库。必须使用的库,优先考虑是否可以使用 `peerDependencies`。 + +getter 不可产生副作用。 + +纯函数和静态变量使用 TS 模块导入。 + +每个模块新建独立的 `*.types.ts` 文件声明接口或类型。 + +目录结构、模块导入导出方式**必须**与现有组件保持一致, 错误的方式可能导致 AOT 编译出错。[see more](./AOT_NOTES.md) + +## Angular + +使用 onPush 模式以获得更好的性能。 + +如果组件的功能是修改元素的内容则写成 `Component`,如果是对元素功能的增强则写成 `Directive`。 + +组件的 `input` 参数名不带组件前缀,指令 `input` 带前缀,命名要就简洁明了。 + +组件 `selector` 使用中划线命名(包括使用属性选择器时),指令使用驼峰命名。 + +## CSS + +关闭 Angular 组件样式。 + +```ts +@Component({ + selector: 'aui-button' + encapsulation: ViewEncapsulation.None, +}) +export class ButtonComponent {} +``` + +使用 BEM 命名方法论。在严格遵守 [BEM](http://getbem.com/) 规范的基础上,可以使用以 `is-` 为前缀的类名 表示状态。 + +```scss +.aui-button { + // ... + + &__text { + // ... + } + + &--primary { + // ... + } + + &.is-disabled { + // ... + } +} +``` + +所有颜色 、字体等在 `./src/theme/var.scss` 中使用语义化变量名进行配置。 + +## Test + + 使用 [Jest](https://facebook.github.io/jest/) 运行单元测试。在运行测试前组件已预编译为 `inline template`,因此在测试时不需再调用异步的 `compileComponents`。 + +虽然 `EventEmitter` 的回调函数是同步调用,但要保证回调函数内测试代码确实得到执行必须在 `subscribe` 内执行 `done()`。 diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md new file mode 100644 index 000000000..71c294f50 --- /dev/null +++ b/docs/CONTRIBUTING.md @@ -0,0 +1,67 @@ +# Contributing + +## Submitting a Pull Request + +The following conditions must be met before merge to `master`: + +- at least 1 approval +- the last commit was successfully built and no failed builds + +## Commit Message + +### Commit Message Format + +```text +(): + + + +