_custom-forms.scss 6.68 KB
Newer Older
1
2
3
4
// Embedded icons from Open Iconic.
// Released under MIT and copyright 2014 Waybury.
// http://useiconic.com/open

Mark Otto's avatar
Mark Otto committed
5

6
// Checkboxes and radios
Mark Otto's avatar
Mark Otto committed
7
8
9
//
// Base class takes care of all the key behavioral aspects.

10
.c-input {
11
12
13
14
15
16
17
18
19
20
21
22
23
24
  position: relative;
  display: inline;
  padding-left: 1.5rem;
  color: #555;
  cursor: pointer;

  > input {
    position: absolute;
    z-index: -1; // Put the input behind the label so it doesn't overlay text
    opacity: 0;

    &:checked ~ .c-indicator {
      color: #fff;
      background-color: #0074d9;
25
      @include box-shadow(none);
26
27
    }

28
    &:focus ~ .c-indicator {
29
      // the mixin is not used here to make sure there is feedback
30
31
32
      box-shadow: 0 0 0 .075rem #fff, 0 0 0 .2rem #0074d9;
    }

33
34
35
    &:active ~ .c-indicator {
      color: #fff;
      background-color: #84c6ff;
36
      @include box-shadow(none);
37
38
39
40
41
42
    }
  }

  + .c-input {
    margin-left: 1rem;
  }
43
44
}

Mark Otto's avatar
Mark Otto committed
45
46
47
48
// Custom indicator
//
// Generates a shadow element to create our makeshift checkbox/radio background.

49
.c-indicator {
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
  position: absolute;
  top: 0;
  left: 0;
  display: block;
  width: 1rem;
  height: 1rem;
  font-size: 65%;
  line-height: 1rem;
  color: #eee;
  text-align: center;
  user-select: none;
  background-color: #eee;
  background-repeat: no-repeat;
  background-position: center center;
  background-size: 50% 50%;
65
  @include box-shadow(inset 0 .125rem .125rem rgba(0,0,0,.1));
66
67
}

Mark Otto's avatar
Mark Otto committed
68
69
70
// Checkboxes
//
// Tweak just a few things for checkboxes.
71

Mark Otto's avatar
Mark Otto committed
72
.c-checkbox {
73
74
75
  .c-indicator {
    border-radius: .25rem;
  }
76

77
78
79
  input:checked ~ .c-indicator {
    background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjwhLS0gR2VuZXJhdG9yOiBBZG9iZSBJbGx1c3RyYXRvciAxNy4xLjAsIFNWRyBFeHBvcnQgUGx1Zy1JbiAuIFNWRyBWZXJzaW9uOiA2LjAwIEJ1aWxkIDApICAtLT4NCjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+DQo8c3ZnIHZlcnNpb249IjEuMSIgaWQ9IkxheWVyXzEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4Ig0KCSB2aWV3Qm94PSIwIDAgOCA4IiBlbmFibGUtYmFja2dyb3VuZD0ibmV3IDAgMCA4IDgiIHhtbDpzcGFjZT0icHJlc2VydmUiPg0KPHBhdGggZmlsbD0iI0ZGRkZGRiIgZD0iTTYuNCwxTDUuNywxLjdMMi45LDQuNUwyLjEsMy43TDEuNCwzTDAsNC40bDAuNywwLjdsMS41LDEuNWwwLjcsMC43bDAuNy0wLjdsMy41LTMuNWwwLjctMC43TDYuNCwxTDYuNCwxeiINCgkvPg0KPC9zdmc+DQo=);
  }
Mark Otto's avatar
Mark Otto committed
80
81
82
83

  input:indeterminate ~ .c-indicator {
    background-color: #0074d9;
    background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjwhLS0gR2VuZXJhdG9yOiBBZG9iZSBJbGx1c3RyYXRvciAxNy4xLjAsIFNWRyBFeHBvcnQgUGx1Zy1JbiAuIFNWRyBWZXJzaW9uOiA2LjAwIEJ1aWxkIDApICAtLT4NCjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+DQo8c3ZnIHZlcnNpb249IjEuMSIgaWQ9IkxheWVyXzEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4Ig0KCSB3aWR0aD0iOHB4IiBoZWlnaHQ9IjhweCIgdmlld0JveD0iMCAwIDggOCIgZW5hYmxlLWJhY2tncm91bmQ9Im5ldyAwIDAgOCA4IiB4bWw6c3BhY2U9InByZXNlcnZlIj4NCjxwYXRoIGZpbGw9IiNGRkZGRkYiIGQ9Ik0wLDN2Mmg4VjNIMHoiLz4NCjwvc3ZnPg0K);
84
    @include box-shadow(none);
Mark Otto's avatar
Mark Otto committed
85
  }
86
87
}

Mark Otto's avatar
Mark Otto committed
88
89
90
// Radios
//
// Tweak just a few things for radios.
91

