forked from canonical/vanilla-framework
/
_patterns_side-navigation.scss
202 lines (169 loc) · 5.68 KB
/
_patterns_side-navigation.scss
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
@import 'settings';
@mixin vf-p-side-navigation {
// space for the right hand icon with default inner spacing on the left
$sp-sidenav--icon-spacing-width: map-get($icon-sizes, default) + $sph-inner;
.p-side-navigation,
.p-side-navigation--icons {
& > .p-side-navigation__list:first-child {
// nudge from top to put text on baseline grid
padding-top: 0.5 * $spv-inner--x-small;
}
}
.p-side-navigation__list {
@extend %vf-list;
& + & {
@extend %vf-pseudo-border--top;
&::after {
@include vf-side-navigation-spacing-left($prop: left);
top: -0.5 * $spv-outer--scaleable; // place border in the middle of the margin
}
.p-side-navigation--icons &::after {
@include vf-side-navigation-spacing-left($prop: left, $offset: $sp-sidenav--icon-spacing-width);
}
}
}
.p-side-navigation__item--title {
font-weight: $font-weight-bold;
}
.p-side-navigation__text,
.p-side-navigation__link {
@include vf-side-navigation-spacing-left;
display: flex;
padding-bottom: $spv-inner--x-small;
padding-right: $sph-inner;
padding-top: $spv-inner--x-small;
.p-side-navigation--icons & {
@include vf-side-navigation-spacing-left($offset: $sp-sidenav--icon-spacing-width);
position: relative;
}
// nested 2nd level of navigation
.p-side-navigation__item .p-side-navigation__item & {
@include vf-side-navigation-spacing-left($multiplier: 2);
// add spacing for variant with right side icons
.p-side-navigation--icons & {
@include vf-side-navigation-spacing-left($multiplier: 2, $offset: $sp-sidenav--icon-spacing-width);
}
}
// nested 3rd level of navigation
.p-side-navigation__item .p-side-navigation__item .p-side-navigation__item & {
@include vf-side-navigation-spacing-left($multiplier: 3);
// add spacing for variant with right side icons
.p-side-navigation--icons & {
@include vf-side-navigation-spacing-left($multiplier: 3, $offset: $sp-sidenav--icon-spacing-width);
}
}
}
.p-side-navigation--icons {
.p-side-navigation__icon {
@include vf-side-navigation-spacing-left($prop: left);
position: absolute;
top: $sph-inner--small;
}
}
.p-side-navigation__link {
@include vf-focus;
// vf-highlight-bar is rendered above focus outline
// so we need to hide it on focus
&:focus::before {
display: none;
}
&:hover {
text-decoration: none;
}
}
.p-side-navigation__status {
margin-left: auto;
padding-left: $spv-inner--small;
}
// Theming
@if ($theme-default-p-side-navigation == 'dark') {
.p-side-navigation,
.p-side-navigation--icons {
@include vf-side-navigation-theme-dark;
&.is-light {
@include vf-side-navigation-theme-light;
}
}
} @else {
.p-side-navigation,
.p-side-navigation--icons {
@include vf-side-navigation-theme-light;
&.is-dark {
@include vf-side-navigation-theme-dark;
}
}
}
}
// helper
// elements in side nav should be aligned from left based on grid margin for given screen size
// additional offset is added when icons are used or for nested navigation levels
@mixin vf-side-navigation-spacing-left(
// property to adjust spacing, defaults to `padding-left`
$prop: padding-left,
// how many times grid margin width should be multiplied (for nested navigation levels)
$multiplier: 1,
// offset to use for additional spacing (for icons)
$offset: 0
) {
@media (max-width: $threshold-4-6-col) {
#{$prop}: $multiplier * map-get($grid-margin-widths, small) + $offset;
}
@media (min-width: $threshold-4-6-col) and (max-width: $threshold-6-12-col) {
#{$prop}: $multiplier * map-get($grid-margin-widths, medium) + $offset;
}
@media (min-width: $threshold-6-12-col) {
#{$prop}: $multiplier * map-get($grid-margin-widths, large) + $offset;
}
}
// theme
@mixin vf-side-navigation-theme(
// default text color in sidebar
$color-sidenav-text-default,
// text color of highlighted items
$color-sidenav-text-active,
// background color of active/hovered items
$color-sidenav-item-background-highlight,
// border color of active item
$color-sidenav-item-border-highlight,
// border color of items list
$color-sidenav-list-border
) {
& {
color: $color-sidenav-text-default;
}
.p-side-navigation__list::after {
background: $color-sidenav-list-border;
}
.p-side-navigation__link {
&,
&:visited {
color: $color-sidenav-text-default;
}
&:hover,
&.is-active {
background: $color-sidenav-item-background-highlight;
color: $color-sidenav-text-active;
}
&.is-active {
@include vf-highlight-bar($color-sidenav-item-border-highlight, left);
}
}
}
@mixin vf-side-navigation-theme-light {
@include vf-side-navigation-theme(
$color-sidenav-text-default: $colors--light-theme--text-muted,
$color-sidenav-text-active: $colors--light-theme--text-default,
$color-sidenav-item-background-highlight: $colors--light-theme--background-highlight,
$color-sidenav-item-border-highlight: $colors--light-theme--text-default,
$color-sidenav-list-border: $colors--light-theme--border-low-contrast
);
}
@mixin vf-side-navigation-theme-dark {
@include vf-side-navigation-theme(
$color-sidenav-text-default: $colors--dark-theme--text-muted,
$color-sidenav-text-active: $colors--dark-theme--text-default,
$color-sidenav-item-background-highlight: $colors--dark-theme--background-highlight,
$color-sidenav-item-border-highlight: $colors--dark-theme--text-default,
$color-sidenav-list-border: $colors--dark-theme--border-low-contrast
);
}