-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #193 from silinternational/develop
Release version 10.0.0
- Loading branch information
Showing
13 changed files
with
1,916 additions
and
1,355 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
<script> | ||
/** | ||
* @component DateInput | ||
* @description Date input with custom styling | ||
*/ | ||
/** | ||
* @prop {string} | ||
* @description sets color of input text | ||
*/ | ||
export let color = 'black' | ||
/** | ||
* @prop {string} | ||
* @description sets color of input border | ||
*/ | ||
export let borderColor = 'black' | ||
/** | ||
* @prop {string} | ||
* @description sets color of input text after blur when required and empty | ||
*/ | ||
export let errorColor = 'red' | ||
/** | ||
* @prop {string} | ||
* @description sets padding of input | ||
*/ | ||
export let padding = '12px' | ||
/** | ||
* @prop {string} | ||
* @description sets width of input | ||
*/ | ||
export let width = '220px' | ||
/** | ||
* @prop {string} | ||
* @description sets font size input text | ||
*/ | ||
export let fontSize = '14px' | ||
/** | ||
* @prop {string} | ||
* @description sets name of input | ||
*/ | ||
export let name = '' | ||
/** | ||
* @prop {string} date in locale with no time data | ||
* @description sets initial date of input | ||
*/ | ||
export let value = '' | ||
/** | ||
* @prop {boolean} | ||
* @description sets whether input is disabled | ||
*/ | ||
export let disabled = false | ||
/** | ||
* @prop {boolean} | ||
* @description sets whether input is focused on load | ||
*/ | ||
export let autofocus = false | ||
/** | ||
* @prop {boolean} | ||
* @description sets whether input is required and has error color when empty after blur | ||
*/ | ||
export let required = false | ||
const onBlur = (e) => { | ||
if (required && !e.target.value) { | ||
e.target.style.color = errorColor | ||
e.target.style.borderColor = errorColor | ||
} | ||
} | ||
const onInput = (e) => { | ||
if (required && e.target.value) { | ||
e.target.style.color = color | ||
e.target.style.borderColor = borderColor | ||
} | ||
} | ||
const focus = (node) => autofocus && node.focus() | ||
</script> | ||
|
||
<style> | ||
*, | ||
*::before, | ||
*::after { | ||
box-sizing: border-box; | ||
} | ||
.custom-field { | ||
font-size: 14px; | ||
position: relative; | ||
border-top: 20px solid transparent; | ||
} | ||
.custom-field input { | ||
border-radius: 8px; | ||
border: 1px solid var(--border-color); | ||
font-family: var(--mdc-typography-font-family); | ||
} | ||
</style> | ||
|
||
<label class="{$$props.class} custom-field"> | ||
<input | ||
type="date" | ||
{required} | ||
{disabled} | ||
{name} | ||
bind:value | ||
on:blur={onBlur} | ||
on:input={onInput} | ||
use:focus | ||
style:color | ||
style:padding | ||
style:width | ||
style:font-size={fontSize} | ||
style:--border-color={borderColor} | ||
/> | ||
</label> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import DateInput from './DateInput.svelte' | ||
|
||
export default DateInput |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.