Vue 3 Wall Unit
Workshop recommendation: Vue 3 Wall Unit—one tag drops a complete AC, remote, energy sticker, and sound controller into Vue, Nuxt, or VitePress.
@yunlefun-home/air-conditioner builds on @yunlefun-home/air-conditioner-core to deliver ready-to-use Vue 3 components with automatic light/dark mode support.
Install
pnpm add @yunlefun-home/air-conditionerQuick Start
<script setup lang="ts">
import { AirConditionerWidget } from '@yunlefun-home/air-conditioner'
import '@yunlefun-home/air-conditioner/style.css'
</script>
<template>
<AirConditionerWidget storage-key="ac:state" />
</template>AirConditionerWidget bundles the state provider, AC unit, remote control, audio, and notifications out of the box.
Static Assets
All audio is now synthesized directly via the Web Audio API (zero .mp3/.m4a audio downloads), so you only need to host the seven-segment font in your project's public/ directory:
mkdir -p public/assets
cp -r node_modules/@yunlefun-home/air-conditioner/dist/assets/. public/assets/If your build lacks these files in
dist, copy them frompackages/vue/public/assets.
Expected layout:
public/
└── assets/
└── fonts/
└── digital-7-mono.ttf- Audio synthesis requires no external files (
assets-base-urlandaudio-extare kept as optional backward-compatible props). style.cssreferences/assets/fonts/digital-7-mono.ttfby default; override@font-facein your own stylesheet if hosted elsewhere. Missing fonts fall back cleanly to monospace.
AirConditionerWidget Props
| Prop | Type | Default | Description |
|---|---|---|---|
initialState | Partial<AcState> | — | Initial state when storage is empty |
storageKey | string | 'ac:state' | localStorage persistence key |
storage | Storage | null | localStorage | Pass null to disable persistence |
logoUrl | string | '/yun-logo.svg' | Center logo URL ('' hides it) |
assetsBaseUrl | string | '/assets' | Base URL for audio files |
audioExt | string | 'm4a' | Audio extension (e.g. mp3) |
enableAudio | boolean | true | Enable sound effects |
showEnergyLabel | boolean | true | Show energy efficiency label |
Events
| Event | Payload | Description |
|---|---|---|
change | (event: AcChangeEvent) | Fired on every state change |
notify | (notification: AcNotification, event: AcChangeEvent) | Fired when tips/limits trigger (see Notifications) |
Composing Manually
Wrap AirConditioner and RemoteControl with AirConditionerProvider for custom layouts:
<script setup lang="ts">
import {
AirConditioner,
AirConditionerProvider,
RemoteControl,
} from '@yunlefun-home/air-conditioner'
import '@yunlefun-home/air-conditioner/style.css'
</script>
<template>
<AirConditionerProvider storage-key="ac:state">
<AirConditioner />
<RemoteControl />
</AirConditionerProvider>
</template>Note: manual composition omits audio and toast notes unless wired with
useAcAudiobelow.
You can also render AirConditioner standalone in static display mode using overrides:
<template>
<AirConditioner :overrides="{ status: true, mode: 'hot', temperature: 20 }" />
</template>Dark Mode, Sizing & Motion
style.cssfollowsprefers-color-schemeand supports explicit.dark/.lightroot classes. The indoor unit casing stays crisp white while surrounding text and notes adapt.- Default unit geometry is 360 × 128 (
size="wide"renders 600 × 200), scaling proportionally inside narrow containers and tilting subtly with pointer movement when reduced motion is off. - Motion tokens (
--acw-motion-*) come from core'sacMotionand honorprefers-reduced-motion: reduce.
Composables
useAirConditioner()
<script setup lang="ts">
import { useAirConditioner } from '@yunlefun-home/air-conditioner'
const ac = useAirConditioner()
// ac.state.value
// ac.toggleStatus()
// ac.setMode('hot')
// ac.increase() / ac.decrease()
// ac.cycleSound()
// ac.toggleSwing()
</script>Audio Integration
Connect useAcAudio via @change on AirConditionerProvider. By default it synthesizes stereo airflow, startup chimes, and key beeps natively through Web Audio without <audio> elements (you can still pass custom <audio> element getters optionally):
<script setup lang="ts">
import { AirConditioner, AirConditionerProvider, RemoteControl, useAcAudio } from '@yunlefun-home/air-conditioner'
import '@yunlefun-home/air-conditioner/style.css'
const { handleChange } = useAcAudio()
</script>
<template>
<AirConditionerProvider @change="handleChange">
<AirConditioner />
<RemoteControl />
</AirConditionerProvider>
</template>Exports
| Export | Kind | Description |
|---|---|---|
AirConditionerWidget | Component | All-in-one AC + remote + audio |
AirConditionerProvider | Component | Provides reactive AC context |
AirConditioner | Component | Indoor unit (casing, display, airflow) |
RemoteControl | Component | Remote control |
EnergyLabel | Component | Energy efficiency label |
useAirConditioner | Composable | Read state & dispatch commands |
useOptionalAirConditioner | Composable | Same, returns null outside provider |
useAcAudio | Composable | Attach audio controller |
createAirConditionerContext | Function | Create context from a store |