UNPKG

9.56 kBSCSSView Raw
1// Name: Table
2// Description: Styles for tables
3//
4// Component: `uk-table`
5//
6// Modifiers: `uk-table-middle`
7// `uk-table-divider`
8// `uk-table-striped`
9// `uk-table-hover`
10// `uk-table-small`
11// `uk-table-justify`
12// `uk-table-shrink`
13// `uk-table-expand`
14// `uk-table-link`
15// `uk-table-responsive`
16//
17// States: `uk-active`
18//
19// ========================================================================
20
21
22// Variables
23// ========================================================================
24
25$table-margin-vertical: $global-margin !default;
26
27$table-cell-padding-vertical: 16px !default;
28$table-cell-padding-horizontal: 12px !default;
29
30$table-header-cell-font-size: $global-font-size !default;
31$table-header-cell-font-weight: bold !default;
32$table-header-cell-color: $global-color !default;
33
34$table-footer-font-size: $global-small-font-size !default;
35
36$table-caption-font-size: $global-small-font-size !default;
37$table-caption-color: $global-muted-color !default;
38
39$table-row-active-background: #ffd !default;
40
41$table-divider-border-width: $global-border-width !default;
42$table-divider-border: $global-border !default;
43
44$table-striped-row-background: $global-muted-background !default;
45
46$table-hover-row-background: $table-row-active-background !default;
47
48$table-small-cell-padding-vertical: 10px !default;
49$table-small-cell-padding-horizontal: 12px !default;
50
51$table-large-cell-padding-vertical: 22px !default;
52$table-large-cell-padding-horizontal: 12px !default;
53
54$table-expand-min-width: 150px !default;
55
56
57/* ========================================================================
58 Component: Table
59 ========================================================================== */
60
61/*
62 * 1. Remove most spacing between table cells.
63 * 2. Behave like a block element
64 * 3. Style
65 */
66
67.uk-table {
68 /* 1 */
69 border-collapse: collapse;
70 border-spacing: 0;
71 /* 2 */
72 width: 100%;
73 /* 3 */
74 margin-bottom: $table-margin-vertical;
75 @if(mixin-exists(hook-table)) {@include hook-table();}
76}
77
78/* Add margin if adjacent element */
79* + .uk-table { margin-top: $table-margin-vertical; }
80
81
82/* Header cell
83 ========================================================================== */
84
85/*
86 * 1. Style
87 */
88
89.uk-table th {
90 padding: $table-cell-padding-vertical $table-cell-padding-horizontal;
91 text-align: left;
92 vertical-align: bottom;
93 /* 1 */
94 font-size: $table-header-cell-font-size;
95 font-weight: $table-header-cell-font-weight;
96 color: $table-header-cell-color;
97 @if(mixin-exists(hook-table-header-cell)) {@include hook-table-header-cell();}
98}
99
100
101/* Cell
102 ========================================================================== */
103
104.uk-table td {
105 padding: $table-cell-padding-vertical $table-cell-padding-horizontal;
106 vertical-align: top;
107 @if(mixin-exists(hook-table-cell)) {@include hook-table-cell();}
108}
109
110/*
111 * Remove margin from the last-child
112 */
113
114.uk-table td > :last-child { margin-bottom: 0; }
115
116
117/* Footer
118 ========================================================================== */
119
120.uk-table tfoot {
121 font-size: $table-footer-font-size;
122 @if(mixin-exists(hook-table-footer)) {@include hook-table-footer();}
123}
124
125
126/* Caption
127 ========================================================================== */
128
129.uk-table caption {
130 font-size: $table-caption-font-size;
131 text-align: left;
132 color: $table-caption-color;
133 @if(mixin-exists(hook-table-caption)) {@include hook-table-caption();}
134}
135
136
137/* Alignment modifier
138 ========================================================================== */
139
140.uk-table-middle,
141.uk-table-middle td { vertical-align: middle !important; }
142
143
144/* Style modifiers
145 ========================================================================== */
146
147/*
148 * Divider
149 */
150
151.uk-table-divider > tr:not(:first-child),
152.uk-table-divider > :not(:first-child) > tr,
153.uk-table-divider > :first-child > tr:not(:first-child) {
154 border-top: $table-divider-border-width solid $table-divider-border;
155 @if(mixin-exists(hook-table-divider)) {@include hook-table-divider();}
156}
157
158/*
159 * Striped
160 */
161
162.uk-table-striped > tr:nth-of-type(odd),
163.uk-table-striped tbody tr:nth-of-type(odd) {
164 background: $table-striped-row-background;
165 @if(mixin-exists(hook-table-striped)) {@include hook-table-striped();}
166}
167
168/*
169 * Hover
170 */
171
172.uk-table-hover > tr:hover,
173.uk-table-hover tbody tr:hover {
174 background: $table-hover-row-background;
175 @if(mixin-exists(hook-table-hover)) {@include hook-table-hover();}
176}
177
178
179/* Active state
180 ========================================================================== */
181
182.uk-table > tr.uk-active,
183.uk-table tbody tr.uk-active {
184 background: $table-row-active-background;
185 @if(mixin-exists(hook-table-row-active)) {@include hook-table-row-active();}
186}
187
188/* Size modifier
189 ========================================================================== */
190
191.uk-table-small th,
192.uk-table-small td {
193 padding: $table-small-cell-padding-vertical $table-small-cell-padding-horizontal;
194 @if(mixin-exists(hook-table-small)) {@include hook-table-small();}
195}
196
197.uk-table-large th,
198.uk-table-large td {
199 padding: $table-large-cell-padding-vertical $table-large-cell-padding-horizontal;
200 @if(mixin-exists(hook-table-large)) {@include hook-table-large();}
201}
202
203
204/* Justify modifier
205 ========================================================================== */
206
207.uk-table-justify th:first-child,
208.uk-table-justify td:first-child { padding-left: 0; }
209
210.uk-table-justify th:last-child,
211.uk-table-justify td:last-child { padding-right: 0; }
212
213
214/* Cell size modifier
215 ========================================================================== */
216
217.uk-table-shrink { width: 1px; }
218.uk-table-expand { min-width: $table-expand-min-width; }
219
220
221/* Cell link modifier
222 ========================================================================== */
223
224/*
225 * Does not work with `uk-table-justify` at the moment
226 */
227
228.uk-table-link { padding: 0 !important; }
229
230.uk-table-link > a {
231 display: block;
232 padding: $table-cell-padding-vertical $table-cell-padding-horizontal;
233}
234
235.uk-table-small .uk-table-link > a { padding: $table-small-cell-padding-vertical $table-small-cell-padding-horizontal; }
236
237
238/* Responsive table
239 ========================================================================== */
240
241
242/* Phone landscape and smaller */
243@media (max-width: $breakpoint-small-max) {
244
245 .uk-table-responsive,
246 .uk-table-responsive tbody,
247 .uk-table-responsive th,
248 .uk-table-responsive td,
249 .uk-table-responsive tr { display: block; }
250
251 .uk-table-responsive thead { display: none; }
252
253 .uk-table-responsive th,
254 .uk-table-responsive td {
255 width: auto !important;
256 max-width: none !important;
257 min-width: 0 !important;
258 overflow: visible !important;
259 white-space: normal !important;
260 }
261
262 .uk-table-responsive th:not(:first-child):not(.uk-table-link),
263 .uk-table-responsive td:not(:first-child):not(.uk-table-link),
264 .uk-table-responsive .uk-table-link:not(:first-child) > a { padding-top: round($table-cell-padding-vertical / 3) !important; }
265
266 .uk-table-responsive th:not(:last-child):not(.uk-table-link),
267 .uk-table-responsive td:not(:last-child):not(.uk-table-link),
268 .uk-table-responsive .uk-table-link:not(:last-child) > a { padding-bottom: round($table-cell-padding-vertical / 3) !important; }
269
270 .uk-table-justify.uk-table-responsive th,
271 .uk-table-justify.uk-table-responsive td {
272 padding-left: 0;
273 padding-right: 0;
274 }
275
276}
277
278
279// Hooks
280// ========================================================================
281
282@if(mixin-exists(hook-table-misc)) {@include hook-table-misc();}
283
284// @mixin hook-table(){}
285// @mixin hook-table-header-cell(){}
286// @mixin hook-table-cell(){}
287// @mixin hook-table-footer(){}
288// @mixin hook-table-caption(){}
289// @mixin hook-table-row-active(){}
290// @mixin hook-table-divider(){}
291// @mixin hook-table-striped(){}
292// @mixin hook-table-hover(){}
293// @mixin hook-table-small(){}
294// @mixin hook-table-large(){}
295// @mixin hook-table-misc(){}
296
297
298// Inverse
299// ========================================================================
300
301$inverse-table-header-cell-color: $inverse-global-color !default;
302$inverse-table-caption-color: $inverse-global-muted-color !default;
303$inverse-table-row-active-background: fade-out($inverse-global-muted-background, 0.02) !default;
304$inverse-table-divider-border: $inverse-global-border !default;
305$inverse-table-striped-row-background: $inverse-global-muted-background !default;
306$inverse-table-hover-row-background: $inverse-table-row-active-background !default;
307
308
309
310// @mixin hook-inverse-table-header-cell(){}
311// @mixin hook-inverse-table-caption(){}
312// @mixin hook-inverse-table-row-active(){}
313// @mixin hook-inverse-table-divider(){}
314// @mixin hook-inverse-table-striped(){}
315// @mixin hook-inverse-table-hover(){}
\No newline at end of file