Skip to content

Commit 1cbae46

Browse files
committed
chore: reduse amound of styles for the edit and create views
1 parent 056f334 commit 1cbae46

File tree

4 files changed

+72
-96
lines changed

4 files changed

+72
-96
lines changed

adminforth/modules/styles.ts

Lines changed: 38 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -246,33 +246,32 @@ export const styles = () => ({
246246
lightToastCloseIconFocusRing: "#D1D5DB",
247247
lightToastText: "#6B7280",
248248

249-
lightCreateViewCancelButtonBackground: "#FFFFFF",
250-
lightCreateViewCancelButtonBackgroundHover: "#F3F4F6",
251-
lightCreateViewCancelButtonText: "#111827",
252-
lightCreateViewCancelButtonTextHover: "alias:lightPrimary",
253-
lightCreateViewCancelButtonFocusRing: "#F3F4F6",
254-
lightCreateViewCancelButtonBorder: "#D1D5DB",
255-
256-
lightCreateViewSaveButtonBackground: "#FFFFFF",
257-
lightCreateViewSaveButtonBackgroundHover: "#F3F4F6",
249+
250+
//Show views
251+
/* CreateView buttons */
252+
lightCreateViewButtonBackground: "#FFFFFF",
253+
lightCreateViewButtonBackgroundHover: "#F3F4F6",
254+
lightCreateViewButtonText: "#111827",
255+
lightCreateViewButtonTextHover: "alias:lightPrimary",
256+
lightCreateViewButtonFocusRing: "#F3F4F6",
257+
lightCreateViewButtonBorder: "#D1D5DB",
258+
258259
lightCreateViewSaveButtonText: "#DC2626",
259260
lightCreateViewSaveButtonTextHover: "#B91C1C",
260-
lightCreateViewSaveButtonFocusRing: "#F3F4F6",
261-
lightCreateViewSaveButtonBorder: "#D1D5DB",
262-
263-
lightEditViewCancelButtonBackground: "#FFFFFF",
264-
lightEditViewCancelButtonBackgroundHover: "#F3F4F6",
265-
lightEditViewCancelButtonText: "#111827",
266-
lightEditViewCancelButtonTextHover: "alias:lightPrimary",
267-
lightEditViewCancelButtonFocusRing: "#F3F4F6",
268-
lightEditViewCancelButtonBorder: "#D1D5DB",
269-
270-
lightEditViewSaveButtonBackground: "#FFFFFF",
271-
lightEditViewSaveButtonBackgroundHover: "#F3F4F6",
261+
262+
/* EditView buttons */
263+
lightEditViewButtonBackground: "#FFFFFF",
264+
lightEditViewButtonBackgroundHover: "#F3F4F6",
265+
lightEditViewButtonText: "#111827",
266+
lightEditViewButtonTextHover: "alias:lightPrimary",
267+
lightEditViewButtonFocusRing: "#F3F4F6",
268+
lightEditViewButtonBorder: "#D1D5DB",
269+
272270
lightEditViewSaveButtonText: "#DC2626",
273271
lightEditViewSaveButtonTextHover: "#B91C1C",
274-
lightEditViewSaveButtonFocusRing: "#F3F4F6",
275-
lightEditViewSaveButtonBorder: "#D1D5DB",
272+
273+
/* ListView buttons */
274+
276275

277276

278277

@@ -511,34 +510,27 @@ export const styles = () => ({
511510
darkToastCloseIconFocusRing: "#374151",
512511
darkToastText: "#9CA3AF",
513512

513+
///////////////////////////////////////////////////////////////////
514+
darkCreateViewButtonBackground: "#1F2937",
515+
darkCreateViewButtonBackgroundHover: "#374151",
516+
darkCreateViewButtonText: "#9CA3AF",
517+
darkCreateViewButtonTextHover: "#FFFFFF",
518+
darkCreateViewButtonFocusRing: "#374151",
519+
darkCreateViewButtonBorder: "#4B5563",
514520

515-
darkCreateViewCancelButtonBackground: "#1F2937",
516-
darkCreateViewCancelButtonBackgroundHover: "#374151",
517-
darkCreateViewCancelButtonText: "#9CA3AF",
518-
darkCreateViewCancelButtonTextHover: "#FFFFFF",
519-
darkCreateViewCancelButtonFocusRing: "#374151",
520-
darkCreateViewCancelButtonBorder: "#4B5563",
521-
522-
darkCreateViewSaveButtonBackground: "#1F2937",
523-
darkCreateViewSaveButtonBackgroundHover: "#374151",
524521
darkCreateViewSaveButtonText: "#EF4444",
525522
darkCreateViewSaveButtonTextHover: "#FFFFFF",
526-
darkCreateViewSaveButtonFocusRing: "#374151",
527-
darkCreateViewSaveButtonBorder: "#4B5563",
528-
529-
darkEditViewCancelButtonBackground: "#1F2937",
530-
darkEditViewCancelButtonBackgroundHover: "#374151",
531-
darkEditViewCancelButtonText: "#9CA3AF",
532-
darkEditViewCancelButtonTextHover: "#FFFFFF",
533-
darkEditViewCancelButtonFocusRing: "#374151",
534-
darkEditViewCancelButtonBorder: "#4B5563",
535-
536-
darkEditViewSaveButtonBackground: "#1F2937",
537-
darkEditViewSaveButtonBackgroundHover: "#374151",
523+
524+
darkEditViewButtonBackground: "#1F2937",
525+
darkEditViewButtonBackgroundHover: "#374151",
526+
darkEditViewButtonText: "#9CA3AF",
527+
darkEditViewButtonTextHover: "#FFFFFF",
528+
darkEditViewButtonFocusRing: "#374151",
529+
darkEditViewButtonBorder: "#4B5563",
530+
538531
darkEditViewSaveButtonText: "#EF4444",
539532
darkEditViewSaveButtonTextHover: "#FFFFFF",
540-
darkEditViewSaveButtonFocusRing: "#374151",
541-
darkEditViewSaveButtonBorder: "#4B5563",
533+
542534

543535
},
544536
boxShadow: {

adminforth/spa/src/views/CreateView.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
<BreadcrumbsWithButtons>
1414
<!-- save and cancle -->
1515
<button @click="$router.back()"
16-
class="af-cancel-button flex items-center py-1 px-3 me-2 text-sm font-medium rounded-default text-lightCreateViewCancelButtonText focus:outline-none bg-lightCreateViewCancelButtonBackground rounded border border-lightCreateViewCancelButtonBorder hover:bg-lightCreateViewCancelButtonBackgroundHover hover:text-lightCreateViewCancelButtonTextHover focus:z-10 focus:ring-4 focus:ring-lightCreateViewCancelButtonFocusRing dark:focus:ring-darkCreateViewCancelButtonFocusRing dark:bg-darkCreateViewCancelButtonBackground dark:text-darkCreateViewCancelButtonText dark:border-darkCreateViewCancelButtonBorder dark:hover:text-darkCreateViewCancelButtonTextHover dark:hover:bg-darkCreateViewCancelButtonBackgroundHover"
16+
class="af-cancel-button flex items-center py-1 px-3 me-2 text-sm font-medium rounded-default text-lightCreateViewButtonText focus:outline-none bg-lightCreateViewButtonBackground rounded border border-lightCreateViewButtonBorder hover:bg-lightCreateViewButtonBackgroundHover hover:text-lightCreateViewButtonTextHover focus:z-10 focus:ring-4 focus:ring-lightCreateViewButtonFocusRing dark:focus:ring-darkCreateViewButtonFocusRing dark:bg-darkCreateViewButtonBackground dark:text-darkCreateViewButtonText dark:border-darkCreateViewButtonBorder dark:hover:text-darkCreateViewButtonTextHover dark:hover:bg-darkCreateViewButtonBackgroundHover"
1717
>
1818
{{ $t('Cancel') }}
1919
</button>
2020

2121
<button
2222
@click="saveRecord"
23-
class="af-save-button flex items-center py-1 px-3 text-sm font-medium rounded-default text-lightCreateViewSaveButtonText focus:outline-none bg-lightCreateViewSaveButtonBackground rounded border border-lightCreateViewSaveButtonBorder hover:bg-lightCreateViewSaveButtonBackgroundHover hover:text-lightCreateViewSaveButtonTextHover focus:z-10 focus:ring-4 focus:ring-lightCreateViewSaveButtonFocusRing dark:focus:ring-darkCreateViewSaveButtonFocusRing dark:bg-darkCreateViewSaveButtonBackground dark:text-darkCreateViewSaveButtonText dark:border-darkCreateViewSaveButtonBorder dark:hover:text-darkCreateViewSaveButtonTextHover dark:hover:bg-darkCreateViewSaveButtonBackgroundHover disabled:opacity-50"
23+
class="af-save-button flex items-center py-1 px-3 text-sm font-medium rounded-default text-lightCreateViewSaveButtonText focus:outline-none bg-lightCreateViewButtonBackground rounded border border-lightCreateViewButtonBorder hover:bg-lightCreateViewButtonBackgroundHover hover:text-lightCreateViewSaveButtonTextHover focus:z-10 focus:ring-4 focus:ring-lightCreateViewButtonFocusRing dark:focus:ring-darkCreateViewButtonFocusRing dark:bg-darkCreateViewButtonBackground dark:text-darkCreateViewSaveButtonText dark:border-darkCreateViewButtonBorder dark:hover:text-darkCreateViewSaveButtonTextHover dark:hover:bg-darkCreateViewButtonBackgroundHover disabled:opacity-50"
2424
:disabled="saving || (validating && !isValid)"
2525
>
2626
<svg v-if="saving"

adminforth/spa/src/views/EditView.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212
<BreadcrumbsWithButtons>
1313
<!-- save and cancle -->
1414
<button @click="$router.back()"
15-
class="flex items-center py-1 px-3 me-2 text-sm font-medium text-lightEditViewCancelButtonText rounded-default focus:outline-none bg-lightEditViewCancelButtonBackground rounded border border-lightEditViewCancelButtonBorder hover:bg-lightEditViewCancelButtonBackground hover:text-lightEditViewCancelButtonTextHover focus:z-10 focus:ring-4 focus:ring-lightEditViewCancelButtonFocusRing dark:focus:ring-darkEditViewCancelButtonFocusRing dark:bg-darkEditViewCancelButtonBackground dark:text-darkEditViewCancelButtonText dark:border-darkEditViewCancelButtonBorder dark:hover:text-darkEditViewCancelButtonTextHover dark:hover:bg-darkEditViewCancelButtonBackgroundHover"
15+
class="flex items-center py-1 px-3 me-2 text-sm font-medium text-lightEditViewButtonText rounded-default focus:outline-none bg-lightEditViewButtonBackground rounded border border-lightEditViewButtonBorder hover:bg-lightEditViewButtonBackgroundHover hover:text-lightEditViewButtonTextHover focus:z-10 focus:ring-4 focus:ring-lightEditViewButtonFocusRing dark:focus:ring-darkEditViewButtonFocusRing dark:bg-darkEditViewButtonBackground dark:text-darkEditViewButtonText dark:border-darkEditViewButtonBorder dark:hover:text-darkEditViewButtonTextHover dark:hover:bg-darkEditViewButtonBackgroundHover"
1616
>
1717
{{ $t('Cancel') }}
1818
</button>
1919

2020
<button
2121
@click="saveRecord"
22-
class="flex items-center py-1 px-3 text-sm font-medium rounded-default text-lightEditViewSaveButtonText focus:outline-none bg-lightEditViewSaveButtonBackground rounded border border-lightEditViewSaveButtonBorder hover:bg-lightEditViewSaveButtonBackgroundHover hover:text-lightEditViewSaveButtonTextHover focus:z-10 focus:ring-4 focus:ring-lightEditViewSaveButtonFocusRing dark:focus:ring-darkEditViewSaveButtonFocusRing dark:bg-darkEditViewSaveButtonBackground dark:text-darkEditViewSaveButtonText dark:border-darkEditViewSaveButtonBorder dark:hover:text-darkEditViewSaveButtonTextHover dark:hover:bg-darkEditViewSaveButtonBackground disabled:opacity-50"
22+
class="flex items-center py-1 px-3 text-sm font-medium rounded-default text-lightEditViewSaveButtonText focus:outline-none bg-lightEditViewButtonBackground rounded border border-lightEditViewButtonBorder hover:bg-lightEditViewButtonBackgroundHover hover:text-lightEditViewSaveButtonTextHover focus:z-10 focus:ring-4 focus:ring-lightEditViewButtonFocusRing dark:focus:ring-darkEditViewButtonFocusRing dark:bg-darkEditViewButtonBackground dark:text-darkEditViewSaveButtonText dark:border-darkEditViewButtonBorder dark:hover:text-darkEditViewSaveButtonTextHover dark:hover:bg-darkEditViewButtonBackgroundHover disabled:opacity-50"
2323
:disabled="saving || (validating && !isValid)"
2424
>
2525
<IconFloppyDiskSolid class="w-4 h-4" />

dev-demo/index.ts

Lines changed: 30 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -369,34 +369,26 @@ export const admin = new AdminForth({
369369
ToastCloseIconBackgroundHover: "alias:lightToastCloseIcon opacity:0.6",
370370
ToastCloseIconFocusRing: "alias:lightToastCloseIcon",
371371
ToastText: "alias:lightPrimary inverse",
372+
/////////////////////////////////////////////////////////////////////////////////////////
373+
CreateViewButtonBackground: "alias:lightPrimary",
374+
CreateViewButtonBackgroundHover: "alias:lightCreateViewButtonBackground lighten",
375+
CreateViewButtonText: "alias:lightCreateViewButtonBackground inverse",
376+
CreateViewButtonTextHover: "alias:lightCreateViewButtonText opacity:0.8",
377+
CreateViewButtonFocusRing: "alias:lightCreateViewButtonBackground",
378+
CreateViewButtonBorder: "alias:lightCreateViewButtonBackground darken",
372379

373-
CreateViewCancelButtonBackground: "alias:lightPrimary",
374-
CreateViewCancelButtonBackgroundHover: "alias:lightCreateViewCancelButtonBackground lighten",
375-
CreateViewCancelButtonText: "alias:lightCreateViewCancelButtonBackground inverse",
376-
CreateViewCancelButtonTextHover: "alias:lightCreateViewCancelButtonText opacity:0.8",
377-
CreateViewCancelButtonFocusRing: "alias:lightCreateViewCancelButtonBackground",
378-
CreateViewCancelButtonBorder: "alias:lightCreateViewCancelButtonBackground darken",
379-
380-
CreateViewSaveButtonBackground: "alias:lightPrimary",
381-
CreateViewSaveButtonBackgroundHover: "alias:lightCreateViewCancelButtonBackground lighten",
382380
CreateViewSaveButtonText: "#DC2626",
383381
CreateViewSaveButtonTextHover: "#B91C1C",
384-
CreateViewSaveButtonFocusRing: "alias:lightCreateViewCancelButtonBackground",
385-
CreateViewSaveButtonBorder: "alias:lightCreateViewCancelButtonBackground darken",
386-
387-
EditViewCancelButtonBackground: "alias:lightPrimary",
388-
EditViewCancelButtonBackgroundHover: "alias:lightEditViewCancelButtonBackground lighten",
389-
EditViewCancelButtonText: "alias:lightEditViewCancelButtonBackground inverse",
390-
EditViewCancelButtonTextHover: "alias:lightEditViewCancelButtonText opacity:0.8",
391-
EditViewCancelButtonFocusRing: "alias:lightEditViewCancelButtonBackground",
392-
EditViewCancelButtonBorder: "alias:lightEditViewCancelButtonBackground darken",
393-
394-
EditViewSaveButtonBackground: "alias:lightPrimary",
395-
EditViewSaveButtonBackgroundHover: "alias:lightEditViewCancelButtonBackground lighten",
382+
383+
EditViewButtonBackground: "alias:lightPrimary",
384+
EditViewButtonBackgroundHover: "alias:lightEditViewButtonBackground lighten",
385+
EditViewButtonText: "alias:lightEditViewButtonBackground inverse",
386+
EditViewButtonTextHover: "alias:lightEditViewButtonText opacity:0.8",
387+
EditViewButtonFocusRing: "alias:lightEditViewButtonBackground",
388+
EditViewButtonBorder: "alias:lightEditViewButtonBackground darken",
389+
396390
EditViewSaveButtonText: "#DC2626",
397391
EditViewSaveButtonTextHover: "#B91C1C",
398-
EditViewSaveButtonFocusRing: "alias:lightEditViewCancelButtonBackground",
399-
EditViewSaveButtonBorder: "alias:lightEditViewCancelButtonBackground darken",
400392

401393
},
402394
dark: {
@@ -596,34 +588,26 @@ export const admin = new AdminForth({
596588
ToastCloseIconBackgroundHover: "alias:darkToastCloseIcon lighten",
597589
ToastCloseIconFocusRing: "alias:darkToastCloseIcon",
598590
ToastText: "alias:darkPrimary inverse",
591+
////////////////////////////////////////////////////////////////////////////////////////////////////////
592+
CreateViewButtonBackground: "alias:darkPrimary",
593+
CreateViewButtonBackgroundHover: "alias:darkCreateViewButtonBackground lighten",
594+
CreateViewButtonText: "alias:darkCreateViewButtonBackground inverse",
595+
CreateViewButtonTextHover: "alias:darkCreateViewButtonText opacity:0.8",
596+
CreateViewButtonFocusRing: "alias:darkCreateViewButtonBackground",
597+
CreateViewButtonBorder: "alias:darkCreateViewButtonBackground darken",
599598

600-
CreateViewCancelButtonBackground: "alias:darkPrimary",
601-
CreateViewCancelButtonBackgroundHover: "alias:darkCreateViewCancelButtonBackground lighten",
602-
CreateViewCancelButtonText: "alias:darkCreateViewCancelButtonBackground inverse",
603-
CreateViewCancelButtonTextHover: "alias:darkCreateViewCancelButtonText opacity:0.8",
604-
CreateViewCancelButtonFocusRing: "alias:darkCreateViewCancelButtonBackground",
605-
CreateViewCancelButtonBorder: "alias:darkCreateViewCancelButtonBackground darken",
606-
607-
CreateViewSaveButtonBackground: "alias:darkPrimary",
608-
CreateViewSaveButtonBackgroundHover: "alias:darkCreateViewCancelButtonBackground lighten",
609599
CreateViewSaveButtonText: "#F87171",
610600
CreateViewSaveButtonTextHover: "#FFFFFF",
611-
CreateViewSaveButtonFocusRing: "alias:darkCreateViewCancelButtonBackground",
612-
CreateViewSaveButtonBorder: "alias:darkCreateViewCancelButtonBackground darken",
613-
614-
EditViewCancelButtonBackground: "alias:darkPrimary",
615-
EditViewCancelButtonBackgroundHover: "alias:darkEditViewCancelButtonBackground lighten",
616-
EditViewCancelButtonText: "alias:darkEditViewCancelButtonBackground inverse",
617-
EditViewCancelButtonTextHover: "alias:darkEditViewCancelButtonText opacity:0.8",
618-
EditViewCancelButtonFocusRing: "alias:darkEditViewCancelButtonBackground",
619-
EditViewCancelButtonBorder: "alias:darkEditViewCancelButtonBackground darken",
620-
621-
EditViewSaveButtonBackground: "alias:darkPrimary",
622-
EditViewSaveButtonBackgroundHover: "alias:darkEditViewCancelButtonBackground lighten",
601+
602+
EditViewButtonBackground: "alias:darkPrimary",
603+
EditViewButtonBackgroundHover: "alias:darkEditViewButtonBackground lighten",
604+
EditViewButtonText: "alias:darkEditViewButtonBackground inverse",
605+
EditViewButtonTextHover: "alias:darkEditViewButtonText opacity:0.8",
606+
EditViewButtonFocusRing: "alias:darkEditViewButtonBackground",
607+
EditViewButtonBorder: "alias:darkEditViewButtonBackground darken",
608+
623609
EditViewSaveButtonText: "#F87171",
624610
EditViewSaveButtonTextHover: "#FFFFFF",
625-
EditViewSaveButtonFocusRing: "alias:darkEditViewCancelButtonBackground",
626-
EditViewSaveButtonBorder: "alias:darkEditViewCancelButtonBackground darken",
627611

628612
}
629613
}

0 commit comments

Comments
 (0)