Air Conditioner Skin
Give the cloud air conditioner a new look without re-implementing how it works. Behavior lives in @yunlefun-home/air-conditioner-core; the skin is yours (or your AI's) to invent. This follows the Vercel AI SDK UI / Reka UI idea: logic sinks into a headless core, visuals stay free.
Install this skill:
npx skills add YunYouJun/air-conditioner
Live demo: https://docs.ac.yunyoujun.cn/guide/ai-skin (English: /en/guide/ai-skin).
Note: Shadow DOM ::part() hooks, locale, and createAirConditionerHeadless live on main (and ship in the next release after v0.4.4). If your project is pinned to 0.4.4 or earlier, build from main or upgrade once released.
Pick a tier
| Goal | Tier | What you touch |
|---|
| Recolor / reshape the ready-made widget, keep its layout | Tier 1 · light re-skin | CSS only: --acw-* variables + ::part() on <air-conditioner-widget> |
| Invent a completely different device (retro window AC, cyberpunk panel, pixel handheld…) | Tier 2 · headless | Your own markup + createAirConditionerHeadless from core |
Start with Tier 1 when the user only wants colors, radii, shadows, or fonts. Use Tier 2 when the silhouette, controls, or layout change.
Tier 1 · Light re-skin with ::part() and --acw-*
The widget renders into Shadow DOM, so internal class names are private. Style it only through these public hooks.
npm install @yunlefun-home/air-conditioner-widget
import { cdnAssets, mountAirConditioner } from '@yunlefun-home/air-conditioner-widget'
// Browser only, after the DOM is ready.
mountAirConditioner(document.querySelector('#ac')!, {
...cdnAssets,
placement: 'inline', // 'inline' | 'top-left' | 'top-right'
locale: 'en', // 'zh' (default) | 'en'
enableAudio: false,
})
/* Cream skin: cream-white unit, caramel remote, soft rounded keys */
air-conditioner-widget {
--acw-text-color: #3b2f22;
--acw-border-color: #eadfcd;
--acw-led-on: #f59e0b;
--acw-wind-cold: #a5d8ff;
--acw-wind-hot: #ffc9a3;
}
air-conditioner-widget::part(unit) {
filter: sepia(0.18) saturate(1.1);
}
air-conditioner-widget::part(remote) {
--acw-remote-key: #f6e7cf;
--acw-remote-icon: #7c4a1e;
--acw-remote-power: #c2410c;
border-radius: 28px;
background: #fff8ee;
}
air-conditioner-widget::part(lcd) {
background: #efe3cf;
color: #4a3420;
}
Custom properties set on a ::part() element override the defaults declared inside the shadow tree, so the remote's --acw-remote-* palette can be swapped from outside.
::part() reference
| Part | Element |
|---|
root | Whole widget wrapper (data-status, data-mode live here) |
unit | Indoor unit (shell, louver, display, airflow) |
display | Seven-segment temperature window on the unit |
wind | Airflow lines below the unit |
note | Energy-saving paper note blown out of the vent |
dock | Container for the remote toggle + remote |
toggle | "Open remote / Hide remote" button (floating placements) |
remote-panel | Collapsible panel around the remote |
remote | The remote control body |
lcd | Small screen on the remote |
energy-label | Energy-efficiency sticker on the unit |
--acw-* reference
| Variable | Default | Meaning |
|---|
--acw-text-color | #141414 (#fafafa dark) | Text and icon color |
--acw-border-color | #e0e0e0 | Shell outlines |
--acw-display-color | #cccccc | Unlit display segments |
--acw-led-on | #38f709 | Power LED when on |
--acw-wind-track | rgba(187,187,187,.28) | Airflow track |
--acw-wind-cold / --acw-wind-hot | #8cc4f2 / #f6ad7b | Airflow colors per mode |
--acw-remote-key / --acw-remote-icon | #f2f3f5 / #5f6368 | Remote keys (set on ::part(remote)) |
--acw-remote-power / --acw-remote-cold / --acw-remote-hot | #e5484d / #1e88e5 / #fb8c00 | Remote accent keys (set on ::part(remote)) |
--acw-floating-z-index | 1000 | Stacking order for corner placements |
--acw-motion-duration-* / --acw-motion-ease-* | from core acMotion | Motion tokens; collapse under reduced motion |
--acw-mist | 0–1 | Cold-mist density (written by the widget from state) |
--acw-drip-cycle | e.g. 12000ms | Condensation drip interval (only when dripping) |
--acw-wind-pace / --acw-wind-strength | per fan speed | Airflow speed / opacity (written from state) |
The last three are outputs derived from state: read them in your CSS, do not hard-code them.
Tier 2 · Headless core: build any shell
npm install @yunlefun-home/air-conditioner-core
createAirConditionerHeadless(options?) wraps the real store and returns commands plus prop getters. Spread the getters onto your own elements; every getter already knows the current state and locale.
import { createAirConditionerHeadless } from '@yunlefun-home/air-conditioner-core'
const ac = createAirConditionerHeadless({
locale: 'en', // 'zh' | 'en' — screen-reader labels
storage: null, // or a Storage-like object; defaults to localStorage in browsers
initialState: { status: true, mode: 'cold', temperature: 26 },
})
ac.subscribe(() => render(ac.getState()))
ac.run('power') // 'power' | 'cold' | 'hot' | 'increase' | 'decrease' | 'swing' | 'sound' | 'fan'
| Member | Purpose |
|---|
getState() / subscribe(listener) / dispatch(action) / store | Raw store access; subscribe returns an unsubscribe function |
run(command) | Remote-control command; cold / hot power the unit on like a real remote |
togglePower() setMode(mode, powerOn?) increase() decrease() cycleFan() toggleSwing() cycleSound() reset() | Named shortcuts |
getRootProps() | data-status data-mode data-fan data-swing data-sound data-drip data-temperature + style with --acw-mist --acw-wind-pace --acw-wind-strength (--acw-drip-cycle when dripping) |
getUnitProps() | role="region" + aria-label summary + state data-* |
getDisplayProps() | role="img" + aria-label summary for your readout |
getButtonProps(command) | type="button", data-command, localized aria-label, aria-pressed (power / cold / hot / swing), aria-disabled at the temperature limits |
bindTempButton(el, 'increase' | 'decrease') | Press-and-hold repeat that accelerates and stops at the limit; handles keyboard clicks too. Returns cleanup |
limits / locale | Active temperature limits (default 16–31 °C, step 1) and label language |
Pure helpers for server rendering or other stores: getAcDisplayText(state, locale), getAcRootAttrs(state), getAcUnitAttrs(state, locale), getAcDisplayAttrs(state, locale), getAcButtonAttrs(state, command, locale, limits).
Sound is optional and separate: createAcAudioController(elements, { soundMode, fanSpeed }) plays beeps and the fan loop; feed it the state's sound and fan. Asset URLs come from resolveAcAudioAssets(baseUrl).
React (useSyncExternalStore)
import type { CSSProperties } from 'react'
import { createAirConditionerHeadless } from '@yunlefun-home/air-conditioner-core'
import { useEffect, useRef, useState, useSyncExternalStore } from 'react'
export function CyberAc() {
const [ac] = useState(() => createAirConditionerHeadless({ locale: 'en', storage: null }))
const state = useSyncExternalStore(ac.subscribe, ac.getState, ac.getState)
const plus = useRef<HTMLButtonElement>(null)
useEffect(() => ac.bindTempButton(plus.current!, 'increase'), [ac])
const { style, ...root } = ac.getRootProps()
return (
<div className="cyber" {...root} style={style as CSSProperties}>
<output {...ac.getDisplayProps()}>
{state.temperature}
°C
</output>
<button {...ac.getButtonProps('power')} onClick={() => ac.run('power')}>Power</button>
<button ref={plus} {...ac.getButtonProps('increase')}>+</button>
</div>
)
}
state is a new object after every change, so the snapshot is stable for React.
Vue 3
In Vue, feed the reactive state into the pure helpers so every binding updates on its own:
<script setup lang="ts">
import type { Directive } from 'vue'
import {
createAirConditionerHeadless,
getAcButtonAttrs,
getAcDisplayAttrs,
getAcRootAttrs,
} from '@yunlefun-home/air-conditioner-core'
import { onBeforeUnmount, shallowRef } from 'vue'
const ac = createAirConditionerHeadless({ locale: 'zh', storage: null })
const state = shallowRef(ac.getState())
const stop = ac.subscribe(() => {
state.value = ac.getState()
})
onBeforeUnmount(stop)
const cleanups = new WeakMap<HTMLElement, () => void>()
const vTemp: Directive<HTMLElement, 'increase' | 'decrease'> = {
mounted: (el, { value }) => cleanups.set(el, ac.bindTempButton(el, value)),
unmounted: el => cleanups.get(el)?.(),
}
</script>
<template>
<div class="retro" v-bind="getAcRootAttrs(state)">
<span v-bind="getAcDisplayAttrs(state, 'zh')">{{ state.temperature }}°C</span>
<button v-bind="getAcButtonAttrs(state, 'power', 'zh', ac.limits)" @click="ac.run('power')">
电源
</button>
<button v-temp="'increase'" v-bind="getAcButtonAttrs(state, 'increase', 'zh', ac.limits)">
+
</button>
</div>
</template>
State reference
interface AcState {
status: boolean // power
mode: 'cold' | 'hot'
temperature: number // current mode's target, clamped to limits (default 16–31)
temperatures?: Record<'cold' | 'hot', number> // per-mode memory, like a real remote
sound: 'normal' | 'sleep' | 'mute'
swing: boolean
fan?: 'auto' | 'low' | 'medium' | 'high'
}
type AcRemoteCommand = 'power' | 'cold' | 'hot' | 'increase' | 'decrease' | 'swing' | 'sound' | 'fan'
data-* reference (from getRootProps())
| Attribute | Values | Style idea |
|---|
data-status | on / off | Light up displays, open louvers, start airflow |
data-mode | cold / hot | Ice-cyan vs lava-orange accents |
data-fan | auto / low / medium / high | Fan bars; pair with --acw-wind-pace |
data-swing | on / off | Sweep animation for louvers / airflow |
data-sound | normal / sleep / mute | Speaker icon |
data-drip | on / off | Show a condensation droplet using --acw-drip-cycle |
data-temperature | "16"–"31" | Gauges, knob angle |
Design recipes
- Retro '94 window AC — warm beige plastic (
#efe6d2), inset louver grille whose slats tilt open when data-status="on" and sweep when data-swing="on", amber seven-segment readout (Digital-7 font, glow via text-shadow), chunky mechanical keys with a 3px key-base shadow that collapses on :active, a rotary knob mapped from limits.min..limits.max to −135°…135°, red power key with a green LED.
- Cyber liquid-cooled — dark brushed-metal panel (
repeating-linear-gradient grain), chamfered corners via clip-path, a HUD ring gauge with conic-gradient filled by (temperature - min) / (max - min), glow strip that is ice-cyan for cold, lava-orange for hot, slate when off; flow speed from calc(1.8s * var(--acw-wind-pace)).
- 8-Bit pixel handheld — Game Boy style body with stepped pixel borders (
box-shadow in 4px steps), LCD palette per state (mint for cold, amber for hot, unlit olive when off), pixel-art snowflake / sun / power icons drawn with box-shadow, D-pad up/down = increase/decrease, left/right = cold/hot, A = power, B = fan, SELECT = swing.
Pitfalls checklist
- Never hard-code 16 / 31. Read
ac.limits (real devices such as Home Assistant climate entities report their own range and step). Use aria-disabled from getButtonProps to dim the limit keys.
- Respect
prefers-reduced-motion. Stop louver sweeps, airflow loops, and drips; keep static state cues (color, labels).
- Do not reach into the widget's Shadow DOM or depend on internal
.acw-* classes — only ::part() and --acw-* are public.
- Keep accessible names. Spread
getButtonProps(); if you show visible text, make sure it matches the stable label (e.g. visible "Power", aria-label="Power" with aria-pressed conveying on/off). Keep focus outlines visible.
- Use
bindTempButton for + / − instead of your own setInterval; it accelerates, stops at the limit, and does not double-fire on keyboard.
- Do not fake state. Derive every visual from
getState() / getRootProps() so switching skins or syncing with real devices stays correct.
- SSR: create the headless instance on the client (or pass
storage: null) and only call bindTempButton after mount.
- Audio needs a user gesture. Start
createAcAudioController after the first interaction and honor sound: 'mute'.