diff --git a/src/components.d.ts b/src/components.d.ts index c30ea465b5..fa6c2ba9a0 100644 --- a/src/components.d.ts +++ b/src/components.d.ts @@ -201,6 +201,13 @@ export namespace Components { interface IfxTag { "text": string; } + interface IfxTextInput { + "disabled": boolean; + "error": boolean; + "errorMessage": string; + "placeholder": string; + "success": boolean; + } interface IfxToggle { "checked": boolean; } @@ -469,6 +476,12 @@ declare global { prototype: HTMLIfxTagElement; new (): HTMLIfxTagElement; }; + interface HTMLIfxTextInputElement extends Components.IfxTextInput, HTMLStencilElement { + } + var HTMLIfxTextInputElement: { + prototype: HTMLIfxTextInputElement; + new (): HTMLIfxTextInputElement; + }; interface HTMLIfxToggleElement extends Components.IfxToggle, HTMLStencilElement { } var HTMLIfxToggleElement: { @@ -520,6 +533,7 @@ declare global { "ifx-tab": HTMLIfxTabElement; "ifx-tabs": HTMLIfxTabsElement; "ifx-tag": HTMLIfxTagElement; + "ifx-text-input": HTMLIfxTextInputElement; "ifx-toggle": HTMLIfxToggleElement; "infineon-icon-stencil": HTMLInfineonIconStencilElement; } @@ -724,6 +738,13 @@ declare namespace LocalJSX { interface IfxTag { "text"?: string; } + interface IfxTextInput { + "disabled"?: boolean; + "error"?: boolean; + "errorMessage"?: string; + "placeholder"?: string; + "success"?: boolean; + } interface IfxToggle { "checked"?: boolean; "onValueChanged"?: (event: IfxToggleCustomEvent) => void; @@ -770,6 +791,7 @@ declare namespace LocalJSX { "ifx-tab": IfxTab; "ifx-tabs": IfxTabs; "ifx-tag": IfxTag; + "ifx-text-input": IfxTextInput; "ifx-toggle": IfxToggle; "infineon-icon-stencil": InfineonIconStencil; } @@ -816,6 +838,7 @@ declare module "@stencil/core" { "ifx-tab": LocalJSX.IfxTab & JSXBase.HTMLAttributes; "ifx-tabs": LocalJSX.IfxTabs & JSXBase.HTMLAttributes; "ifx-tag": LocalJSX.IfxTag & JSXBase.HTMLAttributes; + "ifx-text-input": LocalJSX.IfxTextInput & JSXBase.HTMLAttributes; "ifx-toggle": LocalJSX.IfxToggle & JSXBase.HTMLAttributes; "infineon-icon-stencil": LocalJSX.InfineonIconStencil & JSXBase.HTMLAttributes; } diff --git a/src/components/text-input/readme.md b/src/components/text-input/readme.md new file mode 100644 index 0000000000..de55b71663 --- /dev/null +++ b/src/components/text-input/readme.md @@ -0,0 +1,21 @@ +# ifx-text-input + + + + + + +## Properties + +| Property | Attribute | Description | Type | Default | +| -------------- | --------------- | ----------- | --------- | --------------- | +| `disabled` | `disabled` | | `boolean` | `false` | +| `error` | `error` | | `boolean` | `false` | +| `errorMessage` | `error-message` | | `string` | `""` | +| `placeholder` | `placeholder` | | `string` | `"Placeholder"` | +| `success` | `success` | | `boolean` | `false` | + + +---------------------------------------------- + +*Built with [StencilJS](https://stenciljs.com/)* diff --git a/src/components/text-input/text-input.scss b/src/components/text-input/text-input.scss new file mode 100644 index 0000000000..702e378b65 --- /dev/null +++ b/src/components/text-input/text-input.scss @@ -0,0 +1,152 @@ +@use "../../../node_modules/@infineon/design-system-tokens/dist/tokens"; + +.textInput__container { + display: flex; + flex-direction: column; + align-items: flex-start; + padding: 0px; + + //width: 588px; + height: 64px; + + flex: none; + order: 0; + align-self: stretch; + flex-grow: 0; + + &.disabled { + & .textInput__top-wrapper { + & label { + color: #BFBBBB; + } + } + + & .textInput__bottom-wrapper { + input { + border: 1px solid #BFBBBB; + + &::placeholder { + color: #BFBBBB; + } + } + } + + } + + & .textInput__top-wrapper { + display: flex; + flex-direction: row; + align-items: flex-start; + padding: 0px; + gap: 4px; + + flex: none; + order: 0; + align-self: stretch; + flex-grow: 0; + + & label { + font-style: normal; + font-weight: 400; + font-size: 16px; + line-height: 24px; + + display: flex; + align-items: center; + + color: tokens.$color-text-black; + + flex: none; + order: 0; + flex-grow: 0; + } + } + + & .textInput__bottom-wrapper { + display: flex; + flex-direction: column; + align-items: flex-start; + padding: 0px; + gap: 4px; + + flex: none; + order: 1; + align-self: stretch; + flex-grow: 0; + + & input { + box-sizing: border-box; + display: flex; + flex-direction: row; + align-items: center; + padding: 8px 16px; + gap: 6px; + + height: 40px; + + background-color: tokens.$color-text-white; + color: #1D1D1D; + + border: 1px solid #8D8786; + border-radius: 1px; + + flex: none; + order: 0; + align-self: stretch; + flex-grow: 0; + + &.error { + border: 1px solid #CD002F; + &:focus { + outline: none; + } + } + + &.success { + border: 1px solid #4CA460; + &:focus { + outline: none; + } + } + + + &:focus:not(.error, .success) { + outline: none; + border: 1px solid #0A8276; + } + + &:hover:not(:disabled, .error, .success) { + border: 1px solid #3C3A39; + } + + &::placeholder { + font-style: normal; + font-weight: 400; + font-size: 16px; + line-height: 24px; + + color: #8D8786; + + flex: none; + order: 1; + flex-grow: 1; + } + } + + & .textInput__bottom-wrapper-error { + font-style: normal; + font-weight: 400; + font-size: 12px; + line-height: 16px; + + letter-spacing: 0.2px; + + color: #CD002F; + + flex: none; + order: 1; + align-self: stretch; + flex-grow: 0; + } + } +} \ No newline at end of file diff --git a/src/components/text-input/text-input.stories.ts b/src/components/text-input/text-input.stories.ts new file mode 100644 index 0000000000..b482aafe1e --- /dev/null +++ b/src/components/text-input/text-input.stories.ts @@ -0,0 +1,23 @@ +export default { + title: "Components/TextInput", + args: { + error: false, + disabled: false, + success: false, + placeholder: 'Placeholder', + errorMessage: "", + }, + + argTypes: { + + }, +}; + + +const DefaultTemplate = (args) => + `Text field`; + + +export const Default = DefaultTemplate.bind({}); + + diff --git a/src/components/text-input/text-input.tsx b/src/components/text-input/text-input.tsx new file mode 100644 index 0000000000..8b68c7a51b --- /dev/null +++ b/src/components/text-input/text-input.tsx @@ -0,0 +1,40 @@ +import { Component, h, Element, Prop } from '@stencil/core'; + +@Component({ + tag: 'ifx-text-input', + styleUrl: '../../index.scss', + shadow: true +}) + +export class TextInput { + @Element() el; + @Prop() placeholder: string = "Placeholder" + @Prop() error: boolean = false; + @Prop() errorMessage: string = ""; + @Prop() success: boolean = false; + @Prop() disabled: boolean = false; + + render() { + return ( +
+
+ +
+
+ + {this.error && +
+ {this.errorMessage} +
} +
+
+ ); + } +} \ No newline at end of file diff --git a/src/index.html b/src/index.html index b1246954b1..c9dc3227f6 100644 --- a/src/index.html +++ b/src/index.html @@ -30,12 +30,7 @@ - - Item One - Item Two - Item Three - Item Four - + Text field diff --git a/src/index.scss b/src/index.scss index 37f8fb99d2..207c529170 100644 --- a/src/index.scss +++ b/src/index.scss @@ -19,8 +19,11 @@ @import './components/list-group/list-group-notification'; @import './components/number-indicator/number-indicator'; +@import './components/text-input/text-input'; + @import './components/sidebar/sidebar'; @import './components/sidebar/sidebar-item'; + @import './components/checkbox/checkbox';