-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(TextArea): replaced label prop with slot
fix(TextArea): added TextArea.Label component docs(Navigation): added updated flag to TextArea docs(text-area): updated examples, props, and slots tables
- Loading branch information
Showing
6 changed files
with
108 additions
and
55 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 |
---|---|---|
|
@@ -178,7 +178,7 @@ | |
{ | ||
title: 'TextArea', | ||
href: '/text-area', | ||
beta: true | ||
updated: true | ||
}, | ||
{ | ||
title: 'Timeline', | ||
|
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,35 @@ | ||
<script lang="ts"> | ||
import { getContext } from 'svelte'; | ||
import { twMerge } from 'tailwind-merge'; | ||
import { useContext } from '../../utils/useContext'; | ||
import { TEXT_AREA_CONTEXT_ID } from './TextArea.svelte'; | ||
import { get_current_component } from 'svelte/internal'; | ||
import { forwardEventsBuilder, useActions, type ActionArray } from '../../actions'; | ||
export let use: ActionArray = []; | ||
import { exclude } from '../../utils/exclude'; | ||
const forwardEvents = forwardEventsBuilder(get_current_component()); | ||
useContext({ | ||
context_id: TEXT_AREA_CONTEXT_ID, | ||
parent: 'TextArea', | ||
component: 'TextArea.Label' | ||
}); | ||
const { name, error }: { name: string; error: string } = getContext(TEXT_AREA_CONTEXT_ID); | ||
let defaultClass = 'block text-sm font-medium'; | ||
if (error) { | ||
defaultClass = defaultClass + ' text-danger'; | ||
} else { | ||
defaultClass = defaultClass + ' text-light-secondary-content dark:text-dark-secondary-content'; | ||
} | ||
$: finalClass = twMerge(defaultClass, $$props.class); | ||
</script> | ||
|
||
<label | ||
for={name} | ||
class={finalClass} | ||
use:useActions={use} | ||
use:forwardEvents | ||
{...exclude($$props, ['use', 'class'])}><slot /></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
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,3 +1,12 @@ | ||
import TextArea from './TextArea.svelte'; | ||
import OriginalTextArea from './TextArea.svelte'; | ||
import Label from './Label.svelte'; | ||
|
||
const TextArea = OriginalTextArea as TextAreaStatic; | ||
TextArea.Label = Label; | ||
|
||
export default TextArea; | ||
|
||
export interface TextAreaStatic { | ||
new (...args: ConstructorParameters<typeof OriginalTextArea>): OriginalTextArea; | ||
Label: typeof 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
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