Form control - Text: Disabled

<div class="rh-form-group">
    <input id="disabledId" type="text" class="rh-form__control" placeholder="Disabled" disabled>
</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": "",
  "isDisabled": true,
  "labelData": {
    "text": "",
    "forControlId": "disabledId",
    "extendClass": "",
    "requirement": {
      "text": ""
    }
  },
  "controlData": {
    "controlId": "disabledId",
    "placeholder": "Disabled",
    "autocompleteType": "",
    "extendClass": ""
  }
}
  • Content:
    .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";
        }
    }
  • URL: /components/raw/form-control-text/_form-control-text.scss
  • Filesystem Path: components/Atoms/form-control-text/_form-control-text.scss
  • Size: 3 KB
  • Content:
    {
        "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": {}
    }
    
  • URL: /components/raw/form-control-text/composer.json
  • Filesystem Path: components/Atoms/form-control-text/composer.json
  • Size: 307 Bytes
  • Content:
    /* 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;
  • URL: /components/raw/form-control-text/form-control-text.settings.scss
  • Filesystem Path: components/Atoms/form-control-text/form-control-text.settings.scss
  • Size: 1.2 KB

Form control - Text

Komponenten är en HTML form input text element.

1. Struktur

1.1. HTML

Huvudstrukturen är:

<div>
    <label for="elemId">Text</label>
    <input id="elemId" type="text">
</div>

TIP!

  • Man kan också använda komponenten utan <label> tag. Det beror på JSON filen.
  • Glöm inte checka inkommande data när man jobbar med back-end system (Exempel: required, minlength, maxlength, pattern, …)

1.2. JSON data för en variant

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.

2. Referens

3. Version

1.0.0.20200124

  • Globala variabler används.
  • Inställningar skapats i filen .settings.scss.

    1.0.0.20191121 - flyttad till gitrepo

    1.0.0.20190820 - första version.

Planerad utveckling

  • Bryta isär label och input till separata atomer. Det som syns idag bör vara en molekyl.