Skip to content

armgit / bento

Public Imported from GitHub
0

Bento, the office suite that fits in a file

feat(element): optional backdrop-filter (frosted glass)

sergioerm763e8e1c3d49
diff --git a/slides/src/model.ts b/slides/src/model.ts
index 54082973..93e6ca85 100644
--- a/slides/src/model.ts
+++ b/slides/src/model.ts
@@ -35,6 +35,10 @@ export interface ElementBase {
* white glow.
*/
shadow?: ShadowSpec | ShadowSpec[]
+ /** Frosted-glass backdrop blur behind this element, in px (0/undefined = off).
+ * Screen-only: browser print/PDF drops backdrop-filter (pair with a
+ * translucent `fill` so PDFs show a graceful flat panel). */
+ backdropFilter?: number
/** presentation effects, run in present mode only */
fx?: {
/** entrance animation when the slide is shown. fade-* nudge ~16px; slide-*
diff --git a/slides/src/render.ts b/slides/src/render.ts
index 89610716..eab1e98d 100644
--- a/slides/src/render.ts
+++ b/slides/src/render.ts
@@ -132,6 +132,13 @@ export function applyElementFrame(node: HTMLElement, el: SlideElement) {
node.style.filter = shadows.length
? shadows.map((s) => `drop-shadow(${s.x ?? 0}px ${s.y ?? 0}px ${s.blur}px ${s.color})`).join(' ')
: ''
+ if (el.backdropFilter) {
+ const bf = `blur(${el.backdropFilter}px)`
+ node.style.backdropFilter = bf
+ node.style.setProperty('-webkit-backdrop-filter', bf)
+ } else {
+ node.style.backdropFilter = ''
+ }
}
// Gradient ids must be unique per rendered instance: the same element renders