blob: 0651dccc094b1e2379b0b1084bd5601f5c2b6a96 [file]
/*
* Copyright 2026 The Fuchsia Authors
*
* Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0
* <LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0>, or the MIT
* license <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your option.
* This file may not be copied, modified, or distributed except according to
* those terms.
*/
/*
* Bookplate border: the frame of the Aberdeen Public Library bookplate as a
* responsive CSS border, drawn entirely with SVG.
*
* <div class="bookplate">...</div> frame only
* <div class="bookplate bookplate-ornaments">...</div> frame + ornaments
*
* How it works: the element's border reserves room for the frame band, and its
* ::before and ::after pseudo-elements paint the frame as background layers:
* corners drawn once, and edges repeated with `round` between them, so each
* side always ends on whole fret motifs. Each corner image reaches 2 units
* over the start of the neighbouring edges, so the joins are overdrawn and
* cannot open into hairline gaps.
*
* Things to know:
* - The frame uses ::before and ::after, so they are not free for other uses.
* The element gets `position: relative` (any position but static works) and
* `isolation: isolate`.
* - Do not give the framed element itself an `overflow` other than visible: it
* would clip the frame. Put scrolling content in an inner element instead.
* - The element's border box is the outer edge of the frame. The corner
* overhangs stick out 20 units beyond it, so leave that much room around the
* element and do not clip it with `overflow: hidden` on a parent.
* - Each side repeats a 3-motif stretch of fret.
* - Keep the element at least 128 units in each direction; below that the
* corners overlap.
*/
.bookplate {
/*
* One design unit. The frame band is 40.71 units deep. Scales from 0.5px on
* very small screens up to 1px from a 600px-wide viewport.
*/
--bookplate-unit: clamp(0.5px, 0.1667vw, 1px);
--bookplate-padding: calc(24 * var(--bookplate-unit));
position: relative;
isolation: isolate;
border: calc(40.71 * var(--bookplate-unit)) solid transparent;
padding: var(--bookplate-padding);
}
.bookplate::before,
.bookplate::after {
content: "";
position: absolute;
inset: calc(-60.71 * var(--bookplate-unit));
z-index: -1;
pointer-events: none;
box-sizing: border-box;
border: 0 solid transparent;
}
/* Top and bottom edges, repeated between the corners. */
.bookplate::before {
border-width: 0 calc(84 * var(--bookplate-unit));
background:
url("images/frame-edge-top.svg") left top /
calc(69 * var(--bookplate-unit)) calc(84 * var(--bookplate-unit))
round no-repeat padding-box,
url("images/frame-edge-bottom.svg") left bottom /
calc(69 * var(--bookplate-unit)) calc(84 * var(--bookplate-unit))
round no-repeat padding-box;
}
/* Left and right edges, repeated between the corners; the corners on top. */
.bookplate::after {
border-width: calc(84 * var(--bookplate-unit)) 0;
background:
url("images/frame-corner-tl.svg") left top /
calc(86 * var(--bookplate-unit)) calc(86 * var(--bookplate-unit))
no-repeat border-box,
url("images/frame-corner-tr.svg") right top /
calc(86 * var(--bookplate-unit)) calc(86 * var(--bookplate-unit))
no-repeat border-box,
url("images/frame-corner-br.svg") right bottom /
calc(86 * var(--bookplate-unit)) calc(86 * var(--bookplate-unit))
no-repeat border-box,
url("images/frame-corner-bl.svg") left bottom /
calc(86 * var(--bookplate-unit)) calc(86 * var(--bookplate-unit))
no-repeat border-box,
url("images/frame-edge-left.svg") left top /
calc(84 * var(--bookplate-unit)) calc(69 * var(--bookplate-unit))
no-repeat round padding-box,
url("images/frame-edge-right.svg") right top /
calc(84 * var(--bookplate-unit)) calc(69 * var(--bookplate-unit))
no-repeat round padding-box;
}
/*
* Optional corner ornaments, drawn as background images just inside the frame.
* They reach 37 units in from the frame, so this class also raises the default
* padding. Setting `background` (the shorthand) on the element removes them;
* use `background-color`, or list these layers in your own `background-image`.
*/
.bookplate-ornaments {
--bookplate-padding: calc(48 * var(--bookplate-unit));
background-image:
url("images/ornament-tl.svg"),
url("images/ornament-tr.svg"),
url("images/ornament-br.svg"),
url("images/ornament-bl.svg");
background-position: left top, right top, right bottom, left bottom;
background-size:
calc(62 * var(--bookplate-unit)) calc(62 * var(--bookplate-unit));
background-repeat: no-repeat;
background-origin: padding-box;
}