fix(front): use functions to generate classnames dynamically

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2024-02-09 15:00:45 +01:00
parent baa11c18b0
commit 98230a56bb
No known key found for this signature in database
GPG key ID: A061B9DDE0CA0773
2 changed files with 42 additions and 16 deletions

View file

@ -4,25 +4,36 @@ export const orugaConfig = {
statusIcon: true, statusIcon: true,
button: { button: {
rootClass: "btn", rootClass: "btn",
variantClass: "btn-", variantClass: (variant: string) => {
return `btn-${variant}`;
},
roundedClass: "btn-rounded", roundedClass: "btn-rounded",
outlinedClass: "btn-outlined-", outlinedClass: (variant: string) => {
return `btn-outlined-${variant}`;
},
disabledClass: "btn-disabled", disabledClass: "btn-disabled",
sizeClass: "btn-size-", sizeClass: (size: string) => {
return `"btn-size-${size}`;
},
}, },
field: { field: {
rootClass: "field", rootClass: "field",
labelClass: "field-label", labelClass: "field-label",
messageClass: "text-sm italic", messageClass: "text-sm italic",
variantClass: "field-", variantMessageClass: (variant: string) => {
variantMessageClass: "field-message-", return `field-message-${variant}`;
},
}, },
input: { input: {
inputClass: "input", inputClass: "input",
roundedClass: "rounded", roundedClass: "rounded",
variantClass: "input-", variantClass: (variant: string) => {
return `input-${variant}`;
},
iconRightClass: "input-icon-right", iconRightClass: "input-icon-right",
sizeClass: "input-size-", sizeClass: (size: string) => {
return `input-size-${size}`;
},
}, },
taginput: { taginput: {
itemClass: "taginput-item", itemClass: "taginput-item",
@ -44,7 +55,9 @@ export const orugaConfig = {
itemGroupTitleClass: "autocomplete-item-group-title", itemGroupTitleClass: "autocomplete-item-group-title",
}, },
icon: { icon: {
variantClass: "icon-", variantClass: (variant: string) => {
return `icon-${variant}`;
},
}, },
checkbox: { checkbox: {
rootClass: "checkbox", rootClass: "checkbox",
@ -88,7 +101,9 @@ export const orugaConfig = {
}, },
notification: { notification: {
rootClass: "notification", rootClass: "notification",
variantClass: "notification-", variantClass: (variant: string) => {
return `notification-${variant}`;
},
}, },
table: { table: {
tableClass: "table", tableClass: "table",
@ -111,16 +126,24 @@ export const orugaConfig = {
tabs: { tabs: {
rootClass: "tabs", rootClass: "tabs",
navTabsClass: "tabs-nav", navTabsClass: "tabs-nav",
navTypeClass: "tabs-nav-", navTypeClass: (type: string) => {
navSizeClass: "tabs-nav-", return `tabs-nav-${type}`;
},
navSizeClass: (size: string) => {
return `tabs-nav-${size}`;
},
itemWrapperClass: "tabs-nav-item-wrapper", itemWrapperClass: "tabs-nav-item-wrapper",
itemHeaderTypeClass: "tabs-nav-item-", itemHeaderTypeClass: (type: string) => {
itemHeaderActiveClass: "tabs-nav-item-active-", return `tabs-nav-item-${type}`;
},
itemHeaderActiveClass: "tabs-nav-item-active",
}, },
tooltip: { tooltip: {
rootClass: "tooltip", rootClass: "tooltip",
contentClass: "tooltip-content", contentClass: "tooltip-content",
arrowClass: "tooltip-arrow", arrowClass: "tooltip-arrow",
variantClass: "tooltip-content-", variantClass: (variant: string) => {
return `tooltip-content-${variant}`;
},
}, },
}; };

View file

@ -24,13 +24,14 @@
required required
v-model="identity.name" v-model="identity.name"
id="identityName" id="identityName"
@input="(event: any) => updateUsername(event.target.value)" expanded
@update:modelValue="(value: string) => updateUsername(value)"
/> />
</o-field> </o-field>
<o-field <o-field
:label="t('Username')" :label="t('Username')"
:variant="errors.preferred_username ? 'danger' : null" :variant="errors.preferred_username ? 'danger' : 'primary'"
:message="errors.preferred_username" :message="errors.preferred_username"
labelFor="identityPreferredUsername" labelFor="identityPreferredUsername"
> >
@ -47,6 +48,7 @@
expanded expanded
id="identityPreferredUsername" id="identityPreferredUsername"
v-model="identity.preferredUsername" v-model="identity.preferredUsername"
:variant="errors.preferred_username ? 'danger' : ''"
:validation-message=" :validation-message="
identity.preferredUsername identity.preferredUsername
? t( ? t(
@ -75,6 +77,7 @@
rows="2" rows="2"
id="identitySummary" id="identitySummary"
v-model="identity.summary" v-model="identity.summary"
expanded
/> />
</o-field> </o-field>