Add visual kit components
This commit is contained in:
1 parent
d136b9dddc
commit
7207aa914c
20 files changed
+481
-1
No files matched your search
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "@dev-screen-starter/visual-kit",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"exports": {
|
||||
".": "./src/index.ts"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsc --noEmit",
|
||||
"typecheck": "tsc --noEmit"
|
||||
},
|
||||
"dependencies": {
|
||||
"react": "^19.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/react": "^19.1.16",
|
||||
"typescript": "^5.9.2"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import type { ReactNode } from 'react'
|
||||
|
||||
type CornerFrameProps = {
|
||||
className?: string
|
||||
children: ReactNode
|
||||
}
|
||||
|
||||
export function CornerFrame({ className = '', children }: CornerFrameProps) {
|
||||
return (
|
||||
<div className={`vk-corner-frame ${className}`}>
|
||||
<span className="corner corner-tl" />
|
||||
<span className="corner corner-tr" />
|
||||
<span className="corner corner-bl" />
|
||||
<span className="corner corner-br" />
|
||||
{children}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
type DigitalNumberProps = {
|
||||
label: string
|
||||
value: string | number
|
||||
unit?: string
|
||||
tone?: 'blue' | 'green' | 'amber'
|
||||
}
|
||||
|
||||
export function DigitalNumber({ label, value, unit, tone = 'blue' }: DigitalNumberProps) {
|
||||
return (
|
||||
<div className={`vk-digital-number tone-${tone}`}>
|
||||
<span>{label}</span>
|
||||
<strong>
|
||||
{value}
|
||||
{unit ? <small>{unit}</small> : null}
|
||||
</strong>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import type { ReactNode } from 'react'
|
||||
|
||||
type GlowPanelProps = {
|
||||
title?: string
|
||||
tone?: 'blue' | 'green' | 'amber'
|
||||
className?: string
|
||||
children: ReactNode
|
||||
}
|
||||
|
||||
export function GlowPanel({ title, tone = 'blue', className = '', children }: GlowPanelProps) {
|
||||
return (
|
||||
<section className={`vk-glow-panel tone-${tone} ${className}`}>
|
||||
{title ? <header>{title}</header> : null}
|
||||
<div className="vk-glow-panel-body">{children}</div>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
type ScrollTableColumn<T> = {
|
||||
key: keyof T
|
||||
title: string
|
||||
width?: string
|
||||
}
|
||||
|
||||
type ScrollTableProps<T extends Record<string, string | number>> = {
|
||||
columns: Array<ScrollTableColumn<T>>
|
||||
rows: T[]
|
||||
}
|
||||
|
||||
export function ScrollTable<T extends Record<string, string | number>>({ columns, rows }: ScrollTableProps<T>) {
|
||||
return (
|
||||
<div className="vk-scroll-table">
|
||||
<div className="vk-scroll-table-head">
|
||||
{columns.map((column) => (
|
||||
<span key={String(column.key)} style={{ width: column.width }}>
|
||||
{column.title}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
<div className="vk-scroll-table-body">
|
||||
{rows.map((row, index) => (
|
||||
<div className="vk-scroll-table-row" key={index}>
|
||||
{columns.map((column) => (
|
||||
<span key={String(column.key)} style={{ width: column.width }}>
|
||||
{row[column.key]}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
type SectionTitleProps = {
|
||||
title: string
|
||||
subtitle?: string
|
||||
}
|
||||
|
||||
export function SectionTitle({ title, subtitle }: SectionTitleProps) {
|
||||
return (
|
||||
<div className="vk-section-title">
|
||||
<strong>{title}</strong>
|
||||
{subtitle ? <span>{subtitle}</span> : null}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
type StatusPillProps = {
|
||||
label: string
|
||||
status?: 'normal' | 'warning' | 'danger'
|
||||
}
|
||||
|
||||
export function StatusPill({ label, status = 'normal' }: StatusPillProps) {
|
||||
return <span className={`vk-status-pill status-${status}`}>{label}</span>
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
type WaterLevelProps = {
|
||||
label: string
|
||||
value: number
|
||||
unit?: string
|
||||
}
|
||||
|
||||
export function WaterLevel({ label, value, unit = '%' }: WaterLevelProps) {
|
||||
const clamped = Math.min(100, Math.max(0, value))
|
||||
|
||||
return (
|
||||
<div className="vk-water-level">
|
||||
<div className="vk-water-level-tank">
|
||||
<div className="vk-water-level-fill" style={{ height: `${clamped}%` }} />
|
||||
<strong>
|
||||
{clamped}
|
||||
<small>{unit}</small>
|
||||
</strong>
|
||||
</div>
|
||||
<span>{label}</span>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
export * from './GlowPanel'
|
||||
export * from './CornerFrame'
|
||||
export * from './SectionTitle'
|
||||
export * from './DigitalNumber'
|
||||
export * from './StatusPill'
|
||||
export * from './ScrollTable'
|
||||
export * from './WaterLevel'
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"jsx": "react-jsx"
|
||||
},
|
||||
"include": ["src"]
|
||||
}
|
||||
Reference in new issue
Block a user