Skip to content

Commit 50ff98d

Browse files
committed
bug fixes, update colors
1 parent 290f8a8 commit 50ff98d

File tree

3 files changed

+66
-53
lines changed

3 files changed

+66
-53
lines changed

src/components/docs/Doc.astro

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ function color(): string {
7070
<div class="flex flex-row gap-4 flex-shrink-0">
7171
{docType.deprecated ? <h2 class="opacity-50 line-through">{docType.name}</h2> : <h2>{docType.name}</h2>}
7272
<div class="flex-auto sm:flex-0"></div>
73-
<button class="share flex sm:hidden">
73+
74+
<button class="share flex sm:hidden w-[35px] h-[35px]">
7475
<p class="p-2 hidden absolute w-64 my-auto shadow-lg
7576
rounded-full bg-l-icon-hover dark:bg-d-icon-hover">Copied to clipboard</p>
7677
<svg width="18" height="19" viewBox="0 0 18 19" xmlns="http://www.w3.org/2000/svg">
@@ -126,8 +127,7 @@ function color(): string {
126127
{[docType.examples]
127128
.filter(x => x !== null)
128129
.map(_ =>
129-
<button class="examples"
130-
style={{ backgroundColor: `#${color()}` }}>
130+
<button class="examples bg-l-icon-hover dark:bg-d-icon-hover">
131131
<svg class="transition my-auto fill-white" width="18" height="18" viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg">
132132
<path d="M8.60627 10.8563L5.88752 8.1375C5.85002 8.1 5.82202 8.0595 5.80352 8.016C5.78502 7.9725 5.77552 7.9255 5.77502 7.875C5.77502 7.775 5.80952 7.6875 5.87852 7.6125C5.94752 7.5375 6.03802 7.5 6.15002 7.5H11.85C11.9625 7.5 12.0533 7.5375 12.1223 7.6125C12.1913 7.6875 12.2255 7.775 12.225 7.875C12.225 7.9 12.1875 7.9875 12.1125 8.1375L9.39377 10.8563C9.33127 10.9188 9.26877 10.9625 9.20627 10.9875C9.14377 11.0125 9.07502 11.025 9.00002 11.025C8.92502 11.025 8.85627 11.0125 8.79377 10.9875C8.73127 10.9625 8.66877 10.9188 8.60627 10.8563Z"/>
133133
</svg>

src/components/docs/DocsFilters.astro

Lines changed: 62 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -209,58 +209,71 @@ for (let i = latestMinor + 1; i > latestMinor - 4; i--) {
209209

210210
element.classList.remove("hidden-by-type", "hidden-by-changed", "hidden-by-supported");
211211

212-
switch (attribute) {
213-
case "type":
214-
if (filter.types.length === 0) {
215-
return;
216-
}
212+
checkType(element);
213+
checkSupported(element);
214+
checkSince(element);
215+
});
216+
}
217+
218+
/**
219+
* Check if the element matches the current type filter.
220+
* @param element The element to check.
221+
*/
222+
function checkType(element: Element) {
223+
if (filter.types.length === 0) {
224+
return;
225+
}
217226

218-
for (const t of filter.types) {
219-
if (element.getAttribute("data-type")?.includes(types[t])) {
220-
return;
221-
}
222-
}
227+
for (const t of filter.types) {
228+
if (element.getAttribute("data-type")?.includes(types[t])) {
229+
return;
230+
}
231+
}
223232

224-
element.classList.add("hidden-by-type");
225-
break;
226-
case "supported":
227-
if (filter.supported === "") {
228-
return;
229-
}
230-
231-
const since1 = element.getAttribute("data-since");
232-
if (since1 === null) {
233-
return;
234-
}
235-
236-
const minor1 = parseInt(filter.supported.match(/\d+\.(\d+)/)!![1], 10);
237-
since1.matchAll(/\d+\.(\d+)/g).forEach((match) => {
238-
const otherMinor = parseInt(match[1], 10);
239-
240-
if (otherMinor > minor1) {
241-
element.classList.add("hidden-by-supported");
242-
return;
243-
}
244-
});
245-
break;
246-
case "changed":
247-
const since = element.getAttribute("data-since");
248-
if (since === null) {
249-
return;
250-
}
251-
252-
if (!since.includes(filter.changed)) {
253-
element.classList.add("hidden-by-changed");
254-
return;
255-
}
256-
break;
257-
default:
258-
console.warn(`Unknown filter type: ${button.getAttribute("data-type")}`);
259-
return;
233+
element.classList.add("hidden-by-type");
234+
}
235+
236+
/**
237+
* Check if the element matches the current supported filter.
238+
* @param element The element to check.
239+
*/
240+
function checkSupported(element: Element) {
241+
if (filter.supported === "") {
242+
return;
243+
}
244+
245+
const since1 = element.getAttribute("data-since");
246+
if (since1 === null) {
247+
return;
248+
}
249+
250+
const minor1 = parseInt(filter.supported.match(/\d+\.(\d+)/)!![1], 10);
251+
since1.matchAll(/\d+\.(\d+)/g).forEach((match) => {
252+
const otherMinor = parseInt(match[1], 10);
253+
254+
if (otherMinor > minor1) {
255+
element.classList.add("hidden-by-supported");
256+
return;
260257
}
261258
});
262259
}
263-
260+
261+
/**
262+
* Check if the element matches the current since filter.
263+
* @param element The element to check.
264+
*/
265+
function checkSince(element: Element) {
266+
const since = element.getAttribute("data-since");
267+
if (since === null) {
268+
return;
269+
}
270+
271+
if (!since.includes(filter.changed)) {
272+
element.classList.add("hidden-by-changed");
273+
return;
274+
}
275+
}
276+
264277
/**
265278
* Reset all filter buttons to their default state.
266279
*/
@@ -324,8 +337,8 @@ for (let i = latestMinor + 1; i > latestMinor - 4; i--) {
324337
button.addEventListener("click", () => handleClick(button as HTMLButtonElement));
325338
});
326339

327-
(buttons[0] as HTMLButtonElement).click();
328-
(buttons[0] as HTMLButtonElement).click();
340+
(buttons[1] as HTMLButtonElement).click();
341+
(buttons[1] as HTMLButtonElement).click();
329342
});
330343
</script>
331344

src/style.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
--color-l-search-text: #333333;
3838
--color-d-search-text: #c2c2c2;
3939

40-
--color-l-icon-hover: #C8C8C8;
40+
--color-l-icon-hover: #929292;
4141
--color-d-icon-hover: #373737;
4242

4343
--color-l-bg-secondary: #DCDCDC;

0 commit comments

Comments
 (0)