Skip to content

Commit 6fedb6a

Browse files
authored
Add support to customize the path of the custom fonts (#12)
* Add support to customize the path of the custom fonts * Remove unnecessary conditional check * Improve body resets * Avoid always adding the :root selector
1 parent 3310e06 commit 6fedb6a

File tree

1 file changed

+39
-33
lines changed

1 file changed

+39
-33
lines changed

packages/unanimo/src/unanimo.scss

Lines changed: 39 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444

4545
// Font face
4646
$font-face: true,
47+
$font-face-path: "./assets/fonts/",
4748

4849
// Base
4950
$base-classes: true,
@@ -63,25 +64,25 @@
6364
$tree-view-navigation: true
6465
) {
6566
// font-face
66-
@if $font-face == true {
67+
@if $font-face {
6768
@font-face {
6869
font-family: SourceSansPro_Regular; // 400
69-
src: url("./assets/fonts/SourceSansPro_Regular.woff2");
70+
src: url("#{$font-face-path}SourceSansPro_Regular.woff2");
7071
}
7172

7273
@font-face {
73-
font-family: SourceSansPro_SemiBold; // 700
74-
src: url("./assets/fonts/SourceSansPro_SemiBold.woff2");
74+
font-family: SourceSansPro_SemiBold; // 600
75+
src: url("#{$font-face-path}SourceSansPro_SemiBold.woff2");
7576
}
7677

7778
@font-face {
7879
font-family: SourceSansPro_Bold; // 700
79-
src: url("./assets/fonts/SourceSansPro_Bold.woff2");
80+
src: url("#{$font-face-path}SourceSansPro_Bold.woff2");
8081
}
8182
}
8283

8384
// Light
84-
@if $light-theme == true and $colors == true and $tokens == true {
85+
@if $light-theme and $colors and $tokens {
8586
@media (prefers-color-scheme: light) {
8687
:root {
8788
@include foundation-colors--light();
@@ -91,7 +92,7 @@
9192
}
9293

9394
// Dark
94-
@if $dark-theme == true and $colors == true and $tokens == true {
95+
@if $dark-theme and $colors and $tokens {
9596
@media (prefers-color-scheme: dark) {
9697
:root {
9798
@include foundation-colors--dark();
@@ -100,42 +101,47 @@
100101
}
101102
}
102103

103-
:root {
104-
@if $tokens == true {
104+
@if $tokens and
105+
($border-radius or $box-shadow or $colors or $font-size or $spacing)
106+
{
107+
:root {
105108
// border-radius
106-
@if $border-radius == true {
109+
@if $border-radius {
107110
@include border-radius();
108111
}
109112

110113
// box-shadow
111-
@if $box-shadow == true {
114+
@if $box-shadow {
112115
@include box-shadow();
113116
}
114117

115118
// General colors
116-
@if $colors == true {
119+
@if $colors {
117120
@include semantic-colors--general();
118121
}
119122

120123
// font-size
121-
@if $font-size == true {
124+
@if $font-size {
122125
@include font-size();
123126
}
124127

125128
// spacing
126-
@if $spacing == true {
129+
@if $spacing {
127130
@include spacing();
128131
}
129132
}
130133
}
131134

132135
// Default background-color and color
133-
@if $tokens == true and $colors == true {
136+
@if $tokens and $colors {
134137
body {
138+
display: grid;
139+
min-block-size: 100dvh;
140+
margin: 0;
135141
background-color: var(--surface-un-surface--alternative);
136142
color: var(--text-un-text__on-surface--positive);
137143

138-
@if $font-face == true {
144+
@if $font-face {
139145
font-family: SourceSansPro_Regular;
140146
}
141147
}
@@ -144,83 +150,83 @@
144150
// - - - - - - - - - - - - - - - - - - - -
145151
// Resets
146152
// - - - - - - - - - - - - - - - - - - - -
147-
@if $resets == true {
153+
@if $resets {
148154
// box-sizing
149-
@if $box-sizing-reset == true {
155+
@if $box-sizing-reset {
150156
@include box-sizing();
151157
}
152158

153159
// <button> and <a> reset
154-
@if $button-reset == true {
160+
@if $button-reset {
155161
@include button-reset();
156162
}
157163

158-
@if $input-reset == true {
164+
@if $input-reset {
159165
@include input-reset();
160166
}
161167

162168
// <hr> reset
163-
@if $other-reset == true {
169+
@if $other-reset {
164170
@include other-reset();
165171
}
166172

167173
// Typography reset
168-
@if $typography-reset == true {
174+
@if $typography-reset {
169175
@include typography-reset();
170176
}
171177
}
172178

173179
// - - - - - - - - - - - - - - - - - - - -
174180
// Base classes
175181
// - - - - - - - - - - - - - - - - - - - -
176-
@if $base-classes == true {
182+
@if $base-classes {
177183
// Button classes
178-
@if $button-classes == true {
184+
@if $button-classes {
179185
@include button-classes();
180186
}
181187

182188
// Form control classes
183-
@if $form-controls-classes == true {
189+
@if $form-controls-classes {
184190
@include form-controls-classes();
185191
}
186192

187193
// Typography classes
188-
@if $typography-classes == true {
194+
@if $typography-classes {
189195
@include typography-classes();
190196
}
191197
}
192198

193199
// - - - - - - - - - - - - - - - - - - - -
194200
// Components
195201
// - - - - - - - - - - - - - - - - - - - -
196-
@if $components == true {
202+
@if $components {
197203
// card
198-
@if $card == true {
204+
@if $card {
199205
@include card();
200206
}
201207

202208
// header
203-
@if $header == true {
209+
@if $header {
204210
@include header();
205211
}
206212

207213
// markdown
208-
@if $markdown == true {
214+
@if $markdown {
209215
@include markdown();
210216
}
211217

212218
// tab
213-
@if $tab == true {
219+
@if $tab {
214220
@include tab();
215221
}
216222

217223
// tree-view
218-
@if $tree-view == true {
224+
@if $tree-view {
219225
@include tree-view();
220226
}
221227

222228
// tree-view-navigation
223-
@if $tree-view-navigation == true {
229+
@if $tree-view-navigation {
224230
@include tree-view-navigation();
225231
}
226232
}

0 commit comments

Comments
 (0)