forked from totalizer-team/XForm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: deploy set && avatar components change
Add git pages deploy feature deploy.yml Change static picture url to cdn url avatar example schema.jsx
- Loading branch information
Showing
13 changed files
with
249 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: Deploy to GitHub Pages | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
workflow_dispatch: | ||
|
||
permissions: | ||
contents: read | ||
pages: write | ||
id-token: write | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout your repository using git | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install dependencies | ||
run: yarn | ||
|
||
- name: Build your project | ||
run: yarn run docs:build | ||
|
||
- name: Remove ~demos/:id | ||
run: rm -rf ./docs-dist/~demos/:id | ||
|
||
- name: Show build output directory | ||
run: ls -la ./docs-dist | ||
|
||
- name: Upload build artifact | ||
uses: actions/upload-pages-artifact@v1 | ||
with: | ||
name: github-pages | ||
path: ./docs-dist | ||
|
||
|
||
deploy: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
environment: | ||
name: github-pages | ||
url: ${{ steps.deployment.outputs.page_url }} | ||
steps: | ||
- name: Deploy to GitHub Pages | ||
id: deployment | ||
uses: actions/deploy-pages@v3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 /> | ||
)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: 'https://s2.loli.net/2024/09/14/g6adqDxkCv14LZj.jpg', | ||
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: [ | ||
'https://s2.loli.net/2024/09/14/pFiQIzVUBu29NeE.jpg', | ||
'https://s2.loli.net/2024/09/14/g6adqDxkCv14LZj.jpg', | ||
'https://s2.loli.net/2024/09/14/2PkevRYnHGq46tb.jpg', | ||
'https://s2.loli.net/2024/09/14/KHXqLyimJSYjMek.jpg', | ||
], | ||
size: 32, | ||
}, | ||
}; | ||
|
||
export default schema; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { observer } from 'mobx-react'; | ||
|
||
import { Avatar, AvatarGroup, Stack } from '@mui/material'; | ||
import React from 'react'; | ||
|
||
export default observer(({ path = '', $$store = null }) => { | ||
console.log('~~~ Avatar', path); | ||
|
||
if (!$$store) return null; | ||
|
||
const { | ||
c, | ||
xs, | ||
label, | ||
disabled, | ||
required, | ||
helperText, | ||
errorMsg, | ||
visible, | ||
|
||
/** | ||
* componentProps | ||
*/ | ||
src, | ||
content, | ||
size, | ||
bgColor, | ||
total, | ||
max, | ||
} = $$store?.context?.(path) || {}; | ||
|
||
const isGroup = Array.isArray(src); | ||
const currentSxProps = { | ||
sx: { | ||
height: size, | ||
width: size, | ||
bgcolor: bgColor, | ||
}, | ||
}; | ||
|
||
if (!isGroup) { | ||
return ( | ||
<Stack direction="row" justifyContent="center"> | ||
<Avatar src={src} {...currentSxProps}> | ||
{content} | ||
</Avatar> | ||
</Stack> | ||
); | ||
} else { | ||
const isImageAvatarGroup = !!src?.length; | ||
if (!isImageAvatarGroup) return null; | ||
const currentArr = src; | ||
return ( | ||
<Stack direction="row" justifyContent="center"> | ||
<AvatarGroup max={max} total={total}> | ||
{currentArr.map((item) => ( | ||
<Avatar | ||
key={item} | ||
src={isImageAvatarGroup ? item : undefined} | ||
{...currentSxProps} | ||
/> | ||
))} | ||
</AvatarGroup> | ||
</Stack> | ||
); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters