Skip to content

Commit

Permalink
perf: display border status color when the form is verified incorrect…
Browse files Browse the repository at this point in the history
…ly (#4407)

* perf: display border status color when the form is verified incorrectly

* chore: adjust the document preview file order
  • Loading branch information
anncwb committed Sep 14, 2024
1 parent 02c4014 commit bfae962
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ node_modules
.gitignore
*.md
dist
.turbo
dist.zip
1 change: 0 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@
"*.env": "$(capture).env.*",
"README.md": "README*,CHANGELOG*,LICENSE,CNAME",
"package.json": "pnpm-lock.yaml,pnpm-workspace.yaml,.gitattributes,.gitignore,.gitpod.yml,.npmrc,.browserslistrc,.node-version,.git*,.tazerc.json",
"Dockerfile": "Dockerfile,.docker*,docker-entrypoint.sh,build-local-docker*,nginx.conf",
"eslint.config.mjs": ".eslintignore,.prettierignore,.stylelintignore,.commitlintrc.*,.prettierrc.*,stylelint.config.*,.lintstagedrc.mjs,cspell.json",
"tailwind.config.mjs": "postcss.*"
},
Expand Down
7 changes: 6 additions & 1 deletion docs/.vitepress/config/plugins/demo-preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,12 @@ export const demoPreviewPlugin = (md: MarkdownRenderer) => {
if (!state.tokens[index]) {
return '';
}

const firstString = 'index.vue';
childFiles = childFiles.sort((a, b) => {
if (a === firstString) return -1;
if (b === firstString) return 1;
return a.localeCompare(b, 'en', { sensitivity: 'base' });
});
state.tokens[index].content =
`<DemoPreview files="${encodeURIComponent(JSON.stringify(childFiles))}" ><${ComponentName}/>
`;
Expand Down
9 changes: 9 additions & 0 deletions docs/src/guide/introduction/thin.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,12 @@ pnpm install
}
}
```

## 其他

如果你想更进一步精简,你可以删除参考一下文件或者文件夹的作用,判断自己是否需要,不需要删除即可:

- `.changeset` 文件夹用于管理版本变更
- `.github` 文件夹用于存放 GitHub 的配置文件
- `.vscode` 文件夹用于存放 VSCode 的配置文件,如果你使用其他编辑器,可以删除
- `./scripts/deploy` 文件夹用于存放部署脚本,如果你不需要docker部署,可以删除
10 changes: 9 additions & 1 deletion packages/@core/ui-kit/form-ui/src/form-render/form-field.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
import { cn, isFunction, isObject, isString } from '@vben-core/shared/utils';
import { toTypedSchema } from '@vee-validate/zod';
import { useFormValues } from 'vee-validate';
import { useFieldError, useFormValues } from 'vee-validate';
import { injectRenderFormProps, useFormContext } from './context';
import useDependencies from './dependencies';
Expand All @@ -43,8 +43,11 @@ const {
const { componentBindEventMap, componentMap, isVertical } = useFormContext();
const formRenderProps = injectRenderFormProps();
const values = useFormValues();
const errors = useFieldError(fieldName);
const formApi = formRenderProps.form;
const isInValid = computed(() => errors.value?.length > 0);
const fieldComponent = computed(() => {
const finalComponent = isString(component)
? componentMap.value[component]
Expand Down Expand Up @@ -217,6 +220,7 @@ function createComponentProps(slotProps: Record<string, any>) {
<FormItem
v-show="isShow"
:class="{
'form-valid-error': isInValid,
'flex-col': isVertical,
'flex-row items-center': !isVertical,
}"
Expand Down Expand Up @@ -248,10 +252,14 @@ function createComponentProps(slotProps: Record<string, any>) {
...slotProps,
...createComponentProps(slotProps),
disabled: shouldDisabled,
isInValid,
}"
>
<component
:is="fieldComponent"
:class="{
'border-destructive focus:border-destructive': isInValid,
}"
v-bind="createComponentProps(slotProps)"
:disabled="shouldDisabled"
>
Expand Down
4 changes: 4 additions & 0 deletions packages/styles/src/antd/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@
.ant-notification-notice {
@apply dark:border-border/60 dark:border;
}

.ant-app .form-valid-error .ant-select-selector {
border-color: hsl(var(--destructive));
}
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit bfae962

Please sign in to comment.