-
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(Input): replaced label, leading, trailing props with slots
fix(Input): added Input.Label fix(Input): added Input.Leading fix(Input): added Input.Trailing docs(icons): added phone and lock docs(Navigation): added updated flag to input fix(icons): added eye and eye_off docs(input): updated examples, props, and slots table docs(input): added updated component banner
- Loading branch information
Showing
10 changed files
with
296 additions
and
176 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 |
---|---|---|
|
@@ -97,7 +97,7 @@ | |
{ | ||
title: 'Input', | ||
href: '/input', | ||
beta: true | ||
updated: true | ||
}, | ||
{ | ||
title: 'InputNumber', | ||
|
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,6 @@ | ||
export const email = | ||
'M20,8L12,13L4,8V6L12,11L20,6M20,4H4C2.89,4 2,4.89 2,6V18A2,2 0 0,0 4,20H20A2,2 0 0,0 22,18V6C22,4.89 21.1,4 20,4Z'; | ||
export const phone = | ||
'M6.62,10.79C8.06,13.62 10.38,15.94 13.21,17.38L15.41,15.18C15.69,14.9 16.08,14.82 16.43,14.93C17.55,15.3 18.75,15.5 20,15.5A1,1 0 0,1 21,16.5V20A1,1 0 0,1 20,21A17,17 0 0,1 3,4A1,1 0 0,1 4,3H7.5A1,1 0 0,1 8.5,4C8.5,5.25 8.7,6.45 9.07,7.57C9.18,7.92 9.1,8.31 8.82,8.59L6.62,10.79Z'; | ||
export const lock = | ||
'M12,17A2,2 0 0,0 14,15C14,13.89 13.1,13 12,13A2,2 0 0,0 10,15A2,2 0 0,0 12,17M18,8A2,2 0 0,1 20,10V20A2,2 0 0,1 18,22H6A2,2 0 0,1 4,20V10C4,8.89 4.9,8 6,8H7V6A5,5 0 0,1 12,1A5,5 0 0,1 17,6V8H18M12,3A3,3 0 0,0 9,6V8H15V6A3,3 0 0,0 12,3Z'; |
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,35 @@ | ||
<script lang="ts"> | ||
import { getContext } from 'svelte'; | ||
import { twMerge } from 'tailwind-merge'; | ||
import { useContext } from '../../utils/useContext'; | ||
import { INPUT_CONTEXT_ID } from './Input.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: INPUT_CONTEXT_ID, | ||
parent: 'Input', | ||
component: 'Input.Label' | ||
}); | ||
const { name, error }: { name: string; error: string } = getContext(INPUT_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<script lang="ts"> | ||
import { INPUT_CONTEXT_ID } from './Input.svelte'; | ||
import { getContext } from 'svelte'; | ||
import { useContext } from '../../utils/useContext'; | ||
import { twMerge } from 'tailwind-merge'; | ||
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: INPUT_CONTEXT_ID, | ||
parent: 'Input', | ||
component: 'Input.Leading' | ||
}); | ||
const { error }: { error: string } = getContext(INPUT_CONTEXT_ID); | ||
let defaultClass = 'absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none'; | ||
if (error) { | ||
defaultClass = defaultClass + ' text-danger'; | ||
} else { | ||
defaultClass = defaultClass + ' text-light-secondary-content dark:text-dark-secondary-content'; | ||
} | ||
$: finalClass = twMerge(defaultClass, $$props.class); | ||
</script> | ||
|
||
<span | ||
class={finalClass} | ||
use:useActions={use} | ||
use:forwardEvents | ||
{...exclude($$props, ['use', 'class'])} | ||
> | ||
<slot /> | ||
</span> |
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 @@ | ||
<script lang="ts"> | ||
import { INPUT_CONTEXT_ID } from './Input.svelte'; | ||
import { getContext } from 'svelte'; | ||
import { useContext } from '../../utils/useContext'; | ||
import { twMerge } from 'tailwind-merge'; | ||
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: INPUT_CONTEXT_ID, | ||
parent: 'Input', | ||
component: 'Input.Leading' | ||
}); | ||
const { error }: { error: string } = getContext(INPUT_CONTEXT_ID); | ||
let defaultClass = 'absolute inset-y-0 right-0 pr-3 flex items-center pointer-events-none'; | ||
if (error) { | ||
defaultClass = defaultClass + ' text-danger'; | ||
} else { | ||
defaultClass = defaultClass + ' text-light-secondary-content dark:text-dark-secondary-content'; | ||
} | ||
$: finalClass = twMerge(defaultClass, $$props.class); | ||
</script> | ||
|
||
<span | ||
class={finalClass} | ||
use:useActions={use} | ||
use:forwardEvents | ||
{...exclude($$props, ['use', 'class'])} | ||
> | ||
<slot /> | ||
</span> |
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,18 @@ | ||
import Input from './Input.svelte'; | ||
import OriginalInput from './Input.svelte'; | ||
import Label from './Label.svelte'; | ||
import Leading from './Leading.svelte'; | ||
import Trailing from './Trailing.svelte'; | ||
|
||
const Input = OriginalInput as InputStatic; | ||
Input.Label = Label; | ||
Input.Leading = Leading; | ||
Input.Trailing = Trailing; | ||
|
||
export default Input; | ||
|
||
export interface InputStatic { | ||
new (...args: ConstructorParameters<typeof OriginalInput>): OriginalInput; | ||
Label: typeof Label; | ||
Leading: typeof Leading; | ||
Trailing: typeof Trailing; | ||
} |
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.