@codefast/ui 0.0.24 → 0.0.25

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.
@@ -0,0 +1,277 @@
1
+ import plugin from "tailwindcss/plugin";
2
+ import { type Config } from "tailwindcss/types/config";
3
+
4
+ type Theme = <TDefaultValue = Config["theme"]>(path?: string, defaultValue?: TDefaultValue) => TDefaultValue;
5
+
6
+ const animate = plugin(
7
+ ({ addUtilities, matchUtilities, theme }) => {
8
+ addUtilities({
9
+ "@keyframes enter": {
10
+ from: {
11
+ opacity: "var(--animate-enter-opacity, 1)",
12
+ transform: [
13
+ "translate3d(var(--animate-enter-translate-x, 0), var(--animate-enter-translate-y, 0), 0)",
14
+ "scale3d(var(--animate-enter-scale, 1), var(--animate-enter-scale, 1), var(--animate-enter-scale, 1))",
15
+ "rotate(var(--animate-enter-rotate, 0))",
16
+ ].join(" "),
17
+ },
18
+ },
19
+
20
+ "@keyframes exit": {
21
+ to: {
22
+ opacity: "var(--animate-exit-opacity, 1)",
23
+ transform: [
24
+ "translate3d(var(--animate-exit-translate-x, 0), var(--animate-exit-translate-y, 0), 0)",
25
+ "scale3d(var(--animate-exit-scale, 1), var(--animate-exit-scale, 1), var(--animate-exit-scale, 1))",
26
+ "rotate(var(--animate-exit-rotate, 0))",
27
+ ].join(" "),
28
+ },
29
+ },
30
+
31
+ ".animate-in": {
32
+ animationName: "enter",
33
+ animationDuration: theme("animationDuration.DEFAULT"),
34
+ "--animate-enter-opacity": "initial",
35
+ "--animate-enter-scale": "initial",
36
+ "--animate-enter-rotate": "initial",
37
+ "--animate-enter-translate-x": "initial",
38
+ "--animate-enter-translate-y": "initial",
39
+ },
40
+
41
+ ".animate-out": {
42
+ animationName: "exit",
43
+ animationDuration: theme("animationDuration.DEFAULT"),
44
+ "--animate-exit-opacity": "initial",
45
+ "--animate-exit-scale": "initial",
46
+ "--animate-exit-rotate": "initial",
47
+ "--animate-exit-translate-x": "initial",
48
+ "--animate-exit-translate-y": "initial",
49
+ },
50
+ });
51
+
52
+ addUtilities({
53
+ ".animation-running": {
54
+ animationPlayState: "running",
55
+ },
56
+ ".animation-paused": {
57
+ animationPlayState: "paused",
58
+ },
59
+ });
60
+
61
+ // Delay
62
+ matchUtilities(
63
+ {
64
+ "animation-delay": (value) => ({
65
+ animationDelay: value,
66
+ }),
67
+ },
68
+ {
69
+ values: theme("animationDelay"),
70
+ },
71
+ );
72
+
73
+ // Direction
74
+ matchUtilities(
75
+ {
76
+ "animation-direction": (value) => ({
77
+ animationDirection: value,
78
+ }),
79
+ },
80
+ {
81
+ values: theme("animationDirection"),
82
+ },
83
+ );
84
+
85
+ // Duration
86
+ matchUtilities(
87
+ {
88
+ "animation-duration": (value) => ({
89
+ animationDuration: value,
90
+ }),
91
+ },
92
+ {
93
+ values: theme("animationDuration"),
94
+ },
95
+ );
96
+
97
+ // Fill mode
98
+ matchUtilities(
99
+ {
100
+ "animation-fill-mode": (value) => ({
101
+ animationFillMode: value,
102
+ }),
103
+ },
104
+ {
105
+ values: theme("animationFillMode"),
106
+ },
107
+ );
108
+
109
+ // Opacity
110
+ matchUtilities(
111
+ {
112
+ "fade-in": (value) => ({
113
+ "--animate-enter-opacity": value,
114
+ }),
115
+ "fade-out": (value) => ({
116
+ "--animate-exit-opacity": value,
117
+ }),
118
+ },
119
+ {
120
+ values: theme("animationOpacity"),
121
+ },
122
+ );
123
+
124
+ // Repeat
125
+ matchUtilities(
126
+ {
127
+ "animation-repeat": (value) => ({
128
+ animationIterationCount: value,
129
+ }),
130
+ },
131
+ {
132
+ values: theme("animationRepeat"),
133
+ },
134
+ );
135
+
136
+ // Rotate
137
+ matchUtilities(
138
+ {
139
+ "spin-in": (value) => ({
140
+ "--animate-enter-rotate": value,
141
+ }),
142
+ "spin-out": (value) => ({
143
+ "--animate-exit-rotate": value,
144
+ }),
145
+ },
146
+ {
147
+ values: theme("animationRotate"),
148
+ },
149
+ );
150
+
151
+ // Scale - Zoom
152
+ matchUtilities(
153
+ {
154
+ "zoom-in": (value) => ({
155
+ "--animate-enter-scale": value,
156
+ }),
157
+ "zoom-out": (value) => ({
158
+ "--animate-exit-scale": value,
159
+ }),
160
+ },
161
+ {
162
+ values: theme("animationScale"),
163
+ },
164
+ );
165
+
166
+ // Timing function
167
+ matchUtilities(
168
+ {
169
+ "animation-ease": (value) => ({
170
+ animationTimingFunction: value,
171
+ }),
172
+ },
173
+ {
174
+ values: theme("animationTimingFunction"),
175
+ },
176
+ );
177
+
178
+ // Translate - Slide
179
+ matchUtilities(
180
+ {
181
+ "slide-in-from-top": (value) => ({
182
+ "--animate-enter-translate-y": `-${value}`,
183
+ }),
184
+
185
+ "slide-in-from-bottom": (value) => ({
186
+ "--animate-enter-translate-y": value,
187
+ }),
188
+
189
+ "slide-in-from-left": (value) => ({
190
+ "--animate-enter-translate-x": `-${value}`,
191
+ }),
192
+
193
+ "slide-in-from-right": (value) => ({
194
+ "--animate-enter-translate-x": value,
195
+ }),
196
+
197
+ "slide-out-to-top": (value) => ({
198
+ "--animate-exit-translate-y": `-${value}`,
199
+ }),
200
+
201
+ "slide-out-to-bottom": (value) => ({
202
+ "--animate-exit-translate-y": value,
203
+ }),
204
+
205
+ "slide-out-to-left": (value) => ({
206
+ "--animate-exit-translate-x": `-${value}`,
207
+ }),
208
+
209
+ "slide-out-to-right": (value) => ({
210
+ "--animate-exit-translate-x": value,
211
+ }),
212
+ },
213
+ {
214
+ values: theme("animationTranslate"),
215
+ },
216
+ );
217
+ },
218
+ {
219
+ theme: {
220
+ extend: {
221
+ animationDelay: ({ theme }: { theme: Theme }) => ({
222
+ ...theme("transitionDelay"),
223
+ }),
224
+
225
+ animationDirection: {
226
+ normal: "normal",
227
+ reverse: "reverse",
228
+ alternate: "alternate",
229
+ "alternate-reverse": "alternate-reverse",
230
+ },
231
+
232
+ animationDuration: ({ theme }: { theme: Theme }) => ({
233
+ ...theme("transitionDuration"),
234
+ }),
235
+
236
+ animationFillMode: {
237
+ none: "none",
238
+ forwards: "forwards",
239
+ backwards: "backwards",
240
+ both: "both",
241
+ },
242
+
243
+ animationOpacity: ({ theme }: { theme: Theme }) => ({
244
+ DEFAULT: 0,
245
+ ...theme("opacity"),
246
+ }),
247
+
248
+ animationRepeat: {
249
+ 0: "0",
250
+ 1: "1",
251
+ infinite: "infinite",
252
+ },
253
+
254
+ animationRotate: ({ theme }: { theme: Theme }) => ({
255
+ DEFAULT: "30deg",
256
+ ...theme("rotate"),
257
+ }),
258
+
259
+ animationScale: ({ theme }: { theme: Theme }) => ({
260
+ DEFAULT: 0,
261
+ ...theme("scale"),
262
+ }),
263
+
264
+ animationTimingFunction: ({ theme }: { theme: Theme }) => ({
265
+ ...theme("transitionTimingFunction"),
266
+ }),
267
+
268
+ animationTranslate: ({ theme }: { theme: Theme }) => ({
269
+ DEFAULT: "100%",
270
+ ...theme("translate"),
271
+ }),
272
+ },
273
+ },
274
+ },
275
+ );
276
+
277
+ export default animate;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codefast/ui",
3
- "version": "0.0.24",
3
+ "version": "0.0.25",
4
4
  "license": "MIT",
