Skip to content

Commit cea44ad

Browse files
committed
[chrome] give bookmark button proper margin and highlight
1 parent f7974c6 commit cea44ad

File tree

5 files changed

+47
-23
lines changed

5 files changed

+47
-23
lines changed

packages/chrome/src/components/Omnibar/BookmarkButton.tsx

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1-
import { createState } from "dreamland/core";
1+
import { createState, css } from "dreamland/core";
22
import { OmnibarButton } from "./OmnibarButton";
33
import { browser } from "../../Browser";
44
import { createMenuCustom } from "../Menu";
55
import { BookmarkPopup } from "../BookmarkPopup";
66
import { emToPx } from "../../utils";
77

88
import { iconStar, iconStarFilled } from "../../icons";
9+
import { Icon } from "../Icon";
910

1011
export function BookmarkButton(s: { url: URL }) {
1112
return (
12-
<OmnibarButton
13-
click={(e) => {
13+
<button
14+
on:click={(e) => {
1415
e.stopPropagation();
1516
e.preventDefault();
1617
let bookmark = browser.bookmarks.find((b) => b.url == s.url.href);
@@ -33,11 +34,34 @@ export function BookmarkButton(s: { url: URL }) {
3334
<BookmarkPopup new={isnew} bookmark={bookmark}></BookmarkPopup>
3435
);
3536
}}
36-
icon={use(browser.bookmarks, s.url).map(() =>
37-
browser.bookmarks.some((b) => b.url == s.url.href)
38-
? iconStarFilled
39-
: iconStar
40-
)}
41-
></OmnibarButton>
37+
>
38+
<Icon
39+
icon={use(browser.bookmarks, s.url).map(() =>
40+
browser.bookmarks.some((b) => b.url == s.url.href)
41+
? iconStarFilled
42+
: iconStar
43+
)}
44+
></Icon>
45+
</button>
4246
);
4347
}
48+
BookmarkButton.style = css`
49+
:scope {
50+
font-size: 1em;
51+
color: var(--fg2);
52+
display: flex;
53+
margin: 0.25em;
54+
padding: 0.25em;
55+
box-sizing: border-box;
56+
aspect-ratio: 1/1;
57+
display: flex;
58+
align-items: center;
59+
justify-content: center;
60+
61+
color: var(--fg2);
62+
border-radius: 0.2em;
63+
}
64+
:scope:hover {
65+
background: var(--bg01);
66+
}
67+
`;

packages/chrome/src/components/Omnibar/OmnibarButton.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,23 @@ import type { IconifyIcon } from "@iconify/types";
22
import { css } from "dreamland/core";
33
import { Icon } from "../Icon";
44

5-
export function OmnibarButton(s: {
5+
export function OmnibarButton(props: {
66
icon: IconifyIcon;
77
click?: (e: MouseEvent) => void;
88
rightclick?: (e: MouseEvent) => void;
99
active?: boolean;
1010
tooltip?: string;
1111
}) {
12-
s.active ??= true;
12+
props.active ??= true;
1313
return (
1414
<button
15-
disabled={use(s.active).map((x) => (x ? undefined : true))}
16-
class:active={use(s.active)}
17-
on:click={(e: MouseEvent) => s.click?.(e)}
18-
on:contextmenu={(e: MouseEvent) => s.rightclick?.(e)}
19-
title={s.tooltip}
15+
disabled={use(props.active).map((x) => (x ? undefined : true))}
16+
class:active={use(props.active)}
17+
on:click={(e: MouseEvent) => props.click?.(e)}
18+
on:contextmenu={(e: MouseEvent) => props.rightclick?.(e)}
19+
title={props.tooltip}
2020
>
21-
<Icon icon={use(s.icon)} />
21+
<Icon icon={use(props.icon)} />
2222
</button>
2323
);
2424
}

packages/chrome/src/components/Omnibar/Omnibox.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,7 @@ Omnibox.style = css`
426426
margin: 0 auto;
427427
428428
border-bottom: 1px solid var(--fg5);
429+
margin-bottom: 0.5em;
429430
}
430431
431432
.spacertext {

packages/chrome/src/components/Omnibar/SiteOptionsButton.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { iconOptions } from "../../icons";
99
export function SiteOptionsButton() {
1010
return (
1111
<button
12-
class="optionsbutton"
1312
on:click={(e: MouseEvent) => {
1413
createMenuCustom(
1514
{
@@ -27,7 +26,7 @@ export function SiteOptionsButton() {
2726
);
2827
}
2928
SiteOptionsButton.style = css`
30-
.optionsbutton {
29+
:scope {
3130
width: 100%;
3231
cursor: pointer;
3332
padding: 0;
@@ -44,7 +43,7 @@ SiteOptionsButton.style = css`
4443
justify-content: center;
4544
background: var(--bg01);
4645
}
47-
.optionsbutton:hover {
46+
:scope:hover {
4847
background: var(--bg02);
4948
}
5049
`;

packages/chrome/src/components/SmallIconButton.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ import type { IconifyIcon } from "@iconify/types";
22
import { css } from "dreamland/core";
33
import { Icon } from "./Icon";
44

5-
export function SmallIconButton(s: {
5+
export function SmallIconButton(props: {
66
click: (e: MouseEvent) => void;
77
icon: IconifyIcon;
88
}) {
99
return (
10-
<button on:click={s.click}>
11-
<Icon icon={s.icon}></Icon>
10+
<button on:click={props.click}>
11+
<Icon icon={props.icon}></Icon>
1212
</button>
1313
);
1414
}

0 commit comments

Comments
 (0)