matcha-theme 1.0.1 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,21 +14,26 @@
14
14
  // @param $primary
15
15
  // @param $lighter
16
16
  @function palette($base-palette, $default: 500, $lighter: 100, $darker: 700) {
17
- $result: map_merge($base-palette,
18
- (default: map-get($base-palette, $default),
17
+ $result: map_merge(
18
+ $base-palette,
19
+ (
20
+ default: map-get($base-palette, $default),
19
21
  lighter: map-get($base-palette, $lighter),
20
22
  darker: map-get($base-palette, $darker),
21
23
  default-contrast: map-contrast($base-palette, $default),
22
24
  lighter-contrast: map-contrast($base-palette, $lighter),
23
- darker-contrast: map-contrast($base-palette, $darker),
24
- ));
25
+ darker-contrast: map-contrast($base-palette, $darker)
26
+ )
27
+ );
25
28
 
26
29
  // For each hue in the palette, add a "-contrast" color to the map.
27
- @each $hue,
28
- $color in $base-palette {
29
- $result: map_merge($result,
30
- ("#{$hue}-contrast": map-contrast($base-palette, $hue),
31
- ));
30
+ @each $hue, $color in $base-palette {
31
+ $result: map_merge(
32
+ $result,
33
+ (
34
+ "#{$hue}-contrast": map-contrast($base-palette, $hue)
35
+ )
36
+ );
32
37
  }
33
38
 
34
39
  @return $result;
@@ -43,10 +48,9 @@
43
48
  // be treated as opacity.
44
49
  // @param $opacity The alpha channel value for the color.
45
50
  @function map-color($palette, $hue: default, $opacity: null) {
46
-
47
51
  // If hueKey is a number between zero and one, then it actually contains an
48
52
  // opacity value, so recall this function with the default hue and that given opacity.
49
- @if type-of($hue)==number and $hue >=0 and $hue <=1 {
53
+ @if type-of($hue) ==number and $hue >=0 and $hue <=1 {
50
54
  @return map-color($palette, default, $hue);
51
55
  }
52
56
 
@@ -64,65 +68,78 @@
64
68
 
65
69
  // Creates a container object for a light theme to be given to individual component theme mixins.
66
70
  @function light-theme($primary, $accent, $warn) {
67
- @return (primary: $primary,
71
+ @return (
72
+ primary: $primary,
68
73
  accent: $accent,
69
74
  warn: $warn,
70
75
  is-dark: false,
71
76
  foreground: $light-theme-foreground-palette,
72
- background: $light-theme-background-palette );
77
+ background: $light-theme-background-palette
78
+ );
73
79
  }
74
80
 
75
81
  // Creates a container object for a dark theme to be given to individual component theme mixins.
76
82
  @function dark-theme($primary, $accent, $warn) {
77
- @return (primary: $primary,
83
+ @return (
84
+ primary: $primary,
78
85
  accent: $accent,
79
86
  warn: $warn,
80
87
  is-dark: true,
81
88
  foreground: $dark-theme-foreground-palette,
82
- background: $dark-theme-background-palette );
89
+ background: $dark-theme-background-palette
90
+ );
83
91
  }
84
92
 
85
93
  // Creates a container object for a custom light theme to be given to individual component theme mixins.
86
94
  @function light-custom-theme($primary, $accent, $warn, $custom-light-fg, $custom-light-bg) {
87
- @return (primary: $primary,
95
+ @return (
96
+ primary: $primary,
88
97
  accent: $accent,
89
98
  warn: $warn,
90
99
  is-dark: false,
91
100
  foreground: $custom-light-fg,
92
- background: $custom-light-bg );
101
+ background: $custom-light-bg
102
+ );
93
103
  }
94
104
 
95
105
  // Creates a container object for a custom dark theme to be given to individual component theme mixins.
96
106
  @function dark-custom-theme($primary, $accent, $warn, $custom-dark-fg, $custom-dark-bg) {
97
- @return (primary: $primary,
107
+ @return (
108
+ primary: $primary,
98
109
  accent: $accent,
99
110
  warn: $warn,
100
111
  is-dark: true,
101
112
  foreground: $custom-dark-fg,
102
- background: $custom-dark-bg );
113
+ background: $custom-dark-bg
114
+ );
103
115
  }
104
116
 
105
117
  // -------------------------------------------------------------------------------------------------------------------
106
118
  // @ Typography functions
107
119
  // --------------------------------------------------------------------------------------------------------------------
108
120
  // Represents a typography level from the Material design spec.
109
- @function matcha-typography-level($font-size,
121
+ @function matcha-typography-level(
122
+ $font-size,
110
123
  $line-height: $font-size,
111
124
  $font-weight: 400,
112
125
  $font-family: null,
113
- $letter-spacing: null) {
114
- @return (font-size: $font-size,
126
+ $letter-spacing: null
127
+ ) {
128
+ @return (
129
+ font-size: $font-size,
115
130
  line-height: $line-height,
116
131
  font-weight: $font-weight,
117
132
  font-family: $font-family,
118
- letter-spacing: $letter-spacing );
133
+ letter-spacing: $letter-spacing
134
+ );
119
135
  }
120
136
 
121
137
  // Represents a collection of typography levels.
122
138
  // Defaults come from https://material.io/guidelines/style/typography.html
123
139
  // Note: The spec doesn't mention letter spacing. The values here come from
124
140
  // eyeballing it until it looked exactly like the spec examples.
125
- @function matcha-typography-config($font-family: '"CircularStd-Regular", "Helvetica Neue", "Arial", sans-serif, "angular";',
141
+ @function matcha-typography-config(
142
+ $font-family: '"CircularStd-Regular", "Helvetica Neue", "Arial", sans-serif, "angular";',
126
143
  $display-4: matcha-typography-level(112px, 112px, 300, $letter-spacing: -0.05em),
127
144
  $display-3: matcha-typography-level(56px, 56px, 400, $letter-spacing: -0.02em),
128
145
  $display-2: matcha-typography-level(45px, 48px, 400, $letter-spacing: -0.005em),
@@ -135,10 +152,12 @@
135
152
  $body-1: matcha-typography-level(14px, 20px, 400),
136
153
  $caption: matcha-typography-level(12px, 20px, 400),
137
154
  $button: matcha-typography-level(14px, 14px, 500),
138
- $input: matcha-typography-level(inherit, 1.125, 400)) {
155
+ $input: matcha-typography-level(inherit, 1.125, 400)
156
+ ) {
139
157
  // Line-height must be unit-less fraction of the font-size.
140
158
  // Declare an initial map with all of the levels.
141
- $config: (display-4: $display-4,
159
+ $config: (
160
+ display-4: $display-4,
142
161
  display-3: $display-3,
143
162
  display-2: $display-2,
144
163
  display-1: $display-1,
@@ -150,27 +169,35 @@
150
169
  body-1: $body-1,
151
170
  caption: $caption,
152
171
  button: $button,
153
- input: $input,
172
+ input: $input
154
173
  );
155
174
 
156
175
  // Loop through the levels and set the `font-family` of the ones that don't have one to the base.
157
176
  // Note that Sass can't modify maps in place, which means that we need to merge and re-assign.
158
- @each $key,
159
- $level in $config {
160
- @if map-get($level, font-family)==null {
161
- $new-level: map-merge($level,
162
- (font-family: $font-family,
163
- ));
164
- $config: map-merge($config,
165
- ($key: $new-level,
166
- ));
177
+ @each $key, $level in $config {
178
+ @if map-get($level, font-family) ==null {
179
+ $new-level: map-merge(
180
+ $level,
181
+ (
182
+ font-family: $font-family
183
+ )
184
+ );
185
+ $config: map-merge(
186
+ $config,
187
+ (
188
+ $key: $new-level
189
+ )
190
+ );
167
191
  }
168
192
  }
169
193
 
170
194
  // Add the base font family to the config.
171
- @return map-merge($config,
172
- (font-family: $font-family,
173
- ));
195
+ @return map-merge(
196
+ $config,
197
+ (
198
+ font-family: $font-family
199
+ )
200
+ );
174
201
  }
175
202
 
176
203
  // Utility for fetching a nested value from a typography config.
@@ -207,7 +234,7 @@
207
234
  }
208
235
 
209
236
  // Guard against unquoting non-string values, because it's deprecated.
210
- @return if(type-of($font-family)==string, unquote($font-family), $font-family);
237
+ @return if(type-of($font-family) ==string, unquote($font-family), $font-family);
211
238
  }
212
239
 
213
240
  // -------------------------------------------------------------------------------------------------------------------
@@ -216,9 +243,10 @@
216
243
  // A collection of functions that can be used to apply elevation to a material
217
244
 
218
245
  @function _get-umbra-map($color, $opacity) {
219
- $shadow-color: if(type-of($color)==color, rgba($color, $opacity * 0.033), $color);
246
+ $shadow-color: if(type-of($color) ==color, rgba($color, $opacity * 0.033), $color);
220
247
 
221
- @return (0: "0px 0px 0px 0px #{$shadow-color}",
248
+ @return (
249
+ 0: "0px 0px 0px 0px #{$shadow-color}",
222
250
  1: "0px 2px 2px 0px #{$shadow-color}",
223
251
  2: "0px 3px 2px -2px #{$shadow-color}",
224
252
  3: "0px 3px 3px -2px #{$shadow-color}",
@@ -247,9 +275,10 @@
247
275
  }
248
276
 
249
277
  @function _get-penumbra-map($color, $opacity) {
250
- $shadow-color: if(type-of($color)==color, rgba($color, $opacity * 0.033), $color);
278
+ $shadow-color: if(type-of($color) ==color, rgba($color, $opacity * 0.033), $color);
251
279
 
252
- @return (0: "0px 0px 0px 0px #{$shadow-color}",
280
+ @return (
281
+ 0: "0px 0px 0px 0px #{$shadow-color}",
253
282
  1: "0px 2px 2px 0px #{$shadow-color}",
254
283
  2: "0px 2px 3px 0px #{$shadow-color}",
255
284
  3: "0px 3px 4px 0px #{$shadow-color}",
@@ -278,9 +307,10 @@
278
307
  }
279
308
 
280
309
  @function _get-ambient-map($color, $opacity) {
281
- $shadow-color: if(type-of($color)==color, rgba($color, $opacity * 0.033), $color);
310
+ $shadow-color: if(type-of($color) ==color, rgba($color, $opacity * 0.033), $color);
282
311
 
283
- @return (0: "0px 0px 0px 0px #{$shadow-color}",
312
+ @return (
313
+ 0: "0px 0px 0px 0px #{$shadow-color}",
284
314
  1: "0px 2px 2px 0px #{$shadow-color}",
285
315
  2: "0px 1px 5px 0px #{$shadow-color}",
286
316
  3: "0px 1px 8px 0px #{$shadow-color}",
@@ -315,7 +345,24 @@
315
345
  // .foo {
316
346
  // transition: elevation-transition-property-value(), opacity 100ms ease;
317
347
  // }
318
- @function elevation-transition-property-value($duration: $elevation-transition-duration,
319
- $easing: $elevation-transition-timing-function) {
348
+ @function elevation-transition-property-value(
349
+ $duration: $elevation-transition-duration,
350
+ $easing: $elevation-transition-timing-function
351
+ ) {
320
352
  @return box-shadow #{$duration} #{$easing};
321
353
  }
354
+
355
+ // Define the variable for the base size (usually 16 pixels = 1 rem).
356
+ $base-font-size: 16px;
357
+
358
+ // Function to convert pixels to rem.
359
+ @function px-to-rem($value-in-px) {
360
+ @return ($value-in-px / $base-font-size) * 1rem;
361
+ }
362
+
363
+ // Example of use of the function:
364
+ // .example {
365
+ // font-size: px-to-rem(24px); // Converte 24px para rem.
366
+ // margin: px-to-rem(16px); // Converte 16px para rem.
367
+ // padding: px-to-rem(8px); // Converte 8px para rem.
368
+ // }
@@ -2,9 +2,7 @@
2
2
  // @ Display grids generator
3
3
  // -------------------------------------------------------------------------------------------------------------------
4
4
  @mixin display-grid($grid-prefix, $grid-length, $grid-sizes, $helper-breakpoints) {
5
-
6
- @each $sizeLabel,
7
- $value in $grid-sizes {
5
+ @each $sizeLabel, $value in $grid-sizes {
8
6
  .row-#{$sizeLabel} {
9
7
  display: flex;
10
8
  flex-direction: column;
@@ -12,11 +10,11 @@
12
10
 
13
11
  @media only screen and (min-width: #{$value}) {
14
12
  @for $i from 1 through $grid-length {
15
- .row>.#{$grid-prefix}-#{$sizeLabel}-#{$i} {
13
+ .row > .#{$grid-prefix}-#{$sizeLabel}-#{$i} {
16
14
  flex-basis: $i / $grid-length * 100%;
17
15
  }
18
16
 
19
- .row>.#{$grid-prefix}-offset-#{$sizeLabel}-#{$i} {
17
+ .row > .#{$grid-prefix}-offset-#{$sizeLabel}-#{$i} {
20
18
  margin-left: $i / $grid-length * 100%;
21
19
  }
22
20
  }
@@ -41,8 +39,7 @@
41
39
  }
42
40
  }
43
41
 
44
- @each $breakpoint,
45
- $materialBreakpoint in $helper-breakpoints {
42
+ @each $breakpoint, $materialBreakpoint in $helper-breakpoints {
46
43
  @include media-breakpoint($materialBreakpoint) {
47
44
  $infix: if($materialBreakpoint ==null, "", "-#{$breakpoint}");
48
45
 
@@ -72,16 +69,15 @@
72
69
  // @ Display flex generator
73
70
  // -------------------------------------------------------------------------------------------------------------------
74
71
  @mixin display-flex($grid-prefix, $grid-length, $grid-sizes) {
75
-
76
72
  .row {
77
73
  display: flex;
78
74
  flex-wrap: wrap;
79
75
 
80
- >div[class*="#{$grid-prefix}-"] {
76
+ > div[class*="#{$grid-prefix}-"] {
81
77
  box-sizing: border-box;
82
78
  }
83
79
 
84
- >div:not([class*="#{$grid-prefix}-"]) {
80
+ > div:not([class*="#{$grid-prefix}-"]) {
85
81
  flex: 1;
86
82
  }
87
83
 
@@ -94,8 +90,7 @@
94
90
  margin-left: $i / $grid-length * 100%;
95
91
  }
96
92
 
97
- @each $sizeLabel,
98
- $value in $grid-sizes {
93
+ @each $sizeLabel, $value in $grid-sizes {
99
94
  [class*="#{$grid-prefix}-offset-#{$sizeLabel}-"] {
100
95
  margin-left: 0;
101
96
  }
@@ -106,19 +101,22 @@
106
101
  }
107
102
  }
108
103
 
109
- @each $classLabel,
110
- $cssValue in (align-start flex-start, align-center center, align-end flex-end) {
111
- >div[class*="#{$grid-prefix}-"].#{$classLabel} {
104
+ @each $classLabel, $cssValue in (align-start flex-start, align-center center, align-end flex-end) {
105
+ > div[class*="#{$grid-prefix}-"].#{$classLabel} {
112
106
  align-self: $cssValue;
113
107
  }
114
108
  }
115
109
 
116
110
  @each $classLabel,
117
- $cssValue in (align-start flex-start,
118
- align-center center,
119
- align-end flex-end,
120
- space-around space-around,
121
- space-between space-between) {
111
+ $cssValue
112
+ in (
113
+ align-start flex-start,
114
+ align-center center,
115
+ align-end flex-end,
116
+ space-around space-around,
117
+ space-between space-between
118
+ )
119
+ {
122
120
  &.#{$classLabel} {
123
121
  justify-content: $cssValue;
124
122
  }
@@ -1,8 +1,8 @@
1
1
  // -----------------------------------------------------------------------------------------------------
2
2
  // @ Size helpers
3
3
  // -----------------------------------------------------------------------------------------------------
4
- @each $prop,
5
- $abbrev in (height: h, width: w) {
4
+ @each $prop, $abbrev in (height: h, width: w) {
5
+ // pixels - Without breakpoint infix
6
6
  @for $index from 0 through 64 {
7
7
  $size: $index * 4;
8
8
  $length: #{$size}px;
@@ -30,45 +30,125 @@ $abbrev in (height: h, width: w) {
30
30
  .min-#{$abbrev}-#{$size}--force {
31
31
  min-#{$prop}: $length !important;
32
32
  }
33
+ }
34
+
35
+ // percentage - Without breakpoint infix
36
+ @for $i from 0 through 20 {
37
+ $i-p: 5 * $i;
38
+ $size-p: 5% * $i;
39
+
40
+ .#{$abbrev}-#{$i-p}-p {
41
+ #{$prop}: $size-p !important;
42
+ }
43
+
44
+ .max-#{$abbrev}-#{$i-p}-p {
45
+ max-#{$prop}: $size-p !important;
46
+ }
47
+
48
+ .min-#{$abbrev}-#{$i-p}-p {
49
+ min-#{$prop}: $size-p !important;
50
+ }
51
+ }
52
+
53
+ // big sizes - Without breakpoint infix
54
+ @for $i from 3 through 8 {
55
+ $size: $i * 100;
56
+ $length: #{$size}px;
57
+
58
+ .#{$abbrev}-#{$size} {
59
+ #{$prop}: $length !important;
60
+ }
33
61
 
34
- @each $name,
35
- $value in $grid-sizes {
36
- @media only screen and (min-width: #{$value}) {
37
- .#{$abbrev}-#{$name}-#{$size} {
62
+ .max-#{$abbrev}-#{$size} {
63
+ max-#{$prop}: $length !important;
64
+ }
65
+
66
+ .min-#{$abbrev}-#{$size} {
67
+ min-#{$prop}: $length !important;
68
+ }
69
+ }
70
+
71
+ // auto - Without breakpoint infix
72
+ .#{$abbrev}-auto {
73
+ #{$prop}: auto !important;
74
+ }
75
+ }
76
+
77
+ @each $breakpoint-infix, $media-size in $helper-breakpoints {
78
+ @include media-breakpoint($media-size) {
79
+ $infix: if($media-size ==null, "", "-#{$breakpoint-infix}");
80
+
81
+ @each $prop, $abbrev in (height: h, width: w) {
82
+ // pixels - With breakpoint infix
83
+ @for $index from 0 through 64 {
84
+ $size: $index * 4;
85
+ $length: #{$size}px;
86
+
87
+ .#{$abbrev}#{$infix}-#{$size} {
38
88
  #{$prop}: $length;
39
89
  }
40
90
 
41
- .max-#{$abbrev}-#{$name}-#{$size} {
91
+ .max-#{$abbrev}#{$infix}-#{$size} {
42
92
  max-#{$prop}: $length;
43
93
  }
44
94
 
45
- .min-#{$abbrev}-#{$name}-#{$size} {
95
+ .min-#{$abbrev}#{$infix}-#{$size} {
46
96
  min-#{$prop}: $length;
47
97
  }
48
98
 
49
- .#{$abbrev}-#{$name}-#{$size}--force {
99
+ .#{$abbrev}#{$infix}-#{$size}--force {
50
100
  #{$prop}: $length !important;
51
101
  }
52
102
 
53
- .max-#{$abbrev}-#{$name}-#{$size}--force {
103
+ .max-#{$abbrev}#{$infix}-#{$size}--force {
54
104
  max-#{$prop}: $length !important;
55
105
  }
56
106
 
57
- .min-#{$abbrev}-#{$name}-#{$size}--force {
107
+ .min-#{$abbrev}#{$infix}-#{$size}--force {
58
108
  min-#{$prop}: $length !important;
59
109
  }
110
+ }
111
+
112
+ // percentage - With breakpoint infix
113
+ @for $i from 0 through 20 {
114
+ $i-p: 5 * $i;
115
+ $size-p: 5% * $i;
116
+
117
+ .#{$abbrev}#{$infix}-#{$i-p}-p {
118
+ #{$prop}: $size-p !important;
119
+ }
60
120
 
121
+ .max-#{$abbrev}#{$infix}-#{$i-p}-p {
122
+ max-#{$prop}: $size-p !important;
123
+ }
124
+
125
+ .min-#{$abbrev}#{$infix}-#{$i-p}-p {
126
+ min-#{$prop}: $size-p !important;
127
+ }
61
128
  }
62
- }
63
- }
64
129
 
65
- // Percentage
66
- @for $i from 0 through 20 {
67
- $i-p: 5 * $i;
68
- $size-p: 5% * $i;
130
+ // big sizes - With breakpoint infix
131
+ @for $i from 3 through 8 {
132
+ $size: $i * 100;
133
+ $length: #{$size}px;
69
134
 
70
- .#{$abbrev}-#{$i-p}-p {
71
- #{$prop}: $size-p !important;
135
+ .#{$abbrev}#{$infix}-#{$size} {
136
+ #{$prop}: $length !important;
137
+ }
138
+
139
+ .max-#{$abbrev}#{$infix}-#{$size} {
140
+ max-#{$prop}: $length !important;
141
+ }
142
+
143
+ .min-#{$abbrev}#{$infix}-#{$size} {
144
+ min-#{$prop}: $length !important;
145
+ }
146
+ }
147
+
148
+ // auto - With breakpoint infix
149
+ .#{$abbrev}#{$infix}-auto {
150
+ #{$prop}: auto !important;
151
+ }
72
152
  }
73
153
  }
74
154
  }