Inputs components classes

.c-input

scss
.c-input {
  @include use-font('body', 'regular');
  border: 1px solid use-color('grey', light-i);
  border-radius: 4px;
  box-sizing: border-box;
  color: use-color('base', 'black');
  margin-bottom: 12px;
  padding: 8px;
  width: 100%;

  @include modifier('search') {
    height: 28px;
    margin-bottom: 0;
    padding: 4px 8px 4px 32px;
    position: relative;

  }

  @include modifier('file') {
    display: none;

    &::-webkit-file-upload-button {
      visibility: hidden;
    }
  }

  @include modifier('message') {
    margin-bottom: 0;
  }

  @include modifier('thin') {
    height: 34px !important;
    padding-left: 8px !important;
  }

  @include modifier('file') {
    display: none;

    &::-webkit-file-upload-button {
      visibility: hidden;
    }
  }

  @include modifier('message') {
    margin-bottom: 0;
  }

  @include modifier('error') {
    border: 1px solid use-color(event, error);
  }

  @include element('label') {
    @include use-font('body', 'regular');
    color: use-color(base, 'black');
    display: inline-block;
    margin-bottom: 8px;
    width: 100%;
  }

  @include element('error-message') {
    @include use-font('caption', 'regular');
    color: use-color(event, error);
    margin: -8px 0 8px;
    padding: 0;
    width: 100%;
  }
  
  @include element('hint-message') {
    @include use-font('caption', 'regular');
    color: use-color('grey', light);
    margin: -8px 0 8px;
    padding: 0;
    width: 100%;
  }

  @include element('actions') {
    display: flex;
    justify-content: space-between;
    margin: 0 0 8px;
  }

  &:focus {
    box-shadow: $box-shadow-input-focus;
    outline: 0;
  }

  &:disabled,
  &[disabled] {
    background-color: use-color('grey', light-i);
    border: 1px solid use-color('grey', light-alt);
    cursor: not-allowed;
  }
}

Esta clase esta hecha para el uso en elementos del tipo inputs y textarea.

Consta con clases para el label, modificadores de error y estado disable:

  • .c-input__label - clase para el label del input
  • .c-input - estilos base del input
  • .c-input .c-input--error - clase modificadora para estilos de error en input
  • .c-input__error-message - clase para los mensajes de error
  • .c-input__hint-message - clase para los mensajes de ayuda

Modificadores para inputs:

  • .c-input--search
  • .c-input--file

Examples

html
<input type="text" class="c-input" placeholder="USUARIO" />
<!-- input disabled -->
<input type="text" class="c-input" placeholder="USUARIO" disabled />
html error
<!-- input with error -->
<input type="text" class="c-input c-input--error" placeholder="USUARIO" />
<p class="c-input__error-message">
  Mensaje de error predeterminado
</p>
html hint
<!-- input with error -->
<input type="text" class="c-input" placeholder="USUARIO" />
<p class="c-input__hint-message">
  Mensaje de ayuda predeterminado
</p>
html w/ label
<!-- input with label -->
<label class="c-input__label">Input label:</label>
<input type="text" class="c-input" placeholder="USUARIO" />
html app input search
<form class="app-form--search">
  <input type="text" class="c-input c-input--search" placeholder="Buscar" />
</form>

Requires

@mixin element()

@mixin modifier()

@mixin use-font()

@function use-color()

.c-select

scss
.c-select {
  @include use-font('body', 'regular');
  appearance: none;
  background-color: use-color(base, true-white);
  background-image: 
    linear-gradient(45deg, transparent 50%, use-color('grey', light) 50%), 
    linear-gradient(135deg, use-color('grey', light) 50%, transparent 50%);
  background-position:
    calc(100% - 12px) 16px,
    calc(100% - 8px) 16px;
  background-repeat: no-repeat;
  background-size:
    5px 5px,
    5px 5px;
  border: 1px solid use-color('grey', light-i);
  border-radius: 4px;
  box-sizing: border-box;
  cursor: pointer;
  margin-bottom: 12px;
  padding: 8px 24px 8px 8px;
  position: relative;
  width: 100%;

  @include modifier('thin') {
    padding: 5px !important;
  }

  @include modifier(error) {
    border: 1px solid use-color(event, error);
  }

  &:focus {
    outline: 0;
  }

  &:disabled {
    background-image: 
      linear-gradient(45deg, transparent 50%, use-color('grey', light-i) 50%), 
      linear-gradient(135deg, use-color('grey', light-i) 50%, transparent 50%);
    cursor: not-allowed;
  }
}

