Skip to content

Commit bd6e775

Browse files
committed
fix: resolve build errors by converting BackgroundToggle to proper ES module
1 parent fef6edb commit bd6e775

File tree

2 files changed

+32
-57
lines changed

2 files changed

+32
-57
lines changed
Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,34 @@
1-
"use strict";
2-
Object.defineProperty(exports, "__esModule", { value: true });
3-
exports.BackgroundToggle = BackgroundToggle;
4-
var react_1 = require("react");
5-
var styles_module_css_1 = require("./styles.module.css");
6-
function BackgroundToggle() {
7-
var _a = (0, react_1.useState)(true), isEnabled = _a[0], setIsEnabled = _a[1];
8-
(0, react_1.useEffect)(function () {
9-
// Load saved preference
10-
var savedPreference = localStorage.getItem('animatedBackgroundEnabled');
11-
if (savedPreference !== null) {
12-
setIsEnabled(savedPreference === 'true');
13-
}
14-
}, []);
15-
var handleToggle = function () {
16-
var newValue = !isEnabled;
17-
setIsEnabled(newValue);
18-
localStorage.setItem('animatedBackgroundEnabled', String(newValue));
19-
// Reload the page to apply changes
20-
window.location.reload();
21-
};
22-
return (<button className={styles_module_css_1.default.toggleButton} onClick={handleToggle} title={isEnabled ? 'Disable animated background' : 'Enable animated background'} aria-label={isEnabled ? 'Disable animated background' : 'Enable animated background'}>
1+
import React, { useEffect, useState } from 'react';
2+
import styles from './styles.module.css';
3+
4+
export function BackgroundToggle() {
5+
const [isEnabled, setIsEnabled] = useState(true);
6+
7+
useEffect(() => {
8+
// Load saved preference
9+
const savedPreference = localStorage.getItem('animatedBackgroundEnabled');
10+
if (savedPreference !== null) {
11+
setIsEnabled(savedPreference === 'true');
12+
}
13+
}, []);
14+
15+
const handleToggle = () => {
16+
const newValue = !isEnabled;
17+
setIsEnabled(newValue);
18+
localStorage.setItem('animatedBackgroundEnabled', String(newValue));
19+
20+
// Reload the page to apply changes
21+
window.location.reload();
22+
};
23+
24+
return (
25+
<button
26+
className={styles.toggleButton}
27+
onClick={handleToggle}
28+
title={isEnabled ? 'Disable animated background' : 'Enable animated background'}
29+
aria-label={isEnabled ? 'Disable animated background' : 'Enable animated background'}
30+
>
2331
{isEnabled ? '🎨' : '🚫'}
24-
</button>);
32+
</button>
33+
);
2534
}

src/components/BackgroundToggle/index.tsx

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)