This repository has been archived by the owner on Nov 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
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
13 changed files
with
186 additions
and
20 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 |
---|---|---|
@@ -1,11 +1,12 @@ | ||
.DS_Store | ||
node_modules | ||
/build | ||
/coverage | ||
/dist | ||
/.svelte-kit | ||
/package | ||
.env | ||
.env.* | ||
!.env.example | ||
vite.config.js.timestamp-* | ||
vite.config.ts.timestamp-* | ||
vite.config.ts.timestamp-* |
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,21 @@ | ||
{ | ||
"$schema": "https://docs.rome.tools/schemas/12.1.2/schema.json", | ||
"organizeImports": { | ||
"enabled": false | ||
}, | ||
"linter": { | ||
"enabled": true, | ||
"rules": { | ||
"recommended": true | ||
} | ||
}, | ||
"formatter": { | ||
"enabled": true, | ||
"indentStyle": "space" | ||
}, | ||
"javascript": { | ||
"formatter": { | ||
"quoteStyle": "single" | ||
} | ||
} | ||
} |
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,12 +1,12 @@ | ||
// See https://kit.svelte.dev/docs/types#app | ||
// for information about these interfaces | ||
declare global { | ||
namespace App { | ||
// interface Error {} | ||
// interface Locals {} | ||
// interface PageData {} | ||
// interface Platform {} | ||
} | ||
namespace App { | ||
// interface Error {} | ||
// interface Locals {} | ||
// interface PageData {} | ||
// interface Platform {} | ||
} | ||
} | ||
|
||
export {}; |
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 +1 @@ | ||
import './histoire.css' | ||
import './histoire.css'; |
4 changes: 2 additions & 2 deletions
4
src/routes/stories/Counter.story.svelte → ...mponents/TextField/TextField.story.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 |
---|---|---|
@@ -1,11 +1,11 @@ | ||
<script lang="ts"> | ||
import Counter from '$lib/components/Counter.svelte'; | ||
import TextField from './TextField.svelte'; | ||
import type { Hst as Histoire } from '@histoire/plugin-svelte'; | ||
export let Hst: Histoire; | ||
</script> | ||
|
||
<Hst.Story> | ||
<Counter /> | ||
<TextField /> | ||
</Hst.Story> |
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,101 @@ | ||
<script lang="ts" context="module"> | ||
export enum TextInputVariant { | ||
Default, | ||
Transparent | ||
} | ||
</script> | ||
|
||
<script lang="ts"> | ||
import classNames from 'classnames'; | ||
import { createEventDispatcher } from 'svelte'; | ||
// import Warning from '~icons/custom/warning'; | ||
export let autoComplete: string | undefined = undefined; | ||
export let error: string | undefined = undefined; | ||
export let label: string | undefined = undefined; | ||
export let name: string; | ||
export let placeholder: string | undefined = undefined; | ||
export let tabIndex: number | undefined = undefined; | ||
export let type: 'text' | 'email' | 'tel' | 'password' | 'number' = 'text'; | ||
export let required = false; | ||
export let step: string | undefined = undefined; | ||
export let value: string | number | undefined; | ||
export let variant: TextInputVariant = TextInputVariant.Default; | ||
export let disabled = false; | ||
export let className = ''; | ||
export let icon: any = undefined; | ||
export { className as class }; | ||
const dispatch = createEventDispatcher(); | ||
const TEXT_FIELD_INPUT_CLASS = classNames( | ||
variant === TextInputVariant.Default && | ||
'border border-gray-300 focus:ring-blue-500 focus:border-blue-500 rounded-lg', | ||
'bg-gray-50 text-gray-900 text-sm block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500', | ||
type === 'number' && 'font-mono', | ||
className | ||
); | ||
const TEXT_FIELD_CLASS_NAMES = | ||
'relative transition-[background-color] transition-[box-shadow] duration-200 h-[44px] min-w-full w-full rounded-md inline-flex'; | ||
const inputContainerClassNames = classNames( | ||
TEXT_FIELD_CLASS_NAMES, | ||
!!error && 'border-rose-200!' | ||
); | ||
const handleInput = (event: Event): void => { | ||
const target = event.target as HTMLInputElement; | ||
value = type.match(/^(number|range)$/) ? +target.value : target.value; | ||
dispatch('input', { | ||
value | ||
}); | ||
}; | ||
const handleIconClick = (): void => { | ||
dispatch('clickIcon'); | ||
}; | ||
</script> | ||
|
||
<div class="flex flex-col justify-start no-wrap"> | ||
<label for={name} class="mb-2 text-sm font-medium text-gray-900 dark:text-white" hidden={!label} | ||
>{label} | ||
</label> | ||
<div class={inputContainerClassNames}> | ||
<input | ||
{name} | ||
{type} | ||
{value} | ||
{required} | ||
{placeholder} | ||
{disabled} | ||
{step} | ||
id={name} | ||
autocomplete={autoComplete} | ||
tabindex={tabIndex} | ||
aria-invalid="false" | ||
aria-label="{name}-input" | ||
aria-required={required ? 'true' : 'false'} | ||
class={TEXT_FIELD_INPUT_CLASS} | ||
on:input={handleInput} | ||
/> | ||
{#if icon} | ||
<div on:mousedown={handleIconClick}> | ||
<svelte:component | ||
this={icon} | ||
class="absolute h-8 w-8 inset-y-0 right-0 pt-2 pr-2 flex items-center leading-5" | ||
/> | ||
</div> | ||
{/if} | ||
</div> | ||
<div | ||
class:hidden={!error} | ||
class:flex={!!error} | ||
class="text-sm text-rose-500 items-center space-x-2 py-2" | ||
> | ||
<figure class="flex justify-center items-center"> | ||
<!-- <Warning /> --> | ||
</figure> | ||
<span>{error}</span> | ||
</div> | ||
</div> |
6 changes: 3 additions & 3 deletions
6
src/index.test.ts → ...ib/components/TextField/TextField.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,7 +1,7 @@ | ||
import { describe, it, expect } from 'vitest'; | ||
|
||
describe('sum test', () => { | ||
it('adds 1 + 2 to equal 3', () => { | ||
expect(1 + 2).toBe(3); | ||
}); | ||
it('adds 1 + 2 to equal 3', () => { | ||
expect(1 + 2).toBe(3); | ||
}); | ||
}); |
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default as Button } from './Button.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,18 @@ | ||
const defaultTheme = require('tailwindcss/defaultTheme'); | ||
|
||
/** @type {import('tailwindcss').Config} */ | ||
module.exports = { | ||
content: ['./src/**/*.{html,js,svelte,ts}'], | ||
darkMode: 'class', | ||
theme: { | ||
extend: { | ||
fontFamily: { | ||
sans: ['Inter', ...defaultTheme.fontFamily.sans] | ||
} | ||
}, | ||
variants: { | ||
extend: {} | ||
}, | ||
plugins: [require('@tailwindcss/forms')] | ||
} | ||
}; |
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,15 @@ | ||
import { defineConfig } from 'vitest/config'; | ||
import { svelte } from '@sveltejs/vite-plugin-svelte'; | ||
|
||
export default defineConfig({ | ||
plugins: [svelte()], | ||
test: { | ||
globals: true, | ||
environment: 'jsdom' | ||
}, | ||
resolve: { | ||
alias: { | ||
$lib: '/src/lib/' | ||
} | ||
} | ||
}); |