Skip to content

Commit 2eda140

Browse files
committed
fix: docs: search-input class to inputClass
1 parent ac41931 commit 2eda140

File tree

5 files changed

+43
-4
lines changed

5 files changed

+43
-4
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<script lang="ts">
2+
import { Input } from "$lib";
3+
import { type PhoneInputProps } from "$lib/types";
4+
5+
let { children, pattern="[0-9]{3}-[0-9]{3}-[0-9]{4}", phoneType = "default", floatingLabel = "Phone number", ...restProps }: PhoneInputProps = $props();
6+
</script>
7+
8+
{#if phoneType === "default" }
9+
<div class="relative">
10+
<div class="absolute inset-y-0 start-0 top-0 flex items-center ps-3.5 pointer-events-none">
11+
<svg class="w-4 h-4 text-gray-500 dark:text-gray-400" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 19 18">
12+
<path d="M18 13.446a3.02 3.02 0 0 0-.946-1.985l-1.4-1.4a3.054 3.054 0 0 0-4.218 0l-.7.7a.983.983 0 0 1-1.39 0l-2.1-2.1a.983.983 0 0 1 0-1.389l.7-.7a2.98 2.98 0 0 0 0-4.217l-1.4-1.4a2.824 2.824 0 0 0-4.218 0c-3.619 3.619-3 8.229 1.752 12.979C6.785 16.639 9.45 18 11.912 18a7.175 7.175 0 0 0 5.139-2.325A2.9 2.9 0 0 0 18 13.446Z"/>
13+
</svg>
14+
</div>
15+
<input type="text" {pattern} {...restProps} class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-500 focus:border-primary-500 block w-full ps-10 p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500"/>
16+
</div>
17+
{:else if phoneType === "floating"}
18+
<div class="relative">
19+
<span class="absolute start-0 bottom-3 text-gray-500 dark:text-gray-400">
20+
<svg class="w-4 h-4 rtl:rotate-[270deg]" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 19 18">
21+
<path d="M18 13.446a3.02 3.02 0 0 0-.946-1.985l-1.4-1.4a3.054 3.054 0 0 0-4.218 0l-.7.7a.983.983 0 0 1-1.39 0l-2.1-2.1a.983.983 0 0 1 0-1.389l.7-.7a2.98 2.98 0 0 0 0-4.217l-1.4-1.4a2.824 2.824 0 0 0-4.218 0c-3.619 3.619-3 8.229 1.752 12.979C6.785 16.639 9.45 18 11.912 18a7.175 7.175 0 0 0 5.139-2.325A2.9 2.9 0 0 0 18 13.446Z"/>
22+
</svg>
23+
</span>
24+
<input type="text" class="block py-2.5 ps-6 pe-0 w-full text-sm text-gray-900 bg-transparent border-0 border-b-2 border-gray-300 appearance-none dark:text-white dark:border-gray-600 dark:focus:border-primary-500 focus:outline-none focus:ring-0 focus:border-primary-600 peer" {pattern} {...restProps}/>
25+
<label for="floating-phone-number" class="absolute text-sm text-gray-500 dark:text-gray-400 duration-300 transform -translate-y-6 scale-75 top-3 -z-10 origin-[0] peer-placeholder-shown:start-6 peer-focus:start-0 peer-focus:text-primary-600 peer-focus:dark:text-primary-500 peer-placeholder-shown:scale-100 peer-placeholder-shown:translate-y-0 peer-focus:scale-75 peer-focus:-translate-y-6 rtl:peer-focus:translate-x-1/4 rtl:peer-focus:left-auto">{floatingLabel}</label>
26+
</div>
27+
28+
29+
{/if}

src/lib/forms/phoneinput/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default as PhoneInput } from "./PhoneInput.svelte"

src/lib/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export * from "./forms/helper";
5454
export * from "./forms/input-field";
5555
export * from "./forms/input-addon";
5656
export * from "./forms/label";
57+
export * from "./forms/phoneinput";
5758
export * from "./forms/select";
5859
export * from "./forms/radio";
5960
export * from "./forms/range";

src/lib/types.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -800,6 +800,13 @@ export interface InputAddonProps extends HTMLAttributes<HTMLDivElement> {
800800
size?: "sm" | "md" | "lg";
801801
}
802802

803+
// phoneInput
804+
export interface PhoneInputProps<T extends InputValue = number> extends Omit<HTMLInputAttributes, "size" | "children" | "value"> {
805+
phoneType?: "default" | "floating" | "countryCode" | "copy" | "advanced";
806+
children?: Snippet;
807+
floatingLabel?: string;
808+
}
809+
803810
// label
804811
export interface LabelProps extends HTMLLabelAttributes {
805812
children: Snippet;

src/routes/docs/forms/search-input.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,9 @@ Use the simplest form of a search input component with an icon and a search butt
7575
</script>
7676
7777
<form id="example-form">
78-
<Search bind:value={elementTxt} bind:elementRef={searchRef} class="my-4" />
78+
<Search bind:value={elementTxt} bind:elementRef={searchRef} />
7979
<Button
80+
class="mt-2"
8081
onclick={() => {
8182
searchRef?.setRangeText("ALREADY", 14, 17, "select");
8283
searchRef?.select();
@@ -136,7 +137,7 @@ Use this search component with a dropdown to let your users select a category in
136137
{/each}
137138
</Dropdown>
138139
</div>
139-
<Search size="lg" class="rounded-none py-2.5" placeholder="Search Mockups, Logos, Design Templates..." />
140+
<Search size="lg" inputClass="rounded-none py-2.5" placeholder="Search Mockups, Logos, Design Templates..." />
140141
<Button class="rounded-s-none p-2!">
141142
<SearchOutline class="h-6 w-6" />
142143
</Button>
@@ -201,7 +202,7 @@ Use this example where you can select a country in which you want to search for
201202
{/each}
202203
</Dropdown>
203204
</div>
204-
<Search size="lg" class="rounded-none py-2.5" placeholder="Search Mockups, Logos, Design Templates..." />
205+
<Search size="lg" inputClass="rounded-none py-2.5" placeholder="Search Mockups, Logos, Design Templates..." />
205206
<Button class="rounded-s-none p-2!">
206207
<SearchOutline class="h-6 w-6" />
207208
</Button>
@@ -222,7 +223,7 @@ Get started with this example if you would like to enable voice search for your
222223
</script>
223224
224225
<form class="flex gap-2">
225-
<Search hideClear size="lg" class="flex items-center gap-2" placeholder="Search Mockups, Logos, Design Templates...">
226+
<Search hideClear size="lg" inputClass="flex items-center gap-2" placeholder="Search Mockups, Logos, Design Templates...">
226227
<button type="button" onclick={handleVoiceBtn} class="outline-hidden">
227228
<MicrophoneSolid class="me-2 h-5 w-5" />
228229
</button>

0 commit comments

Comments
 (0)