-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add textarea, add more fields to text-input
- Loading branch information
Showing
18 changed files
with
327 additions
and
9 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -24,3 +24,4 @@ | |
@use "skip-link"; | ||
@use "tabs"; | ||
@use "text-input"; | ||
@use "textarea"; |
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 |
---|---|---|
@@ -1,14 +1,24 @@ | ||
{%- set containerClasses = [params.classes] if params.classes else [] -%} | ||
<div class="tna-form__group {{ containerClasses | join(' ') }}"{% for attribute, value in params.attributes %} {{ attribute }}="{{ value }}"{% endfor %}> | ||
{%- set inputClasses = [params.classes] if params.classes else [] -%} | ||
{%- set containerClasses = [params.formGroupClasses] if params.formGroupClasses else [] -%} | ||
<div class="tna-form__group{% if params.error %} tna-form__group--error{% endif %} {{ containerClasses | join(' ') }}"> | ||
<h{{ params.headingLevel }} class="tna-form__heading tna-form__heading--{{ params.headingSize }}"> | ||
<label class="tna-form__label" for="tna-form__{{ params.name }}"> | ||
<label class="tna-form__label" for="tna-form__{{ params.id }}"> | ||
{{ params.label }} | ||
</label> | ||
</h{{ params.headingLevel }}> | ||
{%- if params.hint %} | ||
<div id="tna-form__{{ params.name }}-hint" class="tna-form__hint"> | ||
<div id="tna-form__{{ params.id }}-hint" class="tna-form__hint"> | ||
{{ params.hint }} | ||
</div> | ||
{%- endif %} | ||
<input type="text" id="tna-form__{{ params.name }}" class="tna-text-input"{% if params.hint %} aria-describedby="tna-form__{{ params.name }}-hint"{% endif %}> | ||
{%- if params.error %} | ||
<p id="tna-form__{{ params.id }}-error" class="tna-form__error-message"> | ||
<span class="tna-!--visually-hidden">Error:</span> {{ params.error.text }} | ||
</p> | ||
{%- endif %} | ||
<input type="text" id="tna-form__{{ params.id }}" class="tna-text-input{% if params.size %} tna-text-input--{{ params.size }}{% endif %} {{ inputClasses | join(' ') }}" name="{{ params.name }}" value="{{ params.value }}" spellcheck="{{ params.spellcheck if params.spellcheck else false }}" | ||
{%- if params.hint or params.error %} aria-describedby="{% if params.hint %}tna-form__{{ params.id }}-hint{% endif %} {% if params.error %}tna-form__{{ params.id }}-error{% endif %}"{% endif %} | ||
{%- if params.autofill %} autofill="{{ params.autofill }}"{% endif %} | ||
{%- if params.inputmode %} inputmode="{{ params.inputmode }}"{% endif %} | ||
{%- for attribute, value in params.attributes %} {{ attribute }}="{{ value }}"{% endfor %}> | ||
</div> |
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
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 @@ | ||
@use "textarea"; |
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,4 @@ | ||
{ | ||
"component": "textarea", | ||
"fixtures": [] | ||
} |
14 changes: 14 additions & 0 deletions
14
src/nationalarchives/components/textarea/macro-options.json
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,14 @@ | ||
[ | ||
{ | ||
"name": "classes", | ||
"type": "string", | ||
"required": false, | ||
"description": "Classes to add to the textarea." | ||
}, | ||
{ | ||
"name": "attributes", | ||
"type": "object", | ||
"required": false, | ||
"description": "HTML attributes (for example data attributes) to add to the textarea." | ||
} | ||
] |
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,3 @@ | ||
{% macro tnaTextarea(params) %} | ||
{%- include "nationalarchives/components/textarea/template.njk" -%} | ||
{% endmacro %} |
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,19 @@ | ||
{%- set containerClasses = [params.classes] if params.classes else [] -%} | ||
<div class="tna-form__group{% if params.error %} tna-form__group--error{% endif %}"> | ||
<h{{ params.headingLevel }} class="tna-form__heading tna-form__heading--{{ params.headingSize }}"> | ||
<label class="tna-form__label" for="tna-form__{{ params.name }}"> | ||
{{ params.label }} | ||
</label> | ||
</h{{ params.headingLevel }}> | ||
{%- if params.hint %} | ||
<div id="tna-form__{{ params.name }}-hint" class="tna-form__hint"> | ||
{{ params.hint }} | ||
</div> | ||
{%- endif %} | ||
{%- if params.error %} | ||
<p id="tna-form__{{ params.name }}-error" class="tna-form__error-message"> | ||
<span class="tna-!--visually-hidden">Error:</span> {{ params.error.text }} | ||
</p> | ||
{%- endif %} | ||
<textarea id="tna-form__{{ params.name }}" class="tna-textarea"{% if params.hint or params.error %} aria-describedby="{% if params.hint %}tna-form__{{ params.name }}-hint{% endif %} {% if params.error %}tna-form__{{ params.name }}-error{% endif %}"{% endif %}{% for attribute, value in params.attributes %} {{ attribute }}="{{ value }}"{% endfor %}>{{ params.value }}</textarea> | ||
</div> |
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,28 @@ | ||
@use "../../variables/forms"; | ||
@use "../../tools/colour"; | ||
@use "../../utilities"; | ||
|
||
.tna-textarea { | ||
width: 100%; | ||
min-height: 5rem; | ||
margin-top: 1rem; | ||
padding: 0.375rem; | ||
|
||
display: block; | ||
box-sizing: border-box; | ||
resize: vertical; | ||
|
||
@include colour.colour-font("input-foreground"); | ||
font-family: inherit; | ||
font-size: inherit; | ||
line-height: 2rem; | ||
|
||
@include colour.colour-background("input-background"); | ||
|
||
@include colour.colour-border("input-border", forms.$form-field-border-width); | ||
border-radius: 0; | ||
|
||
.tna-form__group--error & { | ||
@include colour.colour-border("form-error"); | ||
} | ||
} |
Oops, something went wrong.