mtrl 0.0.3 → 0.1.2

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.
Files changed (45) hide show
  1. package/package.json +1 -1
  2. package/src/components/button/styles.scss +198 -161
  3. package/src/components/checkbox/checkbox.js +3 -2
  4. package/src/components/checkbox/styles.scss +105 -55
  5. package/src/components/container/styles.scss +65 -58
  6. package/src/components/list/constants.js +0 -5
  7. package/src/components/list/list-item.js +12 -4
  8. package/src/components/list/list.js +11 -19
  9. package/src/components/list/styles.scss +240 -11
  10. package/src/components/menu/styles.scss +37 -30
  11. package/src/components/navigation/styles.scss +406 -6
  12. package/src/components/snackbar/styles.scss +46 -17
  13. package/src/components/switch/styles.scss +93 -46
  14. package/src/components/textfield/styles.scss +351 -5
  15. package/src/core/build/_ripple.scss +79 -0
  16. package/src/core/dom/create.js +0 -1
  17. package/src/core/layout/index.js +3 -1
  18. package/src/styles/abstract/_mixins.scss +9 -7
  19. package/src/styles/abstract/_theme.scss +157 -0
  20. package/src/styles/abstract/_variables.scss +72 -6
  21. package/src/styles/base/_reset.scss +86 -0
  22. package/src/styles/base/_typography.scss +155 -0
  23. package/src/styles/main.scss +104 -57
  24. package/src/styles/themes/_autumn.scss +81 -0
  25. package/src/styles/themes/_base-theme.scss +2 -27
  26. package/src/styles/themes/_baseline.scss +64 -39
  27. package/src/styles/themes/_forest.scss +46 -46
  28. package/src/styles/themes/_spring.scss +71 -0
  29. package/src/styles/themes/_summer.scss +82 -0
  30. package/src/styles/themes/_winter.scss +71 -0
  31. package/src/styles/utilities/_color.scss +154 -0
  32. package/src/styles/utilities/_flexbox.scss +194 -0
  33. package/src/styles/utilities/_spacing.scss +139 -0
  34. package/src/styles/utilities/_typography.scss +178 -0
  35. package/src/styles/utilities/_visibility.scss +142 -0
  36. package/src/components/list/styles/_list-item.scss +0 -142
  37. package/src/components/list/styles/_list.scss +0 -89
  38. package/src/components/list/styles/_variables.scss +0 -13
  39. package/src/components/navigation/styles/_bar.scss +0 -51
  40. package/src/components/navigation/styles/_base.scss +0 -129
  41. package/src/components/navigation/styles/_drawer.scss +0 -169
  42. package/src/components/navigation/styles/_rail.scss +0 -65
  43. package/src/components/textfield/styles/base.scss +0 -107
  44. package/src/components/textfield/styles/filled.scss +0 -58
  45. package/src/components/textfield/styles/outlined.scss +0 -66
@@ -41,7 +41,9 @@ const createLayout = (schema, container, structure = {}, level = 0, components =
41
41
  options = schema[i + 2]
42
42
  }
43
43
 
