Skip to content

Commit cb51563

Browse files
committed
Feature: it's now also possible to set values as string
1 parent 0dbaa7c commit cb51563

File tree

3 files changed

+36
-3
lines changed

3 files changed

+36
-3
lines changed

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,34 @@ module.exports = {
264264
}
265265
```
266266

267+
### Set a value as string
268+
```js
269+
// tailwind.config.js
270+
module.exports = {
271+
theme: {
272+
extend: {
273+
fluidType: {
274+
values: {
275+
// ...
276+
'2xs': '11px',
277+
// ...
278+
}
279+
}
280+
}
281+
}
282+
};
283+
```
284+
285+
```html
286+
<p class="text-2xs">The quick brown fox jumps over the lazy dogs</p>
287+
```
288+
289+
```css
290+
.text-2xs {
291+
font-size: 11px;
292+
}
293+
```
294+
267295
### Set a prefix
268296

269297
```js

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "tailwindcss-fluid-type",
3-
"version": "1.3.0",
3+
"version": "1.3.1",
44
"description": "Bring fluid type to tailwindcss",
55
"main": "src/index.js",
66
"license": "MIT",

src/index.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,14 @@ module.exports = plugin(
6565
Object.entries(values).map(([key, value]) => {
6666
let output = {};
6767

68-
// Check if value a number
68+
// Check if value is a string
69+
if (typeof value === 'string') {
70+
output.fontSize = value
71+
}
72+
73+
// Check if value is a number
6974
if (Number.isInteger(value)) {
70-
output.fontSize = Number.isInteger(value) ? calcModularScale(value) : value
75+
output.fontSize = calcModularScale(value)
7176
}
7277

7378
// Check if value is array with length 1

0 commit comments

Comments
 (0)