From 5466a70916c481c229f5642d58933754cd52ea7b Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Wed, 17 Sep 2025 22:08:37 -0700 Subject: [PATCH] Refactored Input component --- src/lib/components/ui/Input.svelte | 467 ++++++++++++++++++ src/lib/components/ui/input/Input.svelte | 342 ------------- src/lib/components/ui/input/input.module.scss | 207 -------- 3 files changed, 467 insertions(+), 549 deletions(-) create mode 100644 src/lib/components/ui/Input.svelte delete mode 100644 src/lib/components/ui/input/Input.svelte delete mode 100644 src/lib/components/ui/input/input.module.scss diff --git a/src/lib/components/ui/Input.svelte b/src/lib/components/ui/Input.svelte new file mode 100644 index 00000000..41b656f7 --- /dev/null +++ b/src/lib/components/ui/Input.svelte @@ -0,0 +1,467 @@ + + +{#if label || error} +
+ {#if label} + + {label} + {#if required} + * + {/if} + + {/if} + + {#if hasWrapper} +
+ {#if leftIcon} + + + + {/if} + + + + {#if rightIcon} + + + + {/if} + + {#if showCounter} + + {currentCount}{maxLength ? `/${maxLength}` : ''} + + {/if} +
+ {:else} + + {/if} + + {#if error} + {error} + {/if} +
+{:else if hasWrapper} +
+ {#if leftIcon} + + + + {/if} + + + + {#if rightIcon} + + + + {/if} + + {#if showCounter} + + {currentCount}{maxLength ? `/${maxLength}` : ''} + + {/if} +
+{:else} + +{/if} + + diff --git a/src/lib/components/ui/input/Input.svelte b/src/lib/components/ui/input/Input.svelte deleted file mode 100644 index 0a2b0078..00000000 --- a/src/lib/components/ui/input/Input.svelte +++ /dev/null @@ -1,342 +0,0 @@ - - -
- {#if label} - - {label} - {#if required} - * - {/if} - - {/if} - - {#if accessory || leftIcon || rightIcon || showCounter} -
- {#if leftIcon} - - - - {/if} - - - - {#if rightIcon} - - - - {/if} - - {#if showCounter} - - {currentCount}{maxLength ? `/${maxLength}` : ''} - - {/if} -
- {:else} - - {/if} - - {#if error} - {error} - {/if} - - {#if children} - {@render children()} - {/if} -
- - \ No newline at end of file diff --git a/src/lib/components/ui/input/input.module.scss b/src/lib/components/ui/input/input.module.scss deleted file mode 100644 index 9289ba40..00000000 --- a/src/lib/components/ui/input/input.module.scss +++ /dev/null @@ -1,207 +0,0 @@ -@use 'themes/spacing'; -@use 'themes/colors'; -@use 'themes/typography'; -@use 'themes/layout'; -@use 'themes/mixins'; - -.fieldset { - display: flex; - flex-direction: column; - gap: spacing.$unit-half; - - &:last-child .error { - margin-bottom: 0; - } - - &.hidden { - display: none; - } - - &.full { - width: 100%; - } - - .label { - color: var(--text-primary); - font-size: typography.$font-small; - font-weight: typography.$medium; - margin-bottom: spacing.$unit-half; - - .required { - color: colors.$error; - margin-left: spacing.$unit-fourth; - } - } - - .error { - color: colors.$error; - font-size: typography.$font-small; - padding: calc(spacing.$unit / 2) (spacing.$unit * 2); - min-width: 100%; - margin-bottom: spacing.$unit; - width: 0; - } - - .fullHeight { - height: 100%; - } - - .input { - -webkit-font-smoothing: antialiased; - background-color: var(--input-bg); - border-radius: layout.$input-corner; - border: none; - box-sizing: border-box; - color: var(--text-primary); - display: block; - font-family: system-ui, -apple-system, 'Helvetica Neue', Helvetica, Arial, sans-serif; - font-size: typography.$font-regular; - width: 100%; - - &:not(.wrapper) { - padding: (spacing.$unit * 1.5) spacing.$unit-2x; - } - - &.accessory, - &.wrapper { - $offset: 2px; - - align-items: center; - background: var(--input-bg); - border-radius: layout.$input-corner; - box-sizing: border-box; - position: relative; - display: flex; - padding: 0; - - .counter { - color: var(--text-tertiary); - display: block; - font-weight: typography.$bold; - line-height: 48px; - position: absolute; - right: spacing.$unit-2x; - top: 0; - pointer-events: none; - } - - input { - background: transparent; - border-radius: layout.$input-corner; - border: 2px solid transparent; - box-sizing: border-box; - color: var(--text-primary); - padding: (spacing.$unit * 1.75) spacing.$unit-2x; - width: 100%; - font-size: typography.$font-regular; - font-family: inherit; - - &:focus { - border: 2px solid colors.$blue; - outline: none; - } - } - - .iconLeft, - .iconRight { - position: absolute; - display: flex; - align-items: center; - pointer-events: none; - color: var(--text-secondary); - - svg { - fill: currentColor; - } - } - - .iconLeft { - left: spacing.$unit-2x; - } - - .iconRight { - right: spacing.$unit-2x; - } - - &:has(.iconLeft) input { - padding-left: spacing.$unit-5x; - } - - &:has(.iconRight) input { - padding-right: spacing.$unit-5x; - } - - &:has(.counter) input { - padding-right: spacing.$unit-8x; - } - } - - &[type='number']::-webkit-inner-spin-button { - -webkit-appearance: none; - } - - &.bound { - background-color: var(--input-bound-bg); - - &:hover { - background-color: var(--input-bound-bg-hover); - } - } - - &.duration { - background: transparent; - border: none; - padding: 0; - width: initial; - height: 100%; - padding: calc(spacing.$unit-2x - 2px) 0; - - &:hover { - background: transparent; - } - - &:focus, - &:focus-visible { - border: none; - } - } - - &.number { - text-align: right; - width: spacing.$unit-8x; - } - - &.range { - text-align: right; - width: spacing.$unit-12x; - } - - &.alignRight { - text-align: right; - } - - &:hover:not(:disabled) { - background-color: var(--input-bg-hover); - } - - &:focus { - border: 2px solid colors.$blue; - outline: none; - } - - &:disabled { - opacity: 0.5; - cursor: not-allowed; - } - } - - .counter { - display: none; - } -} - -.input::placeholder, -.input > input::placeholder { - color: var(--text-tertiary); - opacity: 1; -} \ No newline at end of file