UNPKG

3.57 kBSCSSView Raw
1// Foundation for Sites by ZURB
2// foundation.zurb.com
3// Licensed under MIT Open Source
4
5////
6/// @group accordion
7////
8
9/// Default background color of an accordion group.
10/// @type Color
11$accordion-background: $white !default;
12
13/// If `true`, adds plus and minus icons to the side of each accordion title.
14/// @type Boolean
15$accordion-plusminus: true !default;
16
17/// Font size of accordion titles.
18/// @type Number
19$accordion-title-font-size: rem-calc(12) !default;
20
21/// Default text color for items in a Menu.
22/// @type Color
23$accordion-item-color: $primary-color !default;
24
25/// Default background color on hover for items in a Menu.
26/// @type Color
27$accordion-item-background-hover: $light-gray !default;
28
29/// Default padding of an accordion item.
30/// @type Number | List
31$accordion-item-padding: 1.25rem 1rem !default;
32
33/// Default background color of tab content.
34/// @type Color
35$accordion-content-background: $white !default;
36
37/// Default border color of tab content.
38/// @type Color
39$accordion-content-border: 1px solid $light-gray !default;
40
41/// Default text color of tab content.
42/// @type Color
43$accordion-content-color: $body-font-color !default;
44
45/// Default padding for tab content.
46/// @type Number | List
47$accordion-content-padding: 1rem !default;
48
49/// Adds styles for an accordion container. Apply this to the same element that gets `data-accordion`.
50@mixin accordion-container (
51 $background: $accordion-background
52) {
53 margin-#{$global-left}: 0;
54 background: $background;
55 list-style-type: none;
56 &[disabled] {
57 .accordion-title {
58 cursor: not-allowed;
59 }
60 }
61}
62
63/// Adds styles for the accordion item. Apply this to the list item within an accordion ul.
64@mixin accordion-item {
65 &:first-child > :first-child {
66 border-radius: $global-radius $global-radius 0 0;
67 }
68
69 &:last-child > :last-child {
70 border-radius: 0 0 $global-radius $global-radius;
71 }
72}
73
74/// Adds styles for the title of an accordion item. Apply this to the link within an accordion item.
75@mixin accordion-title (
76 $padding: $accordion-item-padding,
77 $font-size: $accordion-title-font-size,
78 $color: $accordion-item-color,
79 $border: $accordion-content-border,
80 $background-hover: $accordion-item-background-hover
81) {
82 position: relative;
83 display: block;
84 padding: $padding;
85
86 border: $border;
87 border-bottom: 0;
88
89 font-size: $font-size;
90 line-height: 1;
91 color: $color;
92
93 :last-child:not(.is-active) > & {
94 border-bottom: $border;
95 border-radius: 0 0 $global-radius $global-radius;
96 }
97
98 &:hover,
99 &:focus {
100 background-color: $background-hover;
101 }
102
103 @if $accordion-plusminus {
104 &::before {
105 position: absolute;
106 top: 50%;
107 #{$global-right}: 1rem;
108 margin-top: -0.5rem;
109 content: '+';
110 }
111
112 .is-active > &::before {
113 content: '\2013';
114 }
115 }
116}
117
118/// Adds styles for accordion content. Apply this to the content pane below an accordion item's title.
119@mixin accordion-content (
120 $padding: $accordion-content-padding,
121 $border: $accordion-content-border,
122 $background: $accordion-content-background,
123 $color: $accordion-content-color
124) {
125 display: none;
126 padding: $padding;
127
128 border: $border;
129 border-bottom: 0;
130 background-color: $background;
131
132 color: $color;
133
134 :last-child > &:last-child {
135 border-bottom: $border;
136 }
137}
138
139@mixin foundation-accordion {
140 .accordion {
141 @include accordion-container;
142 }
143
144 .accordion-item {
145 @include accordion-item;
146 }
147
148 .accordion-title {
149 @include accordion-title;
150 }
151
152 .accordion-content {
153 @include accordion-content;
154 }
155}