1
0
mirror of https://github.com/home-assistant/frontend.git synced 2026-04-02 00:27:49 +01:00

Add labs feature toggle, translations, and random tips

- Subscribe to frontend.windows_98 lab feature to enable/disable
- Move tips to lazy-loaded translation fragment (ui.panel.windows_98)
- Randomize tip selection
- Sort windows_98 with other fun features in labs page

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Paul Bottein
2026-03-10 09:38:47 +01:00
parent b0d5aa5e27
commit 07878563be
3 changed files with 61 additions and 39 deletions

View File

@@ -4,36 +4,13 @@ import {
applyThemesOnElement,
invalidateThemeCache,
} from "../common/dom/apply_themes_on_element";
import type { LocalizeKeys } from "../common/translations/localize";
import { subscribeLabFeature } from "../data/labs";
import { SubscribeMixin } from "../mixins/subscribe-mixin";
import type { HomeAssistant } from "../types";
import { WINDOWS_98_THEME } from "./ha-windows-98-theme";
const TIPS = [
"Try turning your house off and on again.",
"If your automation doesn't work, just add more YAML.",
"Talk to your devices. They won't answer, but it helps.",
"The best way to secure your smart home is to go back to candles.",
"Rebooting fixes everything. Everything.",
"Naming your vacuum 'DJ Roomba' increases cleaning efficiency by 200%.",
"Your automations run better when you're not looking.",
"Every time you restart Home Assistant, a smart bulb loses its pairing.",
"The cloud is just someone else's Raspberry Pi.",
"You can automate your coffee machine, but you still have to drink it yourself.",
"You can save energy by not having a home.",
"Psst... you can drag me anywhere you want!",
"Did you know? I never sleep. Well, sometimes I do. Zzz...",
"Zigbee, Z-Wave, Wi-Fi, Thread... so many protocols, so little time.",
"The sun can trigger your automations. Nature is the best sensor.",
"It looks like you're trying to automate your home! Would you like help?",
"My previous job was a paperclip. I got promoted.",
"I run entirely on YAML and good vibes.",
"Somewhere, a smart plug is blinking and nobody knows why.",
"Home Assistant runs on a Raspberry Pi. I run on hopes and dreams.",
"Behind every great home, there's someone staring at logs at 2am.",
"404: Motivation not found. Try again after coffee.",
"There are two types of people: those who back up, and those who will.",
"My favorite color is #008080. Don't ask me why.",
"Automations are just spicy if-then statements.",
];
const TIP_COUNT = 25;
type CasitaExpression =
| "hi"
@@ -49,12 +26,25 @@ const BUBBLE_TIMEOUT = 8000;
const SLEEP_TIMEOUT = 30000;
@customElement("ha-windows-98")
export class HaWindows98 extends LitElement {
export class HaWindows98 extends SubscribeMixin(LitElement) {
@property({ attribute: false }) public hass?: HomeAssistant;
@property({ type: Boolean }) public narrow = false;
@state() private _enabled = true;
@state() private _enabled = false;
public hassSubscribe() {
return [
subscribeLabFeature(
this.hass!.connection,
"frontend",
"windows_98",
(feature) => {
this._enabled = feature.enabled;
}
),
];
}
@state() private _casitaVisible = true;
@@ -82,8 +72,6 @@ export class HaWindows98 extends LitElement {
private _sleepTimer?: ReturnType<typeof setTimeout>;
private _tipIndex = 0;
private _boundPointerMove = this._onPointerMove.bind(this);
private _boundPointerUp = this._onPointerUp.bind(this);
@@ -114,6 +102,7 @@ export class HaWindows98 extends LitElement {
protected willUpdate(changedProps: Map<string, unknown>): void {
if (changedProps.has("_enabled")) {
if (this._enabled) {
this.hass!.loadFragmentTranslation("windows_98");
this._applyWin98Theme();
this._startThemeObserver();
} else {
@@ -303,8 +292,10 @@ export class HaWindows98 extends LitElement {
}
private _showTip(): void {
this._bubbleText = TIPS[this._tipIndex % TIPS.length];
this._tipIndex++;
const tipIndex = Math.floor(Math.random() * TIP_COUNT) + 1;
this._bubbleText = this.hass!.localize(
`ui.panel.windows_98.tip_${tipIndex}` as LocalizeKeys
);
this._showBubble = true;
this._expression = "ok-nabu";
this._resetSleepTimer();
@@ -388,7 +379,7 @@ export class HaWindows98 extends LitElement {
@pointerdown=${this._stopPropagation}
@click=${this._dismiss}
>
Dismiss me
${this.hass!.localize("ui.panel.windows_98.dismiss")}
</button>
<div class="bubble-arrow"></div>
</div>

View File

@@ -46,11 +46,14 @@ class HaConfigLabs extends SubscribeMixin(LitElement) {
const featuresToSort = [...features];
return featuresToSort.sort((a, b) => {
// Place frontend.winter_mode at the bottom
if (a.domain === "frontend" && a.preview_feature === "winter_mode")
return 1;
if (b.domain === "frontend" && b.preview_feature === "winter_mode")
return -1;
// Place frontend fun features at the bottom
const funFeatures = ["winter_mode", "windows_98"];
const aIsFun =
a.domain === "frontend" && funFeatures.includes(a.preview_feature);
const bIsFun =
b.domain === "frontend" && funFeatures.includes(b.preview_feature);
if (aIsFun && !bIsFun) return 1;
if (bIsFun && !aIsFun) return -1;
// Sort everything else alphabetically
return domainToName(localize, a.domain).localeCompare(

View File

@@ -10705,6 +10705,34 @@
"add_card": "Add current view as card",
"add_card_error": "Unable to add card",
"error_no_data": "You need to select some data sources first."
},
"windows_98": {
"tip_1": "Try turning your house off and on again.",
"tip_2": "If your automation doesn't work, just add more YAML.",
"tip_3": "Talk to your devices. They won't answer, but it helps.",
"tip_4": "The best way to secure your smart home is to go back to candles.",
"tip_5": "Rebooting fixes everything. Everything.",
"tip_6": "Naming your vacuum 'DJ Roomba' increases cleaning efficiency by 200%.",
"tip_7": "Your automations run better when you're not looking.",
"tip_8": "Every time you restart Home Assistant, a smart bulb loses its pairing.",
"tip_9": "The cloud is just someone else's Raspberry Pi.",
"tip_10": "You can automate your coffee machine, but you still have to drink it yourself.",
"tip_11": "You can save energy by not having a home.",
"tip_12": "Psst... you can drag me anywhere you want!",
"tip_13": "Did you know? I never sleep. Well, sometimes I do. Zzz...",
"tip_14": "Zigbee, Z-Wave, Wi-Fi, Thread... so many protocols, so little time.",
"tip_15": "The sun can trigger your automations. Nature is the best sensor.",
"tip_16": "It looks like you're trying to automate your home! Would you like help?",
"tip_17": "My previous job was a paperclip. I got promoted.",
"tip_18": "I run entirely on YAML and good vibes.",
"tip_19": "Somewhere, a smart plug is blinking and nobody knows why.",
"tip_20": "Home Assistant runs on a Raspberry Pi. I run on hopes and dreams.",
"tip_21": "Behind every great home, there's someone staring at logs at 2am.",
"tip_22": "404: Motivation not found. Try again after coffee.",
"tip_23": "There are two types of people: those who back up, and those who will.",
"tip_24": "My favorite color is #008080. Don't ask me why.",
"tip_25": "Automations are just spicy if-then statements.",
"dismiss": "Dismiss me"
}
},
"tips": {