Skip to content

armgit / bento

Public Imported from GitHub
0

Bento, the office suite that fits in a file

v0.4.1: stacked shadows — hero logos get elevation + 10% warm-white glow

nyblnetb85a726107b6
diff --git a/slides/package.json b/slides/package.json
index 141304aa..4e2010f2 100644
--- a/slides/package.json
+++ b/slides/package.json
@@ -1,7 +1,7 @@
{
"name": "bento-slides",
"private": true,
- "version": "0.4.0",
+ "version": "0.4.1",
"type": "module",
"scripts": {
"dev": "vite",
diff --git a/slides/src/editor/panels.ts b/slides/src/editor/panels.ts
index 96dff8a2..ebfb40c4 100644
--- a/slides/src/editor/panels.ts
+++ b/slides/src/editor/panels.ts
@@ -293,7 +293,7 @@ export class PropsPanel {
if (v === 'none') delete e.shadow
else if (v !== 'custom') e.shadow = { ...SHADOW_PRESETS[v] }
}, true)))
- if (el.shadow) {
+ if (el.shadow && !Array.isArray(el.shadow)) {
// recoloring a preset makes it 'custom' on next rebuild — that's fine
this.row('Shadow color', this.colorAlpha(el.shadow.color, (v, fin) =>
this.mutate(el.id, (e) => { if (e.shadow) e.shadow = { ...e.shadow, color: v } }, fin)))
diff --git a/slides/src/model.ts b/slides/src/model.ts
index e5ccca92..b3607e3f 100644
--- a/slides/src/model.ts
+++ b/slides/src/model.ts
@@ -17,10 +17,12 @@ export interface ElementBase {
rotation: number
opacity: number
/**
- * Drop shadow, rendered with CSS drop-shadow so it follows the element's
- * alpha shape (rounded corners, ellipses, text glyphs, image cutouts).
+ * Drop shadow(s), rendered with CSS drop-shadow so they follow the
+ * element's alpha shape (rounded corners, ellipses, glyphs, image
+ * cutouts). An array stacks: e.g. a dark elevation shadow plus a soft
+ * white glow.
*/
- shadow?: { x?: number; y?: number; blur: number; color: string }
+ shadow?: ShadowSpec | ShadowSpec[]
/** presentation effects, run in present mode only */
fx?: {
/** entrance animation when the slide is shown */
@@ -68,6 +70,13 @@ export interface ElementBase {
role?: string
}
+export interface ShadowSpec {
+ x?: number
+ y?: number
+ blur: number
+ color: string
+}
+
export interface TextElement extends ElementBase {
type: 'text'
/** Rich text as sanitized inline HTML (b/i/u/br/span only). */
diff --git a/slides/src/render.ts b/slides/src/render.ts
index 4c49f289..2fb1bfb8 100644
--- a/slides/src/render.ts
+++ b/slides/src/render.ts
@@ -69,8 +69,9 @@ export function applyElementFrame(node: HTMLElement, el: SlideElement) {
node.style.height = `${el.h}px`
node.style.transform = el.rotation ? `rotate(${el.rotation}deg)` : ''
node.style.opacity = String(el.opacity)
- node.style.filter = el.shadow
- ? `drop-shadow(${el.shadow.x ?? 0}px ${el.shadow.y ?? 0}px ${el.shadow.blur}px ${el.shadow.color})`
+ const shadows = Array.isArray(el.shadow) ? el.shadow : el.shadow ? [el.shadow] : []
+ node.style.filter = shadows.length
+ ? shadows.map((s) => `drop-shadow(${s.x ?? 0}px ${s.y ?? 0}px ${s.blur}px ${s.color})`).join(' ')
: ''
}
diff --git a/slides/src/starterdeck.ts b/slides/src/starterdeck.ts
index 2b0a0690..1cc08ec2 100644
--- a/slides/src/starterdeck.ts
+++ b/slides/src/starterdeck.ts
@@ -358,7 +358,7 @@ export function starterDoc(): BentoDoc {
// the bento logo, built from the cast
shape('rect', {
id: T_D, x: 850, y: 170, w: 320, h: 320, radius: 40, fill: PANEL, fillGradient: GRAD_CARD,
- shadow: { y: 30, blur: 70, color: 'rgba(0,0,0,0.55)' },
+ shadow: [{ y: 30, blur: 70, color: 'rgba(0,0,0,0.55)' }, { blur: 90, color: 'rgba(255,238,214,0.10)' }],
fx: { enter: 'fade', order: 1 },
}),
shape('rect', { id: T_B, x: 886, y: 206, w: 84, h: 248, radius: 16, fill: STEEL, fillGradient: GRAD_STEEL, fx: { enter: 'fade-up', order: 2 } }),
@@ -863,7 +863,7 @@ export function starterDoc(): BentoDoc {
bokeh(900, 478, 8, true, 0.18, 20, 9, 18),
shape('rect', {
id: T_D, x: 500, y: 120, w: 280, h: 280, radius: 52, fill: PANEL, fillGradient: GRAD_CARD,
- shadow: { y: 30, blur: 70, color: 'rgba(0,0,0,0.55)' },
+ shadow: [{ y: 30, blur: 70, color: 'rgba(0,0,0,0.55)' }, { blur: 90, color: 'rgba(255,238,214,0.10)' }],
}),
shape('rect', { id: T_B, x: 532, y: 152, w: 70, h: 216, radius: 14, fill: STEEL, fillGradient: GRAD_STEEL }),
shape('rect', { id: T_A, x: 618, y: 152, w: 130, h: 96, radius: 14, fill: PEACH, fillGradient: GRAD_PEACH }),