tangled
alpha
login
or
join now
leaflet.pub
/
leaflet
289
fork
atom
a tool for shared writing and social publishing
289
fork
atom
overview
issues
27
pulls
pipelines
some tweaks to post selector and combobox
cozylittle.house
3 weeks ago
1adcb2ab
1f5b557c
+46
-30
2 changed files
expand all
collapse all
unified
split
app
lish
[did]
[publication]
dashboard
PublicationAnalytics.tsx
components
Combobox.tsx
+22
-29
app/lish/[did]/[publication]/dashboard/PublicationAnalytics.tsx
···
55
55
<div className="flex justify-between items-center gap-2 pb-2 w-full">
56
56
<div className="flex gap-2 items-center">
57
57
<h3>Traffic</h3>
58
58
-
<ArrowRightTiny />
58
58
+
<ArrowRightTiny className="text-border" />
59
59
<PostSelector
60
60
selectedPost={selectedPost}
61
61
setSelectedPost={setSelectedPost}
62
62
/>
63
63
{selectedReferror && (
64
64
<>
65
65
-
<ArrowRightTiny />
66
66
-
{selectedReferror.name}
65
65
+
<ArrowRightTiny className="text-border" />
66
66
+
<div className="text-tertiary"> {selectedReferror.name}</div>
67
67
</>
68
68
)}
69
69
</div>
···
112
112
return (
113
113
<Combobox
114
114
trigger={
115
115
-
open ? (
116
116
-
<Input
117
117
-
autoFocus
118
118
-
placeholder="search posts…"
119
119
-
className="input-with-border py-0! text-primary"
120
120
-
value={searchValue}
121
121
-
onChange={(e) => setSearchValue(e.target.value)}
122
122
-
onClick={(e) => e.stopPropagation()}
123
123
-
onPointerDown={(e) => e.stopPropagation()}
124
124
-
/>
125
125
-
) : (
126
126
-
<button className="text-tertiary">
127
127
-
{props.selectedPost ?? "All Posts"}
128
128
-
</button>
129
129
-
)
115
115
+
<button className="text-tertiary">
116
116
+
{props.selectedPost ?? "All Posts"}
117
117
+
</button>
130
118
}
131
119
results={filteredPostsWithClear || []}
132
120
highlighted={highlighted}
···
135
123
props.setSelectedPost(highlighted);
136
124
}}
137
125
sideOffset={2}
126
126
+
searchValue={searchValue}
127
127
+
setSearchValue={setSearchValue}
128
128
+
showSearch
138
129
>
139
130
{filteredPostsWithClear.map((post) => {
140
131
if (post === "All Posts")
···
151
142
All Posts
152
143
</ComboboxResult>
153
144
{filteredPosts && filteredPosts.length !== 0 && (
154
154
-
<hr className="mx-1 text-tertiary" />
145
145
+
<hr className="mx-1 border-border-light" />
155
146
)}
156
147
</>
157
148
);
158
149
return (
159
159
-
<ComboboxResult
160
160
-
result={post}
161
161
-
onSelect={() => {
162
162
-
props.setSelectedPost(post);
163
163
-
}}
164
164
-
highlighted={highlighted}
165
165
-
setHighlighted={setHighlighted}
166
166
-
>
167
167
-
{post}
168
168
-
</ComboboxResult>
150
150
+
<>
151
151
+
<ComboboxResult
152
152
+
result={post}
153
153
+
onSelect={() => {
154
154
+
props.setSelectedPost(post);
155
155
+
}}
156
156
+
highlighted={highlighted}
157
157
+
setHighlighted={setHighlighted}
158
158
+
>
159
159
+
{post}
160
160
+
</ComboboxResult>
161
161
+
</>
169
162
);
170
163
})}
171
164
</Combobox>
+24
-1
components/Combobox.tsx
···
2
2
import * as Popover from "@radix-ui/react-popover";
3
3
import { NestedCardThemeProvider } from "components/ThemeManager/ThemeProvider";
4
4
import { create } from "zustand";
5
5
+
import { Input } from "./Input";
5
6
6
7
export const useComboboxState = create(() => ({
7
8
open: false,
···
14
15
onOpenChange,
15
16
highlighted,
16
17
setHighlighted,
18
18
+
searchValue,
19
19
+
setSearchValue,
20
20
+
showSearch,
17
21
trigger,
18
22
triggerClassName,
19
23
sideOffset,
···
26
30
onOpenChange?: (open: boolean) => void;
27
31
highlighted: string | undefined;
28
32
setHighlighted: (h: string | undefined) => void;
33
33
+
searchValue?: string;
34
34
+
setSearchValue?: (s: string) => void;
35
35
+
showSearch?: boolean;
29
36
sideOffset?: number;
30
37
}) => {
31
38
let ref = useRef<HTMLDivElement>(null);
···
112
119
`}
113
120
>
114
121
<NestedCardThemeProvider>
115
115
-
<div className="commandMenuResults w-full max-h-(--radix-popover-content-available-height) overflow-auto flex flex-col group-data-[side=top]/cmd-menu:flex-col-reverse bg-bg-page py-1 gap-0.5 border border-border rounded-md shadow-md">
122
122
+
<div
123
123
+
className={`commandMenuResults w-full max-h-(--radix-popover-content-available-height) overflow-auto flex flex-col group-data-[side=top]/cmd-menu:flex-col-reverse bg-bg-page gap-0.5 border border-border rounded-md shadow-md `}
124
124
+
>
125
125
+
{showSearch && setSearchValue ? (
126
126
+
<Input
127
127
+
autoFocus
128
128
+
placeholder="search…"
129
129
+
className={`px-3 pb-1 pt-1 text-primary focus-within:outline-none! focus:outline-none! focus-visible:outline-none! appearance-none bg-bg-page border-border-light border-b group-data-[side=top]/cmd-menu:border-t group-data-[side=top]/cmd-menu:border-b-0
130
130
+
sticky group-data-[side=top]/cmd-menu:bottom-0 top-0`}
131
131
+
value={searchValue}
132
132
+
onChange={(e) => setSearchValue(e.target.value)}
133
133
+
onClick={(e) => e.stopPropagation()}
134
134
+
onPointerDown={(e) => e.stopPropagation()}
135
135
+
/>
136
136
+
) : null}
137
137
+
<div className="space h-1 w-full bg-transparent" />
116
138
{children}
139
139
+
<div className="space h-1 w-full bg-transparent" />
117
140
</div>
118
141
</NestedCardThemeProvider>
119
142
</Popover.Content>