Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: primaryColor calculation #5337

Merged
merged 1 commit into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion apps/web-naive/src/views/demos/form/basic.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const [Form, formApi] = useVbenForm({
fieldName: 'api',
// 界面显示的label
label: 'ApiSelect',
rules: 'required',
},
{
component: 'ApiTreeSelect',
Expand All @@ -56,16 +57,19 @@ const [Form, formApi] = useVbenForm({
fieldName: 'apiTree',
// 界面显示的label
label: 'ApiTreeSelect',
rules: 'required',
},
{
component: 'Input',
fieldName: 'string',
label: 'String',
rules: 'required',
},
{
component: 'InputNumber',
fieldName: 'number',
label: 'Number',
rules: 'required',
},
{
component: 'RadioGroup',
Expand All @@ -80,6 +84,7 @@ const [Form, formApi] = useVbenForm({
{ value: 'E', label: 'E' },
],
},
rules: 'selectRequired',
},
{
component: 'RadioGroup',
Expand All @@ -94,9 +99,9 @@ const [Form, formApi] = useVbenForm({
{ value: 'C', label: '选项C' },
{ value: 'D', label: '选项D' },
{ value: 'E', label: '选项E' },
{ value: 'F', label: '选项F' },
],
},
rules: 'selectRequired',
},
{
component: 'CheckboxGroup',
Expand All @@ -109,11 +114,22 @@ const [Form, formApi] = useVbenForm({
{ value: 'C', label: '选项C' },
],
},
rules: 'selectRequired',
},
{
component: 'DatePicker',
fieldName: 'date',
label: 'Date',
rules: 'required',
},
{
component: 'Input',
fieldName: 'textArea',
label: 'TextArea',
componentProps: {
type: 'textarea',
},
rules: 'required',
},
],
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import type { BuiltinThemePreset } from '@vben/preferences';
import type { BuiltinThemeType } from '@vben/types';

import { computed, ref } from 'vue';
import { computed, ref, watch } from 'vue';

import { UserRoundPen } from '@vben/icons';
import { $t } from '@vben/locales';
Expand Down Expand Up @@ -80,11 +80,6 @@ function typeView(name: BuiltinThemeType) {

function handleSelect(theme: BuiltinThemePreset) {
modelValue.value = theme.type;
const primaryColor = props.isDark
? theme.darkPrimaryColor || theme.primaryColor
: theme.primaryColor;

themeColorPrimary.value = primaryColor || theme.color;
}

function handleInputChange(e: Event) {
Expand All @@ -95,6 +90,22 @@ function handleInputChange(e: Event) {
function selectColor() {
colorInput.value?.[0]?.click?.();
}

watch(
() => [modelValue.value, props.isDark] as [BuiltinThemeType, boolean],
([themeType, isDark]) => {
const theme = builtinThemePresets.value.find(
(item) => item.type === themeType,
);
if (theme) {
const primaryColor = isDark
? theme.darkPrimaryColor || theme.primaryColor
: theme.primaryColor;

themeColorPrimary.value = primaryColor || theme.color;
}
},
);
</script>

<template>
Expand Down
Loading