Skip to content

Commit

Permalink
ci: change
Browse files Browse the repository at this point in the history
     Avatar.tsx => Avatar.jsx and update related files, simplify apis and examples.

    delete
     Lodash-es libs.

    other
     format some file by prettier
  • Loading branch information
jiaziling committed Sep 14, 2024
1 parent 56ea7bb commit 21e9248
Show file tree
Hide file tree
Showing 15 changed files with 19,346 additions and 8 deletions.
14 changes: 13 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ module.exports = {
},
},
},
ignorePatterns: [
'jest.config.ts',
'docs/*/examples/*',
],
overrides: [
{
env: {
Expand All @@ -24,6 +28,11 @@ module.exports = {
sourceType: 'script',
},
},
{
files: ['*.ts', '*.tsx'],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
},
],
parserOptions: {
ecmaVersion: 'latest',
Expand All @@ -39,12 +48,15 @@ module.exports = {
'react/no-danger': 0,
'no-underscore-dangle': 0,
'import/no-extraneous-dependencies': 0,
// 'no-unused-vars': 0,
'import/no-cycle': 0,
'import/prefer-default-export': 0,
'no-console': 0,
'react/jsx-wrap-multilines': 0,
'react/no-array-index-key': 0,
'no-plusplus': 0,
'no-unused-vars': 0,
'no-cond-assign': 0,
'react/jsx-filename-extension': [1, { extensions: ['.js', '.jsx', '.ts', '.tsx'] }],
'no-else-return': 0,
},
};
7 changes: 5 additions & 2 deletions .stylelintrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"extends": "@umijs/lint/dist/config/stylelint"
}
"extends": "@umijs/lint/dist/config/stylelint",
"rules": {
"selector-class-pattern": null
}
}
13 changes: 13 additions & 0 deletions docs/enh/Avatar.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
order: 05
toc: content
mobile: false
---

# Enh.Avatar

头像展示组件

## 示例

<code src="./examples/Avatar" compact background="#fff"></code>
9 changes: 9 additions & 0 deletions docs/enh/examples/Avatar/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { XBaseForm } from '@totalizer/xform';
import { observer } from 'mobx-react';

import schema from './schema.jsx';
import store from './store.js';

export default observer(() => (
<XBaseForm path="myFormData" store={store} schema={schema} debug />
));
43 changes: 43 additions & 0 deletions docs/enh/examples/Avatar/schema.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
const schema = {
imageAvatar: {
c: 'Enh.Avatar',
xs: 12,
label: '图片头像',
alt: 'alt content',
src: '/avatar_4.jpeg',
size: 64,
},
textAvatar: {
c: 'Enh.Avatar',
xs: 12,
label: '文字头像',
alt: 'alt content',
content: 'T',
bgColor: 'orange',
},
textBgAvatar1: {
c: 'Enh.Avatar',
xs: 12,
label: '文字头像背景颜色1',
alt: 'alt content',
content: 'T',
bgColor: '#1890ff',
size: 64,
},

avatarGroup: {
c: 'Enh.Avatar',
xs: 12,
label: '头像组',
alt: 'alt content',
src: [
'/avatar_1.jpeg',
'/avatar_2.jpeg',
'/avatar_3.jpeg',
'/avatar_4.jpeg',
],
size: 32,
},
};

export default schema;
33 changes: 33 additions & 0 deletions docs/enh/examples/Avatar/store.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { $$get, $$merge, $$set } from '@totalizer/xform';
import { configure, makeAutoObservable } from 'mobx';
import schema from './schema';

configure({
enforceActions: 'never',
});

class Store {
/**
* 定义 myFormData 用于存储表单数据
* $$merge 方法能够确保传入的数据与schema保持一致
*/
myFormData = $$merge(schema, {});

constructor() {
makeAutoObservable(this);
}

/**
* 你需要将 $$set, $$get 这两个方法按照以下示例置于你的 store 中
* 以便表单组件与 store 进行数据通信
*/
$$set(path, value) {
$$set(this, path, value);
}

$$get(path) {
return $$get(this, path);
}
}

export default new Store();
9 changes: 4 additions & 5 deletions jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,12 @@ const config: Config = {
"transform": {
"\\.[jt]sx?$": "babel-jest",
".+\\.(css|styl|less|sass|scss|png|jpg|ttf|woff|woff2)$": "jest-transform-stub"
}
},

// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
// transformIgnorePatterns: [
// "/node_modules/",
// "\\.pnp\\.[^\\/]+$"
// ],
transformIgnorePatterns: [
"/node_modules/(?!lodash-es/)"
],

// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
// unmockedModulePathPatterns: undefined,
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@
"@commitlint/config-conventional": "^17.1.0",
"@types/react": "^18.0.33",
"@types/react-dom": "^18.0.11",
"@typescript-eslint/eslint-plugin": "^8.5.0",
"@typescript-eslint/parser": "^8.5.0",
"@umijs/lint": "^4.0.0",
"babel-jest": "^29.7.0",
"dumi": "^2.3.0",
Expand Down
Loading

0 comments on commit 21e9248

Please sign in to comment.