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}