-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.html
More file actions
191 lines (167 loc) · 6.92 KB
/
test.html
File metadata and controls
191 lines (167 loc) · 6.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Design System Test Bed</title>
<link rel="stylesheet" href="colors/colors.css">
<link rel="stylesheet" href="typography/typography.css">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Work+Sans:wght@400;500;600;700&display=swap" rel="stylesheet">
<style>
html, body {
height: 100%;
margin: 0;
overflow: hidden;
font-family: "Work Sans", ui-sans-serif, system-ui, sans-serif;
color: var(--Colors-Text-Body-Default);
background: var(--Colors-Backgrounds-Main-Default);
}
.test-bed-layout {
display: grid;
grid-template-columns: 250px 1fr;
height: 100%;
}
.sidebar {
background: var(--Colors-Backgrounds-Main-Default);
border-right: 1px solid var(--Colors-Stroke-Default);
padding: 20px;
overflow-y: auto;
}
.sidebar h1 {
font-size: 1.2rem;
margin-bottom: 20px;
color: var(--Colors-Text-Body-Strongest);
padding-bottom: 10px;
border-bottom: 1px solid var(--Colors-Stroke-Default);
}
.nav-section {
margin-bottom: 20px;
}
.nav-header {
font-weight: 600;
color: var(--Colors-Text-Body-Medium);
font-size: 0.85rem;
text-transform: uppercase;
margin-bottom: 10px;
letter-spacing: 0.05em;
}
.nav-links {
list-style: none;
padding: 0;
margin: 0;
}
.nav-links li {
margin-bottom: 4px;
}
.nav-links a {
display: block;
padding: 8px 12px;
color: var(--Colors-Text-Body-Default);
text-decoration: none;
border-radius: 6px;
font-size: 0.95rem;
transition: background-color 0.2s;
}
.nav-links a:hover {
background-color: var(--Colors-Backgrounds-Main-Medium);
color: var(--Colors-Text-Body-Strong);
}
.nav-links a.active {
background-color: var(--Colors-Base-Primary-100);
color: var(--Colors-Base-Primary-700);
font-weight: 500;
}
.content-frame {
width: 100%;
height: 100%;
border: none;
background: white;
}
</style>
</head>
<body>
<div class="test-bed-layout">
<aside class="sidebar">
<h1>Design System</h1>
<div class="nav-section">
<div class="nav-header">Foundations</div>
<ul class="nav-links">
<li><a href="colors/test.html" target="content-frame">Colors</a></li>
<li><a href="typography/test.html" target="content-frame">Typography</a></li>
</ul>
</div>
<div class="nav-section">
<div class="nav-header">Components</div>
<ul class="nav-links">
<li><a href="components/button/test.html" target="content-frame">Button</a></li>
<li><a href="components/boxes/test.html" target="content-frame">Boxes</a></li>
<li><a href="components/dropdown/test.html" target="content-frame">Dropdown</a></li>
<li><a href="components/horizontal-cards/test.html" target="content-frame">Horizontal Cards</a></li>
<li><a href="components/icons/test.html" target="content-frame">Icons</a></li>
<li><a href="components/input/test.html" target="content-frame">Input</a></li>
<li><a href="components/modal/test.html" target="content-frame">Modal</a></li>
<li><a href="components/numeric-slider/test.html" target="content-frame">Numeric Slider</a></li>
<li><a href="components/split-panel/test.html" target="content-frame">Split Panel</a></li>
<li><a href="components/table/test.html" target="content-frame">Table</a></li>
<li><a href="components/tags/test.html" target="content-frame">Tags</a></li>
</ul>
</div>
</aside>
<main>
<iframe name="content-frame" class="content-frame" src="colors/test.html"></iframe>
</main>
</div>
<script>
// Script to handle active state and URL state management
const links = document.querySelectorAll('.nav-links a');
const iframe = document.querySelector('iframe[name="content-frame"]');
// Function to set active link based on href
function setActiveLink(href) {
links.forEach(l => {
l.classList.toggle('active', l.getAttribute('href') === href);
});
}
// Function to load content based on URL parameter
function loadContentFromUrl() {
const params = new URLSearchParams(window.location.search);
const page = params.get('page');
if (page) {
iframe.src = page;
setActiveLink(page);
} else {
// Default to colors/test.html if no page param
const defaultPage = 'colors/test.html';
iframe.src = defaultPage;
setActiveLink(defaultPage);
// Update URL to reflect default
const newUrl = new URL(window.location);
newUrl.searchParams.set('page', defaultPage);
window.history.replaceState({ path: newUrl.href }, '', newUrl.href);
}
}
// Initial load
loadContentFromUrl();
// Handle link clicks
links.forEach(link => {
link.addEventListener('click', (e) => {
// Let the default action (loading iframe) happen?
// No, we want to update URL too.
e.preventDefault();
const href = link.getAttribute('href');
iframe.src = href;
setActiveLink(href);
// Update URL state
const newUrl = new URL(window.location);
newUrl.searchParams.set('page', href);
window.history.pushState({ path: newUrl.href }, '', newUrl.href);
});
});
// Handle browser back/forward buttons
window.addEventListener('popstate', () => {
loadContentFromUrl();
});
</script>
</body>
</html>