Skip to content

Commit 387e522

Browse files
authored
fix(ActionButtons): fixed align of action buttons collection, #6
1 parent fcf3b36 commit 387e522

File tree

3 files changed

+40
-6
lines changed

3 files changed

+40
-6
lines changed

dist/js/field.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/js/components/ActionButtonField.vue

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,46 @@
3333
// Computed
3434
const text = computed(() => props?.field?.text || null);
3535
const icon = computed(() => props?.field?.icon || null);
36-
const name = computed(() => props?.field?.name || null);
36+
const name = computed(() => props?.field?.name || props?.field?.title || null);
3737
const customStyles = computed(() => props?.field?.styles || []);
3838
const customClasses = computed(() => props?.field?.classes || []);
3939
const asToolbarButton = computed(() => props?.field?.asToolbarButton === true);
4040
4141
const actionButtonClasses = computed(() => [
4242
'flex-shrink-0', 'shadow', 'rounded', 'focus:outline-none', 'ring-primary-200', 'dark:ring-gray-600',
4343
'focus:ring', 'bg-primary-500', 'hover:bg-primary-400', 'active:bg-primary-600',
44-
'text-white', 'dark:text-gray-800', 'inline-flex', 'items-center', 'font-bold', 'px-2', 'h-9', 'text-sm', 'flex-shrink-0',
44+
'text-white', 'dark:text-gray-800', 'inline-flex', 'items-center', 'font-bold', 'px-2', 'mx-1', 'h-9', 'text-sm', 'flex-shrink-0',
4545
])
4646
const toolbarButtonClasses = computed(() => [
4747
'toolbar-button', 'hover:text-primary-500', 'px-2', 'v-popper--has-tooltip', 'w-10'
4848
])
4949
50-
const finalStyles = computed(() => ({...(customStyles.value || {})}))
51-
const finalClasses = computed(() => [...(asToolbarButton?.value === true ? toolbarButtonClasses.value : actionButtonClasses.value), ...(customClasses.value || [])])
50+
// Computed
51+
// Get action button styles
52+
const actionButtonStyles = computed(() => {
53+
return {
54+
margin: '0 2px',
55+
}
56+
})
57+
58+
59+
// Computed
60+
// Get final styles
61+
const finalStyles = computed(() => {
62+
return {
63+
...(asToolbarButton?.value === true ? null : actionButtonStyles?.value),
64+
...(customStyles.value || {}),
65+
}
66+
})
67+
68+
// Computed
69+
// Get final classes
70+
const finalClasses = computed(() => {
71+
return [
72+
...(asToolbarButton?.value === true ? toolbarButtonClasses.value : actionButtonClasses.value),
73+
...(customClasses.value || [])
74+
]
75+
})
5276
5377
const queryString = computed(() => ({
5478
action: selectedAction?.value?.uriKey,

resources/js/components/ActionButtonsField.vue

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div class="flex items-center justify-center">
2+
<div class="flex align-center" :class="alignClasses">
33
<template v-for="(action, k) in actions" :key="k">
44
<action-button v-bind="action"/>
55
</template>
@@ -32,4 +32,14 @@
3232
})))
3333
3434
35+
// Computed
36+
// Align classes
37+
const alignClasses = computed(() => {
38+
return {
39+
'justify-end': props?.field?.textAlign === 'right',
40+
'justify-start': props?.field?.textAlign === 'left',
41+
'justify-center': props?.field?.textAlign === 'center',
42+
}
43+
})
44+
3545
</script>

0 commit comments

Comments
 (0)