Esta clase esta hecha para ser utilizada en todos los selects elements.

Nota: En caso de querer usar un mensaje de error, hay que utilizar la clase
.c-input__error-message al igual que en los inputs con la clase .c-input.

Examples

html
<select class="c-select">
  <option id="0">
    Select option
  </option>
  <option id="1">Option 1</option>
  <option id="2">Option 2</option>
</select>
html disabled
<select class="c-select" disabled>
  <option id="0">
    Select option
  </option>
  <option id="1">Option 1</option>
  <option id="2">Option 2</option>
</select>
html error
<select class="c-select c-select--error">
  <option id="0">
    Select option
  </option>
  <option id="1">Option 1</option>
  <option id="2">Option 2</option>
</select>
<p class="c-input__error-message">
  Mensaje de error predeterminado
</p>

Requires

@mixin use-font()

@mixin modifier()

@function use-color()

.c-input-prefix

scss
.c-input-prefix {
  position: relative;

  @include modifier('currency-us') {
    .c-input {
      padding-left: 32px;
    }

    &::before {
      content: 'US$';
    }
  }
  
  @include modifier('currency-cl') {
    .c-input {
      padding-left: 38px;
    }

    &::before {
      content: 'CLP$';
    }
  }

  &::before {
    @include use-font('body', 'regular');
    color: use-color('grey', 'light');
    left: 5px;
    position: absolute;
    top: 9px;
  }
}

Este componente[.c-input-prefix] esta hecho para contener al component .c-input.

Funciona como un modificador del input dando espacio suficiente para agregar un prefijo.

El contenido del prefijo depende de la clase modificadora, actualmente solo tenemos prefijos para los casos de currency:

  • currency us: c-input-prefix--currency-us
  • currency cl: c-input-prefix--currency-cl

Examples

html currency us
<div class="c-input-prefix c-input-prefix--currency-us">
  <input type="text" class="c-input" value="30.00" />
</div>
html currency cl
<div class="c-input-prefix c-input-prefix--currency-cl">
  <input type="text" class="c-input" value="60.000" />
</div>

Requires

@mixin use-font()

@mixin modifier()

@function use-color()

.c-file-drop-area

scss
.c-file-drop-area {
  background-color: use-color('base', 'true-white');
  border: solid 1px use-color('grey', 'light-i');
  border-radius: 4px;
  border-style: dotted;
  color: use-color('grey');
  display: flex;
  flex-direction: column;
  margin-bottom: 8px;
  padding-top: 16px;
  text-align: center;
  text-decoration: none;

  @include element('footer') {
    background-color: use-color('grey', 'light-iii');
    border-radius: 0 0 4px 4px;
    cursor: pointer;
    display: flex;
    margin-top: 12px;
    padding: 12px;
    width: auto;

    [class^='icon-'],
    [class*=' icon-'] {
      color: use-color('grey', 'light');
      font-size: 24px;
    }
  }

  @include element('message') {
    @include use-font('caption');
    margin: auto;
    max-width: 180px;

    strong {
      display: inline-block;
      width: 100%;
    }
  }

  @include element('preview-image') {
    height: 110px;
    margin: 0 auto 4px;
  }

  &:hover {
    background-color: use-color('grey', 'light-iii');
    cursor: pointer;
  }

  span {
    color: use-color('secondary', 'light-alt');
    font-size: 75px;
    margin: auto;
  }

  [class^='icon-'],
  [class*=' icon-'] {
    display: flex;
  }

  .c-action-link {
    @include use-font('body');
  }
}

Estilo de input file para la carga de archivos y preview para la carga de imagenes.

Examples

html drop area
<input type="file" class="c-input--file" id="input-file">

<label for="input-file" class="c-file-drop-area">
  <span class="icon-upload-cloud"></span>

  <div class="c-file-drop-area__footer">
    <div class="c-file-drop-area__message">
      <strong>Arrastra y suelta</strong>
      o selecciona un archivo.
    </div>
  </div>
</label>
html preview image
<div class="c-file-drop-area">
  <img class="c-file-drop-area__preview-image" src="https://feature-ux-450-diseno-migracion-administrador--chattigo-webkit.netlify.app/assets/img/example-preview-image.png" />

  <span class="c-action-link">
    fotoadjunta.jpg
  </span>

  <div class="c-file-drop-area__footer">
    <span class="icon-trash"></span>
  </div>
</div>