Mark Otto's avatar
Mark Otto committed
92
.c-radio {
93
94
95
  .c-indicator {
    border-radius: 50%;
  }
96

Mark Otto's avatar
Mark Otto committed
97
  input:checked ~ .c-indicator {
98
99
    background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjwhLS0gR2VuZXJhdG9yOiBBZG9iZSBJbGx1c3RyYXRvciAxNy4xLjAsIFNWRyBFeHBvcnQgUGx1Zy1JbiAuIFNWRyBWZXJzaW9uOiA2LjAwIEJ1aWxkIDApICAtLT4NCjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+DQo8c3ZnIHZlcnNpb249IjEuMSIgaWQ9IkxheWVyXzEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4Ig0KCSB2aWV3Qm94PSIwIDAgOCA4IiBlbmFibGUtYmFja2dyb3VuZD0ibmV3IDAgMCA4IDgiIHhtbDpzcGFjZT0icHJlc2VydmUiPg0KPHBhdGggZmlsbD0iI0ZGRkZGRiIgZD0iTTQsMUMyLjMsMSwxLDIuMywxLDRzMS4zLDMsMywzczMtMS4zLDMtM1M1LjcsMSw0LDF6Ii8+DQo8L3N2Zz4NCg==);
  }
100
101
}

Mark Otto's avatar
Mark Otto committed
102

103
104
105
106
107
108
// Layout options
//
// By default radios and checkboxes are `inline-block` with no additional spacing
// set. Use these optional classes to tweak the layout.

.c-inputs-stacked {
109
110
111
  .c-input {
    display: inline;

112
    &::after {
113
114
115
116
117
118
119
120
121
      display: block;
      margin-bottom: .25rem;
      content: "";
    }

    + .c-input {
      margin-left: 0;
    }
  }
122
123
}

Mark Otto's avatar
Mark Otto committed
124

125
126
// Select
//
127
128
// Replaces the browser default select with a custom one, mostly pulled from
// http://primercss.io.
Mark Otto's avatar
Mark Otto committed
129
130
//
// Includes IE9-specific hacks (noted by ` \9`).
131

132
.c-select {
133
  display: inline-block;
134
135
  max-width: 100%;
  padding: .375rem 1.75rem .375rem .75rem;
Mark Otto's avatar
Mark Otto committed
136
  padding-right: .75rem \9;
137
  color: $input-color;
Mark Otto's avatar
order    
Mark Otto committed
138
  vertical-align: middle;
139
  background: #fff url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAUCAMAAACzvE1FAAAADFBMVEUzMzMzMzMzMzMzMzMKAG/3AAAAA3RSTlMAf4C/aSLHAAAAPElEQVR42q3NMQ4AIAgEQTn//2cLdRKppSGzBYwzVXvznNWs8C58CiussPJj8h6NwgorrKRdTvuV9v16Afn0AYFOB7aYAAAAAElFTkSuQmCC) no-repeat right .75rem center;
Mark Otto's avatar
Mark Otto committed
140
  background-image: none \9;
141
  background-size: 8px 10px;
142
  border: $input-btn-border-width solid $input-border-color;
Mark Otto's avatar
Mark Otto committed
143
  // Use vendor prefixes as `appearance` isn't part of the CSS spec.
144
  -moz-appearance: none;
Mark Otto's avatar
Mark Otto committed
145
  -webkit-appearance: none;
146
147
148

  &:focus {
    border-color: #51a7e8;
149
    outline: none;
150
    @include box-shadow(inset 0 1px 2px rgba(0, 0, 0, 0.075), 0 0 5px rgba(81, 167, 232, 0.5));
151
152
153
154
155
  }

  // Hides the default caret in IE11
  &::-ms-expand {
    opacity: 0;
156
157
  }
}
158

159
160
161
162
.c-select-sm {
  padding-top: 3px;
  padding-bottom: 3px;
  font-size: 12px;
163

164
165
166
  &:not([multiple]) {
    height: 26px;
    min-height: 26px;
167
  }
168
169
}

Mark Otto's avatar
Mark Otto committed
170

171
172
173
// File
//
// Custom file input.
174
175

.file {
176
177
178
179
  position: relative;
  display: inline-block;
  height: 2.5rem;
  cursor: pointer;
180
181
}
.file input {
182
183
  min-width: 14rem;
  margin: 0;
XhmikosR's avatar
XhmikosR committed
184
  filter: alpha(opacity = 0);
185
  opacity: 0;
186
187
}
.file-custom {
188
189
190
191
192
193
194
195
196
197
198
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  z-index: 5;
  height: 2.5rem;
  padding: .5rem 1rem;
  line-height: 1.5;
  color: #555;
  user-select: none;
  background-color: #fff;
199
  border: $input-btn-border-width solid #ddd;
200
  border-radius: .25rem;
201
  @include box-shadow(inset 0 .2rem .4rem rgba(0,0,0,.05));
202
}
203
.file-custom::after {
204
  content: "Choose file...";
205
}
206
.file-custom::before {
207
208
209
210
211
212
213
214
215
216
217
218
  position: absolute;
  top: -.075rem;
  right: -.075rem;
  bottom: -.075rem;
  z-index: 6;
  display: block;
  height: 2.5rem;
  padding: .5rem 1rem;
  line-height: 1.5;
  color: #555;
  content: "Browse";
  background-color: #eee;
219
  border: $input-btn-border-width solid #ddd;
220
  border-radius: 0 .25rem .25rem 0;
221
222
}

223
// Focus state
224
.file input:focus ~ .file-custom {
225
  @include box-shadow(0 0 0 .075rem #fff, 0 0 0 .2rem #0074d9);
226
}