Skip to content

Commit 96bce79

Browse files
committed
[frontend] add hover highlight to omnibar buttons, "go" button
1 parent a2436ee commit 96bce79

File tree

3 files changed

+46
-13
lines changed

3 files changed

+46
-13
lines changed

frontend/src/components/IconButton.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,24 @@ export const IconButton: Component<{
2020
};
2121
IconButton.style = css`
2222
:scope {
23-
padding: 0.4em;
23+
box-sizing: border-box;
24+
aspect-ratio: 1/1;
25+
align-items: center;
26+
justify-content: center;
27+
padding-top: 0.25em;
28+
29+
padding-bottom: 0.25em;
30+
2431
display: flex;
2532
outline: none;
2633
border: none;
2734
font-size: 1.25em;
2835
background: none;
2936
color: grey;
37+
border-radius: 0.2em;
38+
}
39+
:scope.active:hover {
40+
background-color: #fff;
3041
}
3142
:scope.active {
3243
cursor: pointer;

frontend/src/components/Omnibox.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export const Omnibox: Component<{
5656
tabUrl={use(this.tab.url)}
5757
></UrlInput>
5858
<Spacer></Spacer>
59-
<IconButton icon={iconExtension}></IconButton>
59+
<IconButton active={false} icon={iconExtension}></IconButton>
6060
<IconButton
6161
icon={iconMore}
6262
click={(e: MouseEvent) => {
@@ -97,9 +97,10 @@ Omnibox.style = css`
9797
z-index: 1;
9898
background: var(--aboutbrowser-omnibox-bg);
9999
display: flex;
100-
padding: 0px 7px 0px 7px;
100+
padding: 0 7px 0 7px;
101101
height: 2.5em;
102102
align-items: center;
103103
position: relative;
104+
gap: 0.2em;
104105
}
105106
`;

frontend/src/components/UrlInput.tsx

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
import iconShield from "@ktibow/iconset-ion/shield-outline";
88
import iconStar from "@ktibow/iconset-ion/star-outline";
99
import iconSearch from "@ktibow/iconset-ion/search";
10+
import iconForwards from "@ktibow/iconset-ion/arrow-forward";
1011
import { Icon } from "./Icon";
1112
import { browser, scramjet } from "../main";
1213
import { IconButton } from "./IconButton";
@@ -149,6 +150,19 @@ export const UrlInput: Component<
149150
this.input.scrollLeft = 0;
150151
};
151152

153+
const doSearch = () => {
154+
if (this.focusindex > 0) {
155+
browser.activetab.pushNavigate(
156+
this.overflowItems[this.focusindex - 1].url
157+
);
158+
} else {
159+
browser.searchNavigate(this.value);
160+
}
161+
162+
this.active = false;
163+
this.input.blur();
164+
};
165+
152166
this.selectContent.listen(() => {
153167
activate();
154168
});
@@ -235,16 +249,8 @@ export const UrlInput: Component<
235249
}
236250
if (e.key === "Enter") {
237251
e.preventDefault();
238-
if (this.focusindex > 0) {
239-
browser.activetab.pushNavigate(
240-
this.overflowItems[this.focusindex - 1].url
241-
);
242-
} else {
243-
browser.searchNavigate(this.value);
244-
}
245252

246-
this.active = false;
247-
this.input.blur();
253+
doSearch();
248254
}
249255
}}
250256
// keyup, we want this to happen after the input has been processed (so the user can delete the whole thing)
@@ -282,7 +288,19 @@ export const UrlInput: Component<
282288
<span class="placeholder">Search with Google or enter address</span>
283289
)}
284290

285-
<IconButton icon={iconStar}></IconButton>
291+
{use(this.active)
292+
.map((a) => !a)
293+
.andThen(<IconButton icon={iconStar}></IconButton>)}
294+
{use(this.active).andThen(
295+
<IconButton
296+
click={(e: MouseEvent) => {
297+
doSearch();
298+
e.stopPropagation();
299+
e.preventDefault();
300+
}}
301+
icon={iconForwards}
302+
></IconButton>
303+
)}
286304
</div>
287305
</div>
288306
);
@@ -380,5 +398,8 @@ UrlInput.style = css`
380398
display: flex;
381399
z-index: 1;
382400
align-items: center;
401+
402+
padding-left: 0.25em;
403+
padding-right: 0.25em;
383404
}
384405
`;

0 commit comments

Comments
 (0)