Skip to content

armgit / bento

Public Imported from GitHub
0

Bento, the office suite that fits in a file

3.8 KB
Raw Blame
/* SPDX-License-Identifier: MIT
   Copyright (c) 2026 The Bento authors
   The Save split button and its menu. Prefixed `dxs-` so it can be dropped in
   beside styles.css without either file having to know about the other.

   It knows about styles.css's TOKENS, though, and that is the point: this menu,
   the top bar's own dropdowns, the right-click popovers and the pivot were each
   written separately and each chose its own radius and shadow. They are one
   floating-surface style now, spelled --radius-lg / --shadow-pop, and nothing
   here restates a number that lives there. */

.dxs-wrap { position: relative; display: inline-flex; align-items: stretch; }

/* PRIMARY (maintainer ruling D1, slides and spaces): saving is the act every
   session ends with, so Save and its caret are one INK-FILLED unit — the
   inverse of the surface it sits on (--surface on --ink), which is the one
   pairing that survives a theme flip. It was a light outlined button here. */
.dxs-wrap > .dx-btn:first-child,
.dxs-caret {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--surface);
}
.dxs-wrap > .dx-btn:first-child:hover,
.dxs-caret:hover { background: var(--ink-2); border-color: var(--ink-2); }
.dxs-wrap > .dx-btn:first-child .dx-i { color: inherit; }
.dxs-caret { border-inline-start-color: color-mix(in srgb, var(--surface) 35%, var(--ink)); }

/* The caret sits FLUSH against the Save button so the pair reads as one
   control. It is its own button rather than a click zone inside Save, because a
   miss on a split control that saves is a save to the wrong file. */
.dxs-caret {
  padding: 6px 7px;
  font-size: 11px;
  line-height: 1.4;
  border-left: 0;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  margin-left: -1px;
}
/* …and Save loses its right corners to meet it. Without this the pair read as
   two buttons that happened to touch. */
.dxs-wrap > .dx-btn:first-child {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}
.dxs-wrap .dxs-caret { align-self: stretch; }

.dxs-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 60;
  width: min(264px, calc(100vw - 16px));
  /* a long list on a short window scrolls under the bar rather than running
     off the bottom (nothing in it floats, so a scroll box is safe here) */
  max-height: calc(100dvh - var(--dx-bar-bottom, 56px) - 12px);
  overflow-y: auto;
  /* capped at the viewport: this menu hangs off a button in the right half of
     the bar, and on a phone a 260px start-anchored panel walks off the screen */
  max-width: calc(100vw - 16px);
  padding: 5px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  display: none;
}
.dxs-wrap.dxs-open .dxs-menu { display: flex; flex-direction: column; gap: 1px; }

/* Rows are the bar's menu rows: icon and name on ONE line, a hover fill and
   nothing at rest. The description is the tooltip (D2) — never small print. */
.dxs-menu .dxs-item {
  display: flex;
  width: 100%;
  justify-content: flex-start;
  text-align: start;
  font-size: 12.5px;
  padding: 6px 9px;
  border: 0;
  background: transparent;
  color: var(--ink-2);
}
.dxs-menu .dxs-item:hover:not(:disabled) { background: var(--hover); }
.dxs-menu .dxs-item .dx-i { color: var(--muted); }
.dxs-item:disabled { opacity: 0.35; cursor: default; }
.dxs-sep { height: 1px; margin: 4px 6px; background: var(--line); }

/* Toast: the only feedback these actions have. A share export leaves the open
   file untouched, so without a line of text nothing visibly happened at all. */
.dxs-toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  z-index: 200;
  max-width: min(92vw, 460px);
  padding: 9px 14px;
  border-radius: 999px;
  background: var(--toast-bg);
  color: var(--toast-ink);
  font-size: var(--fs-ui);
  box-shadow: var(--shadow-pop);
}