feat: rewrite to solidjs
This commit is contained in:
parent
74c6215c27
commit
afa2db26e7
21 changed files with 1074 additions and 1835 deletions
28
components/MainToggle.tsx
Normal file
28
components/MainToggle.tsx
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import { createSignal, onMount } from "solid-js";
|
||||
import { featureEnableBlock } from "@/utils/storage";
|
||||
import "./MainToggle.css";
|
||||
|
||||
export const MainToggle = (props) => {
|
||||
const [isEnabled, setIsEnabled] = createSignal(false);
|
||||
onMount(async () => {
|
||||
const getFeatureEnable = await featureEnableBlock.getValue();
|
||||
setIsEnabled(getFeatureEnable);
|
||||
});
|
||||
const toggleOnOff = () => {
|
||||
setIsEnabled(!isEnabled());
|
||||
featureEnableBlock.setValue(isEnabled());
|
||||
};
|
||||
return (
|
||||
<div>
|
||||
<button class="button-toggle" onClick={() => toggleOnOff()}>
|
||||
<img
|
||||
src="/icon/128.png"
|
||||
class={isEnabled() ? "logo logo-on" : "logo"}
|
||||
alt="let me focus logo"
|
||||
/>
|
||||
</button>
|
||||
<br />
|
||||
{isEnabled() ? "[on]" : "[off]"}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue