feat(ui): copyable input partial + dynamic copy-target
- New core partial templates/partials/app-input-copy.phtml renders a
standard label + input with a compact copy button overlaid on the
right edge of the input. Used for privacy/imprint URLs on the tenant
form; reusable for any field where a one-click copy is helpful.
- Extend the shared copy-field component (web/js/components/app-copy-field.js)
with data-copy-target support — the button now reads the target input's
.value at click-time, so users can edit a field and still copy the
current value. Static data-copy-value keeps working unchanged.
- New component CSS web/css/components/app-input-copy.css positions the
button absolute/inset + margin-block:auto (robust vertical centering
regardless of input height) and uses a descendant selector (0,2,0)
so the button wins over the global [data-tooltip] position:relative.
- Also register app-input-copy.css + app-tenant-logo.css in core.css
@import list — they were only in the shared asset group before, which
default-template admin pages don't load, so tenant-logo styles were
effectively missing on admin tenant edit (topbar size etc.).
- Document the Copy-to-Clipboard + Copyable Input standards in
docs/reference-frontend-javascript.md so future consumers don't
re-invent the markup/selectors.
- File-upload preview: pending-file block restructured to a compact
list-item row (small square thumb + filename/size stack + clear X)
and removed the transparency checker pattern on the current-image
preview in favour of a flat --app-preview-bg surface.
- Tenant edit page title + breadcrumb now show the tenant description
("Acme GmbH") instead of the generic "Mandant bearbeiten" when one
is present.
- i18n: add "Copy to clipboard" / "In Zwischenablage kopieren" across
both locales.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -169,11 +169,11 @@
|
||||
}
|
||||
|
||||
/* ── Pending file preview (visible when new file selected) ──
|
||||
Same layout as current: full-width thumb + info row below. */
|
||||
Compact row: small thumb (left) + filename/size stack (middle) + clear X (right). */
|
||||
.app-file-upload-preview {
|
||||
display: none;
|
||||
flex-direction: column;
|
||||
gap: calc(var(--app-spacing) * 0.5);
|
||||
align-items: center;
|
||||
gap: calc(var(--app-spacing) * 0.75);
|
||||
padding: calc(var(--app-spacing) * 0.75);
|
||||
}
|
||||
|
||||
@@ -182,53 +182,50 @@
|
||||
}
|
||||
|
||||
.app-file-upload-thumbnail {
|
||||
width: 100%;
|
||||
aspect-ratio: 16 / 9;
|
||||
padding: var(--app-spacing);
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
border-radius: calc(var(--app-border-radius) * 0.5);
|
||||
object-fit: contain;
|
||||
object-position: center;
|
||||
object-fit: cover;
|
||||
border: 1px solid var(--app-muted-border-color);
|
||||
background-color: var(--app-preview-bg);
|
||||
box-sizing: border-box;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.app-file-upload-file-icon {
|
||||
width: 100%;
|
||||
aspect-ratio: 16 / 9;
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
border-radius: calc(var(--app-border-radius) * 0.5);
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: var(--text-3xl);
|
||||
font-size: var(--text-xl);
|
||||
color: var(--app-muted-color);
|
||||
background: var(--app-background-color);
|
||||
background: var(--app-preview-bg);
|
||||
border: 1px solid var(--app-muted-border-color);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.app-file-upload-meta {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: calc(var(--app-spacing) * 0.5);
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.app-file-upload-filename {
|
||||
font-size: var(--text-sm);
|
||||
font-weight: var(--font-medium);
|
||||
color: var(--app-contrast);
|
||||
color: var(--app-color);
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.app-file-upload-filesize {
|
||||
font-size: var(--text-xs);
|
||||
color: var(--app-muted-color);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.app-file-upload-clear {
|
||||
|
||||
73
web/css/components/app-input-copy.css
Normal file
73
web/css/components/app-input-copy.css
Normal file
@@ -0,0 +1,73 @@
|
||||
@layer components {
|
||||
/* Copyable input — absolute-positioned button overlay on the right edge
|
||||
of a native-width input. Wrapper is a plain block so it fits into
|
||||
any grid cell without overflow; button is positioned absolute and
|
||||
vertically centered via the inset + margin-block:auto pattern. */
|
||||
.app-input-copy {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.app-input-copy > input {
|
||||
padding-right: 2.5rem;
|
||||
width: 100%;
|
||||
display: block;
|
||||
}
|
||||
|
||||
/* High specificity (0,2,0) to beat [data-tooltip] (0,1,0) which sets
|
||||
position: relative on the copy button (tooltip host). */
|
||||
.app-input-copy > .app-input-copy-button {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
right: 0.3rem;
|
||||
margin-block: auto;
|
||||
height: fit-content;
|
||||
background: transparent;
|
||||
border: 0;
|
||||
box-shadow: none;
|
||||
color: var(--app-muted-color);
|
||||
cursor: pointer;
|
||||
padding: 0.3rem 0.45rem;
|
||||
width: auto;
|
||||
line-height: var(--leading-none);
|
||||
border-radius: calc(var(--app-border-radius) * 0.5);
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
transition: color 0.15s ease, background-color 0.15s ease;
|
||||
}
|
||||
|
||||
.app-input-copy > .app-input-copy-button:hover {
|
||||
color: var(--app-primary);
|
||||
background: color-mix(in srgb, var(--app-primary) 10%, transparent);
|
||||
}
|
||||
|
||||
.app-input-copy > .app-input-copy-button:focus-visible {
|
||||
outline: 2px solid var(--app-primary);
|
||||
outline-offset: 1px;
|
||||
}
|
||||
|
||||
.app-input-copy > .app-input-copy-button [data-copy-icon-done] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.app-input-copy > .app-input-copy-button.is-copied {
|
||||
color: var(--app-action-success-border);
|
||||
background: color-mix(in srgb, var(--app-action-success-border) 12%, transparent);
|
||||
}
|
||||
|
||||
.app-input-copy > .app-input-copy-button.is-copied [data-copy-icon-idle] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.app-input-copy > .app-input-copy-button.is-copied [data-copy-icon-done] {
|
||||
display: inline-flex;
|
||||
}
|
||||
|
||||
/* Input inside the wrapper is now the last child of label (no longer
|
||||
a direct <input> child). Add the margin-top that the global
|
||||
label > input rule would have applied. */
|
||||
label > .app-input-copy {
|
||||
margin-top: calc(var(--app-spacing) * 0.25);
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,8 @@
|
||||
@import url("components/app-flash.css");
|
||||
@import url("components/app-brand.css");
|
||||
@import url("components/app-file-upload.css");
|
||||
@import url("components/app-input-copy.css");
|
||||
@import url("components/app-tenant-logo.css");
|
||||
@import url("components/app-footer.css");
|
||||
|
||||
/* Default admin experience */
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
/**
|
||||
* Copy-to-clipboard button — click writes `data-copy-value` to the clipboard
|
||||
* and swaps the button icon to a check for ~1.2s. Self-contained: markup is
|
||||
* fully rendered server-side, this component only wires the click handler.
|
||||
* Copy-to-clipboard button — click writes a value to the clipboard and swaps
|
||||
* the button icon to a check for ~1.2s. Self-contained: markup is fully
|
||||
* rendered server-side, this component only wires the click handler.
|
||||
*
|
||||
* <button type="button" data-copy-button data-copy-value="max@acme.com"
|
||||
* aria-label="Copy email">
|
||||
* <i class="bi bi-copy" data-copy-icon-idle></i>
|
||||
* <i class="bi bi-check2" data-copy-icon-done></i>
|
||||
* </button>
|
||||
* Static value (read from the button itself):
|
||||
* <button type="button" data-copy-button data-copy-value="max@acme.com" …>…</button>
|
||||
*
|
||||
* Live input value (resolved at click-time from the target element's .value):
|
||||
* <button type="button" data-copy-button data-copy-target="privacy_url" …>…</button>
|
||||
*/
|
||||
import { resolveHost } from '../core/app-dom.js';
|
||||
|
||||
@@ -71,7 +71,14 @@ export function initCopyField(root = document, options = {}) {
|
||||
|
||||
const onClick = async (event) => {
|
||||
event.preventDefault();
|
||||
const value = button.dataset.copyValue || '';
|
||||
const targetId = (button.dataset.copyTarget || '').trim();
|
||||
let value = button.dataset.copyValue || '';
|
||||
if (targetId) {
|
||||
const target = document.getElementById(targetId);
|
||||
if (target && 'value' in target) {
|
||||
value = /** @type {HTMLInputElement} */ (target).value;
|
||||
}
|
||||
}
|
||||
const ok = await copyText(value);
|
||||
if (!ok) {return;}
|
||||
button.classList.add(DONE_CLASS);
|
||||
|
||||
Reference in New Issue
Block a user