Skip to content

Commit fd5b760

Browse files
fix: Fix theme toggle icons and add macOS install instructions (#447)
- Replace broken css.gg link with inline SVG moon/sun icons (fixes #434, #435) - Add macOS (Homebrew) installation section to CONTRIBUTING.md Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent bd56571 commit fd5b760

4 files changed

Lines changed: 59 additions & 5 deletions

File tree

CONTRIBUTING.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,17 @@ sudo apt-get install php-curl
1919
sudo apt-get install composer
2020
```
2121

22+
#### macOS
23+
24+
Using [Homebrew](https://brew.sh):
25+
26+
```bash
27+
brew install php
28+
brew install composer
29+
```
30+
31+
PHP on macOS typically includes the curl extension. If you need to enable it, ensure `php.ini` has `extension=curl` uncommented (run `php --ini` to find your config file).
32+
2233
#### Windows
2334

2435
Install PHP from [XAMPP](https://www.apachefriends.org/index.html) or [php.net](https://windows.php.net/download)

src/demo/css/toggle-dark.css

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,35 @@ a.darkmode {
1515
transition: 0.2s ease-in box-shadow;
1616
}
1717

18+
a.darkmode .icon-moon,
19+
a.darkmode .icon-sun {
20+
position: absolute;
21+
width: 1.25em;
22+
height: 1.25em;
23+
}
24+
25+
a.darkmode .icon-moon svg,
26+
a.darkmode .icon-sun svg {
27+
width: 100%;
28+
height: 100%;
29+
}
30+
31+
a.darkmode .icon-moon {
32+
display: block;
33+
}
34+
35+
a.darkmode .icon-sun {
36+
display: none;
37+
}
38+
39+
[data-theme="dark"] a.darkmode .icon-moon {
40+
display: none;
41+
}
42+
43+
[data-theme="dark"] a.darkmode .icon-sun {
44+
display: block;
45+
}
46+
1847
a.darkmode:hover {
1948
box-shadow: 0 0 6px rgb(0 0 0 / 16%), 0 3px 6px rgb(0 0 0 / 23%);
2049
}

src/demo/index.php

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ function gtag() {
1919
<title>Readme Typing SVG - Demo Site</title>
2020
<link rel="preconnect" href="https://fonts.gstatic.com">
2121
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Open+Sans&display=swap">
22-
<link href="https://css.gg/css?=|moon|sun" rel="stylesheet">
2322
<link rel="stylesheet" href="./css/style.css">
2423
<link rel="stylesheet" href="./css/loader.css">
2524
<link rel="stylesheet" href="./css/toggle-dark.css">
@@ -184,8 +183,25 @@ function gtag() {
184183
</div>
185184
</div>
186185

187-
<a href="javascript:toggleTheme()" class="darkmode" title="toggle dark mode">
188-
<i class="<?= isset($_COOKIE["darkmode"]) && $_COOKIE["darkmode"] == "on" ? "gg-sun" : "gg-moon" ?>"></i>
186+
<a href="javascript:toggleTheme()" class="darkmode" title="toggle dark mode" aria-label="Toggle dark mode">
187+
<span class="icon-moon" aria-hidden="true">
188+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
189+
<path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"></path>
190+
</svg>
191+
</span>
192+
<span class="icon-sun" aria-hidden="true">
193+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
194+
<circle cx="12" cy="12" r="5"></circle>
195+
<line x1="12" y1="1" x2="12" y2="3"></line>
196+
<line x1="12" y1="21" x2="12" y2="23"></line>
197+
<line x1="4.22" y1="4.22" x2="5.64" y2="5.64"></line>
198+
<line x1="18.36" y1="18.36" x2="19.78" y2="19.78"></line>
199+
<line x1="1" y1="12" x2="3" y2="12"></line>
200+
<line x1="21" y1="12" x2="23" y2="12"></line>
201+
<line x1="4.22" y1="19.78" x2="5.64" y2="18.36"></line>
202+
<line x1="18.36" y1="5.64" x2="19.78" y2="4.22"></line>
203+
</svg>
204+
</span>
189205
</a>
190206
</body>
191207

src/demo/js/toggle-dark.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,11 @@ function toggleTheme() {
1313
}
1414

1515
function darkmode() {
16-
document.querySelector(".darkmode i").className = "gg-sun";
1716
setCookie("darkmode", "on", 9999);
1817
document.body.setAttribute("data-theme", "dark");
1918
}
2019

2120
function lightmode() {
22-
document.querySelector(".darkmode i").className = "gg-moon";
2321
setCookie("darkmode", "off", 9999);
2422
document.body.removeAttribute("data-theme");
2523
}

0 commit comments

Comments
 (0)