UNPKG

3.58 kBSCSSView Raw
1// Foundation for Sites by ZURB
2// foundation.zurb.com
3// Licensed under MIT Open Source
4
5////
6/// @group top-bar
7////
8
9/// Padding for the top bar.
10/// @type Number
11$topbar-padding: 0.5rem !default;
12
13/// Background color for the top bar. This color also cascades to menus within the top bar.
14/// @type Color
15$topbar-background: $light-gray !default;
16
17/// Background color submenus within the top bar. Usefull if $topbar-background is transparent.
18/// @type Color
19$topbar-submenu-background: $topbar-background !default;
20
21/// Spacing for the top bar title.
22/// @type Number
23$topbar-title-spacing: 0.5rem 1rem 0.5rem 0 !default;
24
25/// Maximum width of `<input>` elements inside the top bar.
26/// @type Number
27$topbar-input-width: 200px !default;
28
29/// Breakpoint at which top bar switches from mobile to desktop view.
30/// @type Breakpoint
31$topbar-unstack-breakpoint: medium !default;
32
33/// Adds styles for a top bar container.
34@mixin top-bar-container {
35 @if $global-flexbox {
36 display: flex;
37 flex-wrap: nowrap;
38 justify-content: space-between;
39 align-items: center;
40 }
41 @else {
42 @include clearfix;
43 }
44
45 padding: $topbar-padding;
46
47 &,
48 ul {
49 background-color: $topbar-background;
50 }
51
52 // Check if $topbar-background is differnt from $topbar-background-submenu
53 @if ($topbar-background != $topbar-submenu-background) {
54 ul ul {
55 background-color: $topbar-submenu-background;
56 }
57 }
58
59 // Restrain width of inputs by default to make them easier to arrange
60 input {
61 max-width: $topbar-input-width;
62 margin-#{$global-right}: 1rem;
63 }
64
65 // The above styles shouldn't apply to input group fields
66 .input-group-field {
67 width: 100%;
68 margin-#{$global-right}: 0;
69 }
70
71 input.button { // sass-lint:disable-line no-qualifying-elements
72 width: auto;
73 }
74}
75
76/// Makes sections of a top bar stack on top of each other.
77@mixin top-bar-stacked {
78 @if $global-flexbox {
79 flex-wrap: wrap;
80
81 // Sub-sections
82 .top-bar-left,
83 .top-bar-right {
84 flex: 0 0 100%;
85 max-width: 100%;
86 }
87 }
88 @else {
89 // Sub-sections
90 .top-bar-left,
91 .top-bar-right {
92 width: 100%;
93 }
94 }
95}
96
97/// Undoes the CSS applied by the `top-bar-stacked()` mixin.
98@mixin top-bar-unstack {
99 @if $global-flexbox {
100 flex-wrap: nowrap;
101
102 .top-bar-left {
103 flex: 1 1 auto;
104 margin-right: auto;
105 }
106
107 .top-bar-right {
108 flex: 0 1 auto;
109 margin-left: auto;
110 }
111 }
112 @else {
113 .top-bar-left,
114 .top-bar-right {
115 width: auto;
116 }
117 }
118}
119
120@mixin foundation-top-bar {
121 // Top bar container
122 .top-bar {
123 @include top-bar-container;
124
125 // Stack on small screens by default
126 @include top-bar-stacked;
127
128 @include breakpoint($topbar-unstack-breakpoint) {
129 @include top-bar-unstack;
130 }
131
132 // Generate classes for stacking on each screen size (defined in $breakpoint-classes)
133 @each $size in $breakpoint-classes {
134 @if $size != $-zf-zero-breakpoint {
135 &.stacked-for-#{$size} {
136 @include breakpoint($size down) {
137 @include top-bar-stacked;
138 }
139 }
140 }
141 }
142 }
143
144 // Sub-sections
145 @if $global-flexbox {
146 .top-bar-title {
147 flex: 0 0 auto;
148 margin: $topbar-title-spacing;
149 }
150
151 .top-bar-left,
152 .top-bar-right {
153 flex: 0 0 auto;
154 }
155 }
156 @else {
157 .top-bar-title {
158 display: inline-block;
159 float: left;
160 padding: $topbar-title-spacing;
161
162 .menu-icon {
163 bottom: 2px;
164 }
165 }
166
167 .top-bar-left {
168 float: left;
169 }
170
171 .top-bar-right {
172 float: right;
173 }
174 }
175}