mtrl 0.0.2 → 0.1.0

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 (52) hide show
  1. package/package.json +2 -2
  2. package/src/components/button/styles.scss +198 -161
  3. package/src/components/checkbox/checkbox.js +4 -3
  4. package/src/components/checkbox/styles.scss +105 -55
  5. package/src/components/container/styles.scss +65 -58
  6. package/src/components/list/styles.scss +240 -11
  7. package/src/components/menu/features/items-manager.js +5 -1
  8. package/src/components/menu/styles.scss +37 -30
  9. package/src/components/navigation/constants.js +19 -54
  10. package/src/components/navigation/styles.scss +406 -6
  11. package/src/components/snackbar/styles.scss +46 -17
  12. package/src/components/switch/styles.scss +104 -40
  13. package/src/components/switch/switch.js +1 -1
  14. package/src/components/textfield/styles.scss +351 -5
  15. package/src/core/build/_ripple.scss +79 -0
  16. package/src/core/compose/features/disabled.js +27 -7
  17. package/src/core/compose/features/input.js +9 -1
  18. package/src/core/compose/features/textinput.js +16 -20
  19. package/src/core/dom/create.js +0 -1
  20. package/src/styles/abstract/_mixins.scss +9 -7
  21. package/src/styles/abstract/_theme.scss +157 -0
  22. package/src/styles/abstract/_variables.scss +72 -6
  23. package/src/styles/base/_reset.scss +86 -0
  24. package/src/styles/base/_typography.scss +155 -0
  25. package/src/styles/main.scss +104 -57
  26. package/src/styles/themes/_base-theme.scss +2 -27
  27. package/src/styles/themes/_baseline.scss +64 -39
  28. package/src/styles/utilities/_color.scss +154 -0
  29. package/src/styles/utilities/_flexbox.scss +194 -0
  30. package/src/styles/utilities/_spacing.scss +139 -0
  31. package/src/styles/utilities/_typography.scss +178 -0
  32. package/src/styles/utilities/_visibility.scss +142 -0
  33. package/test/components/button.test.js +46 -34
  34. package/test/components/checkbox.test.js +238 -0
  35. package/test/components/list.test.js +105 -0
  36. package/test/components/menu.test.js +385 -0
  37. package/test/components/navigation.test.js +227 -0
  38. package/test/components/snackbar.test.js +234 -0
  39. package/test/components/switch.test.js +186 -0
  40. package/test/components/textfield.test.js +314 -0
  41. package/test/core/ripple.test.js +21 -120
  42. package/test/setup.js +152 -239
  43. package/src/components/list/styles/_list-item.scss +0 -142
  44. package/src/components/list/styles/_list.scss +0 -89
  45. package/src/components/list/styles/_variables.scss +0 -13
  46. package/src/components/navigation/styles/_bar.scss +0 -51
  47. package/src/components/navigation/styles/_base.scss +0 -129
  48. package/src/components/navigation/styles/_drawer.scss +0 -169
  49. package/src/components/navigation/styles/_rail.scss +0 -65
  50. package/src/components/textfield/styles/base.scss +0 -107
  51. package/src/components/textfield/styles/filled.scss +0 -58
  52. package/src/components/textfield/styles/outlined.scss +0 -66