5
5
  "sideEffects": [
6
6
  "**/*.css"
@@ -330,7 +330,10 @@
330
330
  },
331
331
  "files": [
332
332
  "dist",
333
- "src"
333
+ "src",
334
+ "animate.plugin.ts",
335
+ "perspective.plugin.ts",
336
+ "tailwind.config.ts"
334
337
  ],
335
338
  "dependencies": {
336
339
  "@radix-ui/primitive": "^1.0.1",
@@ -0,0 +1,11 @@
1
+ import plugin from "tailwindcss/plugin";
2
+
3
+ const perspective = plugin(({ matchUtilities }) => {
4
+ matchUtilities({
5
+ perspective: (value) => ({
6
+ perspective: value,
7
+ }),
8
+ });
9
+ });
10
+
11
+ export default perspective;
@@ -0,0 +1,113 @@
1
+ import type { Config } from "tailwindcss";
2
+ import { fontFamily } from "tailwindcss/defaultTheme";
3
+ import animate from "./animate.plugin";
4
+ import perspective from "./perspective.plugin";
5
+
6
+ const config: Config = {
7
+ content: ["./src/**/*.{js,ts,jsx,tsx,mdx}"],
8
+ darkMode: ["class"],
9
+ plugins: [animate, perspective],
10
+ theme: {
11
+ extend: {
12
+ animation: {
13
+ "accordion-down": "accordion-down 0.2s ease-out",
14
+ "accordion-up": "accordion-up 0.2s ease-out",
15
+ "caret-blink": "caret-blink 1.25s ease-out infinite",
16
+ },
17
+ borderRadius: {
18
+ sm: "calc(var(--radius, 0.25rem) - 0.125px)", // 2px
19
+ DEFAULT: "var(--radius, 0.25rem)", // 4px
20
+ md: "calc(var(--radius, 0.25rem) + 0.125rem)", // 6px
21
+ lg: "calc(var(--radius, 0.25rem) + 0.25rem)", // 8px
22
+ xl: "calc(var(--radius, 0.25rem) + 0.5rem)", // 12px
23
+ "2xl": "calc(var(--radius, 0.25rem) + 0.75rem)", // 16px
24
+ "3xl": "calc(var(--radius, 0.25rem) + 1.25rem)", // 24px
25
+ },
26
+ colors: {
27
+ accent: {
28
+ DEFAULT: "hsl(var(--accent))",
29
+ foreground: "hsl(var(--accent-foreground))",
30
+ },
31
+ background: "hsl(var(--background))",
32
+ border: "hsl(var(--border))",
33
+ card: {
34
+ DEFAULT: "hsl(var(--card))",
35
+ foreground: "hsl(var(--card-foreground))",
36
+ },
37
+ compound: "hsl(var(--compound))",
38
+ destructive: {
39
+ DEFAULT: "hsl(var(--destructive))",
40
+ foreground: "hsl(var(--destructive-foreground))",
41
+ },
42
+ foreground: "hsl(var(--foreground))",
43
+ info: {
44
+ DEFAULT: "hsl(var(--info))",
45
+ foreground: "hsl(var(--info-foreground))",
46
+ },
47
+ input: "hsl(var(--input))",
48
+ muted: {
49
+ DEFAULT: "hsl(var(--muted))",
50
+ foreground: "hsl(var(--muted-foreground))",
51
+ },
52
+ popover: {
53
+ DEFAULT: "hsl(var(--popover))",
54
+ foreground: "hsl(var(--popover-foreground))",
55
+ },
56
+ primary: {
57
+ DEFAULT: "hsl(var(--primary))",
58
+ foreground: "hsl(var(--primary-foreground))",
59
+ },
60
+ ring: "hsl(var(--ring))",
61
+ secondary: {
62
+ DEFAULT: "hsl(var(--secondary))",
63
+ foreground: "hsl(var(--secondary-foreground))",
64
+ },
65
+ success: {
66
+ DEFAULT: "hsl(var(--success))",
67
+ foreground: "hsl(var(--success-foreground))",
68
+ },
69
+ warning: {
70
+ DEFAULT: "hsl(var(--warning))",
71
+ foreground: "hsl(var(--warning-foreground))",
72
+ },
73
+ },
74
+ fontFamily: {
75
+ sans: `var(--font-sans, ${fontFamily.sans.join(", ")})`,
76
+ },
77
+ keyframes: {
78
+ "accordion-down": {
79
+ from: {
80
+ height: "0",
81
+ },
82
+ to: {
83
+ height: "var(--radix-accordion-content-height)",
84
+ },
85
+ },
86
+ "accordion-up": {
87
+ from: {
88
+ height: "var(--radix-accordion-content-height)",
89
+ },
90
+ to: {
91
+ height: "0",
92
+ },
93
+ },
94
+ "caret-blink": {
95
+ "0%,70%,100%": {
96
+ opacity: "1",
97
+ },
98
+ "20%,50%": {
99
+ opacity: "0",
100
+ },
101
+ },
102
+ },
103
+ spacing: {
104
+ 0.75: "0.1875rem", // 3px
105
+ },
106
+ transitionDuration: {
107
+ 250: "250ms",
108
+ },
109
+ },
110
+ },
111
+ };
112
+
113
+ export default config;