Skip to content

Commit 1b28306

Browse files
authored
fix(styles): dialog styles, bracket fixes, share contrast, scroll container (#589)
1 parent 55b81a0 commit 1b28306

File tree

11 files changed

+276
-277
lines changed

11 files changed

+276
-277
lines changed

js/app/packages/app/component/UnifiedListView.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1297,10 +1297,10 @@ export function UnifiedListView(props: UnifiedListViewProps) {
12971297
<div class="grid divide-y divide-edge">
12981298
<section class="gap-1 grid p-2">
12991299
<ToggleSwitch
1300-
size="SM"
1301-
label="Important"
1302-
checked={importantFilter()}
13031300
onChange={setImportantFilter}
1301+
checked={importantFilter()}
1302+
label="Important"
1303+
size="SM"
13041304
/>
13051305
<SegmentedControl
13061306
size="SM"

js/app/packages/app/component/command/Konsole.tsx

Lines changed: 30 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { useChannelsContext } from '@core/component/ChannelsProvider';
2+
import { ClippedPanel } from '@core/component/ClippedPanel';
3+
import { ToggleSwitch } from '@core/component/FormControls/ToggleSwitch';
24
import { StaticMarkdownContext } from '@core/component/LexicalMarkdown/component/core/StaticMarkdown';
35
import { ENABLE_SEARCH_PAGINATION } from '@core/constant/featureFlags';
46
import type { CommandWithInfo } from '@core/hotkey/getCommands';
5-
import { cornerClip } from '@core/util/clipPath';
67
import { createFreshSearch } from '@core/util/freshSort';
78
import { Popover } from '@kobalte/core';
89
import { Command as CommandK, useCommandState } from 'cmdk-solid';
@@ -45,6 +46,7 @@ import {
4546
konsoleOpen,
4647
lastCommandTime,
4748
rawQuery,
49+
setKonsoleMode,
4850
setLastCommandTime,
4951
setRawQuery,
5052
toggleKonsoleVisibility,
@@ -97,32 +99,10 @@ export function KommandMenu() {
9799
<Popover.Portal>
98100
<CommandWindow>
99101
<Popover.Content>
100-
<div class="bg-dialog mt-[25vh] border-2 border-accent w-6xl max-w-[90vw] max-h-[75vh] overflow-hidden">
101-
<div
102-
class="left-0 absolute bg-accent py-1.5 pr-10 pl-2 font-mono font-black text-menu text-xs -translate-y-full"
103-
style={{ 'clip-path': cornerClip(0, '1.5rem', 0, 0) }}
104-
>
105-
<svg
106-
fill="none"
107-
viewBox="0 0 127 16"
108-
xmlns="http://www.w3.org/2000/svg"
109-
xmlns:xlink="http://www.w3.org/1999/xlink"
110-
class="h-2"
111-
>
112-
<clipPath id="a">
113-
<path d="m.599609 0h125.8v16h-125.8z" />
114-
</clipPath>
115-
<g clip-path="url(#a)" fill="currentColor">
116-
<path d="m108.249 0c-2.397 0-4.381 1.94809-4.381 4.30241v7.37539c0 2.3543 1.984 4.3024 4.381 4.3024h13.769c2.398 0 4.382-1.9481 4.382-4.3024v-7.37539c0-2.35432-1.984-4.30241-4.382-4.30241zm0 3.68767h13.769c.368 0 .626.25328.626.61455v7.37538c0 .3612-.258.6145-.626.6145h-13.769c-.368 0-.626-.2533-.626-.6145v-7.37519c0-.36126.258-.61474.626-.61474z" />
117-
<path d="m78.8333 0v15.98h3.7552v-4.917h11.6697l2.5034 4.917h4.1994l-2.6237-5.1522c1.7427-.5698 3.0277-2.1784 3.0277-4.067v-2.45839c0-2.35432-1.984-4.30241-4.3815-4.30241zm3.7552 3.68767h14.395c.3679 0 .6258.25328.6258.61455v2.45838c0 .36127-.2579.61455-.6258.61455h-14.395z" />
118-
<path d="m58.1792 0c-2.3972 0-4.381 1.94809-4.381 4.30241v7.37539c0 2.3543 1.9838 4.3024 4.381 4.3024h18.1505v-3.6877h-18.1505c-.3679 0-.6258-.2533-.6258-.6145v-7.37559c0-.36126.2579-.61454.6258-.61454h18.1505v-3.68787z" />
119-
<path d="m33.1443.0200268c-2.3974 0-4.381 1.9480932-4.381 4.3024132v11.67776h3.7552v-4.9374h15.0209v4.9374h3.7552v-11.67776c0-2.35432-1.9836-4.3024132-4.381-4.3024132zm0 3.6876732h13.7693c.3678 0 .6258.25328.6258.61454v3.05271h-15.0209v-3.05271c0-.36126.2579-.61454.6258-.61454z" />
120-
<path d="m.599609 0v15.98h3.755211v-12.29233h2.35626c.19253 0 .38028.05969.53603.17082.15595.11093.27211.26761.33189.44746l3.8762 11.67425h3.9495l3.888-11.70783c.0564-.16983.1659-.31787.3131-.42291.1473-.10505.3245-.16159.5064-.16159h2.3931v12.29233h3.7552v-15.9802h-8.873c-.1819 0-.3591.0567425-.5064.161588-.1472.105043-.2568.253084-.3131.422918l-3.138 9.447894-3.1379-9.447894c-.0563-.169834-.1659-.317875-.31326-.422918-.14715-.1050419-.3245-.161588-.50644-.161588z" />
121-
</g>
122-
</svg>
123-
</div>
124-
125-
<KommandMenuInner commandKRef={commandKRef} />
102+
<div class="bg-dialog mt-[25vh] w-6xl max-w-[90vw] max-h-[75vh] overflow-hidden">
103+
<ClippedPanel tl active>
104+
<KommandMenuInner commandKRef={commandKRef} />
105+
</ClippedPanel>
126106
</div>
127107
</Popover.Content>
128108
</CommandWindow>
@@ -335,34 +315,42 @@ export function KommandMenuInner(props: {
335315
return (
336316
<CommandK
337317
label="Global CommandK Menu"
338-
class="flex flex-col gap-px bg-accent w-full"
318+
class="flex flex-col gap-px w-full"
339319
value={currentValue()}
340320
shouldFilter={false}
341321
onValueChange={(value) => {
342322
if (isLoadingMore()) return;
343323
setCurrentValue(value);
344324
}}
345325
>
346-
<div
347-
class="flex items-center gap-2 bg-menu p-3"
348-
style={{ 'clip-path': cornerClip(0, 0, '0.25rem', '0.25rem') }}
349-
>
350-
<span class="text-accent"></span>
326+
<div class="flex items-center gap-2 bg-panel px-2 h-[40px] border-b border-edge-muted">
327+
<span class="pl-2 pointer-events-none"></span>
351328
<CommandK.Input
352-
value={rawQuery()}
353-
placeholder="Search files..."
354-
class="flex-1 border-0 outline-none! focus:outline-none ring-0! focus:ring-0 font-mono placeholder:text-edge text-accent-270"
329+
class="flex-1 border-0 outline-none! focus:outline-none ring-0! focus:ring-0 font-mono"
355330
onValueChange={setRawQuery}
331+
placeholder="Search"
332+
value={rawQuery()}
333+
autofocus
334+
/>
335+
<ToggleSwitch
336+
onChange={(val) => {
337+
if (val) {
338+
setKonsoleMode('FULL_TEXT_SEARCH');
339+
} else {
340+
setKonsoleMode('ENTITY_SEARCH');
341+
}
342+
}}
343+
checked={isFullTextSearch()}
344+
// switchRootClass='subtle'
345+
label="Full Text Search"
346+
size="SM"
356347
/>
357348
</div>
358-
<div
359-
class="bg-menu"
360-
style={{ 'clip-path': cornerClip('0.25rem', '0.25rem', 0, 0) }}
361-
>
349+
<div class="bg-panel">
362350
<KonsoleFilter />
363351
<CommandK.List class="scrollbar-hidden">
364352
<CommandK.Empty>
365-
<div class="px-2 pb-2 text-ink-muted">
353+
<div class="px-2 text-ink-muted min-h-[40px]">
366354
{currentKonsoleMode() === 'FULL_TEXT_SEARCH' &&
367355
cleanQuery().length < 3
368356
? 'Enter 3 or more characters to search all documents.'
@@ -375,7 +363,7 @@ export function KommandMenuInner(props: {
375363
<VList
376364
data={filteredItems()}
377365
style={{ height: containerHeight() }}
378-
class="scrollbar-hidden pb-2 bg-dialog"
366+
class="scrollbar-hidden pb-2 bg-panel"
379367
>
380368
{(item, index) => (
381369
<CommandKItemWrapper index={index()} item={item} />
Lines changed: 38 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
1-
import { TextButton } from '@core/component/TextButton';
2-
import {
3-
createEffect,
4-
createSignal,
5-
For,
6-
onCleanup,
7-
onMount,
8-
Show,
9-
} from 'solid-js';
1+
import { SegmentedControl } from '@core/component/FormControls/SegmentControls';
2+
import { createMemo, onCleanup, onMount } from 'solid-js';
103
import {
114
commandCategoryIndex,
125
searchCategories,
@@ -15,8 +8,35 @@ import {
158
import { konsoleOpen } from './state';
169

1710
export function KonsoleFilter() {
18-
const [containerRef, setContainerRef] = createSignal<HTMLDivElement>();
19-
const buttonRefs: HTMLDivElement[] = [];
11+
const visibleCategories = createMemo(() => {
12+
return searchCategories
13+
.listVisible()
14+
.map((category, index) => {
15+
if (searchCategories.isCategoryActive(index)) {
16+
return category.name;
17+
}
18+
return null;
19+
})
20+
.filter(Boolean) as string[];
21+
});
22+
23+
const selectedCategoryName = createMemo(() => {
24+
const categories = searchCategories.listVisible();
25+
const index = commandCategoryIndex();
26+
if (index >= 0 && index < categories.length) {
27+
return categories[index].name;
28+
}
29+
return categories[0]?.name || '';
30+
});
31+
32+
const handleCategoryChange = (categoryName: string) => {
33+
const index = searchCategories
34+
.listVisible()
35+
.findIndex((cat) => cat.name === categoryName);
36+
if (index !== -1) {
37+
setCommandCategoryIndex(index);
38+
}
39+
};
2040

2141
onMount(() => {
2242
const down = (e: KeyboardEvent) => {
@@ -48,62 +68,14 @@ export function KonsoleFilter() {
4868
});
4969
});
5070

51-
// Scroll selected category into view when selection changes
52-
createEffect(() => {
53-
const container = containerRef();
54-
const selectedIndex = commandCategoryIndex();
55-
56-
if (container && buttonRefs[selectedIndex]) {
57-
const selectedButtonDiv = buttonRefs[selectedIndex];
58-
59-
// Use requestAnimationFrame to ensure DOM updates are complete
60-
requestAnimationFrame(() => {
61-
const containerRect = container.getBoundingClientRect();
62-
const buttonRect = selectedButtonDiv.getBoundingClientRect();
63-
64-
const isFullyVisible =
65-
buttonRect.left >= containerRect.left &&
66-
buttonRect.right <= containerRect.right;
67-
68-
if (!isFullyVisible) {
69-
// For rightmost items like "Companies", scroll to show them fully
70-
// Add some padding so the button isn't right at the edge
71-
const scrollLeft =
72-
selectedButtonDiv.offsetLeft -
73-
container.clientWidth +
74-
selectedButtonDiv.offsetWidth +
75-
8;
76-
container.scrollTo({
77-
left: Math.max(0, scrollLeft),
78-
behavior: 'smooth',
79-
});
80-
}
81-
});
82-
}
83-
});
84-
8571
return (
86-
<div
87-
ref={setContainerRef}
88-
class="flex pb-4 overflow-x-auto scrollbar-hidden bg-transparent"
89-
>
90-
<For each={searchCategories.listVisible()}>
91-
{(item, index) => (
92-
<Show when={searchCategories.isCategoryActive(index())}>
93-
<TextButton
94-
ref={(el) => {
95-
if (el) buttonRefs[index()] = el;
96-
}}
97-
theme={
98-
index() === commandCategoryIndex() ? 'accentFill' : 'clear'
99-
}
100-
text={item.name}
101-
onMouseDown={() => setCommandCategoryIndex(index())}
102-
class="flex-shrink-0 h-auto *:h-7 *:px-2"
103-
/>
104-
</Show>
105-
)}
106-
</For>
72+
<div class="flex items-center bg-transparent border-b px-2 border-edge-muted/50 h-[40px]">
73+
<SegmentedControl
74+
onChange={handleCategoryChange}
75+
value={selectedCategoryName()}
76+
list={visibleCategories()}
77+
size="SM"
78+
/>
10779
</div>
10880
);
10981
}

js/app/packages/app/component/command/state.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export function cleanQuery(query?: string) {
4444
}
4545

4646
export const COMMAND_MODES = [
47-
// { id: 'FULL_TEXT_SEARCH', sigil: '%', label: 'Full Text Search' },
47+
{ id: 'FULL_TEXT_SEARCH', sigil: '%', label: 'Full Text Search' },
4848
// { id: "REGEX_SEARCH", sigil: "/", label: "Regex Search" },
4949
// { id: "RUN_COMMAND", sigil: ">", label: "Run" },
5050
// { id: "TEMP_CHAT", sigil: " ", label: "Temporary Chat" },

js/app/packages/app/index.css

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@
212212

213213
--color-task: var(--theme-task);
214214
--color-task-bg: color-mix(in srgb, var(--color-task), var(--color-panel) 90%);
215-
215+
216216
/* SCUFFED We probably want to let the theme determine 3 or 4 "extra" hue offsets. Rights now these are only being */
217217
/* used as debug colors and to improve the consistency of markdown block lightness/chroma with themed css */
218218
--color-accent-30: oklch(var(--a0l) var(--a0c) calc(var(--a0h) + 30deg));
@@ -243,6 +243,13 @@
243243
--color-focus: var(--color-accent);
244244
}
245245

246+
/*
247+
*{
248+
scrollbar-width: thin;
249+
scrollbar-color: var(--color-accent);
250+
}
251+
*/
252+
246253
/* NOTE: We use this as a compile-time css util in this file to be able reuse the
247254
* declarations while still being able to override the color. */
248255
@utility util-bracket-bg-image {
@@ -320,6 +327,10 @@
320327
}
321328
}
322329

330+
@utility hide-scrollbar {
331+
scrollbar-width: none;
332+
}
333+
323334
@utility bracket-* {
324335
background-image:
325336
conic-gradient(from 90deg at top 1px left 1px, #0000 90deg, var(--color-focus) 0),

0 commit comments

Comments
 (0)