Skip to content

Commit 93760f9

Browse files
committed
chore: add styles for the list view buttons. Remove prop state from bulkActions. Add prop for bulk actions: buttonCustomCssClass
1 parent 1cbae46 commit 93760f9

File tree

6 files changed

+41
-18
lines changed

6 files changed

+41
-18
lines changed

adminforth/modules/configValidator.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,6 @@ export default class ConfigValidator implements IConfigValidator {
227227

228228
bulkActions.push({
229229
label: `Delete checked`,
230-
state: 'danger',
231230
icon: 'flowbite:trash-bin-outline',
232231
confirm: 'Are you sure you want to delete selected items?',
233232
allowed: async ({ resource, adminUser, allowedActions }) => { return allowedActions.delete },

adminforth/modules/styles.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,12 @@ export const styles = () => ({
271271
lightEditViewSaveButtonTextHover: "#B91C1C",
272272

273273
/* ListView buttons */
274-
274+
lightListViewButtonBackground: "#FFFFFF",
275+
lightListViewButtonBackgroundHover: "#F3F4F6",
276+
lightListViewButtonText: "#111827",
277+
lightListViewButtonTextHover: "alias:lightPrimary",
278+
lightListViewButtonFocusRing: "#F3F4F6",
279+
lightListViewButtonBorder: "#D1D5DB",
275280

276281

277282

@@ -511,6 +516,8 @@ export const styles = () => ({
511516
darkToastText: "#9CA3AF",
512517

513518
///////////////////////////////////////////////////////////////////
519+
//Show views
520+
/* CreateView buttons */
514521
darkCreateViewButtonBackground: "#1F2937",
515522
darkCreateViewButtonBackgroundHover: "#374151",
516523
darkCreateViewButtonText: "#9CA3AF",
@@ -521,6 +528,7 @@ export const styles = () => ({
521528
darkCreateViewSaveButtonText: "#EF4444",
522529
darkCreateViewSaveButtonTextHover: "#FFFFFF",
523530

531+
/* EditView buttons */
524532
darkEditViewButtonBackground: "#1F2937",
525533
darkEditViewButtonBackgroundHover: "#374151",
526534
darkEditViewButtonText: "#9CA3AF",
@@ -531,6 +539,14 @@ export const styles = () => ({
531539
darkEditViewSaveButtonText: "#EF4444",
532540
darkEditViewSaveButtonTextHover: "#FFFFFF",
533541

542+
/* ListView buttons */
543+
darkListViewButtonBackground: "#1F2937",
544+
darkListViewButtonBackgroundHover: "#374151",
545+
darkListViewButtonText: "#9CA3AF",
546+
darkListViewButtonTextHover: "#FFFFFF",
547+
darkListViewButtonFocusRing: "#374151",
548+
darkListViewButtonBorder: "#4B5563",
549+
534550

535551
},
536552
boxShadow: {

adminforth/spa/src/views/ListView.vue

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
@click="()=>{checkboxes = []}"
2222
v-if="checkboxes.length"
2323
data-tooltip-target="tooltip-remove-all"
24-
class="flex gap-1 items-center py-1 px-3 me-2 text-sm font-medium text-gray-900 focus:outline-none bg-white rounded border border-gray-300 hover:bg-gray-100 hover:text-lightPrimary focus:z-10 focus:ring-4 focus:ring-gray-100 dark:focus:ring-gray-700 dark:bg-darkListTable dark:text-gray-400 dark:border-gray-600 dark:hover:text-white dark:hover:bg-gray-700 rounded-default"
24+
class="flex gap-1 items-center py-1 px-3 me-2 text-sm font-medium text-lightListViewButtonText focus:outline-none bg-lightListViewButtonBackground rounded border border-lightListViewButtonBorder hover:bg-lightListViewButtonBackgroundHover hover:text-lightListViewButtonTextHover focus:z-10 focus:ring-4 focus:ring-lightListViewButtonFocusRing dark:focus:ring-darkListViewButtonFocusRing dark:bg-darkListViewButtonBackground dark:text-darkListViewButtonText dark:border-darkListViewButtonBorder dark:hover:text-darkListViewButtonTextHover dark:hover:bg-darkListViewButtonBackgroundHover rounded-default"
2525
>
2626
<IconBanOutline class="w-5 h-5 "/>
2727

@@ -37,17 +37,13 @@
3737
v-for="(action,i) in coreStore.resource?.options?.bulkActions"
3838
:key="action.id"
3939
@click="startBulkAction(action.id)"
40-
class="flex gap-1 items-center py-1 px-3 text-sm font-medium text-gray-900 focus:outline-none bg-white rounded-default border border-gray-300 hover:bg-gray-100 hover:text-lightPrimary focus:z-10 focus:ring-4 focus:ring-gray-100 dark:focus:ring-gray-700 dark:bg-gray-800 dark:text-gray-400 dark:border-gray-600 dark:hover:text-white dark:hover:bg-gray-700"
41-
:class="{
42-
'bg-red-100 text-red-800 border-red-400 dark:bg-red-700 dark:text-red-400 dark:border-red-400':action.state==='danger',
43-
'bg-green-100 text-green-800 border-green-400 dark:bg-green-700 dark:text-green-400 dark:border-green-400':action.state==='success',
44-
'bg-lightPrimaryOpacity text-lightPrimary border-blue-400 dark:bg-blue-700 dark:text-blue-400 dark:border-blue-400':action.state==='active',
45-
}"
40+
class="flex gap-1 items-center py-1 px-3 text-sm font-medium text-lightListViewButtonText focus:outline-none bg-lightListViewButtonBackground rounded-default border border-lightListViewButtonBorder hover:bg-lightListViewButtonBackgroundHover hover:text-lightListViewButtonTextHover focus:z-10 focus:ring-4 focus:ring-lightListViewButtonFocusRing dark:focus:ring-darkListViewButtonFocusRing dark:bg-darkListViewButtonBackground dark:text-darkListViewButtonText dark:border-darkListViewButtonBorder dark:hover:text-darkListViewButtonTextHover dark:hover:bg-darkListViewButtonBackgroundHover"
41+
:class="action.buttonCustomCssClass || ''"
4642
>
4743
<component
4844
v-if="action.icon && !bulkActionLoadingStates[action.id]"
4945
:is="getIcon(action.icon)"
50-
class="w-5 h-5 text-gray-500 transition duration-75 dark:text-gray-400 group-hover:text-gray-900 dark:group-hover:text-white"></component>
46+
class="w-5 h-5 transition duration-75 group-hover:text-gray-900 dark:group-hover:text-white"></component>
5147
<div v-if="bulkActionLoadingStates[action.id]">
5248
<svg
5349
aria-hidden="true"
@@ -74,14 +70,14 @@
7470

7571
<RouterLink v-if="coreStore.resource?.options?.allowedActions?.create"
7672
:to="{ name: 'resource-create', params: { resourceId: $route.params.resourceId } }"
77-
class="af-create-button flex items-center py-1 px-3 text-sm font-medium text-gray-900 focus:outline-none bg-white rounded border border-gray-300 hover:bg-gray-100 hover:text-lightPrimary focus:z-10 focus:ring-4 focus:ring-gray-100 dark:focus:ring-gray-700 dark:bg-gray-800 dark:text-gray-400 dark:border-gray-600 dark:hover:text-white dark:hover:bg-gray-700 rounded-default"
73+
class="af-create-button flex items-center py-1 px-3 text-sm font-medium text-lightListViewButtonText focus:outline-none bg-lightListViewButtonBackground rounded border border-lightListViewButtonBorder hover:bg-lightListViewButtonBackgroundHover hover:text-lightListViewButtonTextHover focus:z-10 focus:ring-4 focus:ring-lightListViewButtonFocusRing dark:focus:ring-darkListViewButtonFocusRing dark:bg-darkListViewButtonBackground dark:text-darkListViewButtonText dark:border-darkListViewButtonBorder dark:hover:text-darkListViewButtonTextHover dark:hover:bg-darkListViewButtonBackgroundHover rounded-default"
7874
>
7975
<IconPlusOutline class="w-4 h-4 me-2"/>
8076
{{ $t('Create') }}
8177
</RouterLink>
8278

8379
<button
84-
class="af-filter-button flex gap-1 items-center py-1 px-3 me-2 text-sm font-medium text-gray-900 focus:outline-none bg-white rounded border border-gray-300 hover:bg-gray-100 hover:text-lightPrimary focus:z-10 focus:ring-4 focus:ring-gray-100 dark:focus:ring-gray-700 dark:bg-gray-800 dark:text-gray-400 dark:border-gray-600 dark:hover:text-white dark:hover:bg-gray-700 rounded-default"
80+
class="af-filter-button flex gap-1 items-center py-1 px-3 me-2 text-sm font-medium text-lightListViewButtonText focus:outline-none bg-lightListViewButtonBackground rounded border border-lightListViewButtonBorder hover:bg-lightListViewButtonBackgroundHover hover:text-lightListViewButtonTextHover focus:z-10 focus:ring-4 focus:ring-lightListViewButtonFocusRing dark:focus:ring-darkListViewButtonFocusRing dark:bg-darkListViewButtonBackground dark:text-darkListViewButtonText dark:border-darkListViewButtonBorder dark:hover:text-darkListViewButtonTextHover dark:hover:bg-darkListViewButtonBackgroundHover rounded-default"
8581
@click="()=>{filtersShow = !filtersShow}"
8682
v-if="coreStore.resource?.options?.allowedActions?.filter"
8783
>

adminforth/types/Common.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,9 @@ export interface AdminForthBulkActionCommon {
9595
label: string,
9696

9797
/**
98-
* Bulk Action button state 'danger'|success|'active',
99-
* * 'danger' - red button
100-
* * 'success' - green button
101-
* * 'active' - blue button
98+
* Add custom class
10299
**/
103-
state?: 'danger' | 'success' | 'active';
100+
buttonCustomCssClass?: string;
104101

105102
/**
106103
* Optional small badge for button which will be displayed in the list view

dev-demo/index.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,14 @@ export const admin = new AdminForth({
390390
EditViewSaveButtonText: "#DC2626",
391391
EditViewSaveButtonTextHover: "#B91C1C",
392392

393+
ListViewButtonBackground: "alias:lightPrimary",
394+
ListViewButtonBackgroundHover: "alias:lightListViewButtonBackground lighten",
395+
ListViewButtonText: "alias:lightListViewButtonBackground inverse",
396+
ListViewButtonTextHover: "alias:lightListViewButtonText opacity:0.8",
397+
ListViewButtonFocusRing: "alias:lightlistViewButtonBackground",
398+
ListViewButtonBorder: "alias:lightListViewButtonBackground darken",
399+
400+
393401
},
394402
dark: {
395403
primary: '#bd1a76',
@@ -609,6 +617,14 @@ export const admin = new AdminForth({
609617
EditViewSaveButtonText: "#F87171",
610618
EditViewSaveButtonTextHover: "#FFFFFF",
611619

620+
621+
ListViewButtonBackground: "alias:darkPrimary",
622+
ListViewButtonBackgroundHover: "alias:darkListViewButtonBackground lighten",
623+
ListViewButtonText: "alias:darkListViewButtonBackground inverse",
624+
ListViewButtonTextHover: "alias:darkListViewButtonText opacity:0.8",
625+
ListViewButtonFocusRing: "alias:darklistViewButtonBackground",
626+
ListViewButtonBorder: "alias:darkListViewButtonBackground darken",
627+
612628
}
613629
}
614630
},

dev-demo/resources/apartments.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,6 @@ export default {
498498
{
499499
label: "Mark as listed",
500500
// icon: 'typcn:archive',
501-
state: "active",
502501
confirm:
503502
"Are you sure you want to mark all selected apartments as listed?",
504503
action: async function ({ selectedIds, adminUser }: any) {

0 commit comments

Comments
 (0)