Settings refactor
This commit is contained in:
parent
8a9c013f24
commit
25258b43a7
4 changed files with 538 additions and 664 deletions
58
src/components/SettingsInput.svelte
Normal file
58
src/components/SettingsInput.svelte
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
<script lang="ts">
|
||||||
|
import {
|
||||||
|
Input,
|
||||||
|
InputGroup,
|
||||||
|
InputGroupText,
|
||||||
|
Label,
|
||||||
|
FormText,
|
||||||
|
Col,
|
||||||
|
Row
|
||||||
|
} from '@sveltestrap/sveltestrap';
|
||||||
|
|
||||||
|
export let id: string;
|
||||||
|
export let label: string;
|
||||||
|
export let value: string | number;
|
||||||
|
export let type: string = 'text';
|
||||||
|
export let size: string = 'sm';
|
||||||
|
export let required: boolean = false;
|
||||||
|
export let min: number | undefined = undefined;
|
||||||
|
export let max: number | undefined = undefined;
|
||||||
|
export let step: number | string | undefined = undefined;
|
||||||
|
export let suffix: string | undefined = undefined;
|
||||||
|
export let helpText: string | undefined = undefined;
|
||||||
|
export let disabled: boolean = false;
|
||||||
|
export let valid: boolean | undefined = undefined;
|
||||||
|
export let invalid: boolean | undefined = undefined;
|
||||||
|
export let minlength: string | undefined = undefined;
|
||||||
|
export let onChange: (() => void) | undefined = undefined;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<Row>
|
||||||
|
<Label md={6} for={id} {size}>{label}</Label>
|
||||||
|
<Col md="6">
|
||||||
|
<InputGroup {size}>
|
||||||
|
<Input
|
||||||
|
{id}
|
||||||
|
{type}
|
||||||
|
bind:value
|
||||||
|
{required}
|
||||||
|
{min}
|
||||||
|
{max}
|
||||||
|
{step}
|
||||||
|
{disabled}
|
||||||
|
{valid}
|
||||||
|
{invalid}
|
||||||
|
{minlength}
|
||||||
|
bsSize={size}
|
||||||
|
on:change={onChange}
|
||||||
|
/>
|
||||||
|
{#if suffix}
|
||||||
|
<InputGroupText>{suffix}</InputGroupText>
|
||||||
|
{/if}
|
||||||
|
<slot />
|
||||||
|
</InputGroup>
|
||||||
|
{#if helpText}
|
||||||
|
<FormText>{helpText}</FormText>
|
||||||
|
{/if}
|
||||||
|
</Col>
|
||||||
|
</Row>
|
34
src/components/SettingsSelect.svelte
Normal file
34
src/components/SettingsSelect.svelte
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
<script lang="ts">
|
||||||
|
import { Input, Label, FormText, Col, Row } from '@sveltestrap/sveltestrap';
|
||||||
|
|
||||||
|
export let id: string;
|
||||||
|
export let label: string;
|
||||||
|
export let value: string | number;
|
||||||
|
export let options: Array<[string, string | number]>;
|
||||||
|
export let size: string = 'sm';
|
||||||
|
export let helpText: string | undefined = undefined;
|
||||||
|
export let selectClass: string | undefined = undefined;
|
||||||
|
export let onChange: (() => void) | undefined = undefined;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<Row>
|
||||||
|
<Label md={6} for={id} {size}>{label}</Label>
|
||||||
|
<Col md="6">
|
||||||
|
<Input
|
||||||
|
{id}
|
||||||
|
type="select"
|
||||||
|
bind:value
|
||||||
|
name="select"
|
||||||
|
bsSize={size}
|
||||||
|
class={selectClass}
|
||||||
|
on:change={onChange}
|
||||||
|
>
|
||||||
|
{#each options as [key, val]}
|
||||||
|
<option value={val}>{key}</option>
|
||||||
|
{/each}
|
||||||
|
</Input>
|
||||||
|
{#if helpText}
|
||||||
|
<FormText>{helpText}</FormText>
|
||||||
|
{/if}
|
||||||
|
</Col>
|
||||||
|
</Row>
|
15
src/components/SettingsSwitch.svelte
Normal file
15
src/components/SettingsSwitch.svelte
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
<script lang="ts">
|
||||||
|
import { Input, Col } from '@sveltestrap/sveltestrap';
|
||||||
|
|
||||||
|
// Props
|
||||||
|
export let id: string;
|
||||||
|
export let checked: boolean;
|
||||||
|
export let label: string;
|
||||||
|
export let size: string = 'sm';
|
||||||
|
export let disabled: boolean = false;
|
||||||
|
export let col: { [key: string]: string } = { md: '6', xl: '12', xxl: '6' };
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<Col {...col}>
|
||||||
|
<Input {id} bind:checked type="switch" bsSize={size} {label} {disabled} />
|
||||||
|
</Col>
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue