Skip to content

@diginestai/theme — Theme System

@diginestai/theme defines the DigiNest Maps design token system: the SpatialTheme TypeScript interface, lightTheme and darkTheme presets, and the applyTheme function that injects all tokens as CSS custom properties.


Installation

bash
pnpm add @diginestai/theme

Quick Start

tsx
import { SpatialProvider, SpatialMap } from '@diginestai/core';
import { darkTheme } from '@diginestai/theme';

<SpatialProvider>
  <SpatialMap theme={darkTheme} />
</SpatialProvider>

Or apply a custom theme at runtime:

tsx
import { applyTheme, lightTheme } from '@diginestai/theme';

const myTheme = {
  ...lightTheme,
  colors: { ...lightTheme.colors, primary: '#ff5500' },
};

applyTheme(myTheme); // writes CSS vars to document.documentElement

SpatialTheme Interface

SpatialTheme is a public alias for the internal Theme type.

typescript
interface SpatialTheme {
  mode: 'light' | 'dark';
  colors: ThemeColors;
  map: ThemeMap;
  controls: ThemeControls;
  font: ThemeFont;
  radius: ThemeRadius;
  motion: ThemeMotion;
  heatmap: ThemeHeatmap;
  sensorDefaults: Record<SensorKind, string>;
}

ThemeColors

FieldTypeDescription
primarystringBrand primary colour (hex).
primaryReshapestringDarker primary for hover/active states.
secondarystringSecondary accent colour.
accentstringHighlight / call-to-action colour.
surfacestringCard and panel background.
backgroundstringPage background.
textstringBody text colour.
borderstringDivider and outline colour.
alarmstringError / critical alert colour.
warningstringWarning alert colour.
okstringSuccess / healthy state colour.
nodatastringPlaceholder colour for missing data.

ThemeMap

FieldTypeDescription
wallFillstringIMDF wall polygon fill colour.
floorFillstringIMDF floor/unit polygon fill colour.
doorLinestringIMDF door line stroke colour.
amenityIconstringAmenity symbol fill colour.

Other Sub-Interfaces

InterfaceFieldsDescription
ThemeControlsfloorSwitcherBg, toolbarBg, infoCardBgUI control backgrounds.
ThemeFontfamily, sizeBaseFont family string and base size in px.
ThemeRadiussm, md, lgBorder radius values in px.
ThemeMotionduration, easing, durationMsAnimation duration (ms) and CSS easing string.
ThemeHeatmappalette, opacityHeatmap colour ramp (string[]) and global opacity (0–1).

SensorKind values: temperature · humidity · co2 · voc · pressure · peopleCounter.


applyTheme(theme, root?)

Writes all theme tokens as CSS custom properties on the given element (defaults to document.documentElement). Throws descriptively if required fields (heatmap.opacity, motion.durationMs, sensorDefaults) are missing.

typescript
applyTheme(myTheme);                    // apply to <html>
applyTheme(myTheme, containerRef.current); // apply to a specific element

CSS Custom Properties Reference

All properties are written by applyTheme. Consume them in custom CSS or component styles.

Colours

Custom PropertyTheme Source
--spatial-primarycolors.primary
--spatial-primary-reshapecolors.primaryReshape
--spatial-secondarycolors.secondary
--spatial-accentcolors.accent
--spatial-surfacecolors.surface
--spatial-bgcolors.background
--spatial-backgroundcolors.background (legacy alias)
--spatial-textcolors.text
--spatial-bordercolors.border
--spatial-alarmcolors.alarm
--spatial-warningcolors.warning
--spatial-okcolors.ok
--spatial-nodatacolors.nodata

Map Layer Colours

Custom PropertyTheme Source
--spatial-wall-fillmap.wallFill
--spatial-floor-fillmap.floorFill
--spatial-door-linemap.doorLine
--spatial-amenity-iconmap.amenityIcon

UI Controls

Custom PropertyTheme Source
--spatial-floor-switcher-bgcontrols.floorSwitcherBg
--spatial-toolbar-bgcontrols.toolbarBg
--spatial-info-card-bgcontrols.infoCardBg

Typography

Custom PropertyTheme Source
--spatial-font-familyfont.family
--spatial-font-size-basefont.sizeBase (px)

Spacing & Shape

Custom PropertyTheme Source
--spatial-radius-smradius.sm (px)
--spatial-radius-mdradius.md (px)
--spatial-radius-lgradius.lg (px)

Motion

Custom PropertyTheme Source
--spatial-motion-durationmotion.duration (ms)
--spatial-motion-easingmotion.easing
--spatial-motion-duration-msmotion.durationMs (ms)

Heatmap

Custom PropertyTheme Source
--spatial-heatmap-opacityheatmap.opacity

Sensor Defaults

Sensor colours follow the pattern --spatial-sensor-{kind} where {kind} is the camelCase sensor name converted to kebab-case:

Custom PropertySensor
--spatial-sensor-temperaturesensorDefaults.temperature
--spatial-sensor-humiditysensorDefaults.humidity
--spatial-sensor-co2sensorDefaults.co2
--spatial-sensor-vocsensorDefaults.voc
--spatial-sensor-pressuresensorDefaults.pressure
--spatial-sensor-people-countersensorDefaults.peopleCounter

Bundled Presets

Both presets satisfy the full SpatialTheme interface and pass applyTheme validation.

typescript
import { lightTheme, darkTheme } from '@diginestai/theme';
PresetmodePrimaryBackgroundText
lightTheme'light'#2393d4#ffffff#1a1a2e
darkTheme'dark'#38b2f5#0f172a#f1f5f9

Released under commercial licensing.