mirror of https://github.com/halo-dev/halo-admin
perf: improve the layout and style of forms (#673)
Change form style from horizontal to vertical.pull/675/head
parent
aff2447201
commit
d12317b68e
|
@ -1,21 +1,21 @@
|
||||||
const textClassification = {
|
const textClassification = {
|
||||||
label: "block font-bold text-sm formkit-invalid:text-red-500 w-56",
|
label: "block text-sm font-medium text-gray-700 formkit-invalid:text-red-500",
|
||||||
wrapper: "flex flex-col sm:flex-row items-start sm:items-center",
|
wrapper: "flex flex-col gap-4",
|
||||||
inner:
|
inner:
|
||||||
"inline-flex items-center w-full relative box-border border border-gray-300 formkit-invalid:border-red-500 h-9 rounded-base overflow-hidden focus-within:border-primary mt-2 sm:mt-0",
|
"inline-flex items-center w-full relative box-border border border-gray-300 formkit-invalid:border-red-500 h-9 rounded-base overflow-hidden focus-within:border-primary focus-within:shadow-sm w-full sm:max-w-lg transition-all",
|
||||||
input:
|
input:
|
||||||
"outline-0 bg-white antialiased resize-none w-full text-black block transition-all appearance-none h-full px-3 text-sm",
|
"outline-0 bg-white antialiased resize-none w-full text-black block transition-all appearance-none h-full px-3 text-sm",
|
||||||
};
|
};
|
||||||
|
|
||||||
const boxClassification = {
|
const boxClassification = {
|
||||||
|
label: textClassification.label,
|
||||||
|
legend: textClassification.label,
|
||||||
fieldset:
|
fieldset:
|
||||||
"border border-gray-300 rounded-base px-2 py-2 focus-within:border-primary",
|
"border border-gray-300 rounded-base px-2 py-2 focus-within:border-primary max-w-lg",
|
||||||
legend: "font-bold text-sm",
|
|
||||||
wrapper: "flex items-center mb-1 cursor-pointer",
|
wrapper: "flex items-center mb-1 cursor-pointer",
|
||||||
help: "mb-2",
|
help: "mb-2 mt-0",
|
||||||
input:
|
input:
|
||||||
"form-check-input appearance-none h-4 w-4 mr-2 border border-gray-500 rounded-sm bg-white checked:bg-primary focus:outline-none focus:ring-0 transition duration-200",
|
"form-check-input h-4 w-4 mr-2 border border-gray-500 rounded-sm bg-white checked:bg-primary focus:outline-none focus:ring-0 transition duration-200",
|
||||||
label: "text-sm text-gray-700",
|
|
||||||
inner: "flex items-center",
|
inner: "flex items-center",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -27,23 +27,21 @@ const buttonClassification = {
|
||||||
|
|
||||||
const theme: Record<string, Record<string, string>> = {
|
const theme: Record<string, Record<string, string>> = {
|
||||||
global: {
|
global: {
|
||||||
outer: "formkit-disabled:opacity-50",
|
form: "divide-y divide-gray-100",
|
||||||
help: "text-xs mt-1.5 text-gray-500",
|
outer: "formkit-disabled:opacity-50 py-4 first:pt-0 last:pb-0",
|
||||||
|
help: "text-xs mt-2 text-gray-500",
|
||||||
messages: "list-none p-0 mt-1.5 mb-0",
|
messages: "list-none p-0 mt-1.5 mb-0",
|
||||||
message: "text-red-500 mb-1 text-xs",
|
message: "text-red-500 mt-2 text-xs",
|
||||||
form: "flex flex-col space-y-4",
|
|
||||||
},
|
},
|
||||||
button: buttonClassification,
|
button: buttonClassification,
|
||||||
color: {
|
color: {
|
||||||
label: "block mb-1 font-bold text-sm",
|
...textClassification,
|
||||||
|
inner: "",
|
||||||
input:
|
input:
|
||||||
"w-16 h-8 appearance-none cursor-pointer border border-gray-300 rounded-md mb-2 p-1",
|
"w-16 h-8 appearance-none cursor-pointer border border-gray-300 rounded-md mb-2 p-1",
|
||||||
},
|
},
|
||||||
file: {
|
file: {
|
||||||
label: "block mb-1 font-bold text-sm",
|
...textClassification,
|
||||||
inner: "cursor-pointer",
|
|
||||||
input:
|
|
||||||
"text-gray-600 text-sm mb-1 file:mr-4 file:py-2 file:px-4 file:rounded-full file:border-0 file:text-sm file:bg-blue-500 file:text-white hover:file:bg-blue-600",
|
|
||||||
noFiles: "block text-gray-800 text-sm mb-1",
|
noFiles: "block text-gray-800 text-sm mb-1",
|
||||||
fileItem: "block flex text-gray-800 text-sm mb-1",
|
fileItem: "block flex text-gray-800 text-sm mb-1",
|
||||||
fileRemove: "ml-auto text-blue-500 text-sm",
|
fileRemove: "ml-auto text-blue-500 text-sm",
|
||||||
|
@ -54,7 +52,8 @@ const theme: Record<string, Record<string, string>> = {
|
||||||
input: boxClassification.input.replace("rounded-sm", "rounded-full"),
|
input: boxClassification.input.replace("rounded-sm", "rounded-full"),
|
||||||
},
|
},
|
||||||
range: {
|
range: {
|
||||||
inner: "",
|
...textClassification,
|
||||||
|
inner: "w-full sm:max-w-lg",
|
||||||
input:
|
input:
|
||||||
"form-range appearance-none w-full h-2 p-0 bg-gray-200 rounded-full focus:outline-none focus:ring-0 focus:shadow-none",
|
"form-range appearance-none w-full h-2 p-0 bg-gray-200 rounded-full focus:outline-none focus:ring-0 focus:shadow-none",
|
||||||
},
|
},
|
||||||
|
@ -74,10 +73,9 @@ const theme: Record<string, Record<string, string>> = {
|
||||||
"datetime-local": textClassification,
|
"datetime-local": textClassification,
|
||||||
textarea: {
|
textarea: {
|
||||||
...textClassification,
|
...textClassification,
|
||||||
inner:
|
inner: textClassification.inner.replace("h-9", "h-full"),
|
||||||
"inline-flex items-center w-full relative box-border border border-gray-300 formkit-invalid:border-red-500 h-32 rounded-base overflow-hidden focus-within:border-primary mt-2 sm:mt-0",
|
|
||||||
input:
|
input:
|
||||||
"outline-0 bg-white antialiased w-full text-black block transition-all appearance-none h-full px-3 py-2 text-sm",
|
textClassification.input.replace("resize-none", "resize-y") + " py-2",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -137,7 +137,7 @@ watchEffect(() => {
|
||||||
<VModal
|
<VModal
|
||||||
title="回复"
|
title="回复"
|
||||||
:visible="visible"
|
:visible="visible"
|
||||||
:width="600"
|
:width="500"
|
||||||
@update:visible="onVisibleChange"
|
@update:visible="onVisibleChange"
|
||||||
>
|
>
|
||||||
<FormKit
|
<FormKit
|
||||||
|
@ -153,6 +153,7 @@ watchEffect(() => {
|
||||||
type="textarea"
|
type="textarea"
|
||||||
validation="required"
|
validation="required"
|
||||||
validation-label="内容"
|
validation-label="内容"
|
||||||
|
:rows="6"
|
||||||
></FormKit>
|
></FormKit>
|
||||||
</FormKit>
|
</FormKit>
|
||||||
<div class="mt-2 flex justify-end">
|
<div class="mt-2 flex justify-end">
|
||||||
|
|
|
@ -214,6 +214,7 @@ watchEffect(() => {
|
||||||
name="raw"
|
name="raw"
|
||||||
label="自定义摘要"
|
label="自定义摘要"
|
||||||
type="textarea"
|
type="textarea"
|
||||||
|
:rows="5"
|
||||||
></FormKit>
|
></FormKit>
|
||||||
</FormKit>
|
</FormKit>
|
||||||
</VTabItem>
|
</VTabItem>
|
||||||
|
|
|
@ -228,6 +228,7 @@ watchEffect(() => {
|
||||||
label="自定义摘要"
|
label="自定义摘要"
|
||||||
name="raw"
|
name="raw"
|
||||||
type="textarea"
|
type="textarea"
|
||||||
|
:rows="5"
|
||||||
></FormKit>
|
></FormKit>
|
||||||
</FormKit>
|
</FormKit>
|
||||||
</VTabItem>
|
</VTabItem>
|
||||||
|
|
|
@ -53,8 +53,8 @@ watch(
|
||||||
);
|
);
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<div class="bg-white p-4 sm:px-6">
|
<div class="bg-white p-4">
|
||||||
<div class="w-1/3">
|
<div>
|
||||||
<FormKit
|
<FormKit
|
||||||
v-if="group && formSchema && configMapFormData"
|
v-if="group && formSchema && configMapFormData"
|
||||||
:id="group"
|
:id="group"
|
||||||
|
|
|
@ -62,8 +62,8 @@ const handleFetchPlugin = async () => {
|
||||||
await handleFetchPlugin();
|
await handleFetchPlugin();
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<div class="bg-white p-4 sm:px-6">
|
<div class="bg-white p-4">
|
||||||
<div class="w-1/3">
|
<div>
|
||||||
<FormKit
|
<FormKit
|
||||||
v-if="group && formSchema && configMapFormData"
|
v-if="group && formSchema && configMapFormData"
|
||||||
:id="group"
|
:id="group"
|
||||||
|
|
|
@ -33,8 +33,8 @@ await handleFetchSettings();
|
||||||
await handleFetchConfigMap();
|
await handleFetchConfigMap();
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<div class="bg-white p-4 sm:px-6">
|
<div class="bg-white p-4">
|
||||||
<div class="w-1/3">
|
<div>
|
||||||
<FormKit
|
<FormKit
|
||||||
v-if="group && formSchema && configMapFormData"
|
v-if="group && formSchema && configMapFormData"
|
||||||
:id="group"
|
:id="group"
|
||||||
|
|
|
@ -87,7 +87,7 @@ const handleTabChange = (id: string) => {
|
||||||
/>
|
/>
|
||||||
<header class="bg-white">
|
<header class="bg-white">
|
||||||
<div class="h-48 bg-gradient-to-r from-gray-800 to-red-500"></div>
|
<div class="h-48 bg-gradient-to-r from-gray-800 to-red-500"></div>
|
||||||
<div class="px-4 sm:px-6 lg:px-8">
|
<div class="px-4">
|
||||||
<div class="-mt-12 flex items-end space-x-5 sm:-mt-16">
|
<div class="-mt-12 flex items-end space-x-5 sm:-mt-16">
|
||||||
<div v-if="user?.spec?.avatar" class="inline-flex items-center">
|
<div v-if="user?.spec?.avatar" class="inline-flex items-center">
|
||||||
<div class="h-24 w-24 sm:h-32 sm:w-32">
|
<div class="h-24 w-24 sm:h-32 sm:w-32">
|
||||||
|
@ -149,7 +149,7 @@ const handleTabChange = (id: string) => {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
<section class="bg-white p-4 sm:px-6 lg:px-8">
|
<section class="bg-white p-4">
|
||||||
<VTabbar
|
<VTabbar
|
||||||
v-model:active-id="activeTab"
|
v-model:active-id="activeTab"
|
||||||
:items="tabs"
|
:items="tabs"
|
||||||
|
|
Loading…
Reference in New Issue