@@ -14,7 +14,33 @@ export interface AnnotationBadge {
1414 text : string
1515}
1616
17- export type Annotation = AnnotationBadge
17+ export interface AnnotationBox {
18+ type : 'box' | 'highlight' | 'selection'
19+ x : number // reference 800x450 coordinate
20+ y : number // reference 800x450 coordinate
21+ width : number
22+ height : number
23+ rx ?: number
24+ stroke ?: string
25+ strokeWidth ?: number
26+ }
27+
28+ export interface AnnotationText {
29+ type : 'text' | 'label'
30+ x : number // reference 800x450 coordinate
31+ y : number // reference 800x450 coordinate
32+ text : string
33+ width ?: number
34+ height ?: number
35+ rx ?: number
36+ fontSize ?: number
37+ fontWeight ?: string
38+ color ?: string
39+ backgroundColor ?: string
40+ paddingX ?: number
41+ }
42+
43+ export type Annotation = AnnotationBadge | AnnotationBox | AnnotationText
1844
1945export interface ScreenshotTarget {
2046 id : string
@@ -48,6 +74,43 @@ export function buildSvgOverlay(
4874 <text x="${ tx } " y="${ ty } " font-family="-apple-system, BlinkMacSystemFont, Inter, Helvetica, Arial, sans-serif" font-size="${ fontSize } " font-weight="bold" fill="#000000" text-anchor="middle" dominant-baseline="central">${ ann . text } </text>
4975 `
5076 }
77+ if (
78+ ann . type === 'box' ||
79+ ann . type === 'highlight' ||
80+ ann . type === 'selection'
81+ ) {
82+ const bx = ann . x * scale
83+ const by = ann . y * scale
84+ const bw = ann . width * scale
85+ const bh = ann . height * scale
86+ const rx = ( ann . rx ?? 4 ) * scale
87+ const stroke = ann . stroke ?? '#ffffff'
88+ const strokeWidth = ( ann . strokeWidth ?? 1 ) * scale
89+ return `
90+ <rect x="${ bx } " y="${ by } " width="${ bw } " height="${ bh } " rx="${ rx } " ry="${ rx } " fill="none" stroke="${ stroke } " stroke-width="${ strokeWidth } " />
91+ `
92+ }
93+ if ( ann . type === 'text' || ann . type === 'label' ) {
94+ const bx = ann . x * scale
95+ const by = ann . y * scale
96+ const fontSize = ( ann . fontSize ?? 11.5 ) * scale
97+ const paddingX = ( ann . paddingX ?? 4 ) * scale
98+ const bw =
99+ ann . width !== undefined
100+ ? ann . width * scale
101+ : ( ann . text . length * ( fontSize / scale ) * 0.58 + paddingX * 2 ) * scale
102+ const bh = ( ann . height ?? 20 ) * scale
103+ const rx = ( ann . rx ?? 2 ) * scale
104+ const tx = bx + bw / 2
105+ const ty = by + bh / 2 + 0.5 * scale
106+ const fill = ann . backgroundColor ?? '#ffffff'
107+ const color = ann . color ?? '#000000'
108+ const fontWeight = ann . fontWeight ?? 'bold'
109+ return `
110+ <rect x="${ bx } " y="${ by } " width="${ bw } " height="${ bh } " rx="${ rx } " ry="${ rx } " fill="${ fill } " />
111+ <text x="${ tx } " y="${ ty } " font-family="-apple-system, BlinkMacSystemFont, Inter, Helvetica, Arial, sans-serif" font-size="${ fontSize } " font-weight="${ fontWeight } " fill="${ color } " text-anchor="middle" dominant-baseline="central">${ ann . text } </text>
112+ `
113+ }
51114 return ''
52115 } )
53116 . join ( '\n' )
@@ -546,6 +609,36 @@ export const TARGETS: ScreenshotTarget[] = [
546609 ] ,
547610 } ,
548611
612+ // Placeholder content
613+ {
614+ id : 'placeholder-content' ,
615+ name : 'placeholder-content' ,
616+ outputDir : 'docs/components/compositions' ,
617+ path : '/projects/docs_examples/branches/screenshots/components/screenshot-card-container?mode=design&canvas-tool=select&selection=nodes.Iry7BeAO7AjcLcJEL-sPT&rightpanel=attributes' ,
618+ description : 'Placeholder content in slot' ,
619+ setup : async ( page : Page ) => {
620+ await page . waitForTimeout ( 500 )
621+ } ,
622+ annotations : [
623+ {
624+ type : 'box' ,
625+ x : 24 ,
626+ y : 84 ,
627+ width : 104 ,
628+ height : 64 ,
629+ rx : 4 ,
630+ } ,
631+ {
632+ type : 'text' ,
633+ x : 24 ,
634+ y : 152 ,
635+ width : 188 ,
636+ height : 20 ,
637+ text : 'Placeholder content for the slot' ,
638+ } ,
639+ ] ,
640+ } ,
641+
549642 // Export a component
550643 {
551644 id : 'export-a-component' ,
0 commit comments