From 1c24f7197fd316d59141850432927d71eb5f1d77 Mon Sep 17 00:00:00 2001 From: josefaidt Date: Wed, 23 Sep 2020 11:39:24 -0500 Subject: [PATCH] feat(text-input): add inline option for TextInput --- src/TextInput/TextInput.stories.js | 1 + src/TextInput/TextInput.svelte | 135 +++++++++++++++++++---------- 2 files changed, 88 insertions(+), 48 deletions(-) diff --git a/src/TextInput/TextInput.stories.js b/src/TextInput/TextInput.stories.js index 306b497c..c3892a73 100644 --- a/src/TextInput/TextInput.stories.js +++ b/src/TextInput/TextInput.stories.js @@ -29,6 +29,7 @@ export const Default = () => ({ 'This will overwrite your current settings' ), placeholder: text("Placeholder text (placeholder)", "Placeholder text."), + inline: boolean('Inline variant (inline)', false), id: text("TextInput id", "text-input-id"), name: text("TextInput name", "text-input-name"), }, diff --git a/src/TextInput/TextInput.svelte b/src/TextInput/TextInput.svelte index 3aaa8b78..6ac0e74e 100644 --- a/src/TextInput/TextInput.svelte +++ b/src/TextInput/TextInput.svelte @@ -101,6 +101,12 @@ */ export let required = false; + /** + * Set to `true` to use inline version + * @type {boolean} [inline=false] + */ + export let inline = false; + import WarningFilled16 from "carbon-icons-svelte/lib/WarningFilled16"; import WarningAltFilled16 from "carbon-icons-svelte/lib/WarningAltFilled16"; @@ -111,70 +117,103 @@
- {#if labelText} + {#if inline} +
+ {#if labelText} + + {/if} + {#if helperText} +
+ {helperText} +
+ {/if} +
+ {/if} + {#if !inline && labelText} {/if}
+ class:bx--text-input__field-outer-wrapper="{true}" + class:bx--text-input__field-outer-wrapper--inline="{inline}"> +
+ {#if invalid} + + {/if} + {#if !invalid && warn} + + {/if} + +
+ {#if !invalid && !warn && !inline && helperText} +
+ {helperText} +
+ {/if} {#if invalid} - +
+ {invalidText} +
{/if} {#if !invalid && warn} - +
{warnText}
{/if} -
- {#if !invalid && !warn && helperText} -
- {helperText} -
- {/if} - {#if invalid} -
{invalidText}
- {/if} - {#if !invalid && warn} -
{warnText}
- {/if}