Skip to content

Commit c53c9f5

Browse files
authored
[6.x] Asset fixes for the Grid fieldtype (#13058)
1 parent 9a60d89 commit c53c9f5

File tree

3 files changed

+37
-9
lines changed

3 files changed

+37
-9
lines changed

resources/css/components/fieldtypes/grid.css

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
/* ==========================================================================
2-
Grid Fieldtype
3-
========================================================================== */
1+
/* GRID FIELDTYPE
2+
=================================================== */
43
@layer ui {
54
.grid-table {
65
@apply bg-white dark:bg-gray-900 relative w-full rounded-lg border shadow-ui-sm outline-hidden dark:border-gray-700 dark:text-dark-150 text-start;
@@ -100,4 +99,32 @@
10099
.grid-item-header {
101100
@apply flex cursor-move items-center justify-between border-b bg-gray-200 px-4 py-2 text-sm outline-hidden;
102101
}
102+
}
103+
104+
/* GRID FIELDTYPE / Assets fieldtype in a grid fieldtype
105+
=================================================== */
106+
/* Table UI mode */
107+
.grid-table .grid-cell.assets-fieldtype:not(:has([data-asset-picker])) > *,
108+
/* Stacked UI mode */
109+
.grid-stacked [data-asset-browser]:not(:has([data-asset-picker])) {
110+
/* Wrap a border around the container instead of dealing with complex nested table elements, because borders and border-radius don't work as expected with nested table elements */
111+
@apply border-gray-300 dark:border-gray-700 border-1 rounded-lg;
112+
/* Prevent the descended table elements from inheriting this, such as the img thumbnail and the delete button */
113+
*:not(button, button *) {
114+
@apply rounded-lg border-none;
115+
}
116+
}
117+
/* GRID FIELDTYPE / Assets fieldtype in a grid fieldtype / Row Compression
118+
=================================================== */
119+
/* When a grid field has at least 2 columns (so 3 including the menu control) change the presentation and compress the padding so it fits in with the other grid cells */
120+
/* Table UI Mode */
121+
.grid-table tr:has(> :nth-child(3)) .grid-cell.assets-fieldtype:not(:has([data-asset-picker])) > * {
122+
@apply shadow-ui-sm;
123+
td {
124+
padding: 0.3125rem;
125+
}
126+
}
127+
/* Stacked UI mode */
128+
.grid-stacked:not(:has([data-asset-picker])) .publish-fields:has(> :nth-child(3)) .assets-fieldtype td {
129+
padding: 0.3125rem;
103130
}

resources/js/components/fieldtypes/assets/AssetRow.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<!-- Safari doesn't support `position: relative` on `<tr>` elements, but these two properties can be used as an alternative. Source: https://mtsknn.fi/blog/relative-tr-in-safari/ transform: translate(0); clip-path: inset(0); -->
3-
<tr class="relative cursor-grab bg-white hover:bg-gray-50 dark:bg-gray-900 dark:hover:bg-gray-900 border-b dark:border-dark-500 last:border-b-0" style="transform: translate(0); clip-path: inset(0);">
3+
<tr class="group relative cursor-grab bg-white hover:bg-gray-50 dark:bg-gray-900 dark:hover:bg-gray-900 border-b dark:border-dark-500 last:border-b-0" style="transform: translate(0); clip-path: inset(0);">
44
<td class="flex gap-2 sm:gap-3 h-full items-center p-3">
55
<div
66
v-if="canShowSvg"
@@ -31,7 +31,7 @@
3131
{{ asset.basename }}
3232
</button>
3333
</td>
34-
<td class="absolute top-0 right-0 flex items-center bg-gradient-to-r to-20% from-transparent to-white dark:to-gray-900 p-3 ps-[2rem] align-middle text-end">
34+
<td class="absolute top-0 right-0 flex items-center bg-gradient-to-r to-20% from-transparent to-white dark:to-gray-900 p-3 ps-[2rem] align-middle text-end group-hover:to-gray-50 dark:group-hover:to-gray-900">
3535
<ui-badge
3636
v-if="showSetAlt && needsAlt"
3737
as="button"

resources/js/components/fieldtypes/assets/AssetsFieldtype.vue

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div class="@container relative w-full bg-gray-50 dark:bg-transparent rounded-xl">
2+
<div data-asset-browser class="@container relative w-full bg-gray-50 dark:bg-transparent rounded-xl">
33
<div
44
v-if="hasPendingDynamicFolder"
55
class="w-full rounded-md border border-dashed px-4 py-3 text-sm text-gray-700 dark:border-gray-300 dark:text-gray-200"
@@ -28,6 +28,7 @@
2828

2929
<div
3030
v-if="!isReadOnly && showPicker"
31+
data-asset-picker
3132
class="not-[.link-fieldtype_&]:p-2 not-[.link-fieldtype_&]:border border-gray-300 dark:border-gray-700 dark:bg-gray-850 rounded-xl flex flex-col @2xs:flex-row items-center gap-2 sm:gap-3 gap-y-3"
3233
:class="{
3334
'rounded-b-none': expanded,
@@ -124,10 +125,10 @@
124125

125126
<div class="relative overflow-hidden rounded-xl border border-gray-300 dark:border-gray-700 not-[.link-fieldtype_&]:border-t-0! not-[.link-fieldtype_&]:rounded-t-none" v-if="displayMode === 'list'">
126127
<table class="table-fixed w-full">
127-
<thead>
128+
<thead class="sr-only">
128129
<tr>
129-
<th class="sr-only">Asset</th>
130-
<th class="sr-only">Actions</th>
130+
<th>Asset</th>
131+
<th>Actions</th>
131132
</tr>
132133
</thead>
133134
<sortable-list

0 commit comments

Comments
 (0)