-
-
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.
- Loading branch information
1 parent
6d9ca84
commit 0fc3fe2
Showing
43 changed files
with
543 additions
and
157 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<h2>Input Tag</h2> | ||
|
||
|
||
<h3>Normal</h3> | ||
<InputTag bind:value="{val}" /> | ||
<p>Input value: {val}</p> | ||
|
||
<h3>Disabled</h3> | ||
<InputTag disabled value="disabled value" on:input="{oninput}" /> | ||
|
||
|
||
<h3>Label on the left</h3> | ||
<InputTag label="Label is on the left" labelOnTheLeft="true"/> | ||
|
||
|
||
|
||
<CodeExample html="{exampleHtml}" /> | ||
|
||
<API props="{apiProps}"/> | ||
|
||
|
||
<script> | ||
import { InputTag } from '../../../../src'; | ||
import { CodeExample } from '../../../code-example'; | ||
import { API } from '../../../api-table'; | ||
const apiProps = [ | ||
{ name: 'class', type: 'string', description: 'Additional css class name to be added to the component.' }, | ||
{ name: 'disabled', description: 'Make the input disabled.' }, | ||
{ name: 'id', type: 'string', description: 'Assign ID to the underlying input.' }, | ||
{ name: 'info', type: 'string', description: 'Show info message above the input.' }, | ||
{ name: 'error', type: 'string', description: 'Error message to show above the input.' }, | ||
{ name: 'name', type: 'string', description: 'Assign title to the underlying input.' }, | ||
{ name: 'label', type: 'string', description: 'Label for the input.' }, | ||
{ name: 'labelOnTheLeft', type: ['true', 'false'], default: 'false', description: 'Put label to the left of the input (instead of at the top). Usually in longer forms, to align labels and inputs, hence input also gets <em>width: 100%</em>, as it will be constraint by the form container.' }, | ||
{ name: 'placeholder', type: 'string', description: 'Assign placeholder to the underlying input.' }, | ||
{ name: 'required', description: 'Mark the input as <i>aria-required</i>. The actual validation must be done in the consumer.' }, | ||
{ name: 'title', type: 'string', description: 'Assign title to the underlying input.' }, | ||
{ name: 'value', type: ['string', 'number'], description: 'Initial value of the input.' }, | ||
{ name: 'bind:element', type: 'element', description: 'Exposes the HTML element of the component.' }, | ||
{ name: 'bind:inputElement', type: 'element', description: 'Exposes the HTML element of the underlying input.' }, | ||
{ name: 'on:change', type: 'function', description: 'Triggered after the value changes and the focus leaves the input.' }, | ||
{ name: 'on:input', type: 'function', description: 'Triggered as soon as the input value changes.' }, | ||
]; | ||
const exampleHtml = ` | ||
<InputTag label="Email" error="Invalid email" value="admin" on:change="{onChange}" /> | ||
<script> | ||
function onChange (e) { | ||
console.log('value', e.target.value); | ||
} | ||
</script> | ||
`; | ||
let val = ''; | ||
</script> |
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 @@ | ||
export { default as InputTag } from './InputTag.svelte'; |
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 @@ | ||
.panel p { margin: 0; } |
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,63 @@ | ||
<h2>Tag</h2> | ||
|
||
<h3>Normal</h3> | ||
<Tag>Tag 123</Tag> | ||
|
||
|
||
<h3>With icon</h3> | ||
<Tag icon="close">Closable tag</Tag> | ||
<Tag icon="plus">Add tag</Tag> | ||
|
||
|
||
<h3>Colourful</h3> | ||
<Tag color="info">Info</Tag> | ||
<Tag color="warning">Warning</Tag> | ||
<Tag color="danger">Danger</Tag> | ||
<Tag color="success">Success</Tag> | ||
<Tag color="#ac6453">Custom color</Tag> | ||
|
||
|
||
<h3>Round</h3> | ||
<Tag round>Round tag</Tag> | ||
|
||
|
||
<h3>With click action</h3> | ||
<Tag on:click="{onclick}">Click me</Tag> | ||
|
||
|
||
<CodeExample html="{exampleHtml}" /> | ||
<API props="{apiProps}"/> | ||
|
||
|
||
<script> | ||
import { Tag } from '../../../src'; | ||
import { API } from '../../api-table'; | ||
import { CodeExample } from '../../code-example'; | ||
const apiProps = [ | ||
{ name: 'class', type: 'string', description: 'Additional css class name to be added to the component.' }, | ||
{ name: 'color', type: 'string', description: 'Tag color. Standard variations are included (info, warning, danger, success). A color hash or name can also be provided.' }, | ||
{ name: 'icon', type: 'string', description: 'Icon name to display in the tag.' }, | ||
{ name: 'bind:element', type: 'element', description: 'Exposes the HTML element of the component.' }, | ||
{ name: 'on:click', type: 'function', description: 'Triggered when the tag is clicked.' }, | ||
]; | ||
const exampleHtml = ` | ||
<Tag icon="close">Closable tag</Tag> | ||
<Tag color="success">Success</Tag> | ||
<Tag color="#132231">Custom color</Tag> | ||
<Tag on:click="{onclick}">Click me</Tag> | ||
<script> | ||
function onclick () { | ||
alert('Clicked!'); | ||
} | ||
</script> | ||
`; | ||
function onclick () { | ||
alert('Clicked!'); | ||
} | ||
</script> |
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 @@ | ||
export { default as Tag } from './Tag.svelte'; |
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
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,12 @@ | ||
.input-search input { | ||
padding-left: calc(2rem + 6px); | ||
padding-right: 2rem; | ||
appearance: none; | ||
-webkit-appearance: none; | ||
} | ||
::-webkit-search-cancel-button { display: none; } | ||
|
||
.input-search .input-row>.icon { top: 1px; } | ||
|
||
.input-search-button { display: none; } | ||
.input-search-button.visible { display: inline-flex; } |
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,80 @@ | ||
<div | ||
class="input input-search {className}" | ||
class:has-error="{error}" | ||
class:has-value="{value !== ''}" | ||
class:label-on-the-left="{labelOnTheLeft === true || labelOnTheLeft === 'true'}" | ||
bind:this="{element}"> | ||
|
||
<Label {label} {disabled} for="{_id}"/> | ||
<Info msg="{info}" /> | ||
|
||
<div class="input-inner" class:disabled> | ||
<InputError id="{errorMessageId}" msg="{error}" /> | ||
|
||
<div class="input-row"> | ||
<Icon name="tag"/> | ||
|
||
<input | ||
autocomplete="off" | ||
type="text" | ||
{...props} | ||
{disabled} | ||
id="{_id}" | ||
aria-invalid="{error}" | ||
aria-errormessage="{error ? errorMessageId : undefined}" | ||
aria-required="{required}" | ||
bind:this="{inputElement}" | ||
bind:value="{value}" | ||
on:input | ||
on:keydown="{onkeydown}" | ||
on:change | ||
on:focus | ||
on:blur> | ||
|
||
<Button link | ||
icon="close" | ||
class="input-search-button {value !== '' && !disabled ? 'visible' : ''}" | ||
on:click="{clear}"/> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<script> | ||
import { pluck, guid } from '../../utils'; | ||
import { Button } from '../../button'; | ||
import { Icon } from '../../icon'; | ||
import { Info } from '../../info-bar'; | ||
import { InputError } from '../input-error'; | ||
import { Label } from '../label'; | ||
$:props = pluck($$props, ['title', 'name', 'placeholder']); | ||
let className = ''; | ||
export { className as class }; | ||
export let id = ''; | ||
export let required = undefined; | ||
export let disabled = false; | ||
export let value = ''; | ||
export let label = ''; | ||
export let error = undefined; | ||
export let info = undefined; | ||
export let labelOnTheLeft = false; | ||
export let element = undefined; | ||
export let inputElement = undefined; | ||
$:_id = id || name || guid(); | ||
const errorMessageId = guid(); | ||
function clear () { | ||
value = ''; | ||
} | ||
function onkeydown (event) { | ||
if (event.key === 'Escape') clear(); | ||
} | ||
</script> |
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 @@ | ||
export { default as InputTag } from './InputTag.svelte'; |
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,34 @@ | ||
.ui-tag { | ||
border: 1px solid var(--ui-color-border); | ||
background: var(--ui-color-secondary); | ||
border-radius: var(--ui-border-radius); | ||
padding: 0.2rem 0.5rem; | ||
display: inline-flex; | ||
align-items: center; | ||
gap: 0.1rem; | ||
height: 1.6rem; | ||
cursor: default; | ||
color: var(--ui-color-text); | ||
} | ||
|
||
.ui-tag .icon { width: 1.2rem; height: 1.2rem; } | ||
|
||
.ui-tag:focus-visible { | ||
border-color: var(--ui-color-accent); | ||
box-shadow: var(--ui-shadow-focus); | ||
outline: 1px solid transparent; | ||
} | ||
|
||
.ui-tag.dark { color: #fff; } | ||
|
||
.ui-tag.round { border-radius: var(--ui-border-radius-xl); } | ||
|
||
.ui-tag.info { background-color: var(--ui-color-info); } | ||
.ui-tag.success { background-color: var(--ui-color-success); } | ||
.ui-tag.danger { background-color: var(--ui-color-danger); } | ||
.ui-tag.warning { background-color: var(--ui-color-warning); } | ||
|
||
.ui-tag.info, | ||
.ui-tag.success, | ||
.ui-tag.danger, | ||
.ui-tag.warning { color: var(--ui-color-text); } |
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,36 @@ | ||
<!-- svelte-ignore a11y-click-events-have-key-events --> | ||
<div | ||
class="ui-tag {className} {colorClass}" | ||
class:round | ||
class:dark="{color && isColorDark(color)}" | ||
style="{color ? `background-color: ${color};` : ''}" | ||
role="button" | ||
tabindex="0" | ||
bind:this="{element}" | ||
on:click="{onclick}"> | ||
{#if icon} | ||
<Icon name="{icon}"/> | ||
{/if} | ||
<slot/> | ||
</div> | ||
|
||
<script> | ||
import { createEventDispatcher } from 'svelte'; | ||
import { Icon } from '../icon'; | ||
import { isColorDark } from '../utils'; | ||
const dispatch = createEventDispatcher(); | ||
let className = ''; | ||
export { className as class }; | ||
export let round = false; | ||
export let icon = undefined; | ||
export let color = undefined; | ||
export let element = undefined; | ||
$: colorClass = (['info', 'warning', 'danger', 'success'].includes(color) ? color : ''); | ||
function onclick () { | ||
dispatch('click', { target: element }); | ||
} | ||
</script> |
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 @@ | ||
export { default as Tag } from './Tag.svelte'; |
Oops, something went wrong.