-
Notifications
You must be signed in to change notification settings - Fork 62
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
Showing
17 changed files
with
302 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
--- | ||
title: Textarea | ||
group: 'svelteuidev-core' | ||
packageGroup: '@svelteuidev/core' | ||
slug: /core/textarea/ | ||
category: 'inputs' | ||
description: 'Multiline text input' | ||
importCode: "import { Textarea } from '@svelteuidev/core';" | ||
source: 'svelteui-core/src/components/Textarea/Textarea.svelte' | ||
docs: 'core/textarea' | ||
--- | ||
|
||
<script> | ||
import { Demo, TextareaDemos } from '@svelteuidev/demos'; | ||
import { Heading } from "$lib/components"; | ||
</script> | ||
|
||
<svelte:head> | ||
|
||
<title>{title} - SvelteUI</title> | ||
</svelte:head> | ||
|
||
<Heading {title} {group} {packageGroup} {slug} {category} {description} {importCode} {source} {docs} /> | ||
|
||
## Usage | ||
|
||
<Demo demo={TextareaDemos.configurator} /> | ||
|
||
## Bindings | ||
|
||
```svelte | ||
<script> | ||
import { Textarea } from '@svelteuidev/core'; | ||
let value = ''; | ||
</script> | ||
<Textarea bind:value /> | ||
``` | ||
|
||
## Invalid state and error | ||
|
||
<Demo demo={TextareaDemos.invalid} /> | ||
|
||
## Disabled state | ||
|
||
<Demo demo={TextareaDemos.disabled} /> | ||
|
||
## With icon | ||
|
||
<Demo demo={TextareaDemos.icon} /> | ||
|
||
## With right section | ||
|
||
<Demo demo={TextareaDemos.rightsection} /> | ||
|
||
## Accessibility | ||
|
||
Provide `aria-label` in case you use component without label for screen reader support: | ||
|
||
```svelte | ||
<Textarea /> // -> not ok, input is not labeled | ||
<Textarea label="Comment" /> // -> ok, input and label are connected | ||
<Textarea aria-label="Comment" /> // -> ok, label is not visible but will be announced by screen reader | ||
``` |
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
6 changes: 3 additions & 3 deletions
6
packages/svelteui-core/src/components/TextArea/TextArea.test.ts
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 |
---|---|---|
@@ -1,8 +1,8 @@ | ||
import { describe } from 'vitest'; | ||
import { itSupportsClassName } from '@svelteuidev/tests'; | ||
|
||
import { default as TextArea } from './TextArea.svelte'; | ||
import { default as Textarea } from './Textarea.svelte'; | ||
|
||
describe('TextArea', () => { | ||
itSupportsClassName(TextArea); | ||
describe('Textarea', () => { | ||
itSupportsClassName(Textarea); | ||
}); |
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export { default as TextArea } from './TextArea.svelte'; | ||
export type { TextAreaProps } from './TextArea'; | ||
export { default as Textarea } from './Textarea.svelte'; | ||
export type { TextareaProps } from './Textarea'; |
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
62 changes: 62 additions & 0 deletions
62
packages/svelteui-demos/src/demos/core/Textarea/Textarea.demo.configurator.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,62 @@ | ||
<script lang="ts" context="module"> | ||
import type { ConfiguratorDemoType, ConfiguratorDemoConfiguration } from '$lib/types'; | ||
const codeTemplate = (props: string) => ` | ||
<script> | ||
import { Textarea } from '@svelteuidev/core'; | ||
<\/script> | ||
<Textarea${props}\/> | ||
`; | ||
export const type: ConfiguratorDemoType['type'] = 'configurator'; | ||
export const configuration: ConfiguratorDemoConfiguration = { | ||
codeTemplate, | ||
configurator: [ | ||
{ name: 'placeholder', type: 'string', initialValue: 'Once upon a time' }, | ||
{ name: 'label', type: 'string', initialValue: 'Your story' }, | ||
{ name: 'description', type: 'string' }, | ||
{ name: 'error', type: 'string' }, | ||
{ | ||
name: 'variant', | ||
type: 'select', | ||
data: [ | ||
{ label: 'default', value: 'default' }, | ||
{ label: 'filled', value: 'filled' }, | ||
{ label: 'unstyled', value: 'unstyled' }, | ||
{ label: 'headless', value: 'headless' } | ||
], | ||
initialValue: 'default', | ||
defaultValue: 'default' | ||
}, | ||
{ | ||
name: 'resize', | ||
type: 'select', | ||
data: [ | ||
{ label: 'none', value: 'none' }, | ||
{ label: 'both', value: 'both' }, | ||
{ label: 'horizontal', value: 'horizontal' }, | ||
{ label: 'vertical', value: 'vertical' } | ||
], | ||
initialValue: 'none', | ||
defaultValue: 'none' | ||
}, | ||
{ name: 'rows', type: 'number', initialValue: 3, defaultValue: 3, min: 1 }, | ||
{ name: 'radius', type: 'size', initialValue: 'sm', defaultValue: 'sm' }, | ||
{ name: 'disabled', type: 'boolean', initialValue: false, defaultValue: false }, | ||
{ name: 'required', type: 'boolean', initialValue: true, defaultValue: true }, | ||
{ name: 'invalid', type: 'boolean', initialValue: false, defaultValue: false } | ||
], | ||
multiline: true | ||
}; | ||
</script> | ||
|
||
<script lang="ts"> | ||
import type { TextareaProps } from '@svelteuidev/core'; | ||
import { Textarea } from '@svelteuidev/core'; | ||
export let props: Partial<TextareaProps> = {}; | ||
</script> | ||
|
||
<Textarea {...props} /> |
29 changes: 29 additions & 0 deletions
29
packages/svelteui-demos/src/demos/core/Textarea/Textarea.demo.disabled.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,29 @@ | ||
<script lang="ts" context="module"> | ||
import type { CodeDemoType, CodeDemoConfiguration } from '$lib/types'; | ||
const code = ` | ||
<script> | ||
import { Textarea } from '@svelteuidev/core'; | ||
<\/script> | ||
<Textarea disabled label="Disabled without value" placeholder="Once upon a time" /> | ||
<Textarea disabled label="Disabled with value" value="Once upon a time in a far away kingdom" /> | ||
`; | ||
export const type: CodeDemoType['type'] = 'demo'; | ||
export const configuration: CodeDemoConfiguration = { | ||
code | ||
}; | ||
</script> | ||
|
||
<script lang="ts"> | ||
import { Center, Stack, Textarea } from '@svelteuidev/core'; | ||
</script> | ||
|
||
<Center> | ||
<Stack justify="center"> | ||
<Textarea disabled label="Disabled without value" placeholder="Once upon a time" /> | ||
<Textarea disabled label="Disabled with value" value="Once upon a time in a far away kingdom" /> | ||
</Stack> | ||
</Center> |
27 changes: 27 additions & 0 deletions
27
packages/svelteui-demos/src/demos/core/Textarea/Textarea.demo.icon.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,27 @@ | ||
<script lang="ts" context="module"> | ||
import type { CodeDemoType, CodeDemoConfiguration } from '$lib/types'; | ||
const code = ` | ||
<script> | ||
import { Textarea } from '@svelteuidev/core'; | ||
import { EnvelopeClosed } from 'radix-icons-svelte'; | ||
<\/script> | ||
<Textarea label="Message" placeholder="Dear John" icon={EnvelopeClosed} /> | ||
`; | ||
export const type: CodeDemoType['type'] = 'demo'; | ||
export const configuration: CodeDemoConfiguration = { | ||
code | ||
}; | ||
</script> | ||
|
||
<script lang="ts"> | ||
import { Center, Textarea } from '@svelteuidev/core'; | ||
import { EnvelopeClosed } from 'radix-icons-svelte'; | ||
</script> | ||
|
||
<Center> | ||
<Textarea label="Message" placeholder="Dear John" icon={EnvelopeClosed} /> | ||
</Center> |
Oops, something went wrong.