Files
o2o-weather/admin/src/cards/Frame.tsx
T

33 lines
1.2 KiB
TypeScript

import type { CSSProperties, ReactNode } from 'react'
import { themeVars } from './themes'
/** 줄바꿈(\n)은 카드에서도 줄바꿈, *별표* 사이는 강조색 */
export function Lines({ text }: { text: string }) {
return text.split('\n').map((line, i) => (
<span className="line" key={i}>
{line.split(/(\*[^*]+\*)/).map((part, j) => (part.startsWith('*') && part.endsWith('*') ? <strong key={j}>{part.slice(1, -1)}</strong> : part))}
</span>
))
}
export function Frame({ page, total, theme, skin, className = '', style, children }: { page: number; total: number; theme?: string; skin?: string; className?: string; style?: CSSProperties; children: ReactNode }) {
return (
<section className={`slide ${className}`} data-skin={skin || 'star'} style={{ ...themeVars(theme), ...style }}>
<header className="topbar">
<div className="brand">
<i className="brand-mark" aria-hidden="true" />
날씨각
</div>
{total > 1 && (
<div className="pagination" aria-hidden="true">
{Array.from({ length: total }, (_, i) => (
<i key={i} className={i === page ? 'active' : ''} />
))}
</div>
)}
</header>
{children}
</section>
)
}