summaryrefslogtreecommitdiffstats
path: root/WebContent/VAADIN/themes/valo/components/_checkbox.scss
blob: 7ffd501dc8772757a103107664978c983b0ef4c6 (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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
@mixin valo-checkbox ($primary-stylename: v-checkbox) {
  
  .#{$primary-stylename},
  .v-radiobutton {
    @include valo-checkbox-style;   
  }
  
}


@mixin valo-checkbox-icon-style {
  content: "\f00c";
  font-family: FontAwesome;
}


@mixin valo-checkbox-style ($background-color: $v-button-background-color, $unit-size: $v-unit-size) {
  $background-color: $background-color or $v-background-color;
  
  position: relative;
  line-height: round($unit-size/2);
  white-space: nowrap;

  &.v-has-width label {
    white-space: normal;
  }

  :root & {
    padding-left: round($unit-size/1.5);

    label {
      @include valo-tappable;
    }
  }
  
  :root & > input {
    position: absolute;
    clip: rect(0,0,0,0);
    left: .2em;
    top: .2em;
    z-index: 0;
    margin: 0;

    &:focus ~ label:before {
      @include valo-button-focus-style($background-color: $background-color, $border-fallback: null);
      box-shadow: valo-button-box-shadow($background-color), valo-focus-box-shadow();
    }

    & ~ label:before,
    & ~ label:after {
      content: "";
      display: inline-block;
      @include box-sizing(border-box);
      width: round($unit-size/2);
      height: round($unit-size/2);
      position: absolute;
      top: 0;
      left: 0;
      border-radius: min(round($unit-size/6), $v-border-radius);
      font-size: round($v-font-size * 0.8 * ($unit-size/$v-unit-size));
      text-align: center;
    }
    
    & ~ label:before {
      @include valo-button-style($background-color: $background-color, $unit-size: $unit-size);
      padding: 0;
      height: round($unit-size/2);
    }

    & ~ label:after {
      @include valo-checkbox-icon-style;
      color: transparent;
      @if $v-animations-enabled {
        @include transition(color 100ms);
      }
    }
    
    &:active ~ label:after {
      @include valo-button-active-style($background-color: $background-color);
    }
    
    &:checked ~ label:after {
      color: valo-selection-color($context: $background-color);
    }

    &[disabled] {
      ~ label:before,
      ~ label:after {
        @include opacity($v-disabled-opacity);
      }

      &:active ~ label:after {
        background: transparent;
      }
    }

  }
    
  & > .v-icon,
  & > label .v-icon  {
    margin: 0 round($unit-size/6) 0 round($unit-size/12);
    min-width: 1em;
  }

}