16825 |
efrain |
1 |
// NOTE: by using !default on all variables, we're saying only declare the variable if it doesn't
|
|
|
2 |
// already exist, which allows devs to declare these variables themselves and assign them any value
|
|
|
3 |
// they want before importing this file
|
|
|
4 |
|
|
|
5 |
// rgba is needed for the selected flag hover state to blend in with
|
|
|
6 |
// the border-highlighting some browsers give the input on focus
|
|
|
7 |
$hoverColor: rgba(0, 0, 0, 0.05) !default;
|
|
|
8 |
$greyText: #999 !default;
|
|
|
9 |
$greyBorder: #CCC !default;
|
|
|
10 |
|
|
|
11 |
$flagHeight: 15px !default;
|
|
|
12 |
$flagWidth: 20px !default;
|
|
|
13 |
$flagPadding: 8px !default;
|
|
|
14 |
// this border width is used for the popup and divider, but it is also
|
|
|
15 |
// assumed to be the border width of the input, which we do not control
|
|
|
16 |
$borderWidth: 1px !default;
|
|
|
17 |
|
|
|
18 |
$arrowHeight: 4px !default;
|
|
|
19 |
$arrowWidth: 6px !default;
|
|
|
20 |
$triangleBorder: 3px !default;
|
|
|
21 |
$arrowPadding: 6px !default;
|
|
|
22 |
$arrowColor: #555 !default;
|
|
|
23 |
|
|
|
24 |
$inputPadding: 6px !default;
|
|
|
25 |
$selectedFlagWidth: $flagWidth + (2 * $flagPadding) !default;
|
|
|
26 |
$selectedFlagArrowWidth: $flagWidth + $flagPadding + $arrowWidth + (2 * $arrowPadding) !default;
|
|
|
27 |
|
|
|
28 |
// image related variables
|
|
|
29 |
$flagsImagePath: "../img/" !default;
|
|
|
30 |
$flagsImageName: "flags" !default;
|
|
|
31 |
$flagsImageExtension: "png" !default;
|
|
|
32 |
|
|
|
33 |
// enough space for them to click off to close
|
|
|
34 |
$mobilePopupMargin: 30px !default;
|
|
|
35 |
|
|
|
36 |
.iti {
|
|
|
37 |
// need position on the container so the selected flag can be
|
|
|
38 |
// absolutely positioned over the input
|
|
|
39 |
position: relative;
|
|
|
40 |
// keep the input's default inline properties
|
|
|
41 |
display: inline-block;
|
|
|
42 |
|
|
|
43 |
// paul irish says this is ok
|
|
|
44 |
// http://www.paulirish.com/2012/box-sizing-border-box-ftw/
|
|
|
45 |
* {
|
|
|
46 |
box-sizing: border-box;
|
|
|
47 |
-moz-box-sizing: border-box;
|
|
|
48 |
}
|
|
|
49 |
|
|
|
50 |
&__hide {
|
|
|
51 |
display: none;
|
|
|
52 |
}
|
|
|
53 |
// need this during init, to get the height of the dropdown
|
|
|
54 |
&__v-hide {
|
|
|
55 |
visibility: hidden;
|
|
|
56 |
}
|
|
|
57 |
|
|
|
58 |
// specify types to increase specificity e.g. to override bootstrap v2.3
|
|
|
59 |
input, input[type=text], input[type=tel] {
|
|
|
60 |
position: relative;
|
|
|
61 |
// input is bottom level, below selected flag and dropdown
|
|
|
62 |
z-index: 0;
|
|
|
63 |
|
|
|
64 |
// any vertical margin the user has on their inputs would no longer work as expected
|
|
|
65 |
// because we wrap everything in a container div. i justify the use of !important
|
|
|
66 |
// here because i don't think the user should ever have vertical margin here - when
|
|
|
67 |
// the input is wrapped in a container, vertical margin messes up alignment with other
|
|
|
68 |
// inline elements (e.g. an adjacent button) in firefox, and probably other browsers.
|
|
|
69 |
margin-top: 0 !important;
|
|
|
70 |
margin-bottom: 0 !important;
|
|
|
71 |
|
|
|
72 |
// make space for the selected flag on right of input (if disabled allowDropdown)
|
|
|
73 |
// Note: no !important here, as the user may want to tweak this so that the
|
|
|
74 |
// perceived input padding matches their existing styles
|
|
|
75 |
padding-right: $selectedFlagWidth;
|
|
|
76 |
|
|
|
77 |
// any margin-right here will push the selected-flag away
|
|
|
78 |
margin-right: 0;
|
|
|
79 |
}
|
|
|
80 |
|
|
|
81 |
&__flag-container {
|
|
|
82 |
// positioned over the top of the input
|
|
|
83 |
position: absolute;
|
|
|
84 |
// full height
|
|
|
85 |
top: 0;
|
|
|
86 |
bottom: 0;
|
|
|
87 |
right: 0;
|
|
|
88 |
// prevent the highlighted child from overlapping the input border
|
|
|
89 |
padding: $borderWidth;
|
|
|
90 |
}
|
|
|
91 |
|
|
|
92 |
&__selected-flag {
|
|
|
93 |
// render above the input
|
|
|
94 |
z-index: 1;
|
|
|
95 |
position: relative;
|
|
|
96 |
display: flex;
|
|
|
97 |
align-items: center;
|
|
|
98 |
// this must be full-height both for the hover highlight, and to push down the
|
|
|
99 |
// dropdown so it appears below the input
|
|
|
100 |
height: 100%;
|
|
|
101 |
padding: 0 $arrowPadding 0 $flagPadding;
|
|
|
102 |
}
|
|
|
103 |
|
|
|
104 |
&__arrow {
|
|
|
105 |
margin-left: $arrowPadding;
|
|
|
106 |
|
|
|
107 |
// css triangle
|
|
|
108 |
width: 0;
|
|
|
109 |
height: 0;
|
|
|
110 |
border-left: $triangleBorder solid transparent;
|
|
|
111 |
border-right: $triangleBorder solid transparent;
|
|
|
112 |
border-top: $arrowHeight solid $arrowColor;
|
|
|
113 |
|
|
|
114 |
&--up {
|
|
|
115 |
border-top: none;
|
|
|
116 |
border-bottom: $arrowHeight solid $arrowColor;
|
|
|
117 |
}
|
|
|
118 |
}
|
|
|
119 |
|
|
|
120 |
// the dropdown
|
|
|
121 |
&__country-list {
|
|
|
122 |
position: absolute;
|
|
|
123 |
// popup so render above everything else
|
|
|
124 |
z-index: 2;
|
|
|
125 |
|
|
|
126 |
// override default list styles
|
|
|
127 |
list-style: none;
|
|
|
128 |
// in case any container has text-align:center
|
|
|
129 |
text-align: left;
|
|
|
130 |
|
|
|
131 |
// place menu above the input element
|
|
|
132 |
&--dropup {
|
|
|
133 |
bottom: 100%;
|
|
|
134 |
margin-bottom: (-$borderWidth);
|
|
|
135 |
}
|
|
|
136 |
|
|
|
137 |
padding: 0;
|
|
|
138 |
// margin-left to compensate for the padding on the parent
|
|
|
139 |
margin: 0 0 0 (-$borderWidth);
|
|
|
140 |
|
|
|
141 |
box-shadow: 1px 1px 4px rgba(0,0,0,0.2);
|
|
|
142 |
background-color: white;
|
|
|
143 |
border: $borderWidth solid $greyBorder;
|
|
|
144 |
|
|
|
145 |
// don't let the contents wrap AKA the container will be as wide as the contents
|
|
|
146 |
white-space: nowrap;
|
|
|
147 |
// except on small screens, where we force the dropdown width to match the input
|
|
|
148 |
@media (max-width: 500px) {
|
|
|
149 |
white-space: normal;
|
|
|
150 |
}
|
|
|
151 |
|
|
|
152 |
max-height: 200px;
|
|
|
153 |
overflow-y: scroll;
|
|
|
154 |
|
|
|
155 |
// Fixes https://github.com/jackocnr/intl-tel-input/issues/765
|
|
|
156 |
// Apple still hasn't fixed the issue where setting overflow: scroll on a div element does not use inertia scrolling
|
|
|
157 |
// If this is not set, then the country list scroll stops moving after rasing a finger, and users report that scroll is slow
|
|
|
158 |
// Stackoverflow question about it: https://stackoverflow.com/questions/33601165/scrolling-slow-on-mobile-ios-when-using-overflowscroll
|
|
|
159 |
-webkit-overflow-scrolling: touch;
|
|
|
160 |
}
|
|
|
161 |
|
|
|
162 |
// dropdown flags need consistent width, so wrap in a container
|
|
|
163 |
&__flag-box {
|
|
|
164 |
display: inline-block;
|
|
|
165 |
width: $flagWidth;
|
|
|
166 |
}
|
|
|
167 |
|
|
|
168 |
// the divider below the preferred countries
|
|
|
169 |
&__divider {
|
|
|
170 |
padding-bottom: 5px;
|
|
|
171 |
margin-bottom: 5px;
|
|
|
172 |
border-bottom: $borderWidth solid $greyBorder;
|
|
|
173 |
}
|
|
|
174 |
|
|
|
175 |
// each country item in dropdown (we must have separate class to differentiate from dividers)
|
|
|
176 |
&__country {
|
|
|
177 |
// Note: decided not to use line-height here for alignment because it causes issues e.g. large font-sizes will overlap, and also looks bad if one country overflows onto 2 lines
|
|
|
178 |
padding: 5px 10px;
|
|
|
179 |
outline: none;
|
|
|
180 |
}
|
|
|
181 |
|
|
|
182 |
// the dial codes after the country names are greyed out
|
|
|
183 |
&__dial-code {
|
|
|
184 |
color: $greyText;
|
|
|
185 |
}
|
|
|
186 |
&__country.iti__highlight {
|
|
|
187 |
background-color: $hoverColor;
|
|
|
188 |
}
|
|
|
189 |
|
|
|
190 |
// spacing between country flag, name and dial code
|
|
|
191 |
&__flag-box, &__country-name, &__dial-code {
|
|
|
192 |
vertical-align: middle;
|
|
|
193 |
}
|
|
|
194 |
&__flag-box, &__country-name {
|
|
|
195 |
margin-right: 6px;
|
|
|
196 |
}
|
|
|
197 |
|
|
|
198 |
// these settings are independent of each other, but both move selected flag to left of input
|
|
|
199 |
&--allow-dropdown, &--separate-dial-code {
|
|
|
200 |
input, input[type=text], input[type=tel] {
|
|
|
201 |
padding-right: $inputPadding;
|
|
|
202 |
padding-left: $selectedFlagArrowWidth + $inputPadding;
|
|
|
203 |
margin-left: 0;
|
|
|
204 |
}
|
|
|
205 |
.iti__flag-container {
|
|
|
206 |
right: auto;
|
|
|
207 |
left: 0;
|
|
|
208 |
}
|
|
|
209 |
}
|
|
|
210 |
|
|
|
211 |
&--allow-dropdown {
|
|
|
212 |
// hover state - show flag is clickable
|
|
|
213 |
.iti__flag-container:hover {
|
|
|
214 |
cursor: pointer;
|
|
|
215 |
.iti__selected-flag {
|
|
|
216 |
background-color: $hoverColor;
|
|
|
217 |
}
|
|
|
218 |
}
|
|
|
219 |
// disable hover state when input is disabled
|
|
|
220 |
input[disabled] + .iti__flag-container:hover,
|
|
|
221 |
input[readonly] + .iti__flag-container:hover {
|
|
|
222 |
cursor: default;
|
|
|
223 |
.iti__selected-flag {
|
|
|
224 |
background-color: transparent;
|
|
|
225 |
}
|
|
|
226 |
}
|
|
|
227 |
}
|
|
|
228 |
|
|
|
229 |
&--separate-dial-code {
|
|
|
230 |
.iti__selected-flag {
|
|
|
231 |
// now that we have digits in this section, it needs this visual separation
|
|
|
232 |
background-color: $hoverColor;
|
|
|
233 |
}
|
|
|
234 |
.iti__selected-dial-code {
|
|
|
235 |
margin-left: $arrowPadding;
|
|
|
236 |
}
|
|
|
237 |
}
|
|
|
238 |
|
|
|
239 |
// if dropdownContainer option is set, increase z-index to prevent display issues
|
|
|
240 |
&--container {
|
|
|
241 |
position: absolute;
|
|
|
242 |
top: -1000px;
|
|
|
243 |
left: -1000px;
|
|
|
244 |
// higher than default Bootstrap modal z-index of 1050
|
|
|
245 |
z-index: 1060;
|
|
|
246 |
// to keep styling consistent with .flag-container
|
|
|
247 |
padding: $borderWidth;
|
|
|
248 |
&:hover {
|
|
|
249 |
cursor: pointer;
|
|
|
250 |
}
|
|
|
251 |
}
|
|
|
252 |
}
|
|
|
253 |
|
|
|
254 |
// overrides for mobile popup (note: .iti-mobile class is applied on body)
|
|
|
255 |
.iti-mobile .iti {
|
|
|
256 |
&--container {
|
|
|
257 |
top: $mobilePopupMargin;
|
|
|
258 |
bottom: $mobilePopupMargin;
|
|
|
259 |
left: $mobilePopupMargin;
|
|
|
260 |
right: $mobilePopupMargin;
|
|
|
261 |
position: fixed;
|
|
|
262 |
}
|
|
|
263 |
&__country-list {
|
|
|
264 |
max-height: 100%;
|
|
|
265 |
width: 100%;
|
|
|
266 |
}
|
|
|
267 |
&__country {
|
|
|
268 |
padding: 10px 10px;
|
|
|
269 |
// increase line height because dropdown copy is v likely to overflow on mobile and when it does it needs to be well spaced
|
|
|
270 |
line-height: 1.5em;
|
|
|
271 |
}
|
|
|
272 |
}
|
|
|
273 |
|
|
|
274 |
|
|
|
275 |
|
|
|
276 |
|
|
|
277 |
|
|
|
278 |
|
|
|
279 |
@import "sprite";
|
|
|
280 |
|
|
|
281 |
.iti__flag {
|
|
|
282 |
height: $flagHeight;
|
|
|
283 |
box-shadow: 0px 0px 1px 0px #888;
|
|
|
284 |
background-image: url("#{$flagsImagePath}#{$flagsImageName}.#{$flagsImageExtension}");
|
|
|
285 |
background-repeat: no-repeat;
|
|
|
286 |
// empty state
|
|
|
287 |
background-color: #DBDBDB;
|
|
|
288 |
background-position: $flagWidth 0;
|
|
|
289 |
|
|
|
290 |
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
|
|
|
291 |
background-image: url("#{$flagsImagePath}#{$flagsImageName}@2x.#{$flagsImageExtension}");
|
|
|
292 |
}
|
|
|
293 |
}
|
|
|
294 |
|
|
|
295 |
|
|
|
296 |
|
|
|
297 |
// hack for Nepal which is the only flag that is not square/rectangle, so it has transparency, so you can see the default grey behind it
|
|
|
298 |
.iti__flag.iti__np {
|
|
|
299 |
background-color: transparent;
|
|
|
300 |
}
|