@edwinvakayil/calligraphy 1.0.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/README.md +172 -0
- package/dist/Typography.d.ts +4 -0
- package/dist/fonts.d.ts +22 -0
- package/dist/index.d.ts +51 -0
- package/dist/index.esm.js +242 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +251 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +25 -0
- package/package.json +50 -0
package/README.md
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
# react-type-scale
|
|
2
|
+
|
|
3
|
+
A lightweight **React + TypeScript** typography component with automatic **Google Fonts** support.
|
|
4
|
+
Define your text style with two props: `variant` for scale, `font` for the typeface.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Install
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install react-type-scale
|
|
12
|
+
# or
|
|
13
|
+
yarn add react-type-scale
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Quick Start
|
|
19
|
+
|
|
20
|
+
```tsx
|
|
21
|
+
import { Typography } from "react-type-scale";
|
|
22
|
+
|
|
23
|
+
export default function App() {
|
|
24
|
+
return (
|
|
25
|
+
<div>
|
|
26
|
+
<Typography variant="Display" font="Playfair Display">
|
|
27
|
+
The quick brown fox
|
|
28
|
+
</Typography>
|
|
29
|
+
|
|
30
|
+
<Typography variant="H1" font="Syne">
|
|
31
|
+
Page Title
|
|
32
|
+
</Typography>
|
|
33
|
+
|
|
34
|
+
<Typography variant="Body" font="Inter">
|
|
35
|
+
Regular body copy goes here.
|
|
36
|
+
</Typography>
|
|
37
|
+
</div>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
The `font` prop auto-injects the matching Google Font `<link>` tag — **no manual imports needed**.
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## Variants
|
|
47
|
+
|
|
48
|
+
| Variant | Tag | Role |
|
|
49
|
+
|--------------|----------|-----------------------------------|
|
|
50
|
+
| `Display` | `h1` | Hero / landing page headline |
|
|
51
|
+
| `H1` | `h1` | Primary page heading |
|
|
52
|
+
| `H2` | `h2` | Section heading |
|
|
53
|
+
| `H3` | `h3` | Sub-section heading |
|
|
54
|
+
| `H4` | `h4` | Card / panel heading |
|
|
55
|
+
| `H5` | `h5` | Small heading |
|
|
56
|
+
| `H6` | `h6` | Micro heading |
|
|
57
|
+
| `Subheading` | `h6` | Supporting header / subtitle |
|
|
58
|
+
| `Overline` | `span` | ALL CAPS label above a heading |
|
|
59
|
+
| `Body` | `p` | Main body copy |
|
|
60
|
+
| `Label` | `label` | Form labels, tags |
|
|
61
|
+
| `Caption` | `span` | Image captions, fine print |
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## Props
|
|
66
|
+
|
|
67
|
+
```ts
|
|
68
|
+
interface TypographyProps {
|
|
69
|
+
variant?: TypographyVariant // default: "Body"
|
|
70
|
+
font?: string // Google Font name e.g. "Inter"
|
|
71
|
+
color?: string // Any CSS color value
|
|
72
|
+
align?: "left" | "center" | "right" | "justify"
|
|
73
|
+
as?: ElementType // Override the HTML tag
|
|
74
|
+
truncate?: boolean // Single-line ellipsis
|
|
75
|
+
maxLines?: number // Multi-line clamp
|
|
76
|
+
className?: string
|
|
77
|
+
style?: CSSProperties
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## Examples
|
|
84
|
+
|
|
85
|
+
### Headings
|
|
86
|
+
|
|
87
|
+
```tsx
|
|
88
|
+
<Typography variant="H1" font="Bebas Neue" color="#1a1a1a">
|
|
89
|
+
Big Section Title
|
|
90
|
+
</Typography>
|
|
91
|
+
|
|
92
|
+
<Typography variant="H3" font="DM Sans">
|
|
93
|
+
Article Subheading
|
|
94
|
+
</Typography>
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Overline + Display combo
|
|
98
|
+
|
|
99
|
+
```tsx
|
|
100
|
+
<Typography variant="Overline" color="#6366f1">
|
|
101
|
+
New Feature
|
|
102
|
+
</Typography>
|
|
103
|
+
<Typography variant="Display" font="Fraunces">
|
|
104
|
+
Build faster with types
|
|
105
|
+
</Typography>
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Body + Caption
|
|
109
|
+
|
|
110
|
+
```tsx
|
|
111
|
+
<Typography variant="Body" font="Lora">
|
|
112
|
+
A well-set paragraph in a refined serif font.
|
|
113
|
+
</Typography>
|
|
114
|
+
<Typography variant="Caption" color="#888">
|
|
115
|
+
Fig. 1 — Diagram of the system
|
|
116
|
+
</Typography>
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Truncation
|
|
120
|
+
|
|
121
|
+
```tsx
|
|
122
|
+
{/* Single line */}
|
|
123
|
+
<Typography variant="H2" truncate>
|
|
124
|
+
This very long title will be cut off with an ellipsis
|
|
125
|
+
</Typography>
|
|
126
|
+
|
|
127
|
+
{/* Multi-line clamp */}
|
|
128
|
+
<Typography variant="Body" maxLines={3}>
|
|
129
|
+
This paragraph will show at most three lines before it is clamped...
|
|
130
|
+
</Typography>
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### Override tag with `as`
|
|
134
|
+
|
|
135
|
+
```tsx
|
|
136
|
+
<Typography variant="H2" as="div">
|
|
137
|
+
Renders as a div, styled as H2
|
|
138
|
+
</Typography>
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
## Pre-loading fonts at app root
|
|
144
|
+
|
|
145
|
+
To avoid FOUT (flash of unstyled text), pre-load fonts at the top of your app:
|
|
146
|
+
|
|
147
|
+
```tsx
|
|
148
|
+
import { preloadFonts } from "react-type-scale";
|
|
149
|
+
|
|
150
|
+
// In your _app.tsx / main.tsx / layout.tsx
|
|
151
|
+
preloadFonts(["Playfair Display", "Inter", "Syne"]);
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## Supported Google Fonts (built-in)
|
|
157
|
+
|
|
158
|
+
The package ships with a curated list of ~40 popular Google Fonts that are auto-injected.
|
|
159
|
+
For any font not in the list, either add it to your local fork of `fonts.ts` or import it manually:
|
|
160
|
+
|
|
161
|
+
```html
|
|
162
|
+
<!-- In your index.html -->
|
|
163
|
+
<link href="https://fonts.googleapis.com/css2?family=Your+Font&display=swap" rel="stylesheet" />
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Then pass the name as-is: `font="Your Font"`.
|
|
167
|
+
|
|
168
|
+
---
|
|
169
|
+
|
|
170
|
+
## License
|
|
171
|
+
|
|
172
|
+
MIT
|
package/dist/fonts.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A curated list of popular Google Fonts.
|
|
3
|
+
* Pass any valid Google Font name to the `font` prop — if it's in this list,
|
|
4
|
+
* it will be auto-injected via a <link> tag. For unlisted fonts, add them here
|
|
5
|
+
* or import them manually in your project.
|
|
6
|
+
*/
|
|
7
|
+
export declare const GOOGLE_FONTS: string[];
|
|
8
|
+
/**
|
|
9
|
+
* Builds a Google Fonts URL for a given font family.
|
|
10
|
+
* Requests weights 300, 400, 500, 600, 700, 800 — italic variants included.
|
|
11
|
+
*/
|
|
12
|
+
export declare function buildFontUrl(fontFamily: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* Injects a Google Fonts <link> into <head> once per unique URL.
|
|
15
|
+
* Safe to call multiple times — deduped via a Set.
|
|
16
|
+
*/
|
|
17
|
+
export declare function injectFont(url: string): void;
|
|
18
|
+
/**
|
|
19
|
+
* Pre-load a set of fonts eagerly (e.g. at app root).
|
|
20
|
+
* Usage: preloadFonts(["Playfair Display", "Inter"])
|
|
21
|
+
*/
|
|
22
|
+
export declare function preloadFonts(families: string[]): void;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import React, { HTMLAttributes, ElementType, CSSProperties } from 'react';
|
|
2
|
+
|
|
3
|
+
type TypographyVariant = "Display" | "H1" | "H2" | "H3" | "H4" | "H5" | "H6" | "Subheading" | "Overline" | "Body" | "Label" | "Caption";
|
|
4
|
+
type TextAlign = "left" | "center" | "right" | "justify";
|
|
5
|
+
interface TypographyProps extends HTMLAttributes<HTMLElement> {
|
|
6
|
+
/** Typography scale variant */
|
|
7
|
+
variant?: TypographyVariant;
|
|
8
|
+
/** Google Font name e.g. "Playfair Display", "Inter", "Roboto" */
|
|
9
|
+
font?: string;
|
|
10
|
+
/** Text color — any valid CSS color value */
|
|
11
|
+
color?: string;
|
|
12
|
+
/** Text alignment */
|
|
13
|
+
align?: TextAlign;
|
|
14
|
+
/** Override the rendered HTML tag */
|
|
15
|
+
as?: ElementType;
|
|
16
|
+
/** Truncate to single line with ellipsis */
|
|
17
|
+
truncate?: boolean;
|
|
18
|
+
/** Clamp to N lines with ellipsis */
|
|
19
|
+
maxLines?: number;
|
|
20
|
+
/** Inline style overrides */
|
|
21
|
+
style?: CSSProperties;
|
|
22
|
+
/** Additional class names */
|
|
23
|
+
className?: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
declare const Typography: React.FC<TypographyProps>;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* A curated list of popular Google Fonts.
|
|
30
|
+
* Pass any valid Google Font name to the `font` prop — if it's in this list,
|
|
31
|
+
* it will be auto-injected via a <link> tag. For unlisted fonts, add them here
|
|
32
|
+
* or import them manually in your project.
|
|
33
|
+
*/
|
|
34
|
+
declare const GOOGLE_FONTS: string[];
|
|
35
|
+
/**
|
|
36
|
+
* Builds a Google Fonts URL for a given font family.
|
|
37
|
+
* Requests weights 300, 400, 500, 600, 700, 800 — italic variants included.
|
|
38
|
+
*/
|
|
39
|
+
declare function buildFontUrl(fontFamily: string): string;
|
|
40
|
+
/**
|
|
41
|
+
* Injects a Google Fonts <link> into <head> once per unique URL.
|
|
42
|
+
* Safe to call multiple times — deduped via a Set.
|
|
43
|
+
*/
|
|
44
|
+
declare function injectFont(url: string): void;
|
|
45
|
+
/**
|
|
46
|
+
* Pre-load a set of fonts eagerly (e.g. at app root).
|
|
47
|
+
* Usage: preloadFonts(["Playfair Display", "Inter"])
|
|
48
|
+
*/
|
|
49
|
+
declare function preloadFonts(families: string[]): void;
|
|
50
|
+
|
|
51
|
+
export { GOOGLE_FONTS, TextAlign, Typography, TypographyProps, TypographyVariant, buildFontUrl, Typography as default, injectFont, preloadFonts };
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
/******************************************************************************
|
|
4
|
+
Copyright (c) Microsoft Corporation.
|
|
5
|
+
|
|
6
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
7
|
+
purpose with or without fee is hereby granted.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
10
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
11
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
12
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
13
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
14
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
15
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
16
|
+
***************************************************************************** */
|
|
17
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
function __rest(s, e) {
|
|
21
|
+
var t = {};
|
|
22
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
23
|
+
t[p] = s[p];
|
|
24
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
25
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
26
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
27
|
+
t[p[i]] = s[p[i]];
|
|
28
|
+
}
|
|
29
|
+
return t;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
33
|
+
var e = new Error(message);
|
|
34
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* A curated list of popular Google Fonts.
|
|
39
|
+
* Pass any valid Google Font name to the `font` prop — if it's in this list,
|
|
40
|
+
* it will be auto-injected via a <link> tag. For unlisted fonts, add them here
|
|
41
|
+
* or import them manually in your project.
|
|
42
|
+
*/
|
|
43
|
+
const GOOGLE_FONTS = [
|
|
44
|
+
// Serif
|
|
45
|
+
"Playfair Display",
|
|
46
|
+
"Merriweather",
|
|
47
|
+
"Lora",
|
|
48
|
+
"EB Garamond",
|
|
49
|
+
"Libre Baskerville",
|
|
50
|
+
"Cormorant Garamond",
|
|
51
|
+
"DM Serif Display",
|
|
52
|
+
"Crimson Text",
|
|
53
|
+
"Source Serif 4",
|
|
54
|
+
"Fraunces",
|
|
55
|
+
// Sans-serif
|
|
56
|
+
"Inter",
|
|
57
|
+
"Roboto",
|
|
58
|
+
"Open Sans",
|
|
59
|
+
"Nunito",
|
|
60
|
+
"Poppins",
|
|
61
|
+
"Raleway",
|
|
62
|
+
"Outfit",
|
|
63
|
+
"DM Sans",
|
|
64
|
+
"Manrope",
|
|
65
|
+
"Plus Jakarta Sans",
|
|
66
|
+
"Figtree",
|
|
67
|
+
"Syne",
|
|
68
|
+
"Albert Sans",
|
|
69
|
+
// Display / Expressive
|
|
70
|
+
"Bebas Neue",
|
|
71
|
+
"Oswald",
|
|
72
|
+
"Anton",
|
|
73
|
+
"Barlow Condensed",
|
|
74
|
+
"Righteous",
|
|
75
|
+
"Abril Fatface",
|
|
76
|
+
"Dela Gothic One",
|
|
77
|
+
"Space Grotesk",
|
|
78
|
+
"Unbounded",
|
|
79
|
+
"Big Shoulders Display",
|
|
80
|
+
// Mono
|
|
81
|
+
"JetBrains Mono",
|
|
82
|
+
"Fira Code",
|
|
83
|
+
"Source Code Pro",
|
|
84
|
+
"Space Mono",
|
|
85
|
+
"IBM Plex Mono",
|
|
86
|
+
];
|
|
87
|
+
const injectedFonts = new Set();
|
|
88
|
+
/**
|
|
89
|
+
* Builds a Google Fonts URL for a given font family.
|
|
90
|
+
* Requests weights 300, 400, 500, 600, 700, 800 — italic variants included.
|
|
91
|
+
*/
|
|
92
|
+
function buildFontUrl(fontFamily) {
|
|
93
|
+
const encoded = fontFamily.replace(/ /g, "+");
|
|
94
|
+
return `https://fonts.googleapis.com/css2?family=${encoded}:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;1,400;1,700&display=swap`;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Injects a Google Fonts <link> into <head> once per unique URL.
|
|
98
|
+
* Safe to call multiple times — deduped via a Set.
|
|
99
|
+
*/
|
|
100
|
+
function injectFont(url) {
|
|
101
|
+
if (typeof document === "undefined")
|
|
102
|
+
return; // SSR guard
|
|
103
|
+
if (injectedFonts.has(url))
|
|
104
|
+
return;
|
|
105
|
+
const link = document.createElement("link");
|
|
106
|
+
link.rel = "stylesheet";
|
|
107
|
+
link.href = url;
|
|
108
|
+
document.head.appendChild(link);
|
|
109
|
+
injectedFonts.add(url);
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Pre-load a set of fonts eagerly (e.g. at app root).
|
|
113
|
+
* Usage: preloadFonts(["Playfair Display", "Inter"])
|
|
114
|
+
*/
|
|
115
|
+
function preloadFonts(families) {
|
|
116
|
+
families.forEach((f) => {
|
|
117
|
+
if (GOOGLE_FONTS.includes(f)) {
|
|
118
|
+
injectFont(buildFontUrl(f));
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
console.warn(`[react-type-scale] "${f}" is not in the bundled GOOGLE_FONTS list. ` +
|
|
122
|
+
`Add it to the list or import it manually.`);
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const variantTagMap = {
|
|
128
|
+
Display: "h1",
|
|
129
|
+
H1: "h1",
|
|
130
|
+
H2: "h2",
|
|
131
|
+
H3: "h3",
|
|
132
|
+
H4: "h4",
|
|
133
|
+
H5: "h5",
|
|
134
|
+
H6: "h6",
|
|
135
|
+
Subheading: "h6",
|
|
136
|
+
Overline: "span",
|
|
137
|
+
Body: "p",
|
|
138
|
+
Label: "label",
|
|
139
|
+
Caption: "span",
|
|
140
|
+
};
|
|
141
|
+
const variantStyleMap = {
|
|
142
|
+
Display: {
|
|
143
|
+
fontSize: "clamp(2.5rem, 6vw, 5rem)",
|
|
144
|
+
fontWeight: 800,
|
|
145
|
+
lineHeight: 1.05,
|
|
146
|
+
letterSpacing: "-0.03em",
|
|
147
|
+
},
|
|
148
|
+
H1: {
|
|
149
|
+
fontSize: "clamp(2rem, 4vw, 3rem)",
|
|
150
|
+
fontWeight: 700,
|
|
151
|
+
lineHeight: 1.1,
|
|
152
|
+
letterSpacing: "-0.02em",
|
|
153
|
+
},
|
|
154
|
+
H2: {
|
|
155
|
+
fontSize: "clamp(1.5rem, 3vw, 2.25rem)",
|
|
156
|
+
fontWeight: 700,
|
|
157
|
+
lineHeight: 1.2,
|
|
158
|
+
letterSpacing: "-0.015em",
|
|
159
|
+
},
|
|
160
|
+
H3: {
|
|
161
|
+
fontSize: "clamp(1.25rem, 2.5vw, 1.75rem)",
|
|
162
|
+
fontWeight: 600,
|
|
163
|
+
lineHeight: 1.25,
|
|
164
|
+
letterSpacing: "-0.01em",
|
|
165
|
+
},
|
|
166
|
+
H4: {
|
|
167
|
+
fontSize: "clamp(1.1rem, 2vw, 1.375rem)",
|
|
168
|
+
fontWeight: 600,
|
|
169
|
+
lineHeight: 1.3,
|
|
170
|
+
letterSpacing: "-0.005em",
|
|
171
|
+
},
|
|
172
|
+
H5: {
|
|
173
|
+
fontSize: "clamp(1rem, 1.5vw, 1.125rem)",
|
|
174
|
+
fontWeight: 600,
|
|
175
|
+
lineHeight: 1.35,
|
|
176
|
+
letterSpacing: "0em",
|
|
177
|
+
},
|
|
178
|
+
H6: {
|
|
179
|
+
fontSize: "1rem",
|
|
180
|
+
fontWeight: 600,
|
|
181
|
+
lineHeight: 1.4,
|
|
182
|
+
letterSpacing: "0em",
|
|
183
|
+
},
|
|
184
|
+
Subheading: {
|
|
185
|
+
fontSize: "1.125rem",
|
|
186
|
+
fontWeight: 500,
|
|
187
|
+
lineHeight: 1.5,
|
|
188
|
+
letterSpacing: "0.005em",
|
|
189
|
+
},
|
|
190
|
+
Overline: {
|
|
191
|
+
fontSize: "0.6875rem",
|
|
192
|
+
fontWeight: 700,
|
|
193
|
+
lineHeight: 1.6,
|
|
194
|
+
letterSpacing: "0.12em",
|
|
195
|
+
textTransform: "uppercase",
|
|
196
|
+
},
|
|
197
|
+
Body: {
|
|
198
|
+
fontSize: "1rem",
|
|
199
|
+
fontWeight: 400,
|
|
200
|
+
lineHeight: 1.7,
|
|
201
|
+
letterSpacing: "0.01em",
|
|
202
|
+
},
|
|
203
|
+
Label: {
|
|
204
|
+
fontSize: "0.875rem",
|
|
205
|
+
fontWeight: 500,
|
|
206
|
+
lineHeight: 1.5,
|
|
207
|
+
letterSpacing: "0.02em",
|
|
208
|
+
},
|
|
209
|
+
Caption: {
|
|
210
|
+
fontSize: "0.75rem",
|
|
211
|
+
fontWeight: 400,
|
|
212
|
+
lineHeight: 1.6,
|
|
213
|
+
letterSpacing: "0.03em",
|
|
214
|
+
},
|
|
215
|
+
};
|
|
216
|
+
const Typography = (_a) => {
|
|
217
|
+
var { variant = "Body", font, color, align, className, style, children, as, truncate, maxLines } = _a, rest = __rest(_a, ["variant", "font", "color", "align", "className", "style", "children", "as", "truncate", "maxLines"]);
|
|
218
|
+
// Inject Google Font if provided and it's a known Google Font
|
|
219
|
+
if (font && GOOGLE_FONTS.includes(font)) {
|
|
220
|
+
injectFont(buildFontUrl(font));
|
|
221
|
+
}
|
|
222
|
+
const Tag = (as !== null && as !== void 0 ? as : variantTagMap[variant]);
|
|
223
|
+
const baseStyle = variantStyleMap[variant];
|
|
224
|
+
const computedStyle = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, baseStyle), (font ? { fontFamily: `'${font}', sans-serif` } : {})), (color ? { color } : {})), (align ? { textAlign: align } : {})), (truncate
|
|
225
|
+
? {
|
|
226
|
+
overflow: "hidden",
|
|
227
|
+
textOverflow: "ellipsis",
|
|
228
|
+
whiteSpace: "nowrap",
|
|
229
|
+
}
|
|
230
|
+
: {})), (maxLines && !truncate
|
|
231
|
+
? {
|
|
232
|
+
display: "-webkit-box",
|
|
233
|
+
WebkitLineClamp: maxLines,
|
|
234
|
+
WebkitBoxOrient: "vertical",
|
|
235
|
+
overflow: "hidden",
|
|
236
|
+
}
|
|
237
|
+
: {})), { margin: 0, padding: 0 }), style);
|
|
238
|
+
return (jsx(Tag, Object.assign({ className: className, style: computedStyle }, rest, { children: children })));
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
export { GOOGLE_FONTS, Typography, buildFontUrl, Typography as default, injectFont, preloadFonts };
|
|
242
|
+
//# sourceMappingURL=index.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../node_modules/tslib/tslib.es6.js","../../fonts.ts","../../Typography.tsx"],"sourcesContent":["/******************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise, SuppressedError, Symbol, Iterator */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {\r\n function accept(f) { if (f !== void 0 && typeof f !== \"function\") throw new TypeError(\"Function expected\"); return f; }\r\n var kind = contextIn.kind, key = kind === \"getter\" ? \"get\" : kind === \"setter\" ? \"set\" : \"value\";\r\n var target = !descriptorIn && ctor ? contextIn[\"static\"] ? ctor : ctor.prototype : null;\r\n var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});\r\n var _, done = false;\r\n for (var i = decorators.length - 1; i >= 0; i--) {\r\n var context = {};\r\n for (var p in contextIn) context[p] = p === \"access\" ? {} : contextIn[p];\r\n for (var p in contextIn.access) context.access[p] = contextIn.access[p];\r\n context.addInitializer = function (f) { if (done) throw new TypeError(\"Cannot add initializers after decoration has completed\"); extraInitializers.push(accept(f || null)); };\r\n var result = (0, decorators[i])(kind === \"accessor\" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);\r\n if (kind === \"accessor\") {\r\n if (result === void 0) continue;\r\n if (result === null || typeof result !== \"object\") throw new TypeError(\"Object expected\");\r\n if (_ = accept(result.get)) descriptor.get = _;\r\n if (_ = accept(result.set)) descriptor.set = _;\r\n if (_ = accept(result.init)) initializers.unshift(_);\r\n }\r\n else if (_ = accept(result)) {\r\n if (kind === \"field\") initializers.unshift(_);\r\n else descriptor[key] = _;\r\n }\r\n }\r\n if (target) Object.defineProperty(target, contextIn.name, descriptor);\r\n done = true;\r\n};\r\n\r\nexport function __runInitializers(thisArg, initializers, value) {\r\n var useValue = arguments.length > 2;\r\n for (var i = 0; i < initializers.length; i++) {\r\n value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);\r\n }\r\n return useValue ? value : void 0;\r\n};\r\n\r\nexport function __propKey(x) {\r\n return typeof x === \"symbol\" ? x : \"\".concat(x);\r\n};\r\n\r\nexport function __setFunctionName(f, name, prefix) {\r\n if (typeof name === \"symbol\") name = name.description ? \"[\".concat(name.description, \"]\") : \"\";\r\n return Object.defineProperty(f, \"name\", { configurable: true, value: prefix ? \"\".concat(prefix, \" \", name) : name });\r\n};\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === \"function\" ? Iterator : Object).prototype);\r\n return g.next = verb(0), g[\"throw\"] = verb(1), g[\"return\"] = verb(2), typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n var desc = Object.getOwnPropertyDescriptor(m, k);\r\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\r\n desc = { enumerable: true, get: function() { return m[k]; } };\r\n }\r\n Object.defineProperty(o, k2, desc);\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = Object.create((typeof AsyncIterator === \"function\" ? AsyncIterator : Object).prototype), verb(\"next\"), verb(\"throw\"), verb(\"return\", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }\r\n function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nvar ownKeys = function(o) {\r\n ownKeys = Object.getOwnPropertyNames || function (o) {\r\n var ar = [];\r\n for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;\r\n return ar;\r\n };\r\n return ownKeys(o);\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== \"default\") __createBinding(result, mod, k[i]);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n\r\nexport function __classPrivateFieldIn(state, receiver) {\r\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\r\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\r\n}\r\n\r\nexport function __addDisposableResource(env, value, async) {\r\n if (value !== null && value !== void 0) {\r\n if (typeof value !== \"object\" && typeof value !== \"function\") throw new TypeError(\"Object expected.\");\r\n var dispose, inner;\r\n if (async) {\r\n if (!Symbol.asyncDispose) throw new TypeError(\"Symbol.asyncDispose is not defined.\");\r\n dispose = value[Symbol.asyncDispose];\r\n }\r\n if (dispose === void 0) {\r\n if (!Symbol.dispose) throw new TypeError(\"Symbol.dispose is not defined.\");\r\n dispose = value[Symbol.dispose];\r\n if (async) inner = dispose;\r\n }\r\n if (typeof dispose !== \"function\") throw new TypeError(\"Object not disposable.\");\r\n if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };\r\n env.stack.push({ value: value, dispose: dispose, async: async });\r\n }\r\n else if (async) {\r\n env.stack.push({ async: true });\r\n }\r\n return value;\r\n\r\n}\r\n\r\nvar _SuppressedError = typeof SuppressedError === \"function\" ? SuppressedError : function (error, suppressed, message) {\r\n var e = new Error(message);\r\n return e.name = \"SuppressedError\", e.error = error, e.suppressed = suppressed, e;\r\n};\r\n\r\nexport function __disposeResources(env) {\r\n function fail(e) {\r\n env.error = env.hasError ? new _SuppressedError(e, env.error, \"An error was suppressed during disposal.\") : e;\r\n env.hasError = true;\r\n }\r\n var r, s = 0;\r\n function next() {\r\n while (r = env.stack.pop()) {\r\n try {\r\n if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);\r\n if (r.dispose) {\r\n var result = r.dispose.call(r.value);\r\n if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });\r\n }\r\n else s |= 1;\r\n }\r\n catch (e) {\r\n fail(e);\r\n }\r\n }\r\n if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();\r\n if (env.hasError) throw env.error;\r\n }\r\n return next();\r\n}\r\n\r\nexport function __rewriteRelativeImportExtension(path, preserveJsx) {\r\n if (typeof path === \"string\" && /^\\.\\.?\\//.test(path)) {\r\n return path.replace(/\\.(tsx)$|((?:\\.d)?)((?:\\.[^./]+?)?)\\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {\r\n return tsx ? preserveJsx ? \".jsx\" : \".js\" : d && (!ext || !cm) ? m : (d + ext + \".\" + cm.toLowerCase() + \"js\");\r\n });\r\n }\r\n return path;\r\n}\r\n\r\nexport default {\r\n __extends: __extends,\r\n __assign: __assign,\r\n __rest: __rest,\r\n __decorate: __decorate,\r\n __param: __param,\r\n __esDecorate: __esDecorate,\r\n __runInitializers: __runInitializers,\r\n __propKey: __propKey,\r\n __setFunctionName: __setFunctionName,\r\n __metadata: __metadata,\r\n __awaiter: __awaiter,\r\n __generator: __generator,\r\n __createBinding: __createBinding,\r\n __exportStar: __exportStar,\r\n __values: __values,\r\n __read: __read,\r\n __spread: __spread,\r\n __spreadArrays: __spreadArrays,\r\n __spreadArray: __spreadArray,\r\n __await: __await,\r\n __asyncGenerator: __asyncGenerator,\r\n __asyncDelegator: __asyncDelegator,\r\n __asyncValues: __asyncValues,\r\n __makeTemplateObject: __makeTemplateObject,\r\n __importStar: __importStar,\r\n __importDefault: __importDefault,\r\n __classPrivateFieldGet: __classPrivateFieldGet,\r\n __classPrivateFieldSet: __classPrivateFieldSet,\r\n __classPrivateFieldIn: __classPrivateFieldIn,\r\n __addDisposableResource: __addDisposableResource,\r\n __disposeResources: __disposeResources,\r\n __rewriteRelativeImportExtension: __rewriteRelativeImportExtension,\r\n};\r\n","/**\n * A curated list of popular Google Fonts.\n * Pass any valid Google Font name to the `font` prop — if it's in this list,\n * it will be auto-injected via a <link> tag. For unlisted fonts, add them here\n * or import them manually in your project.\n */\nexport const GOOGLE_FONTS: string[] = [\n // Serif\n \"Playfair Display\",\n \"Merriweather\",\n \"Lora\",\n \"EB Garamond\",\n \"Libre Baskerville\",\n \"Cormorant Garamond\",\n \"DM Serif Display\",\n \"Crimson Text\",\n \"Source Serif 4\",\n \"Fraunces\",\n\n // Sans-serif\n \"Inter\",\n \"Roboto\",\n \"Open Sans\",\n \"Nunito\",\n \"Poppins\",\n \"Raleway\",\n \"Outfit\",\n \"DM Sans\",\n \"Manrope\",\n \"Plus Jakarta Sans\",\n \"Figtree\",\n \"Syne\",\n \"Albert Sans\",\n\n // Display / Expressive\n \"Bebas Neue\",\n \"Oswald\",\n \"Anton\",\n \"Barlow Condensed\",\n \"Righteous\",\n \"Abril Fatface\",\n \"Dela Gothic One\",\n \"Space Grotesk\",\n \"Unbounded\",\n \"Big Shoulders Display\",\n\n // Mono\n \"JetBrains Mono\",\n \"Fira Code\",\n \"Source Code Pro\",\n \"Space Mono\",\n \"IBM Plex Mono\",\n];\n\nconst injectedFonts = new Set<string>();\n\n/**\n * Builds a Google Fonts URL for a given font family.\n * Requests weights 300, 400, 500, 600, 700, 800 — italic variants included.\n */\nexport function buildFontUrl(fontFamily: string): string {\n const encoded = fontFamily.replace(/ /g, \"+\");\n return `https://fonts.googleapis.com/css2?family=${encoded}:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;1,400;1,700&display=swap`;\n}\n\n/**\n * Injects a Google Fonts <link> into <head> once per unique URL.\n * Safe to call multiple times — deduped via a Set.\n */\nexport function injectFont(url: string): void {\n if (typeof document === \"undefined\") return; // SSR guard\n if (injectedFonts.has(url)) return;\n\n const link = document.createElement(\"link\");\n link.rel = \"stylesheet\";\n link.href = url;\n document.head.appendChild(link);\n injectedFonts.add(url);\n}\n\n/**\n * Pre-load a set of fonts eagerly (e.g. at app root).\n * Usage: preloadFonts([\"Playfair Display\", \"Inter\"])\n */\nexport function preloadFonts(families: string[]): void {\n families.forEach((f) => {\n if (GOOGLE_FONTS.includes(f)) {\n injectFont(buildFontUrl(f));\n } else {\n console.warn(\n `[react-type-scale] \"${f}\" is not in the bundled GOOGLE_FONTS list. ` +\n `Add it to the list or import it manually.`\n );\n }\n });\n}\n","import React, { CSSProperties } from \"react\";\nimport { TypographyProps, VariantTagMap, VariantStyleMap } from \"./types\";\nimport { GOOGLE_FONTS, buildFontUrl, injectFont } from \"./fonts\";\n\nconst variantTagMap: VariantTagMap = {\n Display: \"h1\",\n H1: \"h1\",\n H2: \"h2\",\n H3: \"h3\",\n H4: \"h4\",\n H5: \"h5\",\n H6: \"h6\",\n Subheading: \"h6\",\n Overline: \"span\",\n Body: \"p\",\n Label: \"label\",\n Caption: \"span\",\n};\n\nconst variantStyleMap: VariantStyleMap = {\n Display: {\n fontSize: \"clamp(2.5rem, 6vw, 5rem)\",\n fontWeight: 800,\n lineHeight: 1.05,\n letterSpacing: \"-0.03em\",\n },\n H1: {\n fontSize: \"clamp(2rem, 4vw, 3rem)\",\n fontWeight: 700,\n lineHeight: 1.1,\n letterSpacing: \"-0.02em\",\n },\n H2: {\n fontSize: \"clamp(1.5rem, 3vw, 2.25rem)\",\n fontWeight: 700,\n lineHeight: 1.2,\n letterSpacing: \"-0.015em\",\n },\n H3: {\n fontSize: \"clamp(1.25rem, 2.5vw, 1.75rem)\",\n fontWeight: 600,\n lineHeight: 1.25,\n letterSpacing: \"-0.01em\",\n },\n H4: {\n fontSize: \"clamp(1.1rem, 2vw, 1.375rem)\",\n fontWeight: 600,\n lineHeight: 1.3,\n letterSpacing: \"-0.005em\",\n },\n H5: {\n fontSize: \"clamp(1rem, 1.5vw, 1.125rem)\",\n fontWeight: 600,\n lineHeight: 1.35,\n letterSpacing: \"0em\",\n },\n H6: {\n fontSize: \"1rem\",\n fontWeight: 600,\n lineHeight: 1.4,\n letterSpacing: \"0em\",\n },\n Subheading: {\n fontSize: \"1.125rem\",\n fontWeight: 500,\n lineHeight: 1.5,\n letterSpacing: \"0.005em\",\n },\n Overline: {\n fontSize: \"0.6875rem\",\n fontWeight: 700,\n lineHeight: 1.6,\n letterSpacing: \"0.12em\",\n textTransform: \"uppercase\" as CSSProperties[\"textTransform\"],\n },\n Body: {\n fontSize: \"1rem\",\n fontWeight: 400,\n lineHeight: 1.7,\n letterSpacing: \"0.01em\",\n },\n Label: {\n fontSize: \"0.875rem\",\n fontWeight: 500,\n lineHeight: 1.5,\n letterSpacing: \"0.02em\",\n },\n Caption: {\n fontSize: \"0.75rem\",\n fontWeight: 400,\n lineHeight: 1.6,\n letterSpacing: \"0.03em\",\n },\n};\n\nexport const Typography: React.FC<TypographyProps> = ({\n variant = \"Body\",\n font,\n color,\n align,\n className,\n style,\n children,\n as,\n truncate,\n maxLines,\n ...rest\n}) => {\n // Inject Google Font if provided and it's a known Google Font\n if (font && GOOGLE_FONTS.includes(font)) {\n injectFont(buildFontUrl(font));\n }\n\n const Tag = (as ?? variantTagMap[variant]) as React.ElementType;\n const baseStyle = variantStyleMap[variant];\n\n const computedStyle: CSSProperties = {\n ...baseStyle,\n ...(font ? { fontFamily: `'${font}', sans-serif` } : {}),\n ...(color ? { color } : {}),\n ...(align ? { textAlign: align } : {}),\n ...(truncate\n ? {\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n whiteSpace: \"nowrap\",\n }\n : {}),\n ...(maxLines && !truncate\n ? {\n display: \"-webkit-box\",\n WebkitLineClamp: maxLines,\n WebkitBoxOrient: \"vertical\" as CSSProperties[\"WebkitBoxOrient\"],\n overflow: \"hidden\",\n }\n : {}),\n margin: 0,\n padding: 0,\n ...style,\n };\n\n return (\n <Tag className={className} style={computedStyle} {...rest}>\n {children}\n </Tag>\n );\n};\n\nexport default Typography;\n"],"names":["_jsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AA0BA;AACO,SAAS,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE;AAC7B,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;AACf,IAAI,KAAK,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,EAAE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Q;AACV,UAAE;AACE,YAAA,QAAQ,EAAE,QAAQ;AAClB,YAAA,YAAY,EAAE,UAAU;AACxB,YAAA,UAAU,EAAE,QAAQ;AACrB,SAAA;UACD,EAAE,EAAC,GACH,QAAQ,IAAI,CAAC,QAAQ;AACvB,UAAE;AACE,YAAA,OAAO,EAAE,aAAa;AACtB,YAAA,eAAe,EAAE,QAAQ;AACzB,YAAA,eAAe,EAAE,UAA8C;AAC/D,YAAA,QAAQ,EAAE,QAAQ;AACnB,SAAA;AACH,UAAE,EAAE,EAAC,EAAA,EACP,MAAM,EAAE,CAAC,EACT,OAAO,EAAE,CAAC,EACP,CAAA,EAAA,KAAK,CACT,CAAC;AAEF,IAAA,QACEA,GAAC,CAAA,GAAG,EAAC,MAAA,CAAA,MAAA,CAAA,EAAA,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,aAAa,EAAM,EAAA,IAAI,cACtD,QAAQ,EAAA,CAAA,CACL,EACN;AACJ;;;;","x_google_ignoreList":[0]}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
|
|
7
|
+
/******************************************************************************
|
|
8
|
+
Copyright (c) Microsoft Corporation.
|
|
9
|
+
|
|
10
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
11
|
+
purpose with or without fee is hereby granted.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
14
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
15
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
16
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
17
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
18
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
19
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
20
|
+
***************************************************************************** */
|
|
21
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
function __rest(s, e) {
|
|
25
|
+
var t = {};
|
|
26
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
27
|
+
t[p] = s[p];
|
|
28
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
29
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
30
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
31
|
+
t[p[i]] = s[p[i]];
|
|
32
|
+
}
|
|
33
|
+
return t;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
37
|
+
var e = new Error(message);
|
|
38
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* A curated list of popular Google Fonts.
|
|
43
|
+
* Pass any valid Google Font name to the `font` prop — if it's in this list,
|
|
44
|
+
* it will be auto-injected via a <link> tag. For unlisted fonts, add them here
|
|
45
|
+
* or import them manually in your project.
|
|
46
|
+
*/
|
|
47
|
+
const GOOGLE_FONTS = [
|
|
48
|
+
// Serif
|
|
49
|
+
"Playfair Display",
|
|
50
|
+
"Merriweather",
|
|
51
|
+
"Lora",
|
|
52
|
+
"EB Garamond",
|
|
53
|
+
"Libre Baskerville",
|
|
54
|
+
"Cormorant Garamond",
|
|
55
|
+
"DM Serif Display",
|
|
56
|
+
"Crimson Text",
|
|
57
|
+
"Source Serif 4",
|
|
58
|
+
"Fraunces",
|
|
59
|
+
// Sans-serif
|
|
60
|
+
"Inter",
|
|
61
|
+
"Roboto",
|
|
62
|
+
"Open Sans",
|
|
63
|
+
"Nunito",
|
|
64
|
+
"Poppins",
|
|
65
|
+
"Raleway",
|
|
66
|
+
"Outfit",
|
|
67
|
+
"DM Sans",
|
|
68
|
+
"Manrope",
|
|
69
|
+
"Plus Jakarta Sans",
|
|
70
|
+
"Figtree",
|
|
71
|
+
"Syne",
|
|
72
|
+
"Albert Sans",
|
|
73
|
+
// Display / Expressive
|
|
74
|
+
"Bebas Neue",
|
|
75
|
+
"Oswald",
|
|
76
|
+
"Anton",
|
|
77
|
+
"Barlow Condensed",
|
|
78
|
+
"Righteous",
|
|
79
|
+
"Abril Fatface",
|
|
80
|
+
"Dela Gothic One",
|
|
81
|
+
"Space Grotesk",
|
|
82
|
+
"Unbounded",
|
|
83
|
+
"Big Shoulders Display",
|
|
84
|
+
// Mono
|
|
85
|
+
"JetBrains Mono",
|
|
86
|
+
"Fira Code",
|
|
87
|
+
"Source Code Pro",
|
|
88
|
+
"Space Mono",
|
|
89
|
+
"IBM Plex Mono",
|
|
90
|
+
];
|
|
91
|
+
const injectedFonts = new Set();
|
|
92
|
+
/**
|
|
93
|
+
* Builds a Google Fonts URL for a given font family.
|
|
94
|
+
* Requests weights 300, 400, 500, 600, 700, 800 — italic variants included.
|
|
95
|
+
*/
|
|
96
|
+
function buildFontUrl(fontFamily) {
|
|
97
|
+
const encoded = fontFamily.replace(/ /g, "+");
|
|
98
|
+
return `https://fonts.googleapis.com/css2?family=${encoded}:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;1,400;1,700&display=swap`;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Injects a Google Fonts <link> into <head> once per unique URL.
|
|
102
|
+
* Safe to call multiple times — deduped via a Set.
|
|
103
|
+
*/
|
|
104
|
+
function injectFont(url) {
|
|
105
|
+
if (typeof document === "undefined")
|
|
106
|
+
return; // SSR guard
|
|
107
|
+
if (injectedFonts.has(url))
|
|
108
|
+
return;
|
|
109
|
+
const link = document.createElement("link");
|
|
110
|
+
link.rel = "stylesheet";
|
|
111
|
+
link.href = url;
|
|
112
|
+
document.head.appendChild(link);
|
|
113
|
+
injectedFonts.add(url);
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Pre-load a set of fonts eagerly (e.g. at app root).
|
|
117
|
+
* Usage: preloadFonts(["Playfair Display", "Inter"])
|
|
118
|
+
*/
|
|
119
|
+
function preloadFonts(families) {
|
|
120
|
+
families.forEach((f) => {
|
|
121
|
+
if (GOOGLE_FONTS.includes(f)) {
|
|
122
|
+
injectFont(buildFontUrl(f));
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
console.warn(`[react-type-scale] "${f}" is not in the bundled GOOGLE_FONTS list. ` +
|
|
126
|
+
`Add it to the list or import it manually.`);
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const variantTagMap = {
|
|
132
|
+
Display: "h1",
|
|
133
|
+
H1: "h1",
|
|
134
|
+
H2: "h2",
|
|
135
|
+
H3: "h3",
|
|
136
|
+
H4: "h4",
|
|
137
|
+
H5: "h5",
|
|
138
|
+
H6: "h6",
|
|
139
|
+
Subheading: "h6",
|
|
140
|
+
Overline: "span",
|
|
141
|
+
Body: "p",
|
|
142
|
+
Label: "label",
|
|
143
|
+
Caption: "span",
|
|
144
|
+
};
|
|
145
|
+
const variantStyleMap = {
|
|
146
|
+
Display: {
|
|
147
|
+
fontSize: "clamp(2.5rem, 6vw, 5rem)",
|
|
148
|
+
fontWeight: 800,
|
|
149
|
+
lineHeight: 1.05,
|
|
150
|
+
letterSpacing: "-0.03em",
|
|
151
|
+
},
|
|
152
|
+
H1: {
|
|
153
|
+
fontSize: "clamp(2rem, 4vw, 3rem)",
|
|
154
|
+
fontWeight: 700,
|
|
155
|
+
lineHeight: 1.1,
|
|
156
|
+
letterSpacing: "-0.02em",
|
|
157
|
+
},
|
|
158
|
+
H2: {
|
|
159
|
+
fontSize: "clamp(1.5rem, 3vw, 2.25rem)",
|
|
160
|
+
fontWeight: 700,
|
|
161
|
+
lineHeight: 1.2,
|
|
162
|
+
letterSpacing: "-0.015em",
|
|
163
|
+
},
|
|
164
|
+
H3: {
|
|
165
|
+
fontSize: "clamp(1.25rem, 2.5vw, 1.75rem)",
|
|
166
|
+
fontWeight: 600,
|
|
167
|
+
lineHeight: 1.25,
|
|
168
|
+
letterSpacing: "-0.01em",
|
|
169
|
+
},
|
|
170
|
+
H4: {
|
|
171
|
+
fontSize: "clamp(1.1rem, 2vw, 1.375rem)",
|
|
172
|
+
fontWeight: 600,
|
|
173
|
+
lineHeight: 1.3,
|
|
174
|
+
letterSpacing: "-0.005em",
|
|
175
|
+
},
|
|
176
|
+
H5: {
|
|
177
|
+
fontSize: "clamp(1rem, 1.5vw, 1.125rem)",
|
|
178
|
+
fontWeight: 600,
|
|
179
|
+
lineHeight: 1.35,
|
|
180
|
+
letterSpacing: "0em",
|
|
181
|
+
},
|
|
182
|
+
H6: {
|
|
183
|
+
fontSize: "1rem",
|
|
184
|
+
fontWeight: 600,
|
|
185
|
+
lineHeight: 1.4,
|
|
186
|
+
letterSpacing: "0em",
|
|
187
|
+
},
|
|
188
|
+
Subheading: {
|
|
189
|
+
fontSize: "1.125rem",
|
|
190
|
+
fontWeight: 500,
|
|
191
|
+
lineHeight: 1.5,
|
|
192
|
+
letterSpacing: "0.005em",
|
|
193
|
+
},
|
|
194
|
+
Overline: {
|
|
195
|
+
fontSize: "0.6875rem",
|
|
196
|
+
fontWeight: 700,
|
|
197
|
+
lineHeight: 1.6,
|
|
198
|
+
letterSpacing: "0.12em",
|
|
199
|
+
textTransform: "uppercase",
|
|
200
|
+
},
|
|
201
|
+
Body: {
|
|
202
|
+
fontSize: "1rem",
|
|
203
|
+
fontWeight: 400,
|
|
204
|
+
lineHeight: 1.7,
|
|
205
|
+
letterSpacing: "0.01em",
|
|
206
|
+
},
|
|
207
|
+
Label: {
|
|
208
|
+
fontSize: "0.875rem",
|
|
209
|
+
fontWeight: 500,
|
|
210
|
+
lineHeight: 1.5,
|
|
211
|
+
letterSpacing: "0.02em",
|
|
212
|
+
},
|
|
213
|
+
Caption: {
|
|
214
|
+
fontSize: "0.75rem",
|
|
215
|
+
fontWeight: 400,
|
|
216
|
+
lineHeight: 1.6,
|
|
217
|
+
letterSpacing: "0.03em",
|
|
218
|
+
},
|
|
219
|
+
};
|
|
220
|
+
const Typography = (_a) => {
|
|
221
|
+
var { variant = "Body", font, color, align, className, style, children, as, truncate, maxLines } = _a, rest = __rest(_a, ["variant", "font", "color", "align", "className", "style", "children", "as", "truncate", "maxLines"]);
|
|
222
|
+
// Inject Google Font if provided and it's a known Google Font
|
|
223
|
+
if (font && GOOGLE_FONTS.includes(font)) {
|
|
224
|
+
injectFont(buildFontUrl(font));
|
|
225
|
+
}
|
|
226
|
+
const Tag = (as !== null && as !== void 0 ? as : variantTagMap[variant]);
|
|
227
|
+
const baseStyle = variantStyleMap[variant];
|
|
228
|
+
const computedStyle = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, baseStyle), (font ? { fontFamily: `'${font}', sans-serif` } : {})), (color ? { color } : {})), (align ? { textAlign: align } : {})), (truncate
|
|
229
|
+
? {
|
|
230
|
+
overflow: "hidden",
|
|
231
|
+
textOverflow: "ellipsis",
|
|
232
|
+
whiteSpace: "nowrap",
|
|
233
|
+
}
|
|
234
|
+
: {})), (maxLines && !truncate
|
|
235
|
+
? {
|
|
236
|
+
display: "-webkit-box",
|
|
237
|
+
WebkitLineClamp: maxLines,
|
|
238
|
+
WebkitBoxOrient: "vertical",
|
|
239
|
+
overflow: "hidden",
|
|
240
|
+
}
|
|
241
|
+
: {})), { margin: 0, padding: 0 }), style);
|
|
242
|
+
return (jsxRuntime.jsx(Tag, Object.assign({ className: className, style: computedStyle }, rest, { children: children })));
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
exports.GOOGLE_FONTS = GOOGLE_FONTS;
|
|
246
|
+
exports.Typography = Typography;
|
|
247
|
+
exports.buildFontUrl = buildFontUrl;
|
|
248
|
+
exports.default = Typography;
|
|
249
|
+
exports.injectFont = injectFont;
|
|
250
|
+
exports.preloadFonts = preloadFonts;
|
|
251
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../node_modules/tslib/tslib.es6.js","../../fonts.ts","../../Typography.tsx"],"sourcesContent":["/******************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise, SuppressedError, Symbol, Iterator */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {\r\n function accept(f) { if (f !== void 0 && typeof f !== \"function\") throw new TypeError(\"Function expected\"); return f; }\r\n var kind = contextIn.kind, key = kind === \"getter\" ? \"get\" : kind === \"setter\" ? \"set\" : \"value\";\r\n var target = !descriptorIn && ctor ? contextIn[\"static\"] ? ctor : ctor.prototype : null;\r\n var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});\r\n var _, done = false;\r\n for (var i = decorators.length - 1; i >= 0; i--) {\r\n var context = {};\r\n for (var p in contextIn) context[p] = p === \"access\" ? {} : contextIn[p];\r\n for (var p in contextIn.access) context.access[p] = contextIn.access[p];\r\n context.addInitializer = function (f) { if (done) throw new TypeError(\"Cannot add initializers after decoration has completed\"); extraInitializers.push(accept(f || null)); };\r\n var result = (0, decorators[i])(kind === \"accessor\" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);\r\n if (kind === \"accessor\") {\r\n if (result === void 0) continue;\r\n if (result === null || typeof result !== \"object\") throw new TypeError(\"Object expected\");\r\n if (_ = accept(result.get)) descriptor.get = _;\r\n if (_ = accept(result.set)) descriptor.set = _;\r\n if (_ = accept(result.init)) initializers.unshift(_);\r\n }\r\n else if (_ = accept(result)) {\r\n if (kind === \"field\") initializers.unshift(_);\r\n else descriptor[key] = _;\r\n }\r\n }\r\n if (target) Object.defineProperty(target, contextIn.name, descriptor);\r\n done = true;\r\n};\r\n\r\nexport function __runInitializers(thisArg, initializers, value) {\r\n var useValue = arguments.length > 2;\r\n for (var i = 0; i < initializers.length; i++) {\r\n value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);\r\n }\r\n return useValue ? value : void 0;\r\n};\r\n\r\nexport function __propKey(x) {\r\n return typeof x === \"symbol\" ? x : \"\".concat(x);\r\n};\r\n\r\nexport function __setFunctionName(f, name, prefix) {\r\n if (typeof name === \"symbol\") name = name.description ? \"[\".concat(name.description, \"]\") : \"\";\r\n return Object.defineProperty(f, \"name\", { configurable: true, value: prefix ? \"\".concat(prefix, \" \", name) : name });\r\n};\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === \"function\" ? Iterator : Object).prototype);\r\n return g.next = verb(0), g[\"throw\"] = verb(1), g[\"return\"] = verb(2), typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n var desc = Object.getOwnPropertyDescriptor(m, k);\r\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\r\n desc = { enumerable: true, get: function() { return m[k]; } };\r\n }\r\n Object.defineProperty(o, k2, desc);\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = Object.create((typeof AsyncIterator === \"function\" ? AsyncIterator : Object).prototype), verb(\"next\"), verb(\"throw\"), verb(\"return\", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }\r\n function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nvar ownKeys = function(o) {\r\n ownKeys = Object.getOwnPropertyNames || function (o) {\r\n var ar = [];\r\n for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;\r\n return ar;\r\n };\r\n return ownKeys(o);\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== \"default\") __createBinding(result, mod, k[i]);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n\r\nexport function __classPrivateFieldIn(state, receiver) {\r\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\r\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\r\n}\r\n\r\nexport function __addDisposableResource(env, value, async) {\r\n if (value !== null && value !== void 0) {\r\n if (typeof value !== \"object\" && typeof value !== \"function\") throw new TypeError(\"Object expected.\");\r\n var dispose, inner;\r\n if (async) {\r\n if (!Symbol.asyncDispose) throw new TypeError(\"Symbol.asyncDispose is not defined.\");\r\n dispose = value[Symbol.asyncDispose];\r\n }\r\n if (dispose === void 0) {\r\n if (!Symbol.dispose) throw new TypeError(\"Symbol.dispose is not defined.\");\r\n dispose = value[Symbol.dispose];\r\n if (async) inner = dispose;\r\n }\r\n if (typeof dispose !== \"function\") throw new TypeError(\"Object not disposable.\");\r\n if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };\r\n env.stack.push({ value: value, dispose: dispose, async: async });\r\n }\r\n else if (async) {\r\n env.stack.push({ async: true });\r\n }\r\n return value;\r\n\r\n}\r\n\r\nvar _SuppressedError = typeof SuppressedError === \"function\" ? SuppressedError : function (error, suppressed, message) {\r\n var e = new Error(message);\r\n return e.name = \"SuppressedError\", e.error = error, e.suppressed = suppressed, e;\r\n};\r\n\r\nexport function __disposeResources(env) {\r\n function fail(e) {\r\n env.error = env.hasError ? new _SuppressedError(e, env.error, \"An error was suppressed during disposal.\") : e;\r\n env.hasError = true;\r\n }\r\n var r, s = 0;\r\n function next() {\r\n while (r = env.stack.pop()) {\r\n try {\r\n if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);\r\n if (r.dispose) {\r\n var result = r.dispose.call(r.value);\r\n if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });\r\n }\r\n else s |= 1;\r\n }\r\n catch (e) {\r\n fail(e);\r\n }\r\n }\r\n if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();\r\n if (env.hasError) throw env.error;\r\n }\r\n return next();\r\n}\r\n\r\nexport function __rewriteRelativeImportExtension(path, preserveJsx) {\r\n if (typeof path === \"string\" && /^\\.\\.?\\//.test(path)) {\r\n return path.replace(/\\.(tsx)$|((?:\\.d)?)((?:\\.[^./]+?)?)\\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {\r\n return tsx ? preserveJsx ? \".jsx\" : \".js\" : d && (!ext || !cm) ? m : (d + ext + \".\" + cm.toLowerCase() + \"js\");\r\n });\r\n }\r\n return path;\r\n}\r\n\r\nexport default {\r\n __extends: __extends,\r\n __assign: __assign,\r\n __rest: __rest,\r\n __decorate: __decorate,\r\n __param: __param,\r\n __esDecorate: __esDecorate,\r\n __runInitializers: __runInitializers,\r\n __propKey: __propKey,\r\n __setFunctionName: __setFunctionName,\r\n __metadata: __metadata,\r\n __awaiter: __awaiter,\r\n __generator: __generator,\r\n __createBinding: __createBinding,\r\n __exportStar: __exportStar,\r\n __values: __values,\r\n __read: __read,\r\n __spread: __spread,\r\n __spreadArrays: __spreadArrays,\r\n __spreadArray: __spreadArray,\r\n __await: __await,\r\n __asyncGenerator: __asyncGenerator,\r\n __asyncDelegator: __asyncDelegator,\r\n __asyncValues: __asyncValues,\r\n __makeTemplateObject: __makeTemplateObject,\r\n __importStar: __importStar,\r\n __importDefault: __importDefault,\r\n __classPrivateFieldGet: __classPrivateFieldGet,\r\n __classPrivateFieldSet: __classPrivateFieldSet,\r\n __classPrivateFieldIn: __classPrivateFieldIn,\r\n __addDisposableResource: __addDisposableResource,\r\n __disposeResources: __disposeResources,\r\n __rewriteRelativeImportExtension: __rewriteRelativeImportExtension,\r\n};\r\n","/**\n * A curated list of popular Google Fonts.\n * Pass any valid Google Font name to the `font` prop — if it's in this list,\n * it will be auto-injected via a <link> tag. For unlisted fonts, add them here\n * or import them manually in your project.\n */\nexport const GOOGLE_FONTS: string[] = [\n // Serif\n \"Playfair Display\",\n \"Merriweather\",\n \"Lora\",\n \"EB Garamond\",\n \"Libre Baskerville\",\n \"Cormorant Garamond\",\n \"DM Serif Display\",\n \"Crimson Text\",\n \"Source Serif 4\",\n \"Fraunces\",\n\n // Sans-serif\n \"Inter\",\n \"Roboto\",\n \"Open Sans\",\n \"Nunito\",\n \"Poppins\",\n \"Raleway\",\n \"Outfit\",\n \"DM Sans\",\n \"Manrope\",\n \"Plus Jakarta Sans\",\n \"Figtree\",\n \"Syne\",\n \"Albert Sans\",\n\n // Display / Expressive\n \"Bebas Neue\",\n \"Oswald\",\n \"Anton\",\n \"Barlow Condensed\",\n \"Righteous\",\n \"Abril Fatface\",\n \"Dela Gothic One\",\n \"Space Grotesk\",\n \"Unbounded\",\n \"Big Shoulders Display\",\n\n // Mono\n \"JetBrains Mono\",\n \"Fira Code\",\n \"Source Code Pro\",\n \"Space Mono\",\n \"IBM Plex Mono\",\n];\n\nconst injectedFonts = new Set<string>();\n\n/**\n * Builds a Google Fonts URL for a given font family.\n * Requests weights 300, 400, 500, 600, 700, 800 — italic variants included.\n */\nexport function buildFontUrl(fontFamily: string): string {\n const encoded = fontFamily.replace(/ /g, \"+\");\n return `https://fonts.googleapis.com/css2?family=${encoded}:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;1,400;1,700&display=swap`;\n}\n\n/**\n * Injects a Google Fonts <link> into <head> once per unique URL.\n * Safe to call multiple times — deduped via a Set.\n */\nexport function injectFont(url: string): void {\n if (typeof document === \"undefined\") return; // SSR guard\n if (injectedFonts.has(url)) return;\n\n const link = document.createElement(\"link\");\n link.rel = \"stylesheet\";\n link.href = url;\n document.head.appendChild(link);\n injectedFonts.add(url);\n}\n\n/**\n * Pre-load a set of fonts eagerly (e.g. at app root).\n * Usage: preloadFonts([\"Playfair Display\", \"Inter\"])\n */\nexport function preloadFonts(families: string[]): void {\n families.forEach((f) => {\n if (GOOGLE_FONTS.includes(f)) {\n injectFont(buildFontUrl(f));\n } else {\n console.warn(\n `[react-type-scale] \"${f}\" is not in the bundled GOOGLE_FONTS list. ` +\n `Add it to the list or import it manually.`\n );\n }\n });\n}\n","import React, { CSSProperties } from \"react\";\nimport { TypographyProps, VariantTagMap, VariantStyleMap } from \"./types\";\nimport { GOOGLE_FONTS, buildFontUrl, injectFont } from \"./fonts\";\n\nconst variantTagMap: VariantTagMap = {\n Display: \"h1\",\n H1: \"h1\",\n H2: \"h2\",\n H3: \"h3\",\n H4: \"h4\",\n H5: \"h5\",\n H6: \"h6\",\n Subheading: \"h6\",\n Overline: \"span\",\n Body: \"p\",\n Label: \"label\",\n Caption: \"span\",\n};\n\nconst variantStyleMap: VariantStyleMap = {\n Display: {\n fontSize: \"clamp(2.5rem, 6vw, 5rem)\",\n fontWeight: 800,\n lineHeight: 1.05,\n letterSpacing: \"-0.03em\",\n },\n H1: {\n fontSize: \"clamp(2rem, 4vw, 3rem)\",\n fontWeight: 700,\n lineHeight: 1.1,\n letterSpacing: \"-0.02em\",\n },\n H2: {\n fontSize: \"clamp(1.5rem, 3vw, 2.25rem)\",\n fontWeight: 700,\n lineHeight: 1.2,\n letterSpacing: \"-0.015em\",\n },\n H3: {\n fontSize: \"clamp(1.25rem, 2.5vw, 1.75rem)\",\n fontWeight: 600,\n lineHeight: 1.25,\n letterSpacing: \"-0.01em\",\n },\n H4: {\n fontSize: \"clamp(1.1rem, 2vw, 1.375rem)\",\n fontWeight: 600,\n lineHeight: 1.3,\n letterSpacing: \"-0.005em\",\n },\n H5: {\n fontSize: \"clamp(1rem, 1.5vw, 1.125rem)\",\n fontWeight: 600,\n lineHeight: 1.35,\n letterSpacing: \"0em\",\n },\n H6: {\n fontSize: \"1rem\",\n fontWeight: 600,\n lineHeight: 1.4,\n letterSpacing: \"0em\",\n },\n Subheading: {\n fontSize: \"1.125rem\",\n fontWeight: 500,\n lineHeight: 1.5,\n letterSpacing: \"0.005em\",\n },\n Overline: {\n fontSize: \"0.6875rem\",\n fontWeight: 700,\n lineHeight: 1.6,\n letterSpacing: \"0.12em\",\n textTransform: \"uppercase\" as CSSProperties[\"textTransform\"],\n },\n Body: {\n fontSize: \"1rem\",\n fontWeight: 400,\n lineHeight: 1.7,\n letterSpacing: \"0.01em\",\n },\n Label: {\n fontSize: \"0.875rem\",\n fontWeight: 500,\n lineHeight: 1.5,\n letterSpacing: \"0.02em\",\n },\n Caption: {\n fontSize: \"0.75rem\",\n fontWeight: 400,\n lineHeight: 1.6,\n letterSpacing: \"0.03em\",\n },\n};\n\nexport const Typography: React.FC<TypographyProps> = ({\n variant = \"Body\",\n font,\n color,\n align,\n className,\n style,\n children,\n as,\n truncate,\n maxLines,\n ...rest\n}) => {\n // Inject Google Font if provided and it's a known Google Font\n if (font && GOOGLE_FONTS.includes(font)) {\n injectFont(buildFontUrl(font));\n }\n\n const Tag = (as ?? variantTagMap[variant]) as React.ElementType;\n const baseStyle = variantStyleMap[variant];\n\n const computedStyle: CSSProperties = {\n ...baseStyle,\n ...(font ? { fontFamily: `'${font}', sans-serif` } : {}),\n ...(color ? { color } : {}),\n ...(align ? { textAlign: align } : {}),\n ...(truncate\n ? {\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n whiteSpace: \"nowrap\",\n }\n : {}),\n ...(maxLines && !truncate\n ? {\n display: \"-webkit-box\",\n WebkitLineClamp: maxLines,\n WebkitBoxOrient: \"vertical\" as CSSProperties[\"WebkitBoxOrient\"],\n overflow: \"hidden\",\n }\n : {}),\n margin: 0,\n padding: 0,\n ...style,\n };\n\n return (\n <Tag className={className} style={computedStyle} {...rest}>\n {children}\n </Tag>\n );\n};\n\nexport default Typography;\n"],"names":["_jsx"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AA0BA;AACO,SAAS,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE;AAC7B,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;AACf,IAAI,KAAK,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;AACvF,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AACpB,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,OAAO,MAAM,CAAC,qBAAqB,KAAK,UAAU;AACvE,QAAQ,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,qBAAqB,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AAChF,YAAY,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,SAAS,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AAC1F,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAClC,SAAS;AACT,IAAI,OAAO,CAAC,CAAC;AACb,CAAC;AAmRD;AACuB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ariant = "Display" | "H1" | "H2" | "H3" | "H4" | "H5" | "H6" | "Subheading" | "Overline" | "Body" | "Label" | "Caption";
|
|
3
|
+
export type TextAlign = "left" | "center" | "right" | "justify";
|
|
4
|
+
export interface TypographyProps extends HTMLAttributes<HTMLElement> {
|
|
5
|
+
/** Typography scale variant */
|
|
6
|
+
variant?: TypographyVariant;
|
|
7
|
+
/** Google Font name e.g. "Playfair Display", "Inter", "Roboto" */
|
|
8
|
+
font?: string;
|
|
9
|
+
/** Text color — any valid CSS color value */
|
|
10
|
+
color?: string;
|
|
11
|
+
/** Text alignment */
|
|
12
|
+
align?: TextAlign;
|
|
13
|
+
/** Override the rendered HTML tag */
|
|
14
|
+
as?: ElementType;
|
|
15
|
+
/** Truncate to single line with ellipsis */
|
|
16
|
+
truncate?: boolean;
|
|
17
|
+
/** Clamp to N lines with ellipsis */
|
|
18
|
+
maxLines?: number;
|
|
19
|
+
/** Inline style overrides */
|
|
20
|
+
style?: CSSProperties;
|
|
21
|
+
/** Additional class names */
|
|
22
|
+
className?: string;
|
|
23
|
+
}
|
|
24
|
+
export type VariantTagMap = Record<TypographyVariant, keyof JSX.IntrinsicElements>;
|
|
25
|
+
export type VariantStyleMap = Record<TypographyVariant, CSSProperties>;
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@edwinvakayil/calligraphy",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A lightweight React + TypeScript typography component with Google Fonts support. Scale from Display to Caption with a single prop.",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.esm.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "rollup -c",
|
|
13
|
+
"dev": "rollup -c --watch",
|
|
14
|
+
"type-check": "tsc --noEmit",
|
|
15
|
+
"lint": "eslint src --ext .ts,.tsx",
|
|
16
|
+
"prepublishOnly": "npm run build"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"react",
|
|
20
|
+
"typescript",
|
|
21
|
+
"typography",
|
|
22
|
+
"google-fonts",
|
|
23
|
+
"font",
|
|
24
|
+
"heading",
|
|
25
|
+
"text",
|
|
26
|
+
"ui",
|
|
27
|
+
"component"
|
|
28
|
+
],
|
|
29
|
+
"author": "",
|
|
30
|
+
"license": "MIT",
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"react": ">=17.0.0",
|
|
33
|
+
"react-dom": ">=17.0.0"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@rollup/plugin-commonjs": "^25.0.0",
|
|
37
|
+
"@rollup/plugin-node-resolve": "^15.0.0",
|
|
38
|
+
"@rollup/plugin-typescript": "^11.0.0",
|
|
39
|
+
"@types/react": "^18.0.0",
|
|
40
|
+
"@types/react-dom": "^18.0.0",
|
|
41
|
+
"rollup": "^3.0.0",
|
|
42
|
+
"rollup-plugin-dts": "^5.0.0",
|
|
43
|
+
"tslib": "^2.6.0",
|
|
44
|
+
"typescript": "^5.0.0"
|
|
45
|
+
},
|
|
46
|
+
"repository": {
|
|
47
|
+
"type": "git",
|
|
48
|
+
"url": ""
|
|
49
|
+
}
|
|
50
|
+
}
|