<div class="rh-form-group rh-form-group--has-icon">
<label for="errorId" class="rh-form__label">
Error input text control
</label>
<input id="errorId" type="text" class="rh-form__control rh-form__control--error" placeholder="Error placeholder">
<span class="rh-form-icon rh-form-icon--error rh-form-icon__placeholder"></span>
</div>
<div class="rh-form-group{{#if icon}} rh-form-group--has-icon{{/if}}">
{{!-- Label for the control --}}
{{#if labelData.text}}
<label for="{{labelData.forControlId}}" class="rh-form__label{{#if labelData.extendClass}} {{labelData.extendClass}}{{/if}}">
{{labelData.text}}
{{!-- Extend text for requirement --}}
{{#if labelData.requirement.text}}
<span class="rh-form__label-text--required">{{labelData.requirement.text}}</span>
{{/if}}
</label>
{{/if}}
{{!-- Input text control --}}
{{#if controlData}}
<input id="{{controlData.controlId}}" type="text" class="rh-form__control{{#if modifier}} rh-form__control--{{modifier}}{{/if}}{{#if controlData.extendClass}} {{controlData.extendClass}}{{/if}}"
placeholder="{{controlData.placeholder}}" {{#if controlData.autocompleteType}}autocomplete="{{controlData.autocompleteType}}" {{/if}}
{{#if isDisabled}}disabled{{/if}}>
{{/if}}
{{!-- Icon is within control --}}
{{#if icon}}
{{#if modifier}}
<span class="rh-form-icon rh-form-icon--{{modifier}} rh-form-icon__placeholder"></span>
{{/if}}
{{/if}}
</div>
{
"name": "form-control__text",
"extendClass": "",
"modifier": "error",
"icon": true,
"labelData": {
"text": "Error input text control",
"forControlId": "errorId",
"extendClass": "",
"requirement": {
"text": ""
}
},
"controlData": {
"controlId": "errorId",
"placeholder": "Error placeholder",
"autocompleteType": "",
"extendClass": ""
}
}
.rh-form-group {
/* Box-modell/beteende */
margin-bottom: 0.9375em;
// Using when an input text control has an icon that is within
&--has-icon {
/* Positionering */
position: relative;
}
}
.rh-form {
&__control {
/* Box-modell/beteende */
display: block;
height: 2.125em;
width: 100%;
padding: 0.375em 0.75em;
/* Typografi */
font-size: $FORM__CONTROL--FONT-SIZE;
line-height: $FORM__CONTROL--LINE-HEIGHT;
/* Visuellt */
@if $FORM__CONTROL--BACKGROUND-COLOR {
background-color: $FORM__CONTROL--BACKGROUND-COLOR;
}
border: $FORM__CONTROL--BORDER;
border-radius: $FORM__CONTROL--BORDER-RADIUS;
/* Typografi */
@if $FORM__CONTROL-TEXT--COLOR {
color: $FORM__CONTROL-TEXT--COLOR;
}
&:focus {
/* Visuellt */
border: $FORM__CONTROL--FOCUS-BORDER;
/* Typografi */
color: $FORM__CONTROL-TEXT--FOCUS-COLOR;
}
&:disabled {
/* Visuellt */
border: $FORM__CONTROL--DISABLED-BORDER;
background-color: $FORM__CONTROL--DISABLED-BACKGROUND-COLOR;
/* Blandat/övrigt */
cursor: not-allowed;
}
&--success {
/* Visuellt */
border: $FORM__CONTROL--SUCCESS-BORDER;
}
&--error {
/* Visuellt */
border: $FORM__CONTROL--ERROR-BORDER;
}
}
&__label {
display: inline-block;
max-width: 100%;
margin-bottom: 0.3125em;
&-text--required {
color: $FORM__TEXT--REQUIRED-COLOR;
}
}
&__text {
&--muted {
font-size: $FORM__TEXT--MUTED-FONT-SIZE;
}
&--required {
color: $FORM__TEXT--REQUIRED-COLOR;
}
}
}
// Form icon is using for the input text control
.rh-form-icon {
/* Positionering */
position: relative;
top: 0.0625em;
/* Box-modell/beteende */
display: inline-block;
/* Typografi */
font-family: $FORM__ICON--FONT-FAMILY;
font-style: normal;
font-weight: normal;
line-height: $FORM__ICON--LINE-HEIGHT;
&__placeholder {
/* Positionering */
position: absolute;
top: 1.25em;
right: 0;
z-index: $FORM__ICON-PLACEHOLDER--Z-INDEX;
/* Box-modell/beteende */
display: block;
height: 2.125em;
width: 2.125em;
/* Typografi */
line-height: $FORM__ICON-PLACEHOLDER--LINE-HEIGHT;
text-align: $FORM__ICON-PLACEHOLDER--TEXT-ALIGN;
}
&--success:before {
/* Typografi */
color: $FORM__ICON--SUCCESS-COLOR;
/* Blandat/övrigt */
content: "\e83f";
}
&--error:before {
/* Typografi */
color: $FORM__ICON--ERROR-COLOR;
/* Blandat/övrigt */
content: "\e81e";
}
}
{
"name": "regionhalland/form-control-text",
"description": "Atomen form-control-text",
"type": "styleguide-atom",
"license": "GPL-3.0",
"authors": [
{
"name": "Region Halland",
"email": "webbplatser@regionhalland.se"
}
],
"require": {}
}
/* Atoms - Form control text */
$FORM__CONTROL--FONT-SIZE: $font-size--small;
$FORM__CONTROL--LINE-HEIGHT: $line-height--xl;
$FORM__CONTROL--BACKGROUND-COLOR: false; // false - Ex: $white
$FORM__CONTROL--BORDER: $border-thin--standard $grey-light;
$FORM__CONTROL--BORDER-RADIUS: $border-radius--standard;
$FORM__CONTROL-TEXT--COLOR: false; // false - Ex: $black
// Highlight
$FORM__CONTROL--FOCUS-BORDER: $border-thin--standard $complementary2;
$FORM__CONTROL-TEXT--FOCUS-COLOR: $grey-dark;
// Other states - disabled - success - error - muted - required
$FORM__CONTROL--DISABLED-BORDER: $border-thin--standard $grey-light;
$FORM__CONTROL--DISABLED-BACKGROUND-COLOR: $grey-lightest;
$FORM__CONTROL--SUCCESS-BORDER: $border-thin--standard $base3;
$FORM__CONTROL--ERROR-BORDER: $border-thin--standard $warning;
$FORM__TEXT--MUTED-FONT-SIZE: $font-size--small;
$FORM__TEXT--REQUIRED-COLOR: $warning;
// Icon is within input text control
$FORM__ICON--FONT-FAMILY: $icon--font-family;
$FORM__ICON--LINE-HEIGHT: $line-height--small;
$FORM__ICON--SUCCESS-COLOR: $base3;
$FORM__ICON--ERROR-COLOR: $warning;
$FORM__ICON-PLACEHOLDER--Z-INDEX: 2;
$FORM__ICON-PLACEHOLDER--LINE-HEIGHT: 2.125em;
$FORM__ICON-PLACEHOLDER--TEXT-ALIGN: center;
Komponenten är en HTML form input text element.
Huvudstrukturen är:
<div>
<label for="elemId">Text</label>
<input id="elemId" type="text">
</div>
TIP!
<label>
tag. Det beror på JSON filen.Man använder strukturen när man vill rendera komponenten i en annan komponent (Exempel: en atom i en molecules).
{
"name": "",
"status": "",
"context": {
"modifier": "",
"isDisabled": false,
"labelData": {
"text": "",
"forControlId": "",
"extendClass": "",
"requirement": {
"text": ""
}
},
"controlData": {
"controlId": "",
"placeholder":"Placeholder",
"autocompleteType": "",
"extendClass": ""
}
}
}
Man kan också använda extra CSS klasser som ska vara i “extendClass” för att skriva över befintliga CSS klasser i komponenten.
.settings.scss
.