@mezzanine-ui/system 0.16.0 → 1.0.0-alpha.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 (58) hide show
  1. package/_system.scss +46 -7
  2. package/effect/_effect.scss +63 -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 +267 -0
  18. package/palette/_semantic.scss +537 -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 +137 -0
  35. package/spacing/_semantic.scss +566 -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
@@ -0,0 +1,71 @@
1
+ @use '../utils/list';
2
+ @use '../utils/map';
3
+
4
+ $prefix: mzn-radius;
5
+
6
+ // 定義所有可用的 radius 尺寸
7
+ $radius-sizes: (none, tiny, base, roomy, full);
8
+
9
+ // 預設 radius 值定義
10
+ $default-radius: (
11
+ none: 0,
12
+ tiny: 0.125rem, // 2px
13
+ base: 0.25rem, // 4px
14
+ roomy: 0.5rem, // 8px
15
+ full: 62.4375rem, // 999px
16
+ );
17
+
18
+ // 驗證 radius size 是否有效
19
+ @function is-valid-size($size) {
20
+ @return list.index($radius-sizes, $size) != null;
21
+ }
22
+
23
+ // 取得特定 size 的 radius 值
24
+ @function get-radius($size, $radius: $default-radius) {
25
+ @if not is-valid-size($size) {
26
+ @error 'Invalid radius size "#{$size}". Valid sizes are: #{$radius-sizes}';
27
+ }
28
+
29
+ $value: map.get($radius, $size);
30
+
31
+ @if not $value and $value != 0 {
32
+ @error 'Radius value not defined for size "#{$size}"';
33
+ }
34
+
35
+ @return $value;
36
+ }
37
+
38
+ // 取得 CSS 變數名稱
39
+ // 例如: --mzn-radius-base
40
+ @function get-var-name($size) {
41
+ @if $prefix == '' {
42
+ @return --#{$size};
43
+ }
44
+
45
+ @return --#{$prefix}-#{$size};
46
+ }
47
+
48
+ // 使用 CSS 變數引用 radius
49
+ // 例如: radius(base) => var(--mzn-radius-base)
50
+ @function variable($size) {
51
+ @if not is-valid-size($size) {
52
+ @error 'Invalid radius size "#{$size}". Valid sizes are: #{$radius-sizes}';
53
+ }
54
+
55
+ @return var(#{get-var-name($size)});
56
+ }
57
+
58
+ // 生成所有 radius CSS 變數
59
+ @mixin variables($radius: ()) {
60
+ $radius: map.deep-merge($default-radius, $radius);
61
+
62
+ @each $size, $value in $radius {
63
+ @if not is-valid-size($size) {
64
+ @error 'Invalid radius size "#{$size}" in radius map. Valid sizes are: #{$radius-sizes}';
65
+ }
66
+
67
+ @if $value or $value == 0 {
68
+ #{get-var-name($size)}: #{$value};
69
+ }
70
+ }
71
+ }
@@ -0,0 +1 @@
1
+ export declare const radiusPrefix = "mzn-radius";
@@ -0,0 +1,3 @@
1
+ const radiusPrefix = 'mzn-radius';
2
+
3
+ export { radiusPrefix };
@@ -0,0 +1,3 @@
1
+ export type { RadiusSize, RadiusConfig } from './radius';
2
+ export { radiusPrefix } from './constants';
3
+ export { defaultRadius, radiusSizes, isValidRadiusSize, getRadiusVarName, getRadiusVar, } from './radius';
@@ -0,0 +1,2 @@
1
+ export { radiusPrefix } from './constants.js';
2
+ export { defaultRadius, getRadiusVar, getRadiusVarName, isValidRadiusSize, radiusSizes } from './radius.js';
@@ -0,0 +1,18 @@
1
+ export type RadiusSize = 'none' | 'tiny' | 'base' | 'roomy' | 'full';
2
+ export interface RadiusConfig {
3
+ none?: string | number;
4
+ tiny?: string | number;
5
+ base?: string | number;
6
+ roomy?: string | number;
7
+ full?: string | number;
8
+ }
9
+ export declare const defaultRadius: Required<RadiusConfig>;
10
+ export declare const radiusSizes: readonly RadiusSize[];
11
+ export declare function isValidRadiusSize(size: string): size is RadiusSize;
12
+ export declare function getRadiusVarName(size: RadiusSize, prefix?: string): string;
13
+ /**
14
+ * Get CSS variable reference for radius
15
+ * @example
16
+ * getRadiusVar('base') // 'var(--mzn-radius-base)'
17
+ */
18
+ export declare function getRadiusVar(size: RadiusSize, prefix?: string): string;
@@ -0,0 +1,32 @@
1
+ import { radiusPrefix } from './constants.js';
2
+
3
+ const defaultRadius = {
4
+ none: 0,
5
+ tiny: '0.125rem', // 2px
6
+ base: '0.25rem', // 4px
7
+ roomy: '0.5rem', // 8px
8
+ full: '62.4375rem', // 999px
9
+ };
10
+ const radiusSizes = [
11
+ 'none',
12
+ 'tiny',
13
+ 'base',
14
+ 'roomy',
15
+ 'full',
16
+ ];
17
+ function isValidRadiusSize(size) {
18
+ return radiusSizes.includes(size);
19
+ }
20
+ function getRadiusVarName(size, prefix = radiusPrefix) {
21
+ return prefix ? `--${prefix}-${size}` : `--${size}`;
22
+ }
23
+ /**
24
+ * Get CSS variable reference for radius
25
+ * @example
26
+ * getRadiusVar('base') // 'var(--mzn-radius-base)'
27
+ */
28
+ function getRadiusVar(size, prefix = radiusPrefix) {
29
+ return `var(${getRadiusVarName(size, prefix)})`;
30
+ }
31
+
32
+ export { defaultRadius, getRadiusVar, getRadiusVarName, isValidRadiusSize, radiusSizes };
package/size/_size.scss CHANGED
@@ -1,4 +1,9 @@
1
- @use 'sass:list';
1
+ @use '../utils/list';
2
2
 
3
+ /** @deprecated */
3
4
  $sizes: (small, medium, large);
5
+
6
+ /** @deprecated */
4
7
  $sizes-with-extra-large: list.append($sizes, extra-large);
8
+
9
+ $general-sizes: (main, sub, minor);
package/size/size.d.ts CHANGED
@@ -1 +1,3 @@
1
+ /** @deprecated use 'GeneralSize' instead */
1
2
  export type Size = 'small' | 'medium' | 'large';
3
+ export type GeneralSize = 'main' | 'sub' | 'minor';
@@ -1 +1,3 @@
1
- @forward './spacing';
1
+ @forward './spacing'; // @deprecated
2
+ @forward './primitives' as primitive-*;
3
+ @forward './semantic' as semantic-*;
@@ -0,0 +1,137 @@
1
+ @use '../typography/utils' as typography-utils;
2
+ @use '../utils/list';
3
+ @use '../utils/map';
4
+
5
+ // CSS 變數前綴
6
+ $prefix: mzn-spacing-primitive;
7
+
8
+ // 定義所有可用的 spacing 級距(單位為 px)
9
+ $primitive-scales: (
10
+ 0,
11
+ 1,
12
+ 2,
13
+ 3,
14
+ 4,
15
+ 6,
16
+ 8,
17
+ 10,
18
+ 12,
19
+ 14,
20
+ 16,
21
+ 18,
22
+ 20,
23
+ 24,
24
+ 28,
25
+ 32,
26
+ 36,
27
+ 40,
28
+ 48,
29
+ 52,
30
+ 56,
31
+ 60,
32
+ 64,
33
+ 70,
34
+ 80,
35
+ 140,
36
+ 160,
37
+ 240,
38
+ 320,
39
+ 360,
40
+ 400,
41
+ 480,
42
+ 560,
43
+ 640,
44
+ 720,
45
+ 960,
46
+ 1140
47
+ );
48
+
49
+ // 預設 spacing 值定義(px 會自動轉換為 rem)
50
+ $default-primitives: (
51
+ 0: 0,
52
+ 1: 1px,
53
+ 2: 2px,
54
+ 3: 3px,
55
+ 4: 4px,
56
+ 6: 6px,
57
+ 8: 8px,
58
+ 10: 10px,
59
+ 12: 12px,
60
+ 14: 14px,
61
+ 16: 16px,
62
+ 18: 18px,
63
+ 20: 20px,
64
+ 24: 24px,
65
+ 28: 28px,
66
+ 32: 32px,
67
+ 36: 36px,
68
+ 40: 40px,
69
+ 48: 48px,
70
+ 52: 52px,
71
+ 56: 56px,
72
+ 60: 60px,
73
+ 64: 64px,
74
+ 70: 70px,
75
+ 80: 80px,
76
+ 140: 140px,
77
+ 160: 160px,
78
+ 240: 240px,
79
+ 320: 320px,
80
+ 360: 360px,
81
+ 400: 400px,
82
+ 480: 480px,
83
+ 560: 560px,
84
+ 640: 640px,
85
+ 720: 720px,
86
+ 960: 960px,
87
+ 1140: 1140px,
88
+ );
89
+
90
+ // 驗證 scale 是否有效
91
+ @function is-valid-scale($scale) {
92
+ @return list.index($primitive-scales, $scale) != null;
93
+ }
94
+
95
+ // 驗證 spacing 值是否已定義
96
+ @function is-spacing-defined($spacing) {
97
+ @return $spacing != null;
98
+ }
99
+
100
+ // 取得 CSS 變數名稱
101
+ // 例如: --mzn-spacing-primitive-16
102
+ @function get-var-name($scale) {
103
+ @if $prefix == '' {
104
+ @return --#{$scale};
105
+ }
106
+
107
+ @return --#{$prefix}-#{$scale};
108
+ }
109
+
110
+ // 使用 CSS 變數引用 spacing
111
+ // 例如: variable(16) => var(--mzn-spacing-primitive-16)
112
+ @function variable($scale) {
113
+ @if not is-valid-scale($scale) {
114
+ @error 'Invalid spacing scale "#{$scale}". Valid scales are: #{$primitive-scales}';
115
+ }
116
+
117
+ @return var(#{get-var-name($scale)});
118
+ }
119
+
120
+ // 生成所有 spacing primitive CSS 變數
121
+ @mixin variables($primitives: ()) {
122
+ $primitives: map.deep-merge($default-primitives, $primitives);
123
+
124
+ @each $scale, $value in $primitives {
125
+ @if not is-valid-scale($scale) {
126
+ @error 'Invalid spacing scale "#{$scale}" in primitives map. Valid scales are: #{$primitive-scales}';
127
+ }
128
+
129
+ @if is-spacing-defined($value) {
130
+ @if $value == 0 {
131
+ #{get-var-name($scale)}: 0;
132
+ } @else {
133
+ #{get-var-name($scale)}: #{typography-utils.px-to-rem($value)};
134
+ }
135
+ }
136
+ }
137
+ }