@edwinvakayil/calligraphy 1.3.0 → 1.5.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.
package/dist/index.d.ts CHANGED
@@ -17,42 +17,151 @@ interface TypographyProviderProps {
17
17
  children: React.ReactNode;
18
18
  }
19
19
  declare const TypographyProvider: React.FC<TypographyProviderProps>;
20
+ /**
21
+ * Returns the resolved theme from the nearest TypographyProvider.
22
+ * Falls back to DEFAULT_THEME if used outside a provider.
23
+ */
24
+ declare function useTypographyTheme(): Required<TypographyTheme>;
20
25
 
21
26
  type TypographyVariant = "Display" | "H1" | "H2" | "H3" | "H4" | "H5" | "H6" | "Subheading" | "Overline" | "Body" | "Label" | "Caption";
22
27
  type TextAlign = "left" | "center" | "right" | "justify";
23
28
  /**
24
- * Built-in hero text entrance animations.
25
- * Applied via CSS keyframes — GPU-composited, 60fps safe.
29
+ * Hero entrance animations — all GPU-composited (transform + opacity + filter only).
30
+ *
31
+ * ── Batch 1 — originals ──────────────────────────────────────────────────
32
+ * rise smooth upward fade (universal)
33
+ * stagger per-word upward rise in sequence
34
+ * clip text unmasked left to right
35
+ * pop spring scale-in
36
+ * letters each letter slides in with rotation
37
+ * blur emerges from blur
38
+ * flip 3-D rotateX on entry
39
+ * swipe slides in from the right
40
+ * typewriter character-by-character reveal
41
+ * bounce drops from above with bounce
42
+ *
43
+ * ── Batch 2 — modern ─────────────────────────────────────────────────────
44
+ * velvet words drift in with skew
45
+ * curtain each word clips upward
46
+ * morph squash-and-stretch spring
47
+ * ground words emerge from baseline
48
+ * cascade diagonal character waterfall
49
+ * spotlight expands from compressed letterspace
50
+ * ink words fade in with gentle scale
51
+ * hinge words rotate from left edge
52
+ * stretch horizontal rubber-band expand
53
+ * peel bottom-to-top clip per word
54
+ * fold words rotate in on Z from a folded angle
55
+ * shear words skewY then settle
56
+ * ripple words scale from compressed point, elastic outward wave
57
+ * cinch chars pinch on scaleX then snap open with skew
58
+ * tiltrise words rise while untilting from a sideways lean
59
+ * cardFlip chars flip up on X from flat
60
+ * converge outer words fly in, meet in center
61
+ * splitRise alternating words from top/bottom
62
+ *
63
+ * ── Batch 3 — new untouched techniques ───────────────────────────────────
64
+ * tectonic words slam from alternating X sides with skew — collision energy
65
+ * stratify per-word Z-depth flight through blur — true depth-of-field
66
+ * unfurl line expands from horizontal center — origami opening
67
+ * gravityWell chars fall from sky with micro-rotation physics overshoot
68
+ * orbit words grow from dot while rotating on Z-axis
69
+ * liquid per-word cross-axis squash then spring — fluid inertia
70
+ * noiseFade 3 random opacity waveforms per word — signal locking in
71
+ * slab words stamp from left with scaleX — print-press energy
72
+ * thread chars float on individual sine-wave Y offsets — musical
73
+ * billboard whole line rotates in on Y-axis — turning sign
74
+ *
75
+ * ── Batch 7 — genuinely new mechanics ────────────────────────────────────
76
+ * glassReveal backdrop-filter blur evaporates as text solidifies
77
+ * wordPop per-word springs from zero scale at its own centre
78
+ * charDrop chars fall under pure gravity — no overshoot or rotation
79
+ * scanline single-pixel horizontal slice expands to full height
80
+ * chromaShift RGB channel offsets collapse to zero (printing-register feel)
81
+ * wordFade per-word cross-dissolve with warmth scale, no Y movement
82
+ * rotateIn full Y-axis card-flip per word (face-up reveal)
83
+ * pressIn presses to 0.92 then springs past 1 (physical button feel)
84
+ * maskSweep mask-image sweep reveals text left to right
85
+ * gradSweep gradient sweep across text then resolves to solid
86
+ */
87
+ type HeroAnimation = "rise" | "stagger" | "clip" | "pop" | "letters" | "blur" | "flip" | "swipe" | "typewriter" | "bounce" | "velvet" | "curtain" | "morph" | "ground" | "cascade" | "spotlight" | "ink" | "hinge" | "stretch" | "peel" | "fold" | "shear" | "ripple" | "cinch" | "tiltrise" | "cardFlip" | "converge" | "splitRise" | "tectonic" | "stratify" | "unfurl" | "gravityWell" | "orbit" | "liquid" | "noiseFade" | "slab" | "thread" | "billboard" | "glassReveal" | "wordPop" | "charDrop" | "scanline" | "chromaShift" | "wordFade" | "rotateIn" | "pressIn" | "maskSweep" | "gradSweep";
88
+ /**
89
+ * Custom motion configuration for a Typography element.
90
+ * Use this when the built-in `animation` presets don't fit your needs —
91
+ * for example when you have brand-specific easing tokens, or when you want
92
+ * to animate a non-hero variant like H2 or Body.
26
93
  *
27
- * — Original —
28
- * rise — smooth upward fade-in (universal default)
29
- * stagger — each word rises in sequence
30
- * clip — text unmasked left-to-right (editorial)
31
- * pop — spring scale-in (energetic)
32
- * letters — each letter slides in with a slight rotation
33
- * blur — emerges from a blur (cinematic)
34
- * flip — 3-D perspective rotate on entry (depth)
35
- * swipe — slides in from the right
36
- * typewriter — character-by-character reveal
37
- * bounce — drops from above with a soft bounce
94
+ * @example
95
+ * // Whole-element fade up
96
+ * motionConfig={{
97
+ * keyframes: `from { opacity: 0; transform: translateY(24px); }
98
+ * to { opacity: 1; transform: none; }`,
99
+ * duration: "0.8s",
100
+ * easing: "cubic-bezier(0.16, 1, 0.3, 1)",
101
+ * delay: "0.2s",
102
+ * split: "none",
103
+ * }}
38
104
  *
39
- * — Modern —
40
- * velvet — words drift in with a soft skew (buttery & modern)
41
- * curtain — each word clips upward like a rising curtain
42
- * morph — squash-and-stretch spring (expressive & bold)
43
- * ground — words emerge from behind the baseline (editorial)
44
- * cascade — diagonal character waterfall (dynamic & layered)
45
- * spotlight — expands from compressed letterspace (cinematic)
46
- * ink — words fade in with a gentle scale (calm & precise)
47
- * hinge — words rotate in from their left edge (mechanical)
48
- * stretch — horizontal rubber-band expand (playful & punchy)
49
- * peel — bottom-to-top clip reveal per word (sharp)
105
+ * @example
106
+ * // Per-word stagger with custom keyframe
107
+ * motionConfig={{
108
+ * keyframes: `from { opacity: 0; transform: skewX(8deg) translateX(-12px); }
109
+ * to { opacity: 1; transform: none; }`,
110
+ * duration: "0.6s",
111
+ * easing: "cubic-bezier(0.16, 1, 0.3, 1)",
112
+ * staggerDelay: 0.08,
113
+ * split: "words",
114
+ * }}
50
115
  */
