vite-plugin-capsize-radix 0.0.7 → 0.0.9
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 +17 -5
- package/dist/index.d.mts +6 -3
- package/dist/index.d.ts +6 -3
- package/dist/index.js +29 -21
- package/dist/index.mjs +29 -21
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -81,8 +81,20 @@ to be slightly smaller than on desktop. We do that by shifting the text a size s
|
|
|
81
81
|
|
|
82
82
|
## Parameters:
|
|
83
83
|
|
|
84
|
-
* __outputPath (string): Required__
|
|
85
|
-
*
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
84
|
+
* __outputPath (string): Required__. The file path where the generated CSS or design tokens should be saved.
|
|
85
|
+
* __textStyles (TextStyle[]): Optional__. An array of objects, each representing a text style. Each object contains two properties: `fontSize` and `lineHeight`, which are numerical values, pixels for `fontSize` and pixels or relative value for `lineHeight`. Defaults to:
|
|
86
|
+
```ts
|
|
87
|
+
[
|
|
88
|
+
{ fontSize: 9, lineHeight: 21 },
|
|
89
|
+
{ fontSize: 11, lineHeight: 24 },
|
|
90
|
+
{ fontSize: 12, lineHeight: 26 },
|
|
91
|
+
{ fontSize: 14, lineHeight: 27 },
|
|
92
|
+
{ fontSize: 18, lineHeight: 29 },
|
|
93
|
+
{ fontSize: 24, lineHeight: 36 },
|
|
94
|
+
{ fontSize: 36, lineHeight: 44 },
|
|
95
|
+
{ fontSize: 48, lineHeight: 52 },
|
|
96
|
+
{ fontSize: 64, lineHeight: 64 }
|
|
97
|
+
]
|
|
98
|
+
```
|
|
99
|
+
* __defaultFontStack (FontMetrics[]): Optional__. An array of `FontMetrics` objects. Defaults to a System Font stack.
|
|
100
|
+
* __headingFontStack (FontMetrics[]): Optional__. An array of `FontMetrics` objects. Defaults to your `defaultFontStack`.
|
package/dist/index.d.mts
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { Plugin } from 'vite';
|
|
2
2
|
import { FontMetrics } from '@capsizecss/core';
|
|
3
3
|
|
|
4
|
+
interface TextStyle {
|
|
5
|
+
fontSize: number;
|
|
6
|
+
lineHeight: number;
|
|
7
|
+
}
|
|
4
8
|
interface Options {
|
|
5
9
|
outputPath: string;
|
|
6
|
-
|
|
7
|
-
lineHeights?: number[];
|
|
10
|
+
textStyles?: TextStyle[];
|
|
8
11
|
defaultFontStack?: FontMetrics[];
|
|
9
12
|
headingFontStack?: FontMetrics[];
|
|
10
13
|
}
|
|
11
|
-
declare function capsizeRadixPlugin({ outputPath,
|
|
14
|
+
declare function capsizeRadixPlugin({ outputPath, textStyles, defaultFontStack, headingFontStack, }: Options): Plugin;
|
|
12
15
|
|
|
13
16
|
export { capsizeRadixPlugin };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { Plugin } from 'vite';
|
|
2
2
|
import { FontMetrics } from '@capsizecss/core';
|
|
3
3
|
|
|
4
|
+
interface TextStyle {
|
|
5
|
+
fontSize: number;
|
|
6
|
+
lineHeight: number;
|
|
7
|
+
}
|
|
4
8
|
interface Options {
|
|
5
9
|
outputPath: string;
|
|
6
|
-
|
|
7
|
-
lineHeights?: number[];
|
|
10
|
+
textStyles?: TextStyle[];
|
|
8
11
|
defaultFontStack?: FontMetrics[];
|
|
9
12
|
headingFontStack?: FontMetrics[];
|
|
10
13
|
}
|
|
11
|
-
declare function capsizeRadixPlugin({ outputPath,
|
|
14
|
+
declare function capsizeRadixPlugin({ outputPath, textStyles, defaultFontStack, headingFontStack, }: Options): Plugin;
|
|
12
15
|
|
|
13
16
|
export { capsizeRadixPlugin };
|
package/dist/index.js
CHANGED
|
@@ -117,9 +117,9 @@ async function generate(options) {
|
|
|
117
117
|
} else {
|
|
118
118
|
headingFontStack = defaultFontStack;
|
|
119
119
|
}
|
|
120
|
-
const mobileFontData = [options.
|
|
121
|
-
(fontSize, i) => {
|
|
122
|
-
const lineGap =
|
|
120
|
+
const mobileFontData = [options.textStyles[0], ...options.textStyles].map(
|
|
121
|
+
({ fontSize, lineHeight }, i) => {
|
|
122
|
+
const lineGap = lineHeight - fontSize;
|
|
123
123
|
const style = (0, import_core.createStyleString)(
|
|
124
124
|
`rt-r-size-${i + 1}:not(.rt-DialogContent)`,
|
|
125
125
|
{
|
|
@@ -139,8 +139,8 @@ async function generate(options) {
|
|
|
139
139
|
};
|
|
140
140
|
}
|
|
141
141
|
);
|
|
142
|
-
const fontData = options.
|
|
143
|
-
const lineGap =
|
|
142
|
+
const fontData = options.textStyles.map(({ fontSize, lineHeight }, i) => {
|
|
143
|
+
const lineGap = lineHeight - fontSize;
|
|
144
144
|
const style = (0, import_core.createStyleString)(
|
|
145
145
|
`rt-r-size-${i + 1}:not(.rt-DialogContent)`,
|
|
146
146
|
{
|
|
@@ -160,33 +160,33 @@ async function generate(options) {
|
|
|
160
160
|
};
|
|
161
161
|
});
|
|
162
162
|
const mobileTextStyles = (0, import_core.createStyleString)(`rt-Text`, {
|
|
163
|
-
capHeight: options.
|
|
164
|
-
lineGap: options.
|
|
163
|
+
capHeight: options.textStyles[1].fontSize,
|
|
164
|
+
lineGap: options.textStyles[1].lineHeight - options.textStyles[1].fontSize,
|
|
165
165
|
fontMetrics: options.defaultFontStack[0]
|
|
166
166
|
});
|
|
167
167
|
const mobileEmStyles = (0, import_core.createStyleString)(`rt-Em`, {
|
|
168
|
-
capHeight: options.
|
|
169
|
-
lineGap: options.
|
|
168
|
+
capHeight: options.textStyles[1].fontSize,
|
|
169
|
+
lineGap: options.textStyles[1].lineHeight - options.textStyles[1].fontSize,
|
|
170
170
|
fontMetrics: options.defaultFontStack[0]
|
|
171
171
|
});
|
|
172
172
|
const mobileQuoteStyles = (0, import_core.createStyleString)(`rt-Quote`, {
|
|
173
|
-
capHeight: options.
|
|
174
|
-
lineGap: options.
|
|
173
|
+
capHeight: options.textStyles[1].fontSize,
|
|
174
|
+
lineGap: options.textStyles[1].lineHeight - options.textStyles[1].fontSize,
|
|
175
175
|
fontMetrics: options.defaultFontStack[0]
|
|
176
176
|
});
|
|
177
177
|
const textStyles = (0, import_core.createStyleString)(`rt-Text`, {
|
|
178
|
-
capHeight: options.
|
|
179
|
-
lineGap: options.
|
|
178
|
+
capHeight: options.textStyles[2].fontSize,
|
|
179
|
+
lineGap: options.textStyles[2].lineHeight - options.textStyles[2].fontSize,
|
|
180
180
|
fontMetrics: options.defaultFontStack[0]
|
|
181
181
|
});
|
|
182
182
|
const emStyles = (0, import_core.createStyleString)(`rt-Em`, {
|
|
183
|
-
capHeight: options.
|
|
184
|
-
lineGap: options.
|
|
183
|
+
capHeight: options.textStyles[2].fontSize,
|
|
184
|
+
lineGap: options.textStyles[2].lineHeight - options.textStyles[2].fontSize,
|
|
185
185
|
fontMetrics: options.defaultFontStack[0]
|
|
186
186
|
});
|
|
187
187
|
const quoteStyles = (0, import_core.createStyleString)(`rt-Quote`, {
|
|
188
|
-
capHeight: options.
|
|
189
|
-
lineGap: options.
|
|
188
|
+
capHeight: options.textStyles[2].fontSize,
|
|
189
|
+
lineGap: options.textStyles[2].lineHeight - options.textStyles[2].fontSize,
|
|
190
190
|
fontMetrics: options.defaultFontStack[0]
|
|
191
191
|
});
|
|
192
192
|
import_fs.default.writeFileSync(
|
|
@@ -207,8 +207,17 @@ async function generate(options) {
|
|
|
207
207
|
}
|
|
208
208
|
function capsizeRadixPlugin({
|
|
209
209
|
outputPath,
|
|
210
|
-
|
|
211
|
-
|
|
210
|
+
textStyles = [
|
|
211
|
+
{ fontSize: 9, lineHeight: 19 },
|
|
212
|
+
{ fontSize: 11, lineHeight: 23 },
|
|
213
|
+
{ fontSize: 12, lineHeight: 25 },
|
|
214
|
+
{ fontSize: 14, lineHeight: 28 },
|
|
215
|
+
{ fontSize: 18, lineHeight: 30 },
|
|
216
|
+
{ fontSize: 24, lineHeight: 36 },
|
|
217
|
+
{ fontSize: 36, lineHeight: 44 },
|
|
218
|
+
{ fontSize: 48, lineHeight: 52 },
|
|
219
|
+
{ fontSize: 64, lineHeight: 64 }
|
|
220
|
+
],
|
|
212
221
|
defaultFontStack,
|
|
213
222
|
headingFontStack
|
|
214
223
|
}) {
|
|
@@ -217,8 +226,7 @@ function capsizeRadixPlugin({
|
|
|
217
226
|
buildStart() {
|
|
218
227
|
generate({
|
|
219
228
|
outputPath,
|
|
220
|
-
|
|
221
|
-
lineHeights,
|
|
229
|
+
textStyles,
|
|
222
230
|
defaultFontStack,
|
|
223
231
|
headingFontStack
|
|
224
232
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -87,9 +87,9 @@ async function generate(options) {
|
|
|
87
87
|
} else {
|
|
88
88
|
headingFontStack = defaultFontStack;
|
|
89
89
|
}
|
|
90
|
-
const mobileFontData = [options.
|
|
91
|
-
(fontSize, i) => {
|
|
92
|
-
const lineGap =
|
|
90
|
+
const mobileFontData = [options.textStyles[0], ...options.textStyles].map(
|
|
91
|
+
({ fontSize, lineHeight }, i) => {
|
|
92
|
+
const lineGap = lineHeight - fontSize;
|
|
93
93
|
const style = createStyleString(
|
|
94
94
|
`rt-r-size-${i + 1}:not(.rt-DialogContent)`,
|
|
95
95
|
{
|
|
@@ -109,8 +109,8 @@ async function generate(options) {
|
|
|
109
109
|
};
|
|
110
110
|
}
|
|
111
111
|
);
|
|
112
|
-
const fontData = options.
|
|
113
|
-
const lineGap =
|
|
112
|
+
const fontData = options.textStyles.map(({ fontSize, lineHeight }, i) => {
|
|
113
|
+
const lineGap = lineHeight - fontSize;
|
|
114
114
|
const style = createStyleString(
|
|
115
115
|
`rt-r-size-${i + 1}:not(.rt-DialogContent)`,
|
|
116
116
|
{
|
|
@@ -130,33 +130,33 @@ async function generate(options) {
|
|
|
130
130
|
};
|
|
131
131
|
});
|
|
132
132
|
const mobileTextStyles = createStyleString(`rt-Text`, {
|
|
133
|
-
capHeight: options.
|
|
134
|
-
lineGap: options.
|
|
133
|
+
capHeight: options.textStyles[1].fontSize,
|
|
134
|
+
lineGap: options.textStyles[1].lineHeight - options.textStyles[1].fontSize,
|
|
135
135
|
fontMetrics: options.defaultFontStack[0]
|
|
136
136
|
});
|
|
137
137
|
const mobileEmStyles = createStyleString(`rt-Em`, {
|
|
138
|
-
capHeight: options.
|
|
139
|
-
lineGap: options.
|
|
138
|
+
capHeight: options.textStyles[1].fontSize,
|
|
139
|
+
lineGap: options.textStyles[1].lineHeight - options.textStyles[1].fontSize,
|
|
140
140
|
fontMetrics: options.defaultFontStack[0]
|
|
141
141
|
});
|
|
142
142
|
const mobileQuoteStyles = createStyleString(`rt-Quote`, {
|
|
143
|
-
capHeight: options.
|
|
144
|
-
lineGap: options.
|
|
143
|
+
capHeight: options.textStyles[1].fontSize,
|
|
144
|
+
lineGap: options.textStyles[1].lineHeight - options.textStyles[1].fontSize,
|
|
145
145
|
fontMetrics: options.defaultFontStack[0]
|
|
146
146
|
});
|
|
147
147
|
const textStyles = createStyleString(`rt-Text`, {
|
|
148
|
-
capHeight: options.
|
|
149
|
-
lineGap: options.
|
|
148
|
+
capHeight: options.textStyles[2].fontSize,
|
|
149
|
+
lineGap: options.textStyles[2].lineHeight - options.textStyles[2].fontSize,
|
|
150
150
|
fontMetrics: options.defaultFontStack[0]
|
|
151
151
|
});
|
|
152
152
|
const emStyles = createStyleString(`rt-Em`, {
|
|
153
|
-
capHeight: options.
|
|
154
|
-
lineGap: options.
|
|
153
|
+
capHeight: options.textStyles[2].fontSize,
|
|
154
|
+
lineGap: options.textStyles[2].lineHeight - options.textStyles[2].fontSize,
|
|
155
155
|
fontMetrics: options.defaultFontStack[0]
|
|
156
156
|
});
|
|
157
157
|
const quoteStyles = createStyleString(`rt-Quote`, {
|
|
158
|
-
capHeight: options.
|
|
159
|
-
lineGap: options.
|
|
158
|
+
capHeight: options.textStyles[2].fontSize,
|
|
159
|
+
lineGap: options.textStyles[2].lineHeight - options.textStyles[2].fontSize,
|
|
160
160
|
fontMetrics: options.defaultFontStack[0]
|
|
161
161
|
});
|
|
162
162
|
fs.writeFileSync(
|
|
@@ -177,8 +177,17 @@ async function generate(options) {
|
|
|
177
177
|
}
|
|
178
178
|
function capsizeRadixPlugin({
|
|
179
179
|
outputPath,
|
|
180
|
-
|
|
181
|
-
|
|
180
|
+
textStyles = [
|
|
181
|
+
{ fontSize: 9, lineHeight: 19 },
|
|
182
|
+
{ fontSize: 11, lineHeight: 23 },
|
|
183
|
+
{ fontSize: 12, lineHeight: 25 },
|
|
184
|
+
{ fontSize: 14, lineHeight: 28 },
|
|
185
|
+
{ fontSize: 18, lineHeight: 30 },
|
|
186
|
+
{ fontSize: 24, lineHeight: 36 },
|
|
187
|
+
{ fontSize: 36, lineHeight: 44 },
|
|
188
|
+
{ fontSize: 48, lineHeight: 52 },
|
|
189
|
+
{ fontSize: 64, lineHeight: 64 }
|
|
190
|
+
],
|
|
182
191
|
defaultFontStack,
|
|
183
192
|
headingFontStack
|
|
184
193
|
}) {
|
|
@@ -187,8 +196,7 @@ function capsizeRadixPlugin({
|
|
|
187
196
|
buildStart() {
|
|
188
197
|
generate({
|
|
189
198
|
outputPath,
|
|
190
|
-
|
|
191
|
-
lineHeights,
|
|
199
|
+
textStyles,
|
|
192
200
|
defaultFontStack,
|
|
193
201
|
headingFontStack
|
|
194
202
|
});
|
package/package.json
CHANGED