@@ -1,89 +0,0 @@
1
- // src/components/list/styles/_list.scss
2
-
3
- @use '../../../styles/abstract/config' as c;
4
- @use 'variables' as v;
5
-
6
- .#{c.$prefix}-list {
7
- display: flex;
8
- flex-direction: column;
9
- padding: v.$list-padding 0;
10
- min-width: 200px;
11
- background-color: var(--mtrl-sys-color-surface);
12
-
13
- // Sections
14
- &-section {
15
- display: flex;
16
- flex-direction: column;
17
- width: 100%;
18
-
19
- &:not(:last-child) {
20
- margin-bottom: v.$list-padding;
21
- }
22
- }
23
-
24
- &-section-title {
25
- @include c.typography('label-large');
26
- color: v.$list-section-title-color;
27
- padding: v.$list-section-padding v.$list-item-padding 8px;
28
- }
29
-
30
- // Dividers
31
- &-divider {
32
- height: 1px;
33
- margin: v.$list-padding 0;
34
- background-color: v.$list-divider-color;
35
- }
36
-
37
- // Selection states
38
- &[data-type="single"],
39
- &[data-type="multi"],
40
- &[data-type="radio"] {
41
- .#{c.$prefix}-list-item {
42
- cursor: pointer;
43
-
44
- &--selected {
45
- background-color: var(--mtrl-sys-color-secondary-container);
46
- color: var(--mtrl-sys-color-on-secondary-container);
47
-
48
- &:hover {
49
- background-color: var(--mtrl-sys-color-secondary-container);
50
- @include c.state-layer(var(--mtrl-sys-color-on-secondary-container), 'hover');
51
- }
52
-
53
- .#{c.$prefix}-list-item-supporting {
54
- color: var(--mtrl-sys-color-on-secondary-container);
55
- }
56
- }
57
- }
58
- }
59
-
60
- // Dense variant
61
- &--dense {
62
- .#{c.$prefix}-list-item {
63
- min-height: v.$list-item-dense-height;
64
- }
65
- }
66
-
67
- // Disabled state
68
- &--disabled {
69
- pointer-events: none;
70
- opacity: 0.38;
71
- }
72
-
73
- // RTL Support
74
- @include c.rtl {
75
- .#{c.$prefix}-list-section-title {
76
- text-align: right;
77
- }
78
- }
79
-
80
- // High contrast mode
81
- @include c.high-contrast {
82
- border: 1px solid currentColor;
83
-
84
- &-divider {
85
- border-top: 1px solid currentColor;
86
- background: none;
87
- }
88
- }
89
- }
@@ -1,13 +0,0 @@
1
- // src/components/list/styles/_variables.scss
2
-
3
- // Component variables
4
- $list-item-height: 48px !default;
5
- $list-item-dense-height: 40px !default;
6
- $list-padding: 8px !default;
7
- $list-item-padding: 16px !default;
8
- $list-section-padding: 16px !default;
9
-
10
- // Color variables - can be overridden
11
- $list-divider-color: var(--mtrl-sys-color-outline-variant) !default;
12
- $list-section-title-color: var(--mtrl-sys-color-primary) !default;
13
- $list-hover-state-layer-color: var(--mtrl-sys-color-on-surface) !default;
@@ -1,51 +0,0 @@
1
- // src/components/navigation/styles/_bar.scss
2
- @use 'sass:map';
3
- @use '../../../styles/abstract/config' as c;
4
- @use 'base';
5
-
6
- .#{c.$prefix}-nav {
7
- &--bar {
8
- flex-direction: row;
9
- width: 100%;
10
- height: 80px;
11
- padding: 0 12px;
12
- justify-content: space-around;
13
-
14
- .#{c.$prefix}-nav-item {
15
- flex: 1;
16
- flex-direction: column;
17
- height: 100%;
18
- max-width: 168px;
19
- gap: 4px;
20
-
21
- &:hover {
22
- .#{c.$prefix}-nav-item-icon {
23
- @include c.state-layer(var(--mtrl-sys-color-on-surface), 'hover');
24
- }
25
- }
26
-
27
- &--active {
28
- .#{c.$prefix}-nav-item-icon {
29
- background-color: var(--mtrl-sys-color-secondary-container);
30
- }
31
- }
32
-
33
- &-icon {
34
- margin-bottom: 4px;
35
- padding: 16px;
36
- @include c.motion-transition(background-color);
37
- }
38
-
39
- &-label {
40
- @include c.typography('label-medium');
41
- text-align: center;
42
- }
43
-
44
- &-badge {
45
- top: 4px;
46
- right: 50%;
47
- transform: translateX(12px);
48
- }
49
- }
50
- }
51
- }
@@ -1,129 +0,0 @@
1
- // src/components/navigation/styles/_base.scss
2
- @use 'sass:map';
3
- @use '../../../styles/abstract/config' as c;
4
-
5
- .#{c.$prefix}-nav {
6
- display: flex;
7
- position: relative;
8
- background-color: var(--mtrl-sys-color-surface-container);
9
-
10
- // Base nav item styles
11
- &-item {
12
- display: flex;
13
- align-items: center;
14
- justify-content: center;
15
- position: relative;
16
- border: none;
17
- background: none;
18
- cursor: pointer;
19
- padding: 12px;
20
- gap: 12px;
21
- color: var(--mtrl-sys-color-on-surface-variant);
22
- @include c.motion-transition(all);
23
-
24
- &-icon {
25
- display: flex;
26
- align-items: center;
27
- justify-content: center;
28
- width: 24px;
29
- height: 24px;
30
- color: inherit;
31
- border-radius: 50%;
32
- padding: 8px;
33
-
34
- svg {
35
- width: 24px;
36
- height: 24px;
37
- fill: currentColor;
38
- }
39
- }
40
-
41
- &--active {
42
- color: var(--mtrl-sys-color-primary);
43
- }
44
-
45
- &-label {
46
- @include c.typography('label-large');
47
- @include c.motion-transition(opacity);
48
- }
49
-
50
- &-badge {
51
- position: absolute;
52
- top: 8px;
53
- right: 8px;
54
- min-width: 16px;
55
- height: 16px;
56
- padding: 0 4px;
57
- border-radius: 8px;
58
- background-color: var(--mtrl-sys-color-error);
59
- color: var(--mtrl-sys-color-on-error);
60
- @include c.typography('label-small');
61
- display: flex;
62
- align-items: center;
63
- justify-content: center;
64
- }
65
- }
66
-
67
- // Navigation positions
68
- &--left {
69
- left: 0;
70
- }
71
-
72
- &--right {
73
- right: 0;
74
- }
75
-
76
- &--top {
77
- top: 0;
78
- }
79
-
80
- &--bottom {
81
- bottom: 0;
82
- }
83
-
84
- // States
85
- &--disabled {
86
- opacity: 0.38;
87
- pointer-events: none;
88
- }
89
-
90
- // RTL Support
91
- @include c.rtl {
92
- &--left {
93
- right: 0;
94
- left: auto;
95
- }
96
-
97
- &--right {
98
- left: 0;
99
- right: auto;
100
- }
101
-
102
- .#{c.$prefix}-nav-item {
103
- &-badge {
104
- right: auto;
105
- left: 8px;
106
- }
107
- }
108
- }
109
-
110
- // Motion
111
- @include c.reduced-motion {
112
- &-item,
113
- &-item-label {
114
- transition: none;
115
- }
116
- }
117
-
118
- // High contrast
119
- @include c.high-contrast {
120
- border: 1px solid currentColor;
121
-
122
- &-item {
123
- &--active {
124
- outline: 2px solid currentColor;
125
- outline-offset: -2px;
126
- }
127
- }
128
- }
129
- }
@@ -1,169 +0,0 @@
1
- // src/components/navigation/styles/_drawer.scss
2
- @use 'sass:map';
3
- @use '../../../styles/abstract/config' as c;
4
- @use 'base';
5
-
6
- .#{c.$prefix}-nav {
7
- &--drawer,
8
- &--drawer-modal,
9
- &--drawer-standard {
10
- flex-direction: column;
11
- width: 256px;
12
- height: 100%;
13
- padding: 12px 0;
14
- transition: transform 0.2s ease-in-out;
15
- transform: translateX(0);
16
-
17
- // Hidden state
18
- &.#{c.$prefix}-nav--hidden {
19
- transform: translateX(-100%);
20
-
21
- @include c.rtl {
22
- transform: translateX(100%);
23
- }
24
- }
25
-
26
- // Item container for nesting
27
- .#{c.$prefix}-nav-item-container {
28
- width: 100%;
29
- display: flex;
30
- flex-direction: column;
31
- }
32
-
33
- // Base nav item styles
34
- .#{c.$prefix}-nav-item {
35
- padding: 12px 16px;
36
- align-items: center;
37
- justify-content: flex-start;
38
- border-radius: 28px;
39
- margin: 0 12px;
40
- width: calc(100% - 24px);
41
-
42
- &:hover {
43
- @include c.state-layer(var(--mtrl-sys-color-on-surface), 'hover');
44
- }
45
-
46
- &--active {
47
- background-color: var(--mtrl-sys-color-secondary-container);
48
- color: var(--mtrl-sys-color-on-secondary-container);
49
-
50
- &:hover {
51
- background-color: var(--mtrl-sys-color-secondary-container);
52
- }
53
- }
54
-
55
- &-icon {
56
- margin-right: 12px;
57
- flex-shrink: 0;
58
- }
59
-
60
- &-label {
61
- @include c.typography('label-large');
62
- flex-grow: 1;
63
- text-align: left;
64
- }
65
-
66
- &-badge {
67
- position: static;
68
- margin-left: auto;
69
- margin-right: 8px;
70
- }
71
- }
72
-
73
- // Nested navigation styles
74
- .#{c.$prefix}-nav-nested-container {
75
- display: flex;
76
- flex-direction: column;
77
- width: 100%;
78
- margin-left: 28px;
79
- padding-right: 12px;
80
-
81
- &[hidden] {
82
- display: none;
83
- }
84
-
85
- // Adjust nested items styles
86
- .#{c.$prefix}-nav-item {
87
- margin: 0;
88
- padding: 8px 16px;
89
- font-size: 14px;
90
-
91
- &-icon {
92
- width: 20px;
93
- height: 20px;
94
- padding: 6px;
95
-
96
- svg {
97
- width: 20px;
98
- height: 20px;
99
- }
100
- }
101
- }
102
- }
103
-
104
- // Expand icon styles
105
- .#{c.$prefix}-nav-expand-icon {
106
- display: flex;
107
- align-items: center;
108
- justify-content: center;
109
- width: 20px;
110
- height: 20px;
111
- margin-left: auto;
112
- color: inherit;
113
- @include c.motion-transition(transform);
114
-
115
- svg {
116
- width: 20px;
117
- height: 20px;
118
- fill: none;
119
- stroke: currentColor;
120
- stroke-width: 2px;
121
- }
122
- }
123
-
124
- // RTL support
125
- @include c.rtl {
126
- .#{c.$prefix}-nav-item {
127
- &-icon {
128
- margin-right: 0;
129
- margin-left: 12px;
130
- }
131
-
132
- &-label {
133
- text-align: right;
134
- }
135
-
136
- &-badge {
137
- margin-left: 8px;
138
- margin-right: auto;
139
- }
140
- }
141
-
142
- .#{c.$prefix}-nav-nested-container {
143
- margin-left: 0;
144
- margin-right: 28px;
145
- padding-right: 0;
146
- padding-left: 12px;
147
- }
148
-
149
- .#{c.$prefix}-nav-expand-icon {
150
- margin-left: 0;
151
- margin-right: auto;
152
- transform: scaleX(-1);
153
- }
154
- }
155
- }
156
-
157
- &--drawer-modal {
158
- @include c.elevation(2);
159
- }
160
-
161
- &--drawer-standard {
162
- border-right: 1px solid var(--mtrl-sys-color-outline-variant);
163
-
164
- @include c.rtl {
165
- border-right: none;
166
- border-left: 1px solid var(--mtrl-sys-color-outline-variant);
167
- }
168
- }
169
- }
@@ -1,65 +0,0 @@
1
- // src/components/navigation/styles/_rail.scss
2
- @use 'sass:map';
3
- @use '../../../styles/abstract/config' as c;
4
- @use 'base';
5
-
6
- .#{c.$prefix}-nav {
7
- &--rail {
8
- flex-direction: column;
9
- width: 80px;
10
- height: 100%;
11
- padding: 12px 0;
12
-
13
- .#{c.$prefix}-nav-item {
14
- flex-direction: column;
15
- width: 100%;
16
- min-height: 56px;
17
- padding: 2px;
18
- margin: -2px auto 14px;
19
- gap: 0;
20
-
21
- &:hover {
22
- .#{c.$prefix}-nav-item-icon {
23
- @include c.state-layer(var(--mtrl-sys-color-on-surface), 'hover');
24
- }
25
- }
26
-
27
- &--active {
28
- .#{c.$prefix}-nav-item-icon {
29
- background-color: var(--mtrl-sys-color-secondary-container);
30
- }
31
- }
32
-
33
- &-icon {
34
- margin-bottom: 4px;
35
- padding: 8px;
36
- width: 56px;
37
- height: 32px;
38
- display: flex;
39
- align-items: center;
40
- justify-content: center;
41
- border-radius: 16px;
42
- @include c.motion-transition(background-color);
43
-
44
- svg {
45
- width: 24px;
46
- height: 24px;
47
- fill: currentColor;
48
- }
49
- }
50
-
51
- &-label {
52
- @include c.typography('label-small');
53
- text-align: center;
54
- color: inherit;
55
- font-size: 12px;
56
- line-height: 16px;
57
- }
58
-
59
- &-badge {
60
- top: 4px;
61
- right: 16px;
62
- }
63
- }
64
- }
65
- }
@@ -1,107 +0,0 @@
1
- // src/components/textfield/styles/_base.scss
2
- @use 'sass:map';
3
- @use '../../../styles/abstract/config' as c;
4
-
5
- .#{c.$prefix}-textfield {
6
- position: relative;
7
- display: inline-flex;
8
- flex-direction: column;
9
- min-width: 210px;
10
-
11
- &--small {
12
- .#{c.$prefix}-textfield-input {
13
- height: 48px;
14
- }
15
- }
16
-
17
- &--large {
18
- .#{c.$prefix}-textfield-input {
19
- height: 64px;
20
- }
21
- }
22
-
23
- &-label {
24
- @include c.typography('body-large');
25
- user-select: none;
26
- position: absolute;
27
- left: 16px;
28
- top: 50%;
29
- transform: translateY(-50%);
30
- transform-origin: left top;
31
- pointer-events: none;
32
- border-radius: 2px;
33
- color: var(--mtrl-sys-color-on-surface-variant);
34
- transition: transform map.get(c.$motion, 'duration-short4') map.get(c.$motion, 'easing-emphasized'),
35
- color map.get(c.$motion, 'duration-short2') map.get(c.$motion, 'easing-standard');
36
- }
37
-
38
- &-input {
39
- @include c.typography('body-large');
40
- @include c.shape('extra-small');
41
- padding: 13px 16px;
42
- width: 100%;
43
- color: var(--mtrl-sys-color-on-surface);
44
- border: 0;
45
- appearance: none;
46
- outline: none;
47
- &::placeholder {
48
- color: transparent;
49
- }
50
-
51
- // Autofill styles
52
- &:-webkit-autofill {
53
- // font: inherit;
54
- -webkit-text-fill-color: var(--mtrl-sys-color-on-surface);
55
- transition: background-color 5000s ease-in-out 0s; // Long transition to keep the background
56
-
57
- & ~ .#{c.$prefix}-textfield-label {
58
- transform: translateY(-95%) scale(0.75);
59
- background-color: var(--mtrl-sys-color-surface);
60
- }
61
- }
62
-
63
- // Firefox autofill
64
- &:autofill {
65
- color: var(--mtrl-sys-color-on-surface);
66
-
67
- & ~ .#{c.$prefix}-textfield-label {
68
- transform: translateY(-95%) scale(0.75);
69
- background-color: var(--mtrl-sys-color-surface);
70
- }
71
- }
72
- }
73
-
74
- &--error {
75
- border-color: var(--mtrl-sys-color-error);
76
- .#{c.$prefix}-textfield-label {
77
- color: var(--mtrl-sys-color-error);
78
- }
79
- }
80
-
81
- &-input:disabled {
82
- opacity: 0.38;
83
- border-color: var(--mtrl-sys-color-on-surface);
84
- background-color: rgba(var(--mtrl-sys-color-on-surface-rgb), 0.04);
85
- pointer-events: none;
86
-
87
- & ~ .#{c.$prefix}-textfield-label {
88
- color: var(--mtrl-sys-color-on-surface);
89
- opacity: 0.38;
90
- }
91
- }
92
-
93
- &-helper {
94
- @include c.typography('body-small');
95
- margin-top: 4px;
96
- color: var(--mtrl-sys-color-on-surface-variant);
97
-
98
- &--error {
99
- color: var(--mtrl-sys-color-error);
100
- }
101
- }
102
-
103
- &-required {
104
- color: var(--mtrl-sys-color-error);
105
- margin-left: 4px;
106
- }
107
- }
@@ -1,58 +0,0 @@
1
- // src/components/textfield/styles/_filled.scss
2
- @use 'sass:map';
3
- @use '../../../styles/abstract/config' as c;
4
-
5
- .#{c.$prefix}-textfield {
6
- &--filled {
7
- border-bottom: 1px solid var(--mtrl-sys-color-outline);
8
-
9
- .#{c.$prefix}-textfield-input {
10
- background-color: var(--mtrl-sys-color-surface-container-highest);
11
- padding: 20px 16px 7px;
12
- border-radius: 4px 4px 0 0;
13
-
14
- &:focus {
15
- padding-bottom: 6px;
16
- }
17
-
18
- // Autofill styles for filled variant
19
- &:-webkit-autofill {
20
- border-radius: 4px 4px 0 0;
21
-
22
- & ~ .#{c.$prefix}-textfield-label {
23
- transform: translateY(-95%) scale(0.75);
24
- color: var(--mtrl-sys-color-on-surface-variant);
25
- }
26
- }
27
-
28
- &:autofill {
29
- & ~ .#{c.$prefix}-textfield-label {
30
- transform: translateY(-95%) scale(0.75);
31
- color: var(--mtrl-sys-color-on-surface-variant);
32
- }
33
- }
34
- }
35
-
36
- &:not(.#{c.$prefix}-textfield--empty) .#{c.$prefix}-textfield-label,
37
- &.#{c.$prefix}-textfield--focused .#{c.$prefix}-textfield-label {
38
- transform: translateY(-95%) scale(0.75);
39
- }
40
-
41
- &.#{c.$prefix}-textfield--focused {
42
- border-bottom: 2px solid var(--mtrl-sys-color-primary);
43
- .#{c.$prefix}-textfield-label {
44
- color: var(--mtrl-sys-color-primary);
45
- }
46
- &:hover {
47
- border-bottom: 2px solid var(--mtrl-sys-color-primary);
48
- }
49
- }
50
-
51
- &:hover {
52
- border-bottom: 1px solid var(--mtrl-sys-color-primary);
53
- .#{c.$prefix}-textfield-label {
54
- color: var(--mtrl-sys-color-primary);
55
- }
56
- }
57
- }
58
- }