@mezzanine-ui/system 1.0.0-canary.0 → 1.0.0-canary.10

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 (58) hide show
  1. package/_system.scss +46 -7
  2. package/effect/_effect.scss +78 -0
  3. package/effect/_index.scss +1 -0
  4. package/effect/constants.d.ts +1 -0
  5. package/effect/constants.js +3 -0
  6. package/effect/index.d.ts +2 -0
  7. package/effect/index.js +1 -0
  8. package/effect/typings.d.ts +32 -0
  9. package/motion/_motion.scss +47 -11
  10. package/motion/duration.d.ts +1 -1
  11. package/motion/duration.js +6 -5
  12. package/motion/easing.d.ts +1 -1
  13. package/motion/easing.js +3 -4
  14. package/package.json +1 -1
  15. package/palette/_index.scss +3 -1
  16. package/palette/_palette.scss +3 -203
  17. package/palette/_primitives.scss +269 -0
  18. package/palette/_semantic.scss +549 -0
  19. package/palette/constants.d.ts +1 -1
  20. package/palette/constants.js +2 -2
  21. package/palette/index.js +1 -1
  22. package/palette/typings.d.ts +86 -0
  23. package/radius/_index.scss +1 -0
  24. package/radius/_radius.scss +71 -0
  25. package/radius/constants.d.ts +1 -0
  26. package/radius/constants.js +3 -0
  27. package/radius/index.d.ts +3 -0
  28. package/radius/index.js +2 -0
  29. package/radius/radius.d.ts +18 -0
  30. package/radius/radius.js +32 -0
  31. package/size/_size.scss +6 -1
  32. package/size/size.d.ts +2 -0
  33. package/spacing/_index.scss +3 -1
  34. package/spacing/_primitives.scss +155 -0
  35. package/spacing/_semantic.scss +663 -0
  36. package/spacing/_spacing.scss +2 -18
  37. package/spacing/constants.d.ts +1 -0
  38. package/spacing/constants.js +2 -1
  39. package/spacing/index.js +1 -1
  40. package/spacing/toSpacingCssVar.d.ts +1 -0
  41. package/spacing/toSpacingCssVar.js +1 -0
  42. package/spacing/typings.d.ts +81 -0
  43. package/transition/_transition.scss +25 -9
  44. package/typography/SF-Mono/SFMonoMedium.woff +0 -0
  45. package/typography/SF-Mono/SFMonoRegular.woff +0 -0
  46. package/typography/SF-Mono/SFMonoSemibold.woff +0 -0
  47. package/typography/_index.scss +4 -1
  48. package/typography/_primitives.scss +318 -0
  49. package/typography/_semantic.scss +237 -0
  50. package/typography/_sf-mono.scss +34 -0
  51. package/typography/_typography.scss +4 -248
  52. package/typography/_utils.scss +4 -0
  53. package/typography/index.js +1 -0
  54. package/typography/typings.d.ts +9 -1
  55. package/typography/typings.js +4 -0
  56. package/z-index/_z-index.scss +1 -1
  57. package/palette/_constants.scss +0 -267
  58. package/palette/_utils.scss +0 -47
package/_system.scss CHANGED
@@ -3,13 +3,19 @@
3
3
  @use './spacing';
4
4
  @use './typography';
5
5
  @use './z-index';
6
+ @use './radius';
7
+ @use './effect';
6
8
  @use './palette' as system-palette;
7
9
 
