Skip to content

Commit 9e4ca28

Browse files
committed
Added 'Add All' and 'Clear All' buttons #1055
1 parent e1b35a3 commit 9e4ca28

File tree

3 files changed

+44
-8
lines changed

3 files changed

+44
-8
lines changed

src/pages/icons/AddIcon.svelte

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1-
<svg xmlns="http://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor">
1+
<script>
2+
export let style = ""
3+
</script>
4+
5+
<svg {style} xmlns="http://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor">
26
<path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z" />
37
</svg>

src/pages/icons/CloseIcon.svelte

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1-
<svg xmlns="http://www.w3.org/2000/svg" height="20px" viewBox="0 -960 960 960" width="20px" fill="currentColor"
1+
<script>
2+
export let style = ""
3+
</script>
4+
5+
<svg {style} xmlns="http://www.w3.org/2000/svg" height="20px" viewBox="0 -960 960 960" width="20px" fill="currentColor"
26
><path d="m291-240-51-51 189-189-189-189 51-51 189 189 189-189 51 51-189 189 189 189-51 51-189-189-189 189Z" /></svg
37
>

src/pages/options_src/Services/Instances.svelte

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,17 +136,29 @@
136136

137137
<Row>
138138
<Label>{browser.i18n.getMessage("addYourFavoriteInstances") || "Add your favorite instances"}</Label>
139+
<button
140+
on:click={() => {
141+
if (_options[selectedFrontend]) {
142+
_options[selectedFrontend] = []
143+
options.set(_options)
144+
}
145+
}}
146+
class="add"
147+
title="Remove All Instances"
148+
>
149+
<CloseIcon style="color: var(--active);" />
150+
</button>
139151
</Row>
140152
<div dir="ltr">
141153
<Row>
142154
<Input
143155
bind:value={addInstanceValue}
144156
type="url"
145157
placeholder="https://instance.com"
146-
aria-label="Add instance input"
158+
title="Add instance input"
147159
on:keydown={e => e.key === "Enter" && addInstance()}
148160
/>
149-
<button on:click={addInstance} class="add" aria-label="Add the instance">
161+
<button on:click={addInstance} class="add" title="Add the instance">
150162
<AddIcon />
151163
</button>
152164
</Row>
@@ -164,7 +176,7 @@
164176
</span>
165177
<button
166178
class="add"
167-
aria-label="Remove Instance"
179+
title="Remove Instance"
168180
on:click={() => {
169181
const index = _options[selectedFrontend].indexOf(instance)
170182
if (index > -1) {
@@ -184,7 +196,23 @@
184196
{#each Object.entries(_config.networks) as [networkName, network]}
185197
{#if redirects[selectedFrontend] && redirects[selectedFrontend][networkName] && redirects[selectedFrontend][networkName].length > 0}
186198
<Row></Row>
187-
<Row><Label>{network.name}</Label></Row>
199+
<Row>
200+
<Label>{network.name}</Label>
201+
<button
202+
on:click={() => {
203+
if (_options[selectedFrontend]) {
204+
for (const instance of redirects[selectedFrontend][networkName]) {
205+
if (!_options[selectedFrontend].includes(instance)) _options[selectedFrontend].push(instance)
206+
}
207+
options.set(_options)
208+
}
209+
}}
210+
class="add"
211+
title="Add All Instances"
212+
>
213+
<AddIcon style="color: var(--active);" />
214+
</button>
215+
</Row>
188216
<hr />
189217
{#each redirects[selectedFrontend][networkName] as instance}
190218
<Row>
@@ -210,7 +238,7 @@
210238
{#if !_options[selectedFrontend].includes(instance)}
211239
<button
212240
class="add"
213-
aria-label="Add instance"
241+
title="Add instance"
214242
on:click={() => {
215243
if (_options[selectedFrontend]) {
216244
_options[selectedFrontend].push(instance)
@@ -223,7 +251,7 @@
223251
{:else}
224252
<button
225253
class="add"
226-
aria-label="Remove Instance"
254+
title="Remove Instance"
227255
on:click={() => {
228256
const index = _options[selectedFrontend].indexOf(instance)
229257
if (index > -1) {

0 commit comments

Comments
 (0)