UNPKG

6.84 kBSCSSView Raw
1// Copyright 2016 Palantir Technologies, Inc. All rights reserved.
2// Licensed under the Apache License, Version 2.0.
3
4@import "../../common/variables";
5@import "../button/common";
6
7/*
8Input groups
9
10Markup:
11<div class="#{$ns}-input-group {{.modifier}}">
12 <span class="#{$ns}-icon #{$ns}-icon-filter"></span>
13 <input type="text" class="#{$ns}-input" {{:modifier}} placeholder="Filter histogram..." />
14</div>
15<div class="#{$ns}-input-group {{.modifier}}">
16 <input type="password" class="#{$ns}-input" {{:modifier}} placeholder="Enter your password..." />
17 <button class="#{$ns}-button #{$ns}-minimal #{$ns}-intent-warning #{$ns}-icon-lock" {{:modifier}}></button>
18</div>
19<div class="#{$ns}-input-group {{.modifier}}">
20 <span class="#{$ns}-icon #{$ns}-icon-search"></span>
21 <input type="text" class="#{$ns}-input" {{:modifier}} placeholder="Search" />
22 <button class="#{$ns}-button #{$ns}-minimal #{$ns}-intent-primary #{$ns}-icon-arrow-right" {{:modifier}}></button>
23</div>
24
25:disabled - Disabled input. Must be added separately to the <code>&#60;input&#62;</code> and <code>&#60;button&#62;</code>. Also add <code>.#{$ns}-disabled</code> to <code>.#{$ns}-input-group</code> for icon coloring (not shown below).
26.#{$ns}-round - Rounded caps. Button will also be rounded.
27.#{$ns}-large - Large group. Children will adjust size accordingly.
28.#{$ns}-small - Small group. Children will adjust size accordingly.
29.#{$ns}-intent-primary - Primary intent. (All 4 intents are supported.)
30.#{$ns}-fill - Take up full width of parent element.
31
32Styleguide input-group
33*/
34
35// 3px space between small button and regular input
36$input-button-height: $pt-button-height-small !default;
37// 5px space between regular button and large input
38$input-button-height-large: $pt-button-height !default;
39// 1px space between regular button and small input
40$input-button-height-small: $pt-button-height-smaller !default;
41
42.#{$ns}-input-group {
43 display: block;
44 position: relative;
45
46 .#{$ns}-input {
47 // explicit position prevents shadow clipping https://github.com/palantir/blueprint/pull/490#issuecomment-273342170
48 position: relative;
49 width: 100%;
50
51 // add space if there's something before or after the input
52 &:not(:first-child) {
53 padding-left: $pt-input-height;
54 }
55
56 &:not(:last-child) {
57 padding-right: $pt-input-height;
58 }
59 }
60
61 .#{$ns}-input-action,
62 > .#{$ns}-input-left-container,
63 > .#{$ns}-button,
64 > .#{$ns}-icon {
65 position: absolute;
66 top: 0;
67
68 // glue it to the end it appears on
69 &:first-child {
70 left: 0;
71 }
72
73 &:last-child {
74 right: 0;
75 }
76 }
77
78 .#{$ns}-button {
79 @include pt-button-height($input-button-height);
80 margin: ($pt-input-height - $input-button-height) / 2;
81 padding: $button-padding-small;
82
83 // icons CSS API support
84 &:empty { padding: 0; }
85 }
86
87 // bump icon or left content up so it sits above input
88 > .#{$ns}-input-left-container,
89 > .#{$ns}-icon {
90 z-index: 1;
91 }
92
93 // direct descendant to exclude icons in buttons
94 > .#{$ns}-input-left-container > .#{$ns}-icon,
95 > .#{$ns}-icon {
96 color: $pt-icon-color;
97
98 &:empty {
99 @include pt-icon($pt-icon-size-standard);
100 }
101 }
102
103 // adjusting the margin of spinners in input groups
104 // we have to avoid targetting buttons that contain a spinner
105 > .#{$ns}-input-left-container > .#{$ns}-icon,
106 > .#{$ns}-icon,
107 .#{$ns}-input-action > .#{$ns}-spinner {
108 margin: ($pt-input-height - $pt-icon-size-standard) / 2;
109 }
110
111 .#{$ns}-tag {
112 margin: $pt-grid-size / 2;
113 }
114
115 // all buttons go gray in default state and assume their native colors only when hovered
116 // or when input is focused. this prevents distracting colors in the UI.
117 .#{$ns}-input:not(:focus) + .#{$ns}-button,
118 .#{$ns}-input:not(:focus) + .#{$ns}-input-action .#{$ns}-button {
119 &.#{$ns}-minimal:not(:hover):not(:focus) {
120 color: $pt-text-color-muted;
121
122 // same goes for dark
123 /* stylelint-disable-next-line selector-max-compound-selectors */
124 .#{$ns}-dark & {
125 color: $pt-dark-text-color-muted;
126 }
127
128 #{$icon-classes} {
129 color: $pt-icon-color;
130 }
131 }
132
133 &.#{$ns}-minimal:disabled {
134 // override more specific selector above
135 /* stylelint-disable declaration-no-important */
136 color: $pt-icon-color-disabled !important;
137
138 #{$icon-classes} {
139 color: $pt-icon-color-disabled !important;
140 }
141 }
142 }
143
144 // this class echoes `input:disabled` on the child input, but each action must individually be disabled
145 &.#{$ns}-disabled {
146 // note that enabled buttons inside this input group are still clickable
147 cursor: not-allowed;
148
149 .#{$ns}-icon {
150 color: $pt-icon-color-disabled;
151 }
152 }
153
154 &.#{$ns}-large {
155 .#{$ns}-button {
156 @include pt-button-height($input-button-height-large);
157 margin: ($pt-input-height-large - $input-button-height-large) / 2;
158 }
159
160 > .#{$ns}-input-left-container > .#{$ns}-icon,
161 > .#{$ns}-icon,
162 .#{$ns}-input-action > .#{$ns}-spinner {
163 margin: ($pt-input-height-large - $pt-icon-size-standard) / 2;
164 }
165
166 .#{$ns}-input {
167 @include pt-input-large();
168
169 &:not(:first-child) {
170 padding-left: $pt-button-height-large;
171 }
172
173 &:not(:last-child) {
174 padding-right: $pt-button-height-large;
175 }
176 }
177 }
178
179 &.#{$ns}-small {
180 .#{$ns}-button {
181 @include pt-button-height($pt-button-height-smaller);
182 margin: ($pt-input-height-small - $pt-button-height-smaller) / 2;
183 }
184
185 .#{$ns}-tag {
186 @include pt-button-height($pt-button-height-smaller);
187 margin: ($pt-input-height-small - $pt-button-height-smaller) / 2;
188 }
189
190 > .#{$ns}-input-left-container > .#{$ns}-icon,
191 > .#{$ns}-icon,
192 .#{$ns}-input-action > .#{$ns}-spinner {
193 margin: ($pt-input-height-small - $pt-icon-size-standard) / 2;
194 }
195
196 .#{$ns}-input {
197 @include pt-input-small();
198
199 &:not(:first-child) {
200 padding-left: $pt-icon-size-standard + $input-small-padding;
201 }
202
203 &:not(:last-child) {
204 padding-right: $pt-icon-size-standard + $input-small-padding;
205 }
206 }
207 }
208
209 &.#{$ns}-fill {
210 flex: 1 1 auto;
211 width: 100%;
212 }
213
214 &.#{$ns}-round {
215 .#{$ns}-button,
216 .#{$ns}-input,
217 .#{$ns}-tag {
218 border-radius: $pt-input-height;
219 }
220 }
221
222 .#{$ns}-dark & {
223 .#{$ns}-icon {
224 color: $pt-dark-icon-color;
225 }
226
227 &.#{$ns}-disabled .#{$ns}-icon {
228 color: $pt-dark-icon-color-disabled;
229 }
230 }
231
232 @each $intent, $color in $pt-intent-colors {
233 &.#{$ns}-intent-#{$intent} {
234 .#{$ns}-input {
235 @include pt-input-intent($color);
236 }
237
238 > .#{$ns}-icon {
239 color: map-get($pt-intent-text-colors, $intent);
240
241 .#{$ns}-dark & {
242 color: map-get($pt-dark-intent-text-colors, $intent);
243 }
244 }
245 }
246 }
247}