aboutsummaryrefslogtreecommitdiff
path: root/src/components/select/select.vue
blob: 39d3ca64764d20e08b146b0f1324552322a97d04 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<template>
  <label
    class="Select input"
    :class="{ disabled, unstyled }"
  >
    <select
      :disabled="disabled"
      :value="modelValue"
      v-bind="$attrs"
      @change="$emit('update:modelValue', $event.target.value)"
    >
      <slot />
    </select>
    {{ ' ' }}
    <FAIcon
      v-if="!$attrs.size && !$attrs.multiple"
      class="select-down-icon"
      icon="chevron-down"
    />
  </label>
</template>

<script src="./select.js"> </script>

<style lang="scss">
/* TODO fix order of styles */
label.Select {
  padding: 0;

  select {
    appearance: none;
    background: transparent;
    border: none;
    color: var(--text);
    margin: 0;
    padding: 0 2em 0 0.2em;
    font-family: var(--font);
    font-size: 1em;
    width: 100%;
    z-index: 1;
    height: 2em;
    line-height: 16px;

    &[multiple],
    &[size] {
      height: 100%;
      padding: 0.2em;

      option {
        background-color: transparent;

        &.-active {
          color: var(--selectionText);
          background-color: var(--selectionBackground);
        }
      }
    }
  }

  &.disabled,
  &:disabled {
    background-color: var(--background);
    opacity: 1; /* override browser */

    select {
      &[multiple],
      &[size] {
        option.-active {
          color: var(--text);
          background: transparent;
        }
      }
    }
  }

  .select-down-icon {
    position: absolute;
    top: 0;
    bottom: 0;
    right: 5px;
    height: 100%;
    width: 0.875em;
    font-family: var(--font);
    line-height: 2;
    z-index: 0;
    pointer-events: none;
  }
}
</style>