Skip to content

Commit 06c49bb

Browse files
committed
improve settings, update some browser elements to use button component
1 parent bedb3ba commit 06c49bb

File tree

12 files changed

+159
-197
lines changed

12 files changed

+159
-197
lines changed

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,8 @@
5454
"**/Makefile": false,
5555
"**/*.sh": false,
5656
"**/dist": false
57+
},
58+
"[typescriptreact]": {
59+
"editor.defaultFormatter": "vscode.typescript-language-features"
5760
}
5861
}

packages/chrome/public/icon.png

754 KB
Loading

packages/chrome/src/components/BookmarkPopup.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Icon } from "./Icon";
33
import { browser, type BookmarkEntry } from "../Browser";
44
import { Input } from "./Input";
55
import { closeMenu } from "./Menu";
6+
import { Button } from "./Button";
67

78
export const BookmarkPopup: Component<{
89
bookmark: Stateful<BookmarkEntry>;
@@ -16,7 +17,7 @@ export const BookmarkPopup: Component<{
1617
<Input
1718
label="Title"
1819
value={this.bookmark.title}
19-
onInput={(e) =>
20+
on:input={(e) =>
2021
(this.bookmark.title = (e.target as HTMLInputElement).value)
2122
}
2223
/>
@@ -25,13 +26,13 @@ export const BookmarkPopup: Component<{
2526
<Input
2627
label="URL"
2728
value={this.bookmark.url}
28-
onInput={(e) =>
29+
on:input={(e) =>
2930
(this.bookmark.url = (e.target as HTMLInputElement).value)
3031
}
3132
/>
3233
</div>
3334
<div class="actions">
34-
<button
35+
<Button
3536
on:click={() => {
3637
if (!this.new) {
3738
browser.bookmarks = browser.bookmarks.filter(
@@ -42,9 +43,9 @@ export const BookmarkPopup: Component<{
4243
}}
4344
>
4445
{this.new ? "Cancel" : "Delete"}
45-
</button>
46-
<button
47-
class="accent"
46+
</Button>
47+
<Button
48+
variant="primary"
4849
on:click={() => {
4950
if (this.new) {
5051
browser.bookmarks = [this.bookmark, ...browser.bookmarks];
@@ -54,7 +55,7 @@ export const BookmarkPopup: Component<{
5455
}}
5556
>
5657
{this.new ? "Add" : "Save"}
57-
</button>
58+
</Button>
5859
</div>
5960
</div>
6061
);

packages/chrome/src/components/Checkbox.tsx

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,59 @@
11
import { css, type Component } from "dreamland/core";
22

3-
export const Checkbox: Component<{ value: boolean }> = function () {
3+
export const Checkbox: Component<{
4+
value: boolean;
5+
"on:change"?: (value: boolean) => void;
6+
}> = function () {
47
return (
58
<label>
6-
<input type="checkbox" checked={use(this.value)}></input>
9+
<input
10+
type="checkbox"
11+
checked={use(this.value)}
12+
on:change={(e: any) => this["on:change"]?.(e.target.checked)}
13+
></input>
714
</label>
815
);
916
};
17+
1018
Checkbox.style = css`
1119
:scope {
1220
width: 1em;
1321
height: 1em;
1422
background: var(--bg);
1523
border: 1px solid var(--bg20);
24+
display: inline-block;
25+
position: relative;
26+
border-radius: 4px;
27+
vertical-align: middle;
28+
transition:
29+
background 120ms ease,
30+
border-color 120ms ease;
31+
box-sizing: border-box;
32+
}
33+
34+
:scope::after {
35+
content: "✓";
36+
position: absolute;
37+
inset: 0;
38+
display: flex;
39+
align-items: center;
40+
justify-content: center;
41+
color: var(--bg);
42+
font-size: 0.8em;
43+
transform: scale(0);
44+
transition: transform 120ms ease;
45+
pointer-events: none;
1646
}
47+
1748
:scope:has(input:checked) {
1849
background: var(--accent);
50+
border-color: var(--accent);
51+
}
52+
53+
:scope:has(input:checked)::after {
54+
transform: scale(1);
1955
}
56+
2057
input {
2158
visibility: hidden;
2259
display: block;

packages/chrome/src/components/DownloadsPopup.tsx

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,22 @@ import { closeMenu, createMenuCustom } from "./Menu";
55
import { iconClose, iconFolder, iconOpen, iconPause } from "../icons";
66
import { formatBytes } from "../utils";
77
import { defaultFaviconUrl } from "../assets/favicon";
8+
import { Button } from "./Button";
89

910
export const DownloadsPopup: Component<{}> = function (cx) {
1011
return (
1112
<div>
1213
<div class="title">
1314
<span>Recent Downloads</span>
1415
<div class="buttoniconcontainer">
15-
<button
16+
<Button
17+
variant="icon"
1618
on:click={() => {
1719
closeMenu();
1820
}}
1921
>
2022
<Icon icon={iconClose}></Icon>
21-
</button>
23+
</Button>
2224
</div>
2325
</div>
2426
<div class="entries">
@@ -44,30 +46,32 @@ export const DownloadsPopup: Component<{}> = function (cx) {
4446
.map((b) => !b)
4547
.andThen(
4648
<>
47-
<button>
49+
<Button variant="icon">
4850
<Icon icon={iconFolder}></Icon>
49-
</button>
50-
<button>
51+
</Button>
52+
<Button variant="icon">
5153
<Icon icon={iconOpen}></Icon>
52-
</button>
54+
</Button>
5355
</>
5456
)}
5557
{use(b.progress).andThen(
5658
<>
57-
<button
59+
<Button
60+
variant="icon"
5861
on:click={() => {
5962
b.pause!();
6063
}}
6164
>
6265
<Icon icon={iconPause}></Icon>
63-
</button>
64-
<button
66+
</Button>
67+
<Button
68+
variant="icon"
6569
on:click={() => {
6670
b.cancel!();
6771
}}
6872
>
6973
<Icon icon={iconClose}></Icon>
70-
</button>
74+
</Button>
7175
</>
7276
)}
7377
</div>

packages/chrome/src/components/Input.tsx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,23 @@ export const Input: Component<{
99
required?: boolean;
1010
disabled?: boolean;
1111
autofocus?: boolean;
12-
className?: string;
13-
onInput?: (e: Event) => void;
14-
onFocus?: (e: FocusEvent) => void;
15-
onBlur?: (e: FocusEvent) => void;
16-
onKeyDown?: (e: KeyboardEvent) => void;
17-
onKeyUp?: (e: KeyboardEvent) => void;
12+
class?: string;
13+
"on:input"?: (e: Event) => void;
14+
"on:focus"?: (e: FocusEvent) => void;
15+
"on:blur"?: (e: FocusEvent) => void;
16+
"on:keydown"?: (e: KeyboardEvent) => void;
17+
"on:keyup"?: (e: KeyboardEvent) => void;
1818
}> = function (cx) {
1919
const handleInput = (e: Event) => {
2020
this.value = (e.target as HTMLInputElement).value;
2121

22-
if (this.onInput) {
23-
this.onInput(e);
22+
if (this["on:input"]) {
23+
this["on:input"](e);
2424
}
2525
};
2626

2727
return (
28-
<div class={`input-container ${this.className || ""}`}>
28+
<div class={`input-container ${this.class || ""}`}>
2929
{this.label && <label>{this.label}</label>}
3030
<input
3131
type={this.type || "text"}
@@ -36,10 +36,10 @@ export const Input: Component<{
3636
disabled={this.disabled}
3737
autofocus={this.autofocus}
3838
on:input={handleInput}
39-
on:focus={this.onFocus as any}
40-
on:blur={this.onBlur as any}
41-
on:keydown={this.onKeyDown as any}
42-
on:keyup={this.onKeyUp as any}
39+
on:focus={this["on:focus"] as any}
40+
on:blur={this["on:blur"] as any}
41+
on:keydown={this["on:keydown"] as any}
42+
on:keyup={this["on:keyup"] as any}
4343
/>
4444
</div>
4545
);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ OmnibarButton.style = css`
3232
padding: 0.25em;
3333
3434
font-size: 1.15em;
35-
color: var(--fg5);
35+
color: var(--fg2);
3636
border-radius: 0.2em;
3737
}
3838
:scope.active:hover {

packages/chrome/src/components/SiteInformationPopup.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { splitUrl } from "../utils";
44

55
import { iconClose, iconTrash, iconSettings } from "../icons";
66
import { Icon } from "./Icon";
7-
import { SmallIconButton } from "./SmallIconButton";
7+
import { Button } from "./Button";
88

99
import { closeMenu } from "./Menu";
1010

@@ -18,12 +18,14 @@ export const SiteInformationPopup: Component<{
1818
{use(this.tab.url).map((u) => splitUrl(u)[0] + splitUrl(u)[1])}
1919
</span>
2020
<div class="buttoniconscontainer">
21-
<SmallIconButton
22-
click={() => {
21+
<Button
22+
variant="icon"
23+
on:click={() => {
2324
closeMenu();
2425
}}
25-
icon={iconClose}
26-
></SmallIconButton>
26+
>
27+
<Icon icon={iconClose}></Icon>
28+
</Button>
2729
</div>
2830
</div>
2931
<div class="content">

packages/chrome/src/components/SmallIconButton.tsx

Lines changed: 0 additions & 34 deletions
This file was deleted.

packages/chrome/src/components/TabStrip.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ DragTab.style = css`
218218
color: var(--fg);
219219
220220
border-radius: 4px;
221-
padding: 7px 8px 5px 8px;
221+
padding: 7px 8px;
222222
223223
display: flex;
224224
align-items: center;
@@ -230,11 +230,13 @@ DragTab.style = css`
230230
}
231231
.main span {
232232
flex: 1;
233-
font-size: 13px;
234-
233+
font-size: 12px;
235234
overflow: hidden;
236235
white-space: nowrap;
237236
text-overflow: ellipsis;
237+
height: 100%;
238+
vertical-align: center;
239+
line-height: 100%;
238240
}
239241
.main .close > * {
240242
width: 14px;

0 commit comments

Comments
 (0)