8
- @mixin common-variables($options: ()) {
10
+ @mixin common-variables($mode: default, $options: ()) {
9
11
  $motion: map.get($options, motion);
10
12
  $spacing: map.get($options, spacing);
11
13
  $typography: map.get($options, typography);
14
+ $typography-primitives: map.get($options, typography-primitives);
12
15
  $z-index: map.get($options, z-index);
16
+ $radius: map.get($options, radius);
17
+
18
+ @include effect.variables();
13
19
 
14
20
  @if not $motion {
15
21
  @include motion.variables();
@@ -18,15 +24,41 @@
18
24
  }
19
25
 
20
26
  @if not $spacing {
21
- @include spacing.variables();
27
+ @include spacing.semantic-variables($mode);
28
+ } @else {
29
+ @include spacing.semantic-variables($mode, $spacing);
30
+ }
31
+
32
+ @if not $typography-primitives {
33
+ @include typography.primitive-variables();
34
+ } @else {
35
+ $font-families: map.get($typography-primitives, font-families) or ();
36
+ $font-weights: map.get($typography-primitives, font-weights) or ();
37
+ $font-sizes: map.get($typography-primitives, font-sizes) or ();
38
+ $line-heights: map.get($typography-primitives, line-heights) or ();
39
+ $letter-spacings: map.get($typography-primitives, letter-spacings) or ();
40
+
41
+ @include typography.primitive-variables(
42
+ $font-families,
43
+ $font-weights,
44
+ $font-sizes,
45
+ $line-heights,
46
+ $letter-spacings
47
+ );
48
+ }
49
+
50
+ @if not $typography-primitives {
51
+ font-family: typography.primitive-get-font-family-list();
22
52
  } @else {
23
- @include spacing.variables($spacing);
53
+ $font-families: map.get($typography-primitives, font-families) or ();
54
+
55
+ font-family: typography.primitive-get-font-family-list($font-families);
24
56
  }
25
57
 
26
58
  @if not $typography {
27
- @include typography.variables();
59
+ @include typography.semantic-variables();
28
60
  } @else {
29
- @include typography.variables($typography);
61
+ @include typography.semantic-variables($typography);
30
62
  }
31
63
 
32
64
  @if not $z-index {
@@ -34,8 +66,15 @@
34
66
  } @else {
35
67
  @include z-index.variables($z-index);
36
68
  }
69
+
70
+ @if not $radius {
71
+ @include radius.variables();
72
+ } @else {
73
+ @include radius.variables($radius);
74
+ }
37
75
  }
38
76
 
39
- @mixin palette($mode: 'light', $palette: ()) {
40
- @include system-palette.variables($mode, $palette);
77
+ @mixin colors($mode: 'light', $semantic: (), $primitives: ()) {
78
+ @include system-palette.primitive-variables($primitives);
79
+ @include system-palette.semantic-variables($mode, $semantic);
41
80
  }
@@ -0,0 +1,78 @@
1
+ @use 'sass:map';
2
+ @use 'sass:string';
3
+ @use '../palette/semantic' as semantic;
4
+
5
+ $prefix: mzn-effect;
6
+
7
+ // 定義所有效果類型
8
+ $effect-contexts: (shadow, focus);
9
+
10
+ $effect-values: (
11
+ shadow: (
12
+ raised: (
13
+ value: 0 0 6px 0 semantic.variable(shadow, dark),
14
+ ),
15
+ floating: (
16
+ value: 0 0 16px 0 semantic.variable(shadow, dark),
17
+ ),
18
+ modal: (
19
+ value: string.unquote('0 9px 28px 8px #{semantic.variable(shadow, dark-faint)}, 0 20px 24px -4px #{semantic.variable(shadow, dark-light)}, 0 3px 6px -4px #{semantic.variable(shadow, dark-ghost)}'),
20
+ ),
21
+ drawer: (
22
+ value: -6px 0 10px 0 semantic.variable(shadow, dark),
23
+ ),
24
+ table-sticky-left: (
25
+ value: 1px 0 4px 0 semantic.variable(shadow, dark),
26
+ ),
27
+ table-sticky-right: (
28
+ value: -1px 0 4px 0 semantic.variable(shadow, dark),
29
+ ),
30
+ table-list-floating: (
31
+ value: 0px 6px 16px 0 semantic.variable(shadow, dark),
32
+ ),
33
+ slider-handle: (
34
+ value: 0 2px 3px 0 semantic.variable(shadow, brand),
35
+ ),
36
+ inner-top-and-bottom: (
37
+ value: string.unquote('0 1px 1px 0 #{semantic.variable(shadow, light-faint)} inset, 0 -1px 1px 0 #{semantic.variable(shadow, light-faint)} inset, 0 0 12px 0 #{semantic.variable(shadow, dark)}'),
38
+ ),
39
+ inner-top: (
40
+ value: string.unquote('0 1px 1px 0 #{semantic.variable(shadow, light-faint)} inset, 0 0 12px 0 #{semantic.variable(shadow, dark)}'),
41
+ ),
42
+ inner-bottom: (
43
+ value: string.unquote('0 -1px 1px 0 #{semantic.variable(shadow, light-faint)} inset, 0 0 12px 0 #{semantic.variable(shadow, dark)}'),
44
+ ),
45
+ ),
46
+ focus: (
47
+ primary: (
48
+ value: string.unquote('0 0 0 1px #{semantic.variable(background, base)}, 0 0 0 2px #{semantic.variable(background, brand)}'),
49
+ ),
50
+ error: (
51
+ value: string.unquote('0 0 0 1px #{semantic.variable(background, base)}, 0 0 0 2px #{semantic.variable(background, error)}'),
52
+ ),
53
+ ),
54
+ );
55
+
56
+ /**
57
+ * 取得 effect 變數名稱
58
+ * @param {string} $context - 效果情境 (shadow, focus)
59
+ * @param {string} $type - 效果類型
60
+ * @example
61
+ * variable(shadow, raised) => var(--mzn-effect-shadow-raised)
62
+ */
63
+ @function variable($context, $type) {
64
+ @return var(--#{$prefix}-#{$context}-#{$type});
65
+ }
66
+
67
+ /**
68
+ * 定義 CSS 變數
69
+ * @example
70
+ * @include variables();
71
+ */
72
+ @mixin variables() {
73
+ @each $context, $types in $effect-values {
74
+ @each $type, $config in $types {
75
+ --#{$prefix}-#{$context}-#{$type}: #{map.get($config, value)};
76
+ }
77
+ }
78
+ }
@@ -0,0 +1 @@
1
+ @forward './effect';
@@ -0,0 +1 @@
1
+ export declare const effectPrefix = "mzn-effect";
@@ -0,0 +1,3 @@
1
+ const effectPrefix = 'mzn-effect';
2
+
3
+ export { effectPrefix };
@@ -0,0 +1,2 @@
1
+ export * from './constants';
2
+ export * from './typings';
@@ -0,0 +1 @@
1
+ export { effectPrefix } from './constants.js';
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Shadow types - 陰影類型
3
+ */
4
+ export type ShadowType = 'none' | 'raised' | 'floating' | 'modal' | 'table-sticky' | 'slider-handle' | 'inner-top-and-bottom';
5
+ /**
6
+ * Focus types - 聚焦類型
7
+ */
8
+ export type FocusType = 'primary' | 'error';
9
+ /**
10
+ * Effect contexts - 效果情境
11
+ */
12
+ export type EffectContext = 'shadow' | 'focus';
13
+ /**
14
+ * Effect type mapping
15
+ */
16
+ export type EffectTypeMap = {
17
+ shadow: ShadowType;
18
+ focus: FocusType;
19
+ };
20
+ /**
21
+ * 取得特定 context 的 type
22
+ */
23
+ export type EffectTypeFor<C extends EffectContext> = EffectTypeMap[C];
24
+ /**
25
+ * Effect 完整型別 - context + type 組合
26
+ * @example
27
+ * const effect: Effect = 'shadow-raised';
28
+ * const effect2: Effect = 'focus-primary';
29
+ */
30
+ export type Effect = {
31
+ [C in EffectContext]: `${C}-${EffectTypeFor<C>}`;
32
+ }[EffectContext];
@@ -3,21 +3,37 @@
3
3
 
4
4
  $prefix: mzn-motion;
5
5
 
6
- $duration-names: (shortest, shorter, short, standard, long);
6
+ $duration-names: (fast, moderate, slow, loop, pause-short, pause-long);
7
7
  $default-durations: (
8
- shortest: 150ms,
9
- shorter: 200ms,
10
- short: 250ms,
11
- standard: 300ms,
12
- long: 375ms,
8
+ fast: 150ms,
9
+ moderate: 250ms,
10
+ slow: 400ms,
11
+ loop: 1600ms,
12
+ pause-short: 3000ms,
13
+ pause-long: 10000ms,
13
14
  );
14
15
 
15
- $easing-names: (standard, emphasized, decelerated, accelerated);
16
+ $easing-names: (entrance, exit, standard);
16
17
  $default-easings: (
17
- standard: cubic-bezier(0.58, 0.01, 0.29, 1.01),
18
- emphasized: cubic-bezier(0.83, 0, 0.17, 1),
19
- decelerated: cubic-bezier(0, 0, 0.3, 1),
20
- accelerated: cubic-bezier(0.32, 0, 0.67, 0),
18
+ entrance: cubic-bezier(0.0, 0.0, 0.58, 1),
19
+ exit: cubic-bezier(0.42, 0.0, 1, 1),
20
+ standard: cubic-bezier(0.4, 0.0, 0.2, 1),
21
+ );
22
+
23
+ $pattern-names: (breathe, skeleton-loading, spin);
24
+ $default-pattern: (
25
+ breathe: (
26
+ duration: loop,
27
+ easing: standard,
28
+ ),
29
+ skeleton-loading: (
30
+ duration: loop,
31
+ easing: standard,
32
+ ),
33
+ spin: (
34
+ duration: loop,
35
+ easing: entrance,
36
+ ),
21
37
  );
22
38
 
23
39
  $default-options: (
@@ -33,6 +49,10 @@ $default-options: (
33
49
  @return list.includes($easing-names, $easing-name);
34
50
  }
35
51
 
52
+ @function is-pattern-name-valid($pattern-name) {
53
+ @return list.includes($pattern-names, $pattern-name);
54
+ }
55
+
36
56
  @function duration($duration-name) {
37
57
  @if not is-duration-name-valid($duration-name) {
38
58
  @error 'Invalid duration name #{$duration-name}. Please choose one of #{$duration-names}';
@@ -62,3 +82,19 @@ $default-options: (
62
82
  --#{$prefix}-easing-#{$name}: #{$value};
63
83
  }
64
84
  }
85
+
86
+ @mixin pattern($pattern-name, $action-name: animation) {
87
+ @if not is-pattern-name-valid($pattern-name) {
88
+ @error 'Invalid pattern name #{$pattern-name}. Please choose one of #{$pattern-names}';
89
+ }
90
+
91
+ $pattern: map.get($default-pattern, $pattern-name);
92
+
93
+ @if $pattern {
94
+ $duration-name: map.get($pattern, duration);
95
+ $easing-name: map.get($pattern, easing);
96
+
97
+ #{$action-name}-duration: duration($duration-name);
98
+ #{$action-name}-timing-function: easing($easing-name);
99
+ }
100
+ }
@@ -1,2 +1,2 @@
1
- export type MotionDurationType = 'shortest' | 'shorter' | 'short' | 'standard' | 'long';
1
+ export type MotionDurationType = 'fast' | 'moderate' | 'slow' | 'loop' | 'pauseShort' | 'pauseLong';
2
2
  export declare const MOTION_DURATION: Readonly<Record<MotionDurationType, number>>;
@@ -1,9 +1,10 @@
1
1
  const MOTION_DURATION = {
2
- shortest: 150,
3
- shorter: 200,
4
- short: 250,
5
- standard: 300,
6
- long: 375,
2
+ fast: 150,
3
+ moderate: 250,
4
+ slow: 400,
5
+ loop: 1600,
6
+ pauseShort: 3000,
7
+ pauseLong: 10000,
7
8
  };
8
9
 
9
10
  export { MOTION_DURATION };
@@ -1,2 +1,2 @@
1
- export type MotionEasingType = 'standard' | 'emphasized' | 'decelerated' | 'accelerated';
1
+ export type MotionEasingType = 'entrance' | 'exit' | 'standard';
2
2
  export declare const MOTION_EASING: Readonly<Record<MotionEasingType, string>>;
package/motion/easing.js CHANGED
@@ -1,8 +1,7 @@
1
1
  const MOTION_EASING = {
2
- standard: 'cubic-bezier(0.58, 0.01, 0.29, 1.01)',
3
- emphasized: 'cubic-bezier(0.83, 0, 0.17, 1)',
4
- decelerated: 'cubic-bezier(0, 0, 0.3, 1)',
5
- accelerated: 'cubic-bezier(0.32, 0, 0.67, 0)',
2
+ entrance: 'cubic-bezier(0, 0, 0.58, 1)',
3
+ exit: 'cubic-bezier(0.42, 0, 1, 1)',
4
+ standard: 'cubic-bezier(0.4, 0.0, 0.2, 1)',
6
5
  };
7
6
 
8
7
  export { MOTION_EASING };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mezzanine-ui/system",
3
- "version": "1.0.0-canary.0",
3
+ "version": "1.0.0-canary.10",
4
4
  "description": "Design System for mezzanine-ui",
5
5
  "author": "Mezzanine",
6
6
  "repository": {
@@ -1 +1,3 @@
1
- @forward './palette';
1
+ @forward './palette'; // @deprecated
2
+ @forward './primitives' as primitive-*;
3
+ @forward './semantic' as semantic-*;
@@ -1,206 +1,6 @@
1
- @use 'sass:meta';
2
- @use '../utils/list';
3
- @use '../utils/map';
4
-
5
- $prefix: mzn-color;
6
-
7
- @function _get-main-related-color-names($color) {
8
- @return ($color, #{$color}-light, #{$color}-dark, #{$color}-hover-bg, #{$color}-active-bg, on-#{$color});
9
- }
10
-
11
- @function _get-main-color-transformed-palette($color) {
12
- $rgba: meta.get-function('rgba');
13
-
14
- @return (
15
- #{$color}-hover-bg: (
16
- from: #{$color}-light,
17
- transformer: $rgba,
18
- args: (
19
- 0.15,
20
- )
21
- ),
22
- #{$color}-active-bg: (
23
- from: $color,
24
- transformer: $rgba,
25
- args: (
26
- 0.2,
27
- )
28
- )
29
- );
30
- }
31
-
32
- @function _transform-color-from-palette($palette, $config) {
33
- $transformer: map.get($config, transformer);
34
- $from: map.get($palette, map.get($config, from));
35
- $args: map.get($config, args);
36
-
37
- @return meta.call($transformer, $from, $args...);
38
- }
39
-
40
- $main-color-names: (primary, secondary, error, warning, success);
41
- $color-names: list.flat-push(
42
- list.flat-map($main-color-names, meta.get-function('_get-main-related-color-names')),
43
- (
44
- text-primary,
45
- text-secondary,
46
- text-disabled,
47
- action-active,
48
- action-inactive,
49
- action-disabled,
50
- action-disabled-bg,
51
- bg,
52
- surface,
53
- border,
54
- divider,
55
- overlay-bg,
56
- overlay-surface-bg
57
- )
58
- );
59
-
60
- $default-semantic-palette: map.assign(
61
- (
62
- error: #db2b1d,
63
- error-light: #f75142,
64
- error-dark: #c00f03,
65
- on-error: #fff,
66
- ),
67
- _get-main-color-transformed-palette(error),
68
- (
69
- warning: #f7ac38,
70
- warning-light: #fdd948,
71
- warning-dark: #f1842b,
72
- on-warning: #fff,
73
- ),
74
- _get-main-color-transformed-palette(warning),
75
- (
76
- success: #2e8d36,
77
- success-light: #42ae4a,
78
- success-dark: #0c5d19,
79
- on-success: #fff,
80
- ),
81
- _get-main-color-transformed-palette(success)
82
- );
83
-
84
- $default-light-palette: map.assign(
85
- (
86
- primary: #465bc7,
87
- primary-light: #778de8,
88
- primary-dark: #2d2d9e,
89
- on-primary: #fff,
90
- ),
91
- _get-main-color-transformed-palette(primary),
92
- (
93
- secondary: #383838,
94
- secondary-light: #6a6a6a,
95
- secondary-dark: #161616,
96
- on-secondary: #fff,
97
- ),
98
- _get-main-color-transformed-palette(secondary),
99
- $default-semantic-palette,
100
- (
101
- text-primary: #161616,
102
- text-secondary: #8f8f8f,
103
- text-disabled: #bcbcbc,
104
- action-active: #161616,
105
- action-inactive: #8f8f8f,
106
- action-disabled: #bcbcbc,
107
- action-disabled-bg: #e5e5e5,
108
- bg: #f4f4f4,
109
- surface: #fff,
110
- border: #d9d9d9,
111
- divider: #f2f2f2,
112
- overlay-bg: (
113
- from: action-active,
114
- transformer: meta.get-function('rgba'),
115
- args: (
116
- 0.5,
117
- ),
118
- ),
119
- overlay-surface-bg: (
120
- from: surface,
121
- transformer: meta.get-function('rgba'),
122
- args: (
123
- 0.9,
124
- ),
125
- ),
126
- )
127
- );
128
-
129
- $default-dark-palette: map.assign(
130
- (
131
- primary: #667cd8,
132
- primary-light: #92a7ff,
133
- primary-dark: #3440b2,
134
- on-primary: #fff,
135
- ),
136
- _get-main-color-transformed-palette(primary),
137
- (
138
- secondary: #6a6a6a,
139
- secondary-light: #b2b2b2,
140
- secondary-dark: #383838,
141
- on-secondary: #fff,
142
- ),
143
- _get-main-color-transformed-palette(secondary),
144
- $default-semantic-palette,
145
- (
146
- text-primary: #fff,
147
- text-secondary: #a8a8a8,
148
- text-disabled: #595959,
149
- action-active: #fff,
150
- action-inactive: #a8a8a8,
151
- action-disabled: #595959,
152
- action-disabled-bg: #393939,
153
- bg: #161616,
154
- surface: #242424,
155
- border: #7c7c7c,
156
- divider: #494949,
157
- overlay-bg: (
158
- from: action-active,
159
- transformer: meta.get-function('rgba'),
160
- args: (
161
- 0.5,
162
- ),
163
- ),
164
- overlay-surface-bg: (
165
- from: surface,
166
- transformer: meta.get-function('rgba'),
167
- args: (
168
- 0.9,
169
- ),
170
- ),
171
- )
172
- );
173
-
174
- $default-palette: (
175
- light: $default-light-palette,
176
- dark: $default-dark-palette,
177
- );
178
-
179
- @function is-color-name-valid($color-name) {
180
- @return list.includes($color-names, $color-name);
181
- }
182
-
183
- @mixin variables($mode, $palette: ()) {
184
- $palette: map.deep-merge($default-palette, $palette);
185
- $palette: map.get($palette, $mode);
186
-
187
- @each $color-name, $color in $palette {
188
- @if not is-color-name-valid($color-name) {
189
- @error 'Invalid color name #{$color-name}. Please choose one of #{$color-names}';
190
- }
191
-
192
- @if meta.type-of($color) != 'color' {
193
- $color: _transform-color-from-palette($palette, $color);
194
- }
195
-
196
- --#{$prefix}-#{$color-name}: #{$color};
197
- }
198
- }
199
-
1
+ /* @deprecated */
200
2
  @function color($color-name) {
201
- @if not is-color-name-valid($color-name) {
202
- @error 'Invalid color name #{$color-name}. Please choose one of #{$color-names}';
203
- }
3
+ @warn "This 'color' function is deprecated. Please use 'palette.semantic-variable' instead.";
204
4
 
205
- @return var(--#{$prefix}-#{$color-name});
5
+ @return 'none';
206
6
  }