Skip to content

Commit 4753840

Browse files
committed
chore: more styling, js and html structure
1 parent 8a6f528 commit 4753840

File tree

3 files changed

+59
-29
lines changed

3 files changed

+59
-29
lines changed

src/options.html

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,22 @@
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
77
<meta name="color-scheme" content="dark light" />
88
<link rel="stylesheet" href="/styles/options.css" />
9-
<!--<script src="" type="module"></script>-->
9+
<script src="/options/options.ts" type="module"></script>
1010
<title>Replace Maps Options</title>
1111
</head>
1212
<body>
13-
<form action="">
14-
<input
15-
type="text"
16-
pattern="^\S+\.[^\s\.]+$"
17-
placeholder="Hostname following the schema: ((sub.)sub.)domain.tld"
18-
name="hostname"
19-
id="hostname"
20-
required />
21-
<input type="submit" value="Disable" />
22-
</form>
23-
<div id="table">
24-
<div>
25-
<p>a</p>
26-
<p>b</p>
27-
</div>
28-
<div>b</div>
29-
<div>c</div>
30-
<div>d</div>
31-
<div>e</div>
32-
</div>
13+
<section class="form">
14+
<form action="">
15+
<input
16+
type="text"
17+
pattern="^\S+\.[^\s\.]+$"
18+
placeholder="Hostname following the schema: (sub.)domain.tld"
19+
name="hostname"
20+
id="hostname"
21+
required />
22+
<input type="submit" value="Disable" />
23+
</form>
24+
</section>
25+
<section class="table"></section>
3326
</body>
3427
</html>

src/options/options.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { disabledHosts, invertHostState } from '../bg/utils/storage';
2+
3+
const table = document.querySelector('.table');
4+
5+
function tableEntries() {
6+
const tableItems: HTMLDivElement[] = disabledHosts.map(createEntry);
7+
tableItems.forEach((div) => table?.insertAdjacentElement('beforeend', div));
8+
}
9+
10+
function createEntry(entryText: string, index: number): HTMLDivElement {
11+
const div = document.createElement('div');
12+
div.innerHTML = `<span>${entryText}</span><button onclick="removeEntry(${index})"></button>`;
13+
return div;
14+
}
15+
16+
// TODO: function shouldn't be removed (because 'unused')
17+
function removeEntry(index: number) {
18+
invertHostState(disabledHosts[index]).then(() => document.location.reload());
19+
}
20+
21+
tableEntries();

src/styles/options.css

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ body {
88
--text: black;
99
--bg: white;
1010

11-
--table-even: lightgrey;
12-
--table-odd: lightslategrey;
11+
--table-even: #e3e2eb;
12+
--table-odd: #c3c2cb;
1313
}
1414

1515
@media (prefers-color-scheme: dark) {
1616
:root {
1717
--text: #ccc;
1818
--bg: #1c1b22;
1919

20-
--table-even: grey;
21-
--table-odd: slategrey;
20+
--table-even: #53525b;
21+
--table-odd: #33323b;
2222
}
2323
}
2424

@@ -32,13 +32,13 @@ body {
3232
gap: 0.5rem;
3333
}
3434

35-
body > * {
35+
body > section {
3636
padding: 0.5rem;
3737
gap: 0.25rem;
3838
display: grid;
3939
}
4040

41-
#table > * {
41+
.table > * {
4242
display: flex;
4343
align-items: center;
4444
justify-content: space-between;
@@ -47,14 +47,30 @@ body > * {
4747
padding: 0.5rem 1rem;
4848
}
4949

50-
#table > :nth-child(even) {
50+
.table > :nth-child(even) {
5151
background-color: var(--table-even);
5252
}
5353

54-
#table > :nth-child(odd) {
54+
.table > :nth-child(odd) {
5555
background-color: var(--table-odd);
5656
}
5757

58+
.table button {
59+
width: 2rem;
60+
height: 2rem;
61+
}
62+
63+
.table button::before {
64+
content: 'rm';
65+
}
66+
67+
.form {
68+
position: sticky;
69+
top: 0;
70+
background-color: var(--bg);
71+
box-shadow: var(--text) 0 0 0.25rem;
72+
}
73+
5874
form {
5975
display: flex;
6076
box-sizing: border-box;

0 commit comments

Comments
 (0)