Add a static images manager and polish dashboard layout and fonts.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
co-authored by
Cursor
parent
e79211e3cd
commit
b9024ad77a
@@ -0,0 +1,27 @@
|
||||
export function parseAspectRatio(value?: string | null): number {
|
||||
if (!value) return 16 / 9
|
||||
const [widthRaw, heightRaw] = value.split(':')
|
||||
const width = Number(widthRaw)
|
||||
const height = Number(heightRaw)
|
||||
if (!Number.isFinite(width) || !Number.isFinite(height) || width <= 0 || height <= 0) {
|
||||
return 16 / 9
|
||||
}
|
||||
return width / height
|
||||
}
|
||||
|
||||
export function cssAspectRatio(value?: string | null): string {
|
||||
if (!value?.includes(':')) return '16 / 9'
|
||||
return value.replace(':', ' / ')
|
||||
}
|
||||
|
||||
/** Preview box that keeps the slot ratio: landscape is wide, portrait is tall. */
|
||||
export function slotPreviewSize(value?: string | null): { width: number; height: number } {
|
||||
const aspect = parseAspectRatio(value)
|
||||
const long = 220
|
||||
if (aspect >= 1) {
|
||||
const width = Math.min(360, Math.round(long * aspect))
|
||||
return { width, height: Math.round(width / aspect) }
|
||||
}
|
||||
const height = long
|
||||
return { width: Math.round(height * aspect), height }
|
||||
}
|
||||
Reference in New Issue
Block a user