Skip to content

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 ​

bash
pnpm add @yunlefun-home/air-conditioner

Quick Start ​

vue
<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:

bash
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 from packages/vue/public/assets.

Expected layout:

public/
└── assets/
    └── fonts/
        └── digital-7-mono.ttf
  • Audio synthesis requires no external files (assets-base-url and audio-ext are kept as optional backward-compatible props).
  • style.css references /assets/fonts/digital-7-mono.ttf by default; override @font-face in your own stylesheet if hosted elsewhere. Missing fonts fall back cleanly to monospace.

AirConditionerWidget Props ​

PropTypeDefaultDescription
initialStatePartial<AcState>—Initial state when storage is empty
storageKeystring'ac:state'localStorage persistence key
storageStorage | nulllocalStoragePass null to disable persistence
logoUrlstring'/yun-logo.svg'Center logo URL ('' hides it)
assetsBaseUrlstring'/assets'Base URL for audio files
audioExtstring'm4a'Audio extension (e.g. mp3)
enableAudiobooleantrueEnable sound effects
showEnergyLabelbooleantrueShow energy efficiency label

Events ​

EventPayloadDescription
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:

vue
<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 useAcAudio below.

You can also render AirConditioner standalone in static display mode using overrides:

vue
<template>
  <AirConditioner :overrides="{ status: true, mode: 'hot', temperature: 20 }" />
</template>

Dark Mode, Sizing & Motion ​

  • style.css follows prefers-color-scheme and supports explicit .dark / .light root 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's acMotion and honor prefers-reduced-motion: reduce.

Composables ​

useAirConditioner() ​

vue
<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):

vue
<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 ​

ExportKindDescription
AirConditionerWidgetComponentAll-in-one AC + remote + audio
AirConditionerProviderComponentProvides reactive AC context
AirConditionerComponentIndoor unit (casing, display, airflow)
RemoteControlComponentRemote control
EnergyLabelComponentEnergy efficiency label
useAirConditionerComposableRead state & dispatch commands
useOptionalAirConditionerComposableSame, returns null outside provider
useAcAudioComposableAttach audio controller
createAirConditionerContextFunctionCreate context from a store

Released under the MIT License · The only catch is no actual wind