Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Zakintaliban authored May 4, 2023
1 parent 0c2d7a5 commit 5da34f5
Showing 1 changed file with 49 additions and 1 deletion.
50 changes: 49 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,52 @@ myTheme.applyColors("dark");
- `"light"`: latar belakang putih dan teks hitam
- `"night-vision"`: latar belakang _teal_ (#367978, terinspirasi dari Call of Duty©) dan teks putih

Lisensi: MIT
## Contoh Penggunaan di Aplikasi React lewat Aleph.JS

```tsx
import React, { useState, useEffect } from "https://esm.sh/react";
import Header from "../components/Header.tsx";
import Bravo_Six from "https://deno.land/x/bravo_six/mod.ts";

export default function App({ children }: { children: React.ReactNode }) {
const [colorTheme, setColorTheme] = useState("original");
const [bravoSix, setBravoSix] = useState<Bravo_Six | null>(null);

useEffect(() => {
setBravoSix(new Bravo_Six(document.body));
}, []);

const handleButtonClick = () => {
if (!bravoSix) return;

console.log("Current color theme:", colorTheme);
let newTheme;
switch (colorTheme) {
case "original":
newTheme = "dark";
break;
case "dark":
newTheme = "light";
break;
case "light":
newTheme = "night-vision";
break;
case "night-vision":
newTheme = "original";
break;
default:
newTheme = "original";
}
setColorTheme(newTheme);
bravoSix.applyColors(newTheme);
};

return (
<>
<Header />
{children}
<button onClick={handleButtonClick}>Ganti Tema Warna</button>
</>
);
}
```

0 comments on commit 5da34f5

Please sign in to comment.