ali-mohammadi-design-system 2.0.2 → 2.0.5
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.
- package/dist/index.cjs +20 -25
- package/dist/index.js +314 -446
- package/package.json +9 -1
- package/src/components/Button/Button.jsx +2 -1
- package/src/index.js +4 -0
- package/src/utils/animations.js +159 -0
- package/src/utils/index.js +4 -0
- package/src/utils/useMUI.js +77 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ali-mohammadi-design-system",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.5",
|
|
4
4
|
"description": "خنثی و dynamic Design System — tokens از پروژه میاد",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -30,6 +30,14 @@
|
|
|
30
30
|
"react": ">=18 <20",
|
|
31
31
|
"react-dom": ">=18 <20"
|
|
32
32
|
},
|
|
33
|
+
"peerDependenciesMeta": {
|
|
34
|
+
"@mui/material": {
|
|
35
|
+
"optional": true
|
|
36
|
+
},
|
|
37
|
+
"@mui/system": {
|
|
38
|
+
"optional": true
|
|
39
|
+
}
|
|
40
|
+
},
|
|
33
41
|
"exports": {
|
|
34
42
|
".": {
|
|
35
43
|
"import": "./dist/index.js",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { useTokens } from '../../utils/useTokens.js';
|
|
4
|
+
import { transitions } from '../../utils/animations.js';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Button Component - کامپوننت دکمه با پشتیبانی از تم
|
|
@@ -72,7 +73,7 @@ const Button = ({ variant = 'primary', size = 'md', children, className = '', ..
|
|
|
72
73
|
fontFamily: typography('fontFamily'),
|
|
73
74
|
fontWeight: '500',
|
|
74
75
|
cursor: 'pointer',
|
|
75
|
-
transition:
|
|
76
|
+
transition: transitions.standard({ duration: 200 }),
|
|
76
77
|
...variantStyles[variant],
|
|
77
78
|
...sizeStyles[size],
|
|
78
79
|
...props.style,
|
package/src/index.js
CHANGED
|
@@ -5,6 +5,10 @@ export * from './components/index.js';
|
|
|
5
5
|
export { ThemeProvider, useTheme } from './theme/ThemeProvider.jsx';
|
|
6
6
|
export { useTokens } from './utils/useTokens.js';
|
|
7
7
|
|
|
8
|
+
// Export Animations و Transitions
|
|
9
|
+
export { transitions, easing, duration, keyframes, createTransition, createAnimation, useTransition } from './utils/animations.js';
|
|
10
|
+
export { useMUITransitions, useMUITheme } from './utils/useMUI.js';
|
|
11
|
+
|
|
8
12
|
// Export توکنها
|
|
9
13
|
export { defaultTokens, baseTokens, createTokens, defaultColors } from './tokens/index.js';
|
|
10
14
|
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utilities برای animations و transitions
|
|
3
|
+
* اگر MUI موجود باشد از آن استفاده میکند، وگرنه از CSS animations استفاده میکند
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// MUI به صورت optional است و در runtime بررسی میشود
|
|
7
|
+
// در build time از CSS animations استفاده میکنیم
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Easing functions (مشابه MUI)
|
|
11
|
+
* این easing functions مشابه MUI هستند و بدون نیاز به MUI کار میکنند
|
|
12
|
+
*/
|
|
13
|
+
export const easing = {
|
|
14
|
+
// MUI-compatible easing functions
|
|
15
|
+
easeInOut: 'cubic-bezier(0.4, 0, 0.2, 1)',
|
|
16
|
+
easeOut: 'cubic-bezier(0.0, 0, 0.2, 1)',
|
|
17
|
+
easeIn: 'cubic-bezier(0.4, 0, 1, 1)',
|
|
18
|
+
sharp: 'cubic-bezier(0.4, 0, 0.6, 1)',
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Duration values (مشابه MUI)
|
|
23
|
+
*/
|
|
24
|
+
export const duration = {
|
|
25
|
+
shortest: 150,
|
|
26
|
+
shorter: 200,
|
|
27
|
+
short: 250,
|
|
28
|
+
standard: 300,
|
|
29
|
+
complex: 375,
|
|
30
|
+
enteringScreen: 225,
|
|
31
|
+
leavingScreen: 195,
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* ایجاد transition string برای CSS
|
|
36
|
+
* @param {string|string[]} props - ویژگیهایی که باید transition شوند
|
|
37
|
+
* @param {Object} options - گزینههای transition
|
|
38
|
+
* @returns {string} CSS transition string
|
|
39
|
+
*/
|
|
40
|
+
export function createTransition(props = 'all', options = {}) {
|
|
41
|
+
const {
|
|
42
|
+
duration: durationOption = duration.standard,
|
|
43
|
+
easing: easingOption = easing.easeInOut,
|
|
44
|
+
delay = 0,
|
|
45
|
+
} = options;
|
|
46
|
+
|
|
47
|
+
const properties = Array.isArray(props) ? props.join(', ') : props;
|
|
48
|
+
|
|
49
|
+
return `${properties} ${durationOption}ms ${easingOption} ${delay}ms`;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Transition presets (مشابه MUI)
|
|
54
|
+
*/
|
|
55
|
+
export const transitions = {
|
|
56
|
+
// Standard transitions
|
|
57
|
+
create: createTransition,
|
|
58
|
+
|
|
59
|
+
// Common transitions
|
|
60
|
+
easing,
|
|
61
|
+
duration,
|
|
62
|
+
|
|
63
|
+
// Preset transitions
|
|
64
|
+
all: (options) => createTransition('all', options),
|
|
65
|
+
color: (options) => createTransition(['color', 'background-color', 'border-color'], options),
|
|
66
|
+
backgroundColor: (options) => createTransition('background-color', options),
|
|
67
|
+
opacity: (options) => createTransition('opacity', options),
|
|
68
|
+
transform: (options) => createTransition('transform', options),
|
|
69
|
+
boxShadow: (options) => createTransition('box-shadow', options),
|
|
70
|
+
|
|
71
|
+
// Complex transitions
|
|
72
|
+
standard: (options) => createTransition('all', {
|
|
73
|
+
duration: duration.standard,
|
|
74
|
+
easing: easing.easeInOut,
|
|
75
|
+
...options
|
|
76
|
+
}),
|
|
77
|
+
|
|
78
|
+
enter: (options) => createTransition('all', {
|
|
79
|
+
duration: duration.enteringScreen,
|
|
80
|
+
easing: easing.easeOut,
|
|
81
|
+
...options
|
|
82
|
+
}),
|
|
83
|
+
|
|
84
|
+
leave: (options) => createTransition('all', {
|
|
85
|
+
duration: duration.leavingScreen,
|
|
86
|
+
easing: easing.easeIn,
|
|
87
|
+
...options
|
|
88
|
+
}),
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Hook برای استفاده از transitions در کامپوننتها
|
|
93
|
+
* @param {string|string[]} props - ویژگیهایی که باید transition شوند
|
|
94
|
+
* @param {Object} options - گزینههای transition
|
|
95
|
+
* @returns {string} CSS transition string
|
|
96
|
+
*/
|
|
97
|
+
export function useTransition(props = 'all', options = {}) {
|
|
98
|
+
return createTransition(props, options);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Animation keyframes (CSS-based)
|
|
103
|
+
*/
|
|
104
|
+
export const keyframes = {
|
|
105
|
+
fadeIn: {
|
|
106
|
+
from: { opacity: 0 },
|
|
107
|
+
to: { opacity: 1 },
|
|
108
|
+
},
|
|
109
|
+
fadeOut: {
|
|
110
|
+
from: { opacity: 1 },
|
|
111
|
+
to: { opacity: 0 },
|
|
112
|
+
},
|
|
113
|
+
slideUp: {
|
|
114
|
+
from: { transform: 'translateY(20px)', opacity: 0 },
|
|
115
|
+
to: { transform: 'translateY(0)', opacity: 1 },
|
|
116
|
+
},
|
|
117
|
+
slideDown: {
|
|
118
|
+
from: { transform: 'translateY(-20px)', opacity: 0 },
|
|
119
|
+
to: { transform: 'translateY(0)', opacity: 1 },
|
|
120
|
+
},
|
|
121
|
+
scaleIn: {
|
|
122
|
+
from: { transform: 'scale(0.8)', opacity: 0 },
|
|
123
|
+
to: { transform: 'scale(1)', opacity: 1 },
|
|
124
|
+
},
|
|
125
|
+
scaleOut: {
|
|
126
|
+
from: { transform: 'scale(1)', opacity: 1 },
|
|
127
|
+
to: { transform: 'scale(0.8)', opacity: 0 },
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* ایجاد animation string برای CSS
|
|
133
|
+
* @param {string} name - نام animation
|
|
134
|
+
* @param {Object} options - گزینههای animation
|
|
135
|
+
* @returns {string} CSS animation string
|
|
136
|
+
*/
|
|
137
|
+
export function createAnimation(name, options = {}) {
|
|
138
|
+
const {
|
|
139
|
+
duration: durationOption = duration.standard,
|
|
140
|
+
easing: easingOption = easing.easeInOut,
|
|
141
|
+
delay = 0,
|
|
142
|
+
iterationCount = 1,
|
|
143
|
+
direction = 'normal',
|
|
144
|
+
fillMode = 'both',
|
|
145
|
+
} = options;
|
|
146
|
+
|
|
147
|
+
return `${name} ${durationOption}ms ${easingOption} ${delay}ms ${iterationCount} ${direction} ${fillMode}`;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export default {
|
|
151
|
+
transitions,
|
|
152
|
+
easing,
|
|
153
|
+
duration,
|
|
154
|
+
keyframes,
|
|
155
|
+
createTransition,
|
|
156
|
+
createAnimation,
|
|
157
|
+
useTransition,
|
|
158
|
+
};
|
|
159
|
+
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook برای استفاده اختیاری از MUI
|
|
3
|
+
* اگر MUI موجود باشد از آن استفاده میکند، وگرنه fallback میکند
|
|
4
|
+
*
|
|
5
|
+
* توجه: این hook فقط در runtime کار میکند و MUI باید در پروژه کاربر نصب شده باشد
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { transitions } from './animations.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Hook برای استفاده از MUI transitions (اگر موجود باشد)
|
|
12
|
+
* در runtime بررسی میکند که آیا MUI در window یا global موجود است
|
|
13
|
+
*
|
|
14
|
+
* @param {Object} options - گزینههای transition
|
|
15
|
+
* @returns {Object} Transition utilities
|
|
16
|
+
*/
|
|
17
|
+
export function useMUITransitions(options = {}) {
|
|
18
|
+
// در runtime بررسی میکنیم
|
|
19
|
+
if (typeof window !== 'undefined') {
|
|
20
|
+
// اگر MUI در window موجود باشد (مثلاً از CDN)
|
|
21
|
+
if (window.MUI || window.mui) {
|
|
22
|
+
try {
|
|
23
|
+
// استفاده از MUI transitions
|
|
24
|
+
return {
|
|
25
|
+
create: window.MUI?.transitions?.create || transitions.create,
|
|
26
|
+
easing: window.MUI?.transitions?.easing || transitions.easing,
|
|
27
|
+
duration: window.MUI?.transitions?.duration || transitions.duration,
|
|
28
|
+
useMUI: true,
|
|
29
|
+
};
|
|
30
|
+
} catch {
|
|
31
|
+
// Fallback
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Fallback به animations.js (همیشه کار میکند)
|
|
37
|
+
return {
|
|
38
|
+
...transitions,
|
|
39
|
+
useMUI: false,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* دریافت MUI theme (اگر موجود باشد)
|
|
45
|
+
* این hook فقط در runtime کار میکند
|
|
46
|
+
*/
|
|
47
|
+
export function useMUITheme() {
|
|
48
|
+
// در runtime بررسی میکنیم
|
|
49
|
+
if (typeof window !== 'undefined') {
|
|
50
|
+
// اگر MUI در window موجود باشد
|
|
51
|
+
if (window.MUI || window.mui) {
|
|
52
|
+
try {
|
|
53
|
+
// استفاده از MUI theme
|
|
54
|
+
return window.MUI?.theme || window.mui?.theme || null;
|
|
55
|
+
} catch {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* بررسی اینکه آیا MUI در پروژه نصب شده است (برای documentation)
|
|
66
|
+
* این فقط یک helper است و در runtime کار نمیکند
|
|
67
|
+
*/
|
|
68
|
+
export function checkMUIAvailability() {
|
|
69
|
+
return { available: false, message: 'MUI باید در پروژه کاربر نصب شود' };
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export default {
|
|
73
|
+
useMUITransitions,
|
|
74
|
+
useMUITheme,
|
|
75
|
+
checkMUIAvailability,
|
|
76
|
+
};
|
|
77
|
+
|