-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat(web-twig): Introduce TextArea component #DS-319
- Loading branch information
Showing
6 changed files
with
103 additions
and
2 deletions.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
packages/web-twig/src/Resources/components/TextArea/README.md
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,63 @@ | ||
# TextArea | ||
|
||
This is Twig implementation of the [TextArea] component. | ||
|
||
Basic example usage: | ||
|
||
```twig | ||
<TextArea id="example" label="Label" name="example"></TextArea> | ||
``` | ||
|
||
Advanced example usage: | ||
|
||
```twig | ||
<TextArea | ||
id="example2" | ||
messsage="validation failed" | ||
name="example2" | ||
placeholder="Placeholder" | ||
validationState="error" | ||
maxlength="180" | ||
rows="10" | ||
isRequired | ||
> | ||
TextArea | ||
</TextArea> | ||
``` | ||
|
||
Without lexer: | ||
|
||
```twig | ||
{% include "@spirit/textArea.twig" with { props: { | ||
id: "example", | ||
name: "example", | ||
isRequired: true, | ||
validationState: "error", | ||
message: "validation failed", | ||
}} %} | ||
``` | ||
|
||
## API | ||
|
||
| Prop name | Type | Default | Required | Description | | ||
| ----------------- | ----------------------------- | ------- | -------- | ---------------------------------------------------------- | | ||
| `class` | `string` | `null` | no | Custom CSS class | | ||
| `id` | `string` | — | yes | TextArea and label identification | | ||
| `isDisabled` | `bool` | `false` | no | If true, TextArea is disabled | | ||
| `isFluid` | `bool` | `false` | no | If true, the element spans to the full width of its parent | | ||
| `isLabelHidden` | `bool` | `false` | no | If true, label is hidden | | ||
| `isRequired` | `bool` | `false` | no | If true, TextArea is required | | ||
| `label` | `string` | — | yes | Label text | | ||
| `maxLength` | `number` | `null` | no | Maximum number of characters | | ||
| `message` | `string` | `null` | no | Validation or help message | | ||
| `name` | `string` | `null` | no | TextArea name | | ||
| `placeholder` | `string` | `null` | no | TextArea placeholder | | ||
| `rows` | `number` | `null` | no | Number of visible rows | | ||
| `validationState` | `success`, `warning`, `error` | `null` | no | Type of validation state | | ||
| `value` | `string` | `null` | no | TextArea value | | ||
|
||
On top of the API options, you can add `data-*` or `aria-*` attributes to | ||
further extend component's descriptiveness and accessibility. These attributes | ||
will be passed to the topmost HTML element of the component. | ||
|
||
[textarea]: https://github.com/lmc-eu/spirit-design-system/tree/main/packages/web/src/scss/components/TextArea |
8 changes: 8 additions & 0 deletions
8
packages/web-twig/src/Resources/components/TextArea/TextArea.twig
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,8 @@ | ||
{# API #} | ||
{%- set props = props | default([]) -%} | ||
|
||
{% embed '@spirit/TextFieldBase/TextFieldBase.twig' with { | ||
props: props | merge ({ | ||
isMultiline: true, | ||
}) | ||
} only %}{% endembed %} |
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 @@ | ||
{% extends '@spirit/TextArea/TextArea.twig' %} |
10 changes: 10 additions & 0 deletions
10
...sts/__snapshots__/ComponentsSnapshotTest__test with data set textAreaDefault.twig__1.html
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,10 @@ | ||
<html><body> | ||
<div class="TextArea TextArea--error"> | ||
<label for="example" class="TextArea__label TextArea__label--required"> | ||
TextArea | ||
</label> | ||
<textarea minlength="6" maxlength="10" id="example" name="example" class="TextArea__input" rows="10" required> | ||
TextArea value | ||
</textarea> | ||
</div> | ||
</body></html> |
12 changes: 12 additions & 0 deletions
12
packages/web-twig/tests/components-fixtures/textAreaDefault.twig
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,12 @@ | ||
<TextArea | ||
id="example" | ||
label="TextArea" | ||
messsage="validation failed" | ||
minlength="6" | ||
maxlength="10" | ||
name="example" | ||
validationState="error" | ||
value="TextArea value" | ||
rows="10" | ||
isRequired | ||
/> |