UNPKG

8.09 kBSCSSView Raw
1// Name: Subnav
2// Description: Component to create a sub navigation
3//
4// Component: `uk-subnav`
5//
6// Modifiers: `uk-subnav-divider`
7// `uk-subnav-pill`
8//
9// States: `uk-active`
10// `uk-first-column`
11//
12// ========================================================================
13
14
15// Variables
16// ========================================================================
17
18$subnav-margin-horizontal: 20px !default;
19
20$subnav-item-color: $global-muted-color !default;
21$subnav-item-hover-color: $global-color !default;
22$subnav-item-hover-text-decoration: none !default;
23$subnav-item-active-color: $global-emphasis-color !default;
24
25$subnav-divider-margin-horizontal: $subnav-margin-horizontal !default;
26$subnav-divider-border-height: 1.5em !default;
27$subnav-divider-border-width: $global-border-width !default;
28$subnav-divider-border: $global-border !default;
29
30$subnav-pill-item-padding-vertical: 5px !default;
31$subnav-pill-item-padding-horizontal: 10px !default;
32$subnav-pill-item-background: transparent !default;
33$subnav-pill-item-color: $subnav-item-color !default;
34$subnav-pill-item-hover-background: $global-muted-background !default;
35$subnav-pill-item-hover-color: $global-color !default;
36$subnav-pill-item-onclick-background: $subnav-pill-item-hover-background !default;
37$subnav-pill-item-onclick-color: $subnav-pill-item-hover-color !default;
38$subnav-pill-item-active-background: $global-primary-background !default;
39$subnav-pill-item-active-color: $global-inverse-color !default;
40
41$subnav-item-disabled-color: $global-muted-color !default;
42
43
44/* ========================================================================
45 Component: Subnav
46 ========================================================================== */
47
48/*
49 * 1. Allow items to wrap into the next line
50 * 2. Gutter
51 * 3. Reset list
52 */
53
54.uk-subnav {
55 display: flex;
56 /* 1 */
57 flex-wrap: wrap;
58 /* 2 */
59 margin-left: (-$subnav-margin-horizontal);
60 /* 3 */
61 padding: 0;
62 list-style: none;
63 @if(mixin-exists(hook-subnav)) {@include hook-subnav();}
64}
65
66/*
67 * 1. Space is allocated solely based on content dimensions: 0 0 auto
68 * 2. Gutter
69 * 3. Create position context for dropdowns
70 */
71
72.uk-subnav > * {
73 /* 1 */
74 flex: none;
75 /* 2 */
76 padding-left: $subnav-margin-horizontal;
77 /* 3 */
78 position: relative;
79}
80
81
82/* Items
83 ========================================================================== */
84
85/*
86 * Items must target `a` elements to exclude other elements (e.g. dropdowns)
87 * Using `:first-child` instead of `a` to support `span` elements for text
88 * 1. Prevent gap if child element is `inline-block`, e.g. an icon
89 * 2. Style
90 */
91
92.uk-subnav > * > :first-child {
93 /* 1 */
94 display: block;
95 /* 2 */
96 color: $subnav-item-color;
97 @if(mixin-exists(hook-subnav-item)) {@include hook-subnav-item();}
98}
99
100/* Hover + Focus */
101.uk-subnav > * > a:hover,
102.uk-subnav > * > a:focus {
103 color: $subnav-item-hover-color;
104 text-decoration: $subnav-item-hover-text-decoration;
105 outline: none;
106 @if(mixin-exists(hook-subnav-item-hover)) {@include hook-subnav-item-hover();}
107}
108
109/* Active */
110.uk-subnav > .uk-active > a {
111 color: $subnav-item-active-color;
112 @if(mixin-exists(hook-subnav-item-active)) {@include hook-subnav-item-active();}
113}
114
115
116/* Divider modifier
117 ========================================================================== */
118
119/*
120 * 1. Align items and divider vertically
121 */
122
123.uk-subnav-divider > * {
124 /* 1 */
125 display: flex;
126 align-items: center;
127}
128
129/*
130 * Divider
131 * `nth-child` makes it also work without JS if it's only one row
132 */
133
134.uk-subnav-divider > :nth-child(n+2):not(.uk-first-column)::before {
135 content: "";
136 height: $subnav-divider-border-height;
137 margin-left: ($subnav-divider-margin-horizontal - $subnav-margin-horizontal);
138 margin-right: $subnav-divider-margin-horizontal;
139 border-left: $subnav-divider-border-width solid $subnav-divider-border;
140 @if(mixin-exists(hook-subnav-divider)) {@include hook-subnav-divider();}
141}
142
143
144/* Pill modifier
145 ========================================================================== */
146
147.uk-subnav-pill > * > :first-child {
148 padding: $subnav-pill-item-padding-vertical $subnav-pill-item-padding-horizontal;
149 background: $subnav-pill-item-background;
150 color: $subnav-pill-item-color;
151 @if(mixin-exists(hook-subnav-pill-item)) {@include hook-subnav-pill-item();}
152}
153
154/* Hover + Focus */
155.uk-subnav-pill > * > a:hover,
156.uk-subnav-pill > * > a:focus {
157 background-color: $subnav-pill-item-hover-background;
158 color: $subnav-pill-item-hover-color;
159 @if(mixin-exists(hook-subnav-pill-item-hover)) {@include hook-subnav-pill-item-hover();}
160}
161
162/* OnClick */
163.uk-subnav-pill > * > a:active {
164 background-color: $subnav-pill-item-onclick-background;
165 color: $subnav-pill-item-onclick-color;
166 @if(mixin-exists(hook-subnav-pill-item-onclick)) {@include hook-subnav-pill-item-onclick();}
167}
168
169/* Active */
170.uk-subnav-pill > .uk-active > a {
171 background-color: $subnav-pill-item-active-background;
172 color: $subnav-pill-item-active-color;
173 @if(mixin-exists(hook-subnav-pill-item-active)) {@include hook-subnav-pill-item-active();}
174}
175
176
177/* Disabled
178 * The same for all style modifiers
179 ========================================================================== */
180
181.uk-subnav > .uk-disabled > a {
182 color: $subnav-item-disabled-color;
183 @if(mixin-exists(hook-subnav-item-disabled)) {@include hook-subnav-item-disabled();}
184}
185
186
187// Hooks
188// ========================================================================
189
190@if(mixin-exists(hook-subnav-misc)) {@include hook-subnav-misc();}
191
192// @mixin hook-subnav(){}
193// @mixin hook-subnav-item(){}
194// @mixin hook-subnav-item-hover(){}
195// @mixin hook-subnav-item-active(){}
196// @mixin hook-subnav-divider(){}
197// @mixin hook-subnav-pill-item(){}
198// @mixin hook-subnav-pill-item-hover(){}
199// @mixin hook-subnav-pill-item-onclick(){}
200// @mixin hook-subnav-pill-item-active(){}
201// @mixin hook-subnav-item-disabled(){}
202// @mixin hook-subnav-misc(){}
203
204
205// Inverse
206// ========================================================================
207
208$inverse-subnav-item-color: $inverse-global-muted-color !default;
209$inverse-subnav-item-hover-color: $inverse-global-color !default;
210$inverse-subnav-item-active-color: $inverse-global-emphasis-color !default;
211$inverse-subnav-divider-border: $inverse-global-border !default;
212$inverse-subnav-pill-item-background: transparent !default;
213$inverse-subnav-pill-item-color: $inverse-global-muted-color !default;
214$inverse-subnav-pill-item-hover-background: $inverse-global-muted-background !default;
215$inverse-subnav-pill-item-hover-color: $inverse-global-color !default;
216$inverse-subnav-pill-item-onclick-background: $inverse-subnav-pill-item-hover-background !default;
217$inverse-subnav-pill-item-onclick-color: $inverse-subnav-pill-item-hover-color !default;
218$inverse-subnav-pill-item-active-background: $inverse-global-primary-background !default;
219$inverse-subnav-pill-item-active-color: $inverse-global-inverse-color !default;
220$inverse-subnav-item-disabled-color: $inverse-global-muted-color !default;
221
222
223
224// @mixin hook-inverse-subnav-item(){}
225// @mixin hook-inverse-subnav-item-hover(){}
226// @mixin hook-inverse-subnav-item-active(){}
227// @mixin hook-inverse-subnav-divider(){}
228// @mixin hook-inverse-subnav-pill-item(){}
229// @mixin hook-inverse-subnav-pill-item-hover(){}
230// @mixin hook-inverse-subnav-pill-item-onclick(){}
231// @mixin hook-inverse-subnav-pill-item-active(){}
232// @mixin hook-inverse-subnav-item-disabled(){}