Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enabled auto-focus on magnet url input. #450

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
154 changes: 77 additions & 77 deletions src/components/InputMultiple/InputMultiple.svelte
Original file line number Diff line number Diff line change
@@ -1,77 +1,77 @@
<script>
import Input from '~components/Input';

export let values;
export let type = 'text';
export let label = null;

$: {
if (!values.length) {
values = [''];
}
}

function getAddons(index) {
const addons = [
{
iconName: 'Add',
onClick: addEmptyItem.bind(this, index),
iconSize: '14px',
},
];

if (index !== 0) {
addons.unshift({
iconName: 'Remove',
onClick: removeItem.bind(this, index),
iconSize: '14px',
});
}

return addons;
}

function addEmptyItem(index) {
const clonedValues = [...values];
clonedValues.splice(index + 1, 0, '');
values = clonedValues;
}

function removeItem(index) {
const clonedValues = [...values];
clonedValues.splice(index, 1);
values = clonedValues;
}
</script>

<div class="list">
{#if label}
<label class="label" for="input-multiple-{values.length - 1}">
{label}
</label>
{/if}
{#each values as value, index}
<Input
id="input-multiple-{index}"
type="{type}"
bind:value
addons="{getAddons(index)}"
{...$$restProps}
/>
{/each}
</div>

<style>
label {
display: block;
font-size: 13px;
margin-bottom: 3px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}

.list > :global(.container) {
margin: 0 0 8px;
}
</style>
<script>
import Input from '~components/Input';
export let values;
export let type = 'text';
export let label = null;
$: {
if (!values.length) {
values = [''];
}
}
function getAddons(index) {
const addons = [
{
iconName: 'Add',
onClick: addEmptyItem.bind(this, index),
iconSize: '14px',
},
];
if (index !== 0) {
addons.unshift({
iconName: 'Remove',
onClick: removeItem.bind(this, index),
iconSize: '14px',
});
}
return addons;
}
function addEmptyItem(index) {
const clonedValues = [...values];
clonedValues.splice(index + 1, 0, '');
values = clonedValues;
}
function removeItem(index) {
const clonedValues = [...values];
clonedValues.splice(index, 1);
values = clonedValues;
}
</script>
<div class="list">
{#if label}
<label class="label" for="input-multiple-{values.length - 1}">
{label}
</label>
{/if}
{#each values as value, index}
<Input
id="input-multiple-{index}"
type="{type}"
bind:value
addons="{getAddons(index)}"
{...$$restProps}
/>
{/each}
</div>
<style>
label {
display: block;
font-size: 13px;
margin-bottom: 3px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.list > :global(.container) {
margin: 0 0 8px;
}
</style>
7 changes: 6 additions & 1 deletion src/components/Modal/Add/Add.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@
placeholder="Torrent URL, Magnet Link or hash"
bind:values="{fileNames}"
required="{!cleanFileNames.length}"
autofocus
/>
{:else if tab === 'file'}
<InputFile
Expand Down Expand Up @@ -259,8 +260,12 @@
display: inherit;
}

.content form {
transition: opacity 500ms;
}

.content.loading-initial form {
visibility: hidden;
opacity: 0;
}

.button-group {
Expand Down