51
- type HeroAnimation = "rise" | "stagger" | "clip" | "pop" | "letters" | "blur" | "flip" | "swipe" | "typewriter" | "bounce" | "velvet" | "curtain" | "morph" | "ground" | "cascade" | "spotlight" | "ink" | "hinge" | "stretch" | "peel";
116
+ interface MotionConfig {
117
+ /**
118
+ * CSS keyframes body — the content between @keyframes name { … }.
119
+ * Do not include the @keyframes rule or a name; the component generates both.
120
+ *
121
+ * @example "from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: none; }"
122
+ */
123
+ keyframes: string;
124
+ /**
125
+ * Animation duration. Accepts any CSS time value.
126
+ * @default "0.8s"
127
+ */
128
+ duration?: string;
129
+ /**
130
+ * CSS easing function.
131
+ * @default "cubic-bezier(0.16, 1, 0.3, 1)"
132
+ */
133
+ easing?: string;
134
+ /**
135
+ * Initial delay before the animation begins.
136
+ * @default "0s"
137
+ */
138
+ delay?: string;
139
+ /**
140
+ * animation-fill-mode value.
141
+ * @default "both"
142
+ */
143
+ fillMode?: "none" | "forwards" | "backwards" | "both";
144
+ /**
145
+ * How to split the text before animating.
146
+ *
147
+ * - "none" — animate the whole element (default)
148
+ * - "words" — wrap each word in a <span> and stagger them
149
+ * - "chars" — wrap each character in a <span> and stagger them
150
+ *
151
+ * @default "none"
152
+ */
153
+ split?: "none" | "words" | "chars";
154
+ /**
155
+ * Delay increment between each word or character span (in seconds).
156
+ * Only used when split is "words" or "chars".
157
+ * @default 0.07 (words) | 0.04 (chars)
158
+ */
159
+ staggerDelay?: number;
160
+ }
52
161
  interface TypographyProps extends HTMLAttributes<HTMLElement> {
53
162
  /** Typography scale variant */
54
163
  variant?: TypographyVariant;
55
- /** Google Font name e.g. "Bricolage Grotesque", "Playfair Display" */
164
+ /** Google Font name auto-injects the Google Fonts <link> */
56
165
  font?: string;
57
166
  /** Text color — any valid CSS color */
58
167
  color?: string;
@@ -62,28 +171,46 @@ interface TypographyProps extends HTMLAttributes<HTMLElement> {
62
171
  as?: ElementType;
63
172
  /** Truncate to single line with ellipsis */
64
173
  truncate?: boolean;
65
- /** Clamp to N lines with ellipsis */
174
+ /** Clamp to N lines */
66
175
  maxLines?: number;
67
176
  /**
68
- * Hero entrance animation. Only applies when variant is
69
- * "Display" or "H1". Injects a CSS class and keyframe stylesheet once.
177
+ * Built-in hero entrance animation.
178
+ * Only applied on variant="Display" or variant="H1".
70
179
  */
71
180
  animation?: HeroAnimation;
181
+ /**
182
+ * Custom motion config — use your own keyframes, easing, and split strategy.
183
+ * Works on ALL variants (not just heroes).
184
+ * Takes precedence over `animation` when both are provided.
185
+ *
186
+ * @see MotionConfig
187
+ */
188
+ motionConfig?: MotionConfig;
189
+ /**
190
+ * Ref callback giving direct access to the rendered DOM element.
191
+ * Use this to drive animations with GSAP, Framer Motion, or the Web
192
+ * Animations API. Called after mount and on every re-render.
193
+ * Takes precedence over both `animation` and `motionConfig`.
194
+ *
195
+ * @example
196
+ * motionRef={(el) => {
197
+ * if (!el) return;
198
+ * gsap.from(el, { opacity: 0, y: 40, duration: 0.9 });
199
+ * }}
200
+ */
201
+ motionRef?: (el: HTMLElement | null) => void;
72
202
  /**
73
203
  * Italic accent for Display / H1 heroes.
74
- * When true, any <em> child renders in Instrument Serif italic
75
- * with an accent color. Defaults to false — everything renders
76
- * in the heading font/weight with no serif or italics.
204
+ * When true, <em> children render in Instrument Serif italic + accentColor.
205
+ * Default: false.
77
206
  */
78
207
  italic?: boolean;
79
208
  /**
80
- * Accent color for the <em> italic span inside Display / H1.
81
- * Defaults to a warm sand tone (#c8b89a).
209
+ * Color for the <em> italic accent span.
210
+ * Default: "#c8b89a" (warm sand).
82
211
  */
83
212
  accentColor?: string;
84
- /** Inline style overrides */
85
213
  style?: CSSProperties;
86
- /** Additional class names */
87
214
  className?: string;
88
215
  }
89
216
 
@@ -112,4 +239,4 @@ declare function injectFont(url: string): void;
112
239
  */
113
240
  declare function preloadFonts(families: string[]): void;
114
241
 
115
- export { GOOGLE_FONTS, HeroAnimation, TextAlign, Typography, TypographyProps, TypographyProvider, TypographyProviderProps, TypographyTheme, TypographyVariant, buildFontUrl, Typography as default, injectFont, preloadFonts };
242
+ export { GOOGLE_FONTS, HeroAnimation, MotionConfig, TextAlign, Typography, TypographyProps, TypographyProvider, TypographyProviderProps, TypographyTheme, TypographyVariant, buildFontUrl, Typography as default, injectFont, preloadFonts, useTypographyTheme };