From 1cc2d38edc9743684d54138edc4d224a8936e521 Mon Sep 17 00:00:00 2001 From: Jack Sleight Date: Mon, 15 Apr 2024 15:12:06 +0100 Subject: [PATCH 01/67] WIP --- resources/css/components/publish.css | 12 +++ resources/css/elements/dropdowns.css | 46 ++++++++++++ resources/js/app.js | 1 + resources/js/bootstrap/components.js | 6 ++ resources/js/components/DropdownList.vue | 8 +- resources/js/components/DropdownTools.vue | 30 ++++++++ resources/js/components/HasTools.js | 29 +++++++ resources/js/components/QuickDropdownItem.vue | 37 +++++++++ resources/js/components/QuickDropdownList.vue | 16 ++++ resources/js/components/Statamic.js | 6 ++ resources/js/components/Tools.js | 19 +++++ .../js/components/fieldtypes/Fieldtype.vue | 28 ++++++- .../fieldtypes/bard/BardFieldtype.vue | 27 ++++++- .../fieldtypes/replicator/Replicator.vue | 33 +++++++- .../components/fieldtypes/replicator/Set.vue | 9 ++- resources/js/components/publish/Field.vue | 75 ++++++++++++++++--- tailwind.config.js | 1 + 17 files changed, 362 insertions(+), 21 deletions(-) create mode 100644 resources/js/components/DropdownTools.vue create mode 100644 resources/js/components/HasTools.js create mode 100644 resources/js/components/QuickDropdownItem.vue create mode 100644 resources/js/components/QuickDropdownList.vue create mode 100644 resources/js/components/Tools.js diff --git a/resources/css/components/publish.css b/resources/css/components/publish.css index 98b427dabf..0a0c6153d1 100644 --- a/resources/css/components/publish.css +++ b/resources/css/components/publish.css @@ -70,6 +70,18 @@ code.parent-url { @apply absolute inset-0 cursor-not-allowed bg-white/25; z-index: 100; } + + .field-dropdown { + @apply hidden; + } + .has-dropdown { + .field-inner { + @apply pr-6; + } + .field-dropdown { + @apply block absolute bottom-0 right-0; + } + } } .publish-field { diff --git a/resources/css/elements/dropdowns.css b/resources/css/elements/dropdowns.css index f7d51f7aef..a1ff698520 100644 --- a/resources/css/elements/dropdowns.css +++ b/resources/css/elements/dropdowns.css @@ -40,9 +40,55 @@ .divider { @apply h-px bg-gray-400 overflow-hidden; margin: 6px -8px; + /* Hide dividers that come first, last or immediately after another (due to v-if) */ + & + &, + &:first-child, + &:last-child { + display: none; + } } .align-left & { right: auto ; [dir="rtl"] & { right: auto ; left: auto ; } } + } + +.quick-list { + + @apply relative; + + .quick-list-content { + @apply absolute top-1/2 right-full mr-[8px] -translate-y-1/2 min-w-max transition origin-right flex bg-white shadow-quick rounded-full p-0.5; + &::before { + content: ''; + position: absolute; + inset: -8px -8px -8px -20px; + z-index: -1; + } + button, a { + @apply rounded-full p-1.5 text-gray-800 flex shrink-0; + &:hover { + @apply bg-blue text-white; + } + } + &:empty { + @apply hidden; + } + } + + button.warning, a.warning { + @apply text-red-500; + + &:hover { + @apply bg-red-500 text-white; + } + } + + &:not(:hover) { + .quick-list-content { + @apply opacity-0 pointer-events-none scale-[0.85]; + } + } + +} \ No newline at end of file diff --git a/resources/js/app.js b/resources/js/app.js index 968c30a852..81a8629d29 100644 --- a/resources/js/app.js +++ b/resources/js/app.js @@ -67,6 +67,7 @@ Vue.prototype.$echo = Statamic.$echo; Vue.prototype.$bard = Statamic.$bard; Vue.prototype.$keys = Statamic.$keys; Vue.prototype.$reveal = Statamic.$reveal; +Vue.prototype.$tools = Statamic.$tools; import Moment from 'moment'; window.moment = Vue.moment = Vue.prototype.$moment = Moment; diff --git a/resources/js/bootstrap/components.js b/resources/js/bootstrap/components.js index 8b9cb1269b..7e992c08a9 100644 --- a/resources/js/bootstrap/components.js +++ b/resources/js/bootstrap/components.js @@ -42,6 +42,9 @@ import FileIcon from '../components/FileIcon.vue'; import LoadingGraphic from '../components/LoadingGraphic.vue'; import DropdownList from '../components/DropdownList.vue'; import DropdownItem from '../components/DropdownItem.vue'; +import DropdownTools from '../components/DropdownTools.vue'; +import QuickDropdownList from '../components/QuickDropdownList.vue'; +import QuickDropdownItem from '../components/QuickDropdownItem.vue'; import ValidationErrors from '../components/ValidationErrors.vue'; import Slugify from '../components/Slugify.vue'; import ElementContainer from '../components/ElementContainer.vue'; @@ -119,6 +122,9 @@ Vue.component('file-icon', FileIcon); Vue.component('loading-graphic', LoadingGraphic); Vue.component('dropdown-list', DropdownList); Vue.component('dropdown-item', DropdownItem); +Vue.component('dropdown-tools', DropdownTools); +Vue.component('quick-dropdown-list', QuickDropdownList); +Vue.component('quick-dropdown-item', QuickDropdownItem); Vue.component('validation-errors', ValidationErrors); Vue.component('slugify', Slugify); Vue.component('element-container', ElementContainer); diff --git a/resources/js/components/DropdownList.vue b/resources/js/components/DropdownList.vue index 72329edeab..9e91349619 100644 --- a/resources/js/components/DropdownList.vue +++ b/resources/js/components/DropdownList.vue @@ -1,5 +1,5 @@