44
- if (typeof schema[i + 1] === 'string') {
44
+ if (options.id) {
45
+ name = options.id
46
+ } else if (typeof schema[i + 1] === 'string') {
45
47
  name = schema[i + 1]
46
48
  if (!schema[i].isElement && !schema[i].isComponent) {
47
49
  options.name = name
@@ -232,8 +232,8 @@ $icons: (
232
232
  }
233
233
  }
234
234
 
235
- // Touch Target
236
235
  @mixin touch-target($size: 48px) {
236
+ // Position first to avoid the deprecation warning
237
237
  position: relative;
238
238
 
239
239
  &::after {
@@ -244,6 +244,14 @@ $icons: (
244
244
  height: $size;
245
245
  transform: translate(-50%, -50%);
246
246
  }
247
+
248
+ @media (prefers-reduced-motion: reduce) {
249
+ @content;
250
+ }
251
+
252
+ @media (forced-colors: active) {
253
+ @content;
254
+ }
247
255
  }
248
256
 
249
257
  // Scrollbars
@@ -322,12 +330,6 @@ $icons: (
322
330
  }
323
331
  }
324
332
 
325
- @mixin flex-center {
326
- display: flex;
327
- align-items: center;
328
- justify-content: center;
329
- }
330
-
331
333
  // Print
332
334
  @mixin print {
333
335
  @media print {
@@ -0,0 +1,157 @@
1
+ // src/styles/abstract/_theme.scss
2
+ @use 'sass:map';
3
+ @use 'base' as *;
4
+ @use 'variables' as v;
5
+
6
+ // System-level tokens mapped to CSS variables
7
+ $mtrl-sys-state: (
8
+ 'hover-state-layer-opacity': v.$state('hover-state-layer-opacity'),
9
+ 'focus-state-layer-opacity': v.$state('focus-state-layer-opacity'),
10
+ 'pressed-state-layer-opacity': v.$state('pressed-state-layer-opacity'),
11
+ 'dragged-state-layer-opacity': v.$state('dragged-state-layer-opacity')
12
+ );
13
+
14
+ $mtrl-sys-motion: (
15
+ 'duration-short1': v.$motion('duration-short1'),
16
+ 'duration-short2': v.$motion('duration-short2'),
17
+ 'duration-short3': v.$motion('duration-short3'),
18
+ 'duration-short4': v.$motion('duration-short4'),
19
+ 'duration-medium1': v.$motion('duration-medium1'),
20
+ 'duration-medium2': v.$motion('duration-medium2'),
21
+ 'duration-long1': v.$motion('duration-long1'),
22
+ 'duration-long2': v.$motion('duration-long2'),
23
+ 'easing-standard': v.$motion('easing-standard'),
24
+ 'easing-standard-accelerate': v.$motion('easing-standard-accelerate'),
25
+ 'easing-standard-decelerate': v.$motion('easing-standard-decelerate'),
26
+ 'easing-emphasized': v.$motion('easing-emphasized'),
27
+ 'easing-emphasized-accelerate': v.$motion('easing-emphasized-accelerate'),
28
+ 'easing-emphasized-decelerate': v.$motion('easing-emphasized-decelerate')
29
+ );
30
+
31
+ $mtrl-sys-shape: (
32
+ 'none': v.$shape('none'),
33
+ 'extra-small': v.$shape('extra-small'),
34
+ 'small': v.$shape('small'),
35
+ 'medium': v.$shape('medium'),
36
+ 'large': v.$shape('large'),
37
+ 'extra-large': v.$shape('extra-large'),
38
+ 'full': v.$shape('full'),
39
+ 'pill': v.$shape('pill')
40
+ );
41
+
42
+ // Generate CSS variable utilities
43
+ @function color($key) {
44
+ @return var(--#{$prefix}-sys-color-#{$key});
45
+ }
46
+
47
+ @function rgb($key) {
48
+ @return var(--#{$prefix}-sys-color-#{$key}-rgb);
49
+ }
50
+
51
+ @function alpha($key, $opacity) {
52
+ @return rgba(var(--#{$prefix}-sys-color-#{$key}-rgb), $opacity);
53
+ }
54
+
55
+ @function state($key) {
56
+ @return var(--#{$prefix}-sys-state-#{$key});
57
+ }
58
+
59
+ @function motion($key) {
60
+ @return var(--#{$prefix}-sys-motion-#{$key});
61
+ }
62
+
63
+ @function shape($key) {
64
+ @return var(--#{$prefix}-sys-shape-#{$key});
65
+ }
66
+
67
+ // Theme management utilities
68
+ @mixin dark-theme {
69
+ // Key colors
70
+ --#{$prefix}-sys-color-primary: #D0BCFF;
71
+ --#{$prefix}-sys-color-primary-rgb: 208, 188, 255;
72
+ --#{$prefix}-sys-color-on-primary: #381E72;
73
+ --#{$prefix}-sys-color-primary-container: #4F378B;
74
+ --#{$prefix}-sys-color-on-primary-container: #EADDFF;
75
+
76
+ --#{$prefix}-sys-color-secondary: #CCC2DC;
77
+ --#{$prefix}-sys-color-on-secondary: #332D41;
78
+ --#{$prefix}-sys-color-secondary-container: #4A4458;
79
+ --#{$prefix}-sys-color-on-secondary-container: #E8DEF8;
80
+
81
+ --#{$prefix}-sys-color-tertiary: #EFB8C8;
82
+ --#{$prefix}-sys-color-on-tertiary: #492532;
83
+ --#{$prefix}-sys-color-tertiary-container: #633B48;
84
+ --#{$prefix}-sys-color-on-tertiary-container: #FFD8E4;
85
+
86
+ // Neutral colors
87
+ --#{$prefix}-sys-color-surface: #1C1B1F;
88
+ --#{$prefix}-sys-color-surface-dim: #141218;
89
+ --#{$prefix}-sys-color-surface-bright: #3B383D;
90
+ --#{$prefix}-sys-color-surface-container-lowest: #0F0D13;
91
+ --#{$prefix}-sys-color-surface-container-low: #1D1B20;
92
+ --#{$prefix}-sys-color-surface-container: #211F26;
93
+ --#{$prefix}-sys-color-surface-container-high: #2B2930;
94
+ --#{$prefix}-sys-color-surface-container-highest: #36343B;
95
+
96
+ --#{$prefix}-sys-color-on-surface: #E6E1E5;
97
+ --#{$prefix}-sys-color-on-surface-variant: #CAC4D0;
98
+ --#{$prefix}-sys-color-on-surface-rgb: 230, 225, 229;
99
+
100
+ // Additional colors
101
+ --#{$prefix}-sys-color-outline: #938F99;
102
+ --#{$prefix}-sys-color-outline-variant: #444746;
103
+ --#{$prefix}-sys-color-shadow: #000000;
104
+ --#{$prefix}-sys-color-scrim: #000000;
105
+ --#{$prefix}-sys-color-inverse-surface: #E6E1E5;
106
+ --#{$prefix}-sys-color-inverse-on-surface: #313033;
107
+ --#{$prefix}-sys-color-inverse-primary: #6750A4;
108
+ }
109
+
110
+ @mixin light-theme {
111
+ // Key colors
112
+ --#{$prefix}-sys-color-primary: #6750A4;
113
+ --#{$prefix}-sys-color-primary-rgb: 103, 80, 164;
114
+ --#{$prefix}-sys-color-on-primary: #FFFFFF;
115
+ --#{$prefix}-sys-color-primary-container: #EADDFF;
116
+ --#{$prefix}-sys-color-on-primary-container: #21005D;
117
+
118
+ --#{$prefix}-sys-color-secondary: #625B71;
119
+ --#{$prefix}-sys-color-on-secondary: #FFFFFF;
120
+ --#{$prefix}-sys-color-secondary-container: #E8DEF8;
121
+ --#{$prefix}-sys-color-on-secondary-container: #1D192B;
122
+
123
+ --#{$prefix}-sys-color-tertiary: #7D5260;
124
+ --#{$prefix}-sys-color-on-tertiary: #FFFFFF;
125
+ --#{$prefix}-sys-color-tertiary-container: #FFD8E4;
126
+ --#{$prefix}-sys-color-on-tertiary-container: #31111D;
127
+
128
+ // Neutral colors
129
+ --#{$prefix}-sys-color-surface: #FFFBFE;
130
+ --#{$prefix}-sys-color-surface-dim: #DED8E1;
131
+ --#{$prefix}-sys-color-surface-bright: #FFF8F7;
132
+ --#{$prefix}-sys-color-surface-container-lowest: #FFFFFF;
133
+ --#{$prefix}-sys-color-surface-container-low: #F7F2FA;
134
+ --#{$prefix}-sys-color-surface-container: #F3EDF7;
135
+ --#{$prefix}-sys-color-surface-container-high: #ECE6F0;
136
+ --#{$prefix}-sys-color-surface-container-highest: #E6E0E9;
137
+
138
+ --#{$prefix}-sys-color-on-surface: #1C1B1F;
139
+ --#{$prefix}-sys-color-on-surface-variant: #49454F;
140
+ --#{$prefix}-sys-color-on-surface-rgb: 28, 27, 31;
141
+
142
+ // Additional colors
143
+ --#{$prefix}-sys-color-outline: #79747E;
144
+ --#{$prefix}-sys-color-outline-variant: #CAC4D0;
145
+ --#{$prefix}-sys-color-shadow: #000000;
146
+ --#{$prefix}-sys-color-scrim: #000000;
147
+ --#{$prefix}-sys-color-inverse-surface: #313033;
148
+ --#{$prefix}-sys-color-inverse-on-surface: #F4EFF4;
149
+ --#{$prefix}-sys-color-inverse-primary: #D0BCFF;
150
+ }
151
+
152
+ // Auto dark mode based on system preference
153
+ @mixin auto-dark-mode {
154
+ @media (prefers-color-scheme: dark) {
155
+ @include dark-theme;
156
+ }
157
+ }
@@ -1,14 +1,12 @@
1
1
  // src/styles/abstract/_variables.scss
2
2
  @use 'sass:map';
3
+ @use 'base' as *;
3
4
 
4
- // Core configuration
5
- $prefix: 'mtrl' !default;
6
-
7
- // Design tokens
5
+ // Core design tokens
8
6
  $state: (
9
7
  'hover-state-layer-opacity': 0.08,
10
- 'pressed-state-layer-opacity': 0.12,
11
8
  'focus-state-layer-opacity': 0.12,
9
+ 'pressed-state-layer-opacity': 0.12,
12
10
  'dragged-state-layer-opacity': 0.16
13
11
  ) !default;
14
12
 
@@ -81,6 +79,27 @@ $typescale: (
81
79
  'letter-spacing': 0,
82
80
  'font-weight': 400
83
81
  ),
82
+ 'title-large': (
83
+ 'font-family': ('Roboto', sans-serif),
84
+ 'font-size': 22px,
85
+ 'line-height': 28px,
86
+ 'letter-spacing': 0,
87
+ 'font-weight': 500
88
+ ),
89
+ 'title-medium': (
90
+ 'font-family': ('Roboto', sans-serif),
91
+ 'font-size': 16px,
92
+ 'line-height': 24px,
93
+ 'letter-spacing': 0.15px,
94
+ 'font-weight': 500
95
+ ),
96
+ 'title-small': (
97
+ 'font-family': ('Roboto', sans-serif),
98
+ 'font-size': 14px,
99
+ 'line-height': 20px,
100
+ 'letter-spacing': 0.1px,
101
+ 'font-weight': 500
102
+ ),
84
103
  'body-large': (
85
104
  'font-family': ('Roboto', sans-serif),
86
105
  'font-size': 16px,
@@ -127,6 +146,8 @@ $typescale: (
127
146
 
128
147
  $shape: (
129
148
  'none': 0,
149
+ 'extra-tiny': 1px,
150
+ 'tiny': 2px,
130
151
  'extra-small': 4px,
131
152
  'small': 8px,
132
153
  'medium': 12px,
@@ -156,4 +177,49 @@ $z-index: (
156
177
  'fixed': 50,
157
178
  'default': 1,
158
179
  'below': -1
159
- ) !default;
180
+ ) !default;
181
+
182
+ // Component-specific tokens
183
+ $button: (
184
+ 'height': 40px,
185
+ 'min-width': 64px,
186
+ 'padding-horizontal': 24px,
187
+ 'padding-horizontal-small': 16px,
188
+ 'padding-icon': 16px,
189
+ 'border-radius': map.get($shape, 'full'),
190
+ 'transition-duration': map.get($motion, 'duration-short2'),
191
+ 'transition-easing': map.get($motion, 'easing-standard')
192
+ ) !default;
193
+
194
+ // Helper functions for easier token access
195
+ @function state($key) {
196
+ @return map.get($state, $key);
197
+ }
198
+
199
+ @function motion($key) {
200
+ @return map.get($motion, $key);
201
+ }
202
+
203
+ @function elevation($level) {
204
+ @return map.get($elevation, $level);
205
+ }
206
+
207
+ @function typography($scale) {
208
+ @return map.get($typescale, $scale);
209
+ }
210
+
211
+ @function shape($size) {
212
+ @return map.get($shape, $size);
213
+ }
214
+
215
+ @function z-index($layer) {
216
+ @return map.get($z-index, $layer);
217
+ }
218
+
219
+ @function breakpoint($size) {
220
+ @return map.get($breakpoints, $size);
221
+ }
222
+
223
+ @function button($prop) {
224
+ @return map.get($button, $prop);
225
+ }
@@ -0,0 +1,86 @@
1
+ // src/styles/base/_reset.scss
2
+
3
+ // Modern CSS Reset
4
+ // Adapted and simplified for Material Design
5
+
6
+ // Use border-box by default
7
+ *,
8
+ *::before,
9
+ *::after {
10
+ box-sizing: border-box;
11
+ }
12
+
13
+ // Remove default margin and padding
14
+ html,
15
+ body,
16
+ h1, h2, h3, h4, h5, h6,
17
+ p, figure, blockquote, dl, dd {
18
+ margin: 0;
19
+ padding: 0;
20
+ }
21
+
22
+ // Set core body defaults
23
+ body {
24
+ min-height: 100vh;
25
+ text-rendering: optimizeSpeed;
26
+ line-height: 1.5;
27
+ }
28
+
29
+ // Make images easier to work with
30
+ img,
31
+ picture {
32
+ max-width: 100%;
33
+ display: block;
34
+ }
35
+
36
+ // Inherit fonts for inputs and buttons
37
+ input,
38
+ button,
39
+ textarea,
40
+ select {
41
+ font: inherit;
42
+ }
43
+
44
+ // Remove all animations, transitions and smooth scrolling for people who prefer not to see them
45
+ @media (prefers-reduced-motion: reduce) {
46
+ html:focus-within {
47
+ scroll-behavior: auto;
48
+ }
49
+
50
+ *,
51
+ *::before,
52
+ *::after {
53
+ animation-duration: 0.01ms !important;
54
+ animation-iteration-count: 1 !important;
55
+ transition-duration: 0.01ms !important;
56
+ scroll-behavior: auto !important;
57
+ }
58
+ }
59
+
60
+ // Reset button styles
61
+ button {
62
+ background: transparent;
63
+ border: none;
64
+ cursor: pointer;
65
+ padding: 0;
66
+ }
67
+
68
+ // Remove list styles
69
+ ul,
70
+ ol {
71
+ list-style: none;
72
+ margin: 0;
73
+ padding: 0;
74
+ }
75
+
76
+ // Set default link style
77
+ a {
78
+ text-decoration: none;
79
+ color: inherit;
80
+ }
81
+
82
+ // Tables
83
+ table {
84
+ border-collapse: collapse;
85
+ border-spacing: 0;
86
+ }
@@ -0,0 +1,155 @@
1
+ // src/styles/base/_typography.scss
2
+ @use '../abstract/base' as base;
3
+ @use '../abstract/variables' as v;
4
+ @use '../abstract/mixins' as m;
5
+
6
+ // Typography scale classes
7
+ $prefix: base.$prefix;
8
+
9
+ // Display typography
10
+ .#{$prefix}-display-large {
11
+ @include m.typography('display-large');
12
+ }
13
+
14
+ .#{$prefix}-display-medium {
15
+ @include m.typography('display-medium');
16
+ }
17
+
18
+ .#{$prefix}-display-small {
19
+ @include m.typography('display-small');
20
+ }
21
+
22
+ // Headline typography
23
+ .#{$prefix}-headline-large {
24
+ @include m.typography('headline-large');
25
+ }
26
+
27
+ .#{$prefix}-headline-medium {
28
+ @include m.typography('headline-medium');
29
+ }
30
+
31
+ .#{$prefix}-headline-small {
32
+ @include m.typography('headline-small');
33
+ }
34
+
35
+ // Title typography
36
+ .#{$prefix}-title-large {
37
+ @include m.typography('title-large');
38
+ }
39
+
40
+ .#{$prefix}-title-medium {
41
+ @include m.typography('title-medium');
42
+ }
43
+
44
+ .#{$prefix}-title-small {
45
+ @include m.typography('title-small');
46
+ }
47
+
48
+ // Body typography
49
+ .#{$prefix}-body-large {
50
+ @include m.typography('body-large');
51
+ }
52
+
53
+ .#{$prefix}-body-medium {
54
+ @include m.typography('body-medium');
55
+ }
56
+
57
+ .#{$prefix}-body-small {
58
+ @include m.typography('body-small');
59
+ }
60
+
61
+ // Label typography
62
+ .#{$prefix}-label-large {
63
+ @include m.typography('label-large');
64
+ }
65
+
66
+ .#{$prefix}-label-medium {
67
+ @include m.typography('label-medium');
68
+ }
69
+
70
+ .#{$prefix}-label-small {
71
+ @include m.typography('label-small');
72
+ }
73
+
74
+ // Convenience modifiers
75
+ .#{$prefix}-text-center {
76
+ text-align: center;
77
+ }
78
+
79
+ .#{$prefix}-text-left {
80
+ text-align: left;
81
+ }
82
+
83
+ .#{$prefix}-text-right {
84
+ text-align: right;
85
+ }
86
+
87
+ // Font weight modifiers
88
+ .#{$prefix}-font-thin {
89
+ font-weight: 100;
90
+ }
91
+
92
+ .#{$prefix}-font-light {
93
+ font-weight: 300;
94
+ }
95
+
96
+ .#{$prefix}-font-regular {
97
+ font-weight: 400;
98
+ }
99
+
100
+ .#{$prefix}-font-medium {
101
+ font-weight: 500;
102
+ }
103
+
104
+ .#{$prefix}-font-bold {
105
+ font-weight: 700;
106
+ }
107
+
108
+ // Text truncation with ellipsis
109
+ .#{$prefix}-truncate {
110
+ @include m.truncate;
111
+ }
112
+
113
+ .#{$prefix}-truncate-2 {
114
+ @include m.truncate(2);
115
+ }
116
+
117
+ .#{$prefix}-truncate-3 {
118
+ @include m.truncate(3);
119
+ }
120
+
121
+ // Set base styles for heading elements
122
+ h1 {
123
+ @include m.typography('headline-large');
124
+ margin-bottom: 0.5em;
125
+ }
126
+
127
+ h2 {
128
+ @include m.typography('headline-medium');
129
+ margin-bottom: 0.5em;
130
+ }
131
+
132
+ h3 {
133
+ @include m.typography('headline-small');
134
+ margin-bottom: 0.5em;
135
+ }
136
+
137
+ h4 {
138
+ @include m.typography('title-large');
139
+ margin-bottom: 0.5em;
140
+ }
141
+
142
+ h5 {
143
+ @include m.typography('title-medium');
144
+ margin-bottom: 0.5em;
145
+ }
146
+
147
+ h6 {
148
+ @include m.typography('title-small');
149
+ margin-bottom: 0.5em;
150
+ }
151
+
152
+ p {
153
+ @include m.typography('body-medium');
154
+ margin-bottom: 1em;
155
+ }