|
1 | 1 | <!DOCTYPE html> |
2 | 2 | <html lang="en"> |
3 | 3 | <head> |
4 | | - <title>netjsongraph.js: basic examples</title> |
| 4 | + <title>netjsongraph.js: Examples</title> |
5 | 5 | <meta charset="utf-8" /> |
6 | 6 | <link rel="preconnect" href="https://fonts.googleapis.com" /> |
7 | 7 | <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin /> |
8 | 8 | <link |
9 | | - href="https://fonts.googleapis.com/css2?family=Roboto:wght@100;300;400;500;700&display=swap" |
| 9 | + href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;700&display=swap" |
10 | 10 | rel="stylesheet" |
11 | 11 | /> |
12 | 12 | <style> |
13 | | - body { |
| 13 | + :root { |
| 14 | + --bg-primary: #f4f4f4; |
| 15 | + --bg-secondary: #ffffff; |
| 16 | + --text-primary: #1a1a1a; |
| 17 | + --text-secondary: #333; |
| 18 | + --card-hover: #f0f0f0; |
| 19 | + --accent-color: #3498db; |
| 20 | + --transition-speed: 0.3s; |
| 21 | + } |
| 22 | + |
| 23 | + :root.dark-mode { |
| 24 | + --bg-primary: #121212; |
| 25 | + --bg-secondary: #1e1e1e; |
| 26 | + --text-primary: #e0e0e0; |
| 27 | + --text-secondary: #b0b0b0; |
| 28 | + --card-hover: #2c2c2c; |
| 29 | + --accent-color: #4ecdc4; |
| 30 | + } |
| 31 | + |
| 32 | + * { |
14 | 33 | margin: 0; |
15 | 34 | padding: 0; |
16 | 35 | box-sizing: border-box; |
17 | | - background-color: #eceaea; |
18 | | - overflow-x: hidden; |
19 | | - font-family: "Roboto", sans-serif; |
| 36 | + transition: background-color var(--transition-speed) ease, |
| 37 | + color var(--transition-speed) ease; |
| 38 | + } |
| 39 | + |
| 40 | + body { |
| 41 | + font-family: 'Inter', sans-serif; |
| 42 | + background-color: var(--bg-primary); |
| 43 | + color: var(--text-primary); |
| 44 | + line-height: 1.6; |
| 45 | + } |
| 46 | + |
| 47 | + .theme-toggle { |
| 48 | + position: fixed; |
| 49 | + top: 20px; |
| 50 | + right: 20px; |
| 51 | + background-color: var(--bg-secondary); |
| 52 | + border: none; |
| 53 | + padding: 10px 15px; |
| 54 | + border-radius: 20px; |
| 55 | + cursor: pointer; |
| 56 | + box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); |
| 57 | + display: flex; |
| 58 | + align-items: center; |
| 59 | + gap: 8px; |
| 60 | + font-weight: 600; |
| 61 | + color: var(--text-secondary); |
| 62 | + z-index: 1000; |
| 63 | + } |
| 64 | + |
| 65 | + .theme-toggle:hover { |
| 66 | + background-color: var(--card-hover); |
20 | 67 | } |
21 | 68 |
|
22 | 69 | header { |
23 | 70 | text-align: center; |
24 | | - color: #333; |
25 | | - font-size: 21px; |
| 71 | + padding: 40px 20px; |
| 72 | + background-color: var(--bg-secondary); |
| 73 | + box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05); |
| 74 | + } |
| 75 | + |
| 76 | + header h1 { |
| 77 | + font-size: 2.5rem; |
| 78 | + font-weight: 700; |
| 79 | + color: var(--text-primary); |
26 | 80 | } |
27 | 81 |
|
28 | 82 | main { |
29 | 83 | display: flex; |
30 | | - justify-content: space-between; |
31 | | - width: 80vw; |
| 84 | + justify-content: center; |
32 | 85 | flex-wrap: wrap; |
33 | | - margin: 50px auto; |
| 86 | + gap: 20px; |
| 87 | + max-width: 1200px; |
| 88 | + margin: 40px auto; |
| 89 | + padding: 0 20px; |
34 | 90 | } |
35 | 91 |
|
36 | | - main a { |
37 | | - text-decoration: none; |
38 | | - color: black; |
39 | | - font-size: 17px; |
40 | | - transition: all 0.2s ease; |
41 | | - text-align: center; |
42 | | - font-weight: 300; |
| 92 | + .cards { |
| 93 | + background-color: var(--bg-secondary); |
| 94 | + border-radius: 12px; |
| 95 | + box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1); |
| 96 | + transition: all var(--transition-speed) ease; |
| 97 | + overflow: hidden; |
43 | 98 | } |
44 | 99 |
|
45 | | - .cards { |
46 | | - background-color: #fff; |
47 | | - padding: 12px; |
48 | | - margin: 10px; |
| 100 | + .cards a { |
49 | 101 | display: flex; |
50 | 102 | justify-content: center; |
51 | 103 | align-items: center; |
52 | | - width: 200px; |
53 | | - transition: all 0.2s ease; |
| 104 | + text-decoration: none; |
| 105 | + color: var(--text-secondary); |
| 106 | + font-weight: 500; |
| 107 | + padding: 15px 20px; |
| 108 | + width: 250px; |
| 109 | + text-align: center; |
| 110 | + transition: all var(--transition-speed) ease; |
54 | 111 | } |
55 | 112 |
|
56 | 113 | .cards:hover { |
57 | | - transform: scale(1.2); |
58 | | - border: 1px solid red; |
| 114 | + transform: translateY(-10px); |
| 115 | + box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15); |
59 | 116 | } |
| 117 | + |
60 | 118 | .cards:hover a { |
61 | | - color: red; |
| 119 | + color: var(--accent-color); |
| 120 | + } |
| 121 | + |
| 122 | + @media (max-width: 768px) { |
| 123 | + main { |
| 124 | + flex-direction: column; |
| 125 | + align-items: center; |
| 126 | + } |
| 127 | + .cards a { |
| 128 | + width: 100%; |
| 129 | + } |
62 | 130 | } |
63 | 131 | </style> |
64 | 132 | </head> |
65 | 133 | <body> |
| 134 | + <button class="theme-toggle" aria-label="Toggle Dark Mode"> |
| 135 | + 🌓 Toggle Theme |
| 136 | + </button> |
| 137 | + |
66 | 138 | <header> |
67 | 139 | <h1>NetJSONGraph.js Example Demos</h1> |
68 | 140 | </header> |
| 141 | + |
69 | 142 | <main> |
70 | 143 | <div class="cards"> |
71 | 144 | <a href="./examples/netjsongraph.html" target="_blank">Basic usage</a> |
@@ -164,5 +237,26 @@ <h1>NetJSONGraph.js Example Demos</h1> |
164 | 237 | > |
165 | 238 | </div> |
166 | 239 | </main> |
| 240 | + |
| 241 | + <script> |
| 242 | + const themeToggle = document.querySelector('.theme-toggle'); |
| 243 | + const htmlElement = document.documentElement; |
| 244 | + |
| 245 | + // Check for saved theme preference or system preference |
| 246 | + const savedTheme = localStorage.getItem('theme'); |
| 247 | + const systemPrefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches; |
| 248 | + |
| 249 | + if (savedTheme === 'dark' || (!savedTheme && systemPrefersDark)) { |
| 250 | + htmlElement.classList.add('dark-mode'); |
| 251 | + } |
| 252 | + |
| 253 | + themeToggle.addEventListener('click', () => { |
| 254 | + htmlElement.classList.toggle('dark-mode'); |
| 255 | + |
| 256 | + // Save theme preference |
| 257 | + const currentTheme = htmlElement.classList.contains('dark-mode') ? 'dark' : 'light'; |
| 258 | + localStorage.setItem('theme', currentTheme); |
| 259 | + }); |
| 260 | + </script> |
167 | 261 | </body> |
168 | 262 | </html> |
0 commit comments