Skip to content

Commit f38251c

Browse files
ovflowdavivkeller
andauthored
fix: theme fixes and tiny css fixes (#589)
* fix: theme fixes and tiny css fixes * chore: footer on search * Update src/generators/web/ui/hooks/useTheme.mjs Co-authored-by: Aviv Keller <me@aviv.sh> * Update src/generators/web/template.html Co-authored-by: Aviv Keller <me@aviv.sh> --------- Co-authored-by: Aviv Keller <me@aviv.sh>
1 parent f854fcc commit f38251c

File tree

6 files changed

+118
-8
lines changed

6 files changed

+118
-8
lines changed

src/generators/web/template.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono&family=Open+Sans:ital,wght@0,300..800;1,300..800" />
2020

2121
<!-- Apply theme before paint to avoid Flash of Unstyled Content -->
22-
<script>document.documentElement.setAttribute("data-theme",localStorage.getItem("theme")||(matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"));</script>
22+
<script>document.documentElement.setAttribute("data-theme", document.documentElement.style.colorScheme = localStorage.getItem("theme") || (matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light"));</script>
2323
<script type="importmap">{{importMap}}</script>
2424
<script type="speculationrules">{{speculationRules}}</script>
2525
</head>

src/generators/web/ui/components/SearchBox/index.jsx

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,52 @@
1+
import {
2+
ArrowDownIcon,
3+
ArrowTurnDownLeftIcon,
4+
ArrowUpIcon,
5+
} from '@heroicons/react/24/solid';
16
import SearchModal from '@node-core/ui-components/Common/Search/Modal';
27
import SearchResults from '@node-core/ui-components/Common/Search/Results';
38
import SearchHit from '@node-core/ui-components/Common/Search/Results/Hit';
49

10+
import styles from './index.module.css';
511
import useOrama from '../../hooks/useOrama.mjs';
612

713
const SearchBox = () => {
814
const client = useOrama();
915

1016
return (
11-
<SearchModal client={client} placeholder={'Start typing...'}>
12-
<SearchResults
13-
noResultsTitle={'No results found for'}
14-
onHit={hit => <SearchHit document={hit.document} />}
15-
/>
17+
<SearchModal client={client} placeholder="Start typing...">
18+
<div className={styles.searchResultsContainer}>
19+
<SearchResults
20+
noResultsTitle="No results found for"
21+
onHit={hit => <SearchHit document={hit.document} />}
22+
/>
23+
</div>
24+
25+
<div className={styles.footer}>
26+
<div className={styles.shortcutWrapper}>
27+
<div className={styles.shortcutItem}>
28+
<kbd className={styles.shortcutKey}>
29+
<ArrowTurnDownLeftIcon />
30+
</kbd>
31+
<span className={styles.shortcutLabel}>to select</span>
32+
</div>
33+
34+
<div className={styles.shortcutItem}>
35+
<kbd className={styles.shortcutKey}>
36+
<ArrowDownIcon />
37+
</kbd>
38+
<kbd className={styles.shortcutKey}>
39+
<ArrowUpIcon />
40+
</kbd>
41+
<span className={styles.shortcutLabel}>to navigate</span>
42+
</div>
43+
44+
<div className={styles.shortcutItem}>
45+
<kbd className={styles.shortcutKey}>esc</kbd>
46+
<span className={styles.shortcutLabel}>to close</span>
47+
</div>
48+
</div>
49+
</div>
1650
</SearchModal>
1751
);
1852
};
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
.searchResultsContainer {
2+
display: flex;
3+
flex-grow: 1;
4+
flex-direction: column;
5+
overflow-y: auto;
6+
}
7+
8+
.footer {
9+
display: flex;
10+
justify-content: center;
11+
align-items: baseline;
12+
padding: 1rem;
13+
border-top: 1px solid var(--color-neutral-200);
14+
background-color: var(--color-neutral-100);
15+
}
16+
17+
:where([data-theme='dark'], [data-theme='dark'] *) .footer {
18+
border-top-color: var(--color-neutral-900);
19+
background-color: var(--color-neutral-950);
20+
}
21+
22+
@media (min-width: 1024px) {
23+
.footer {
24+
justify-content: space-between;
25+
border-radius: 0 0 0.75rem 0.75rem;
26+
}
27+
}
28+
29+
.shortcutWrapper {
30+
display: none;
31+
align-items: center;
32+
gap: 0.5rem;
33+
}
34+
35+
@media (min-width: 1024px) {
36+
.shortcutWrapper {
37+
display: flex;
38+
}
39+
}
40+
41+
.shortcutItem {
42+
display: flex;
43+
align-items: center;
44+
gap: 0.5rem;
45+
font-size: 0.75rem;
46+
color: var(--color-neutral-800);
47+
}
48+
49+
:where([data-theme='dark'], [data-theme='dark'] *) .shortcutItem {
50+
color: var(--color-neutral-600);
51+
}
52+
53+
.shortcutKey {
54+
font-family: var(--font-ibm-plex-mono);
55+
border-radius: 0.375rem;
56+
background-color: var(--color-neutral-200);
57+
padding: 0.25rem;
58+
font-size: 0.75rem;
59+
}
60+
61+
:where([data-theme='dark'], [data-theme='dark'] *) .shortcutKey {
62+
background-color: var(--color-neutral-900);
63+
}
64+
65+
.shortcutKey svg {
66+
width: 1rem;
67+
height: 1rem;
68+
}
69+
70+
.shortcutLabel {
71+
color: var(--color-neutral-800);
72+
}
73+
74+
:where([data-theme='dark'], [data-theme='dark'] *) .shortcutLabel {
75+
color: var(--color-neutral-600);
76+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.select {
22
width: 100%;
3+
margin-bottom: -1rem;
34
}

src/generators/web/ui/hooks/useTheme.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { useState, useEffect, useCallback } from 'react';
88
*/
99
const applyTheme = theme => {
1010
document.documentElement.setAttribute('data-theme', theme);
11+
document.documentElement.style.colorScheme = theme;
1112
localStorage.setItem('theme', theme);
1213
};
1314

src/generators/web/ui/index.css

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
}
99

1010
main {
11-
overflow-x: scroll;
12-
1311
/* Code should inherit its font size */
1412
code {
1513
font-size: inherit;

0 commit comments

Comments
 (0)