diff --git a/app/assets/stylesheets/bubbles.css b/app/assets/stylesheets/bubbles.css index 3c5e721d5..67f92c5ea 100644 --- a/app/assets/stylesheets/bubbles.css +++ b/app/assets/stylesheets/bubbles.css @@ -307,47 +307,6 @@ } } -.bubbles-list__divider { - --border-color: var(--divider-color); - --border-size: 2px; - --divider-color: var(--color-subtle-dark); - - block-size: calc(100% + 12ch); - font-size: 1rem; - cursor: grab; - margin-inline: calc(var(--divider-offset) * -1); - visibility: hidden; -} - -.bubbles-list__divider--installed { - visibility: visible; -} - -.divider-drag-image { - background-color: var(--color-link); - border-radius: 1rem; - color: var(--color-ink-reversed); - inset: auto 100% 100% auto; - line-height: 2rem; - padding: 0 1rem; - position: fixed; - text-wrap: nowrap; -} - -.btn--reversed.bubbles-list__handle { - --btn-background: var(--divider-color); - - font-size: 0.9rem; -} - -.bubbles-list__count { - --btn-background: var(--divider-color); - --btn-color: var(--color-ink-reversed); - --btn-gap: 0.5ch; - --btn-icon-size: 1em; - --btn-padding: 0.1em 1em 0.1em 0.7em; -} - .bubble__title-text { font-weight: 700; flex-grow: 1; diff --git a/app/javascript/controllers/divider_controller.js b/app/javascript/controllers/divider_controller.js deleted file mode 100644 index 058bcb6a0..000000000 --- a/app/javascript/controllers/divider_controller.js +++ /dev/null @@ -1,83 +0,0 @@ -import { Controller } from "@hotwired/stimulus" - -const MOVE_ITEM_DATA_TYPE = "x-fizzy/move" -const DIVIDER_ITEM_NODE_NAME = "LI" -const OVERLAP_THRESHOLD = 0.25 - -export default class extends Controller { - static targets = [ "divider", "dragImage", "count" ] - static classes = [ "installed", "dragging" ] - static values = { startCount: Number, maxCount: Number } - - connect() { - this.install() - } - - install() { - this.#moveDividerTo(this.startCountValue) - this.dividerTarget.classList.add(this.installedClass) - } - - configureDrag(event) { - if (event.target == this.dividerTarget) { - event.dataTransfer.dropEffect = "move" - event.dataTransfer.setData(MOVE_ITEM_DATA_TYPE, event.target) - event.dataTransfer.setDragImage(this.dragImageTarget, 0, 0) - this.element.classList.add(this.draggingClass) - } - } - - acceptDrop(event) { - if (event.dataTransfer.types.includes(MOVE_ITEM_DATA_TYPE)) { - event.preventDefault() - } - } - - moveDivider(event) { - if (event.target.nodeName == DIVIDER_ITEM_NODE_NAME) { - const rect = this.dividerTarget.getBoundingClientRect() - const distanceToTop = Math.abs(event.clientY - rect.top) - const distanceToBottom = Math.abs(event.clientY - (rect.top + rect.height)) - const distanceToNearestEdge = Math.min(distanceToTop, distanceToBottom) - const overlap = distanceToNearestEdge / rect.height - - if (overlap > OVERLAP_THRESHOLD) { - this.#moveDividerTo(this.#items.indexOf(event.target)) - } - } - } - - drop() { - this.element.classList.remove(this.draggingClass) - } - - #moveDividerTo(index) { - if (index <= this.maxCountValue) { - if (this.#dividerIndex < index) { - this.#positionDividerAfter(index) - } else if (this.#dividerIndex > index) { - this.#positionDividerBefore(index) - } - } - } - - #positionDividerBefore(index) { - const position = Math.max(index, 1) - this.#items[position].before(this.dividerTarget) - this.countTarget.textContent = position - } - - #positionDividerAfter(index) { - const position = Math.min(index, this.#items.length - 1, this.maxCountValue) - this.#items[position].after(this.dividerTarget) - this.countTarget.textContent = position - } - - get #items() { - return Array.from(this.element.children) - } - - get #dividerIndex() { - return this.#items.indexOf(this.dividerTarget) - } -} diff --git a/app/views/bubbles/index.html.erb b/app/views/bubbles/index.html.erb index c0d78891c..3ba7d8d81 100644 --- a/app/views/bubbles/index.html.erb +++ b/app/views/bubbles/index.html.erb @@ -43,13 +43,7 @@
-
\ No newline at end of file diff --git a/app/views/bubbles/list/_divider.html.erb b/app/views/bubbles/list/_divider.html.erb deleted file mode 100644 index 96cc95754..000000000 --- a/app/views/bubbles/list/_divider.html.erb +++ /dev/null @@ -1,10 +0,0 @@ -
  • -
    Drag up or down
    - - - <%= image_tag "drag.svg", aria: { hidden: true }, size: 24, class: "colorize--white" %> - 10 Bubbled up - - - -