@spark-ui/tailwind-plugins 8.1.8 → 9.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/CHANGELOG.md +4 -0
- package/index.js +0 -4
- package/package.json +3 -3
- package/animations/index.doc.mdx +0 -73
- package/index.doc.mdx +0 -12
- package/sizings/index.doc.mdx +0 -72
- package/spark-config.doc.mdx +0 -135
- package/spark-theme/index.doc.mdx +0 -97
package/CHANGELOG.md
CHANGED
@@ -3,6 +3,10 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
5
5
|
|
6
|
+
# [9.0.0](https://github.com/adevinta/spark/compare/v8.1.8...v9.0.0) (2025-02-06)
|
7
|
+
|
8
|
+
**Note:** Version bump only for package @spark-ui/tailwind-plugins
|
9
|
+
|
6
10
|
## [8.1.8](https://github.com/adevinta/spark/compare/v8.1.7...v8.1.8) (2025-01-28)
|
7
11
|
|
8
12
|
**Note:** Version bump only for package @spark-ui/tailwind-plugins
|
package/index.js
CHANGED
@@ -4,8 +4,6 @@ const sizings = require('./sizings')
|
|
4
4
|
const utilities = require('./utilities')
|
5
5
|
const variants = require('./variants')
|
6
6
|
const sparkTheme = require('./spark-theme')
|
7
|
-
const tailwindConfigViewerUtils = require('./tailwind-config-viewer')
|
8
|
-
const tailwindConfigViewerMisc = require('./tailwind-config-viewer/misc')
|
9
7
|
const tailwindcssRadix = require('tailwindcss-radix')
|
10
8
|
|
11
9
|
/**
|
@@ -38,6 +36,4 @@ module.exports = {
|
|
38
36
|
variants,
|
39
37
|
sparkTheme,
|
40
38
|
sparkConfig,
|
41
|
-
tailwindConfigViewerUtils,
|
42
|
-
tailwindConfigViewerMisc,
|
43
39
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@spark-ui/tailwind-plugins",
|
3
|
-
"version": "
|
3
|
+
"version": "9.0.0",
|
4
4
|
"description": "Spark Tailwind plugins",
|
5
5
|
"publishConfig": {
|
6
6
|
"access": "public"
|
@@ -15,7 +15,7 @@
|
|
15
15
|
],
|
16
16
|
"main": "index.js",
|
17
17
|
"dependencies": {
|
18
|
-
"@spark-ui/theme-utils": "^
|
18
|
+
"@spark-ui/theme-utils": "^9.0.0",
|
19
19
|
"tailwindcss-radix": "2.9.0"
|
20
20
|
},
|
21
21
|
"peerDependencies": {
|
@@ -35,5 +35,5 @@
|
|
35
35
|
},
|
36
36
|
"homepage": "https://sparkui.vercel.app",
|
37
37
|
"license": "MIT",
|
38
|
-
"gitHead": "
|
38
|
+
"gitHead": "8fe6ef5b52e2440947f6278e00d00c89410a9ca8"
|
39
39
|
}
|
package/animations/index.doc.mdx
DELETED
@@ -1,73 +0,0 @@
|
|
1
|
-
import { Meta } from '@storybook/blocks'
|
2
|
-
import { Callout } from '@docs/helpers/Callout'
|
3
|
-
|
4
|
-
<Meta title="utils/Tailwind plugins/animations" />
|
5
|
-
|
6
|
-
# Tailwind animation plugin
|
7
|
-
|
8
|
-
## Installation
|
9
|
-
|
10
|
-
To use our Tailwind animation plugin, simply install the `@spark-ui/tailwind-plugins` package and add the animation plugin to your `tailwind.config.js` file
|
11
|
-
|
12
|
-
```bash
|
13
|
-
$ npm i @spark-ui/tailwind-plugins
|
14
|
-
```
|
15
|
-
|
16
|
-
```js
|
17
|
-
// tailwind.config.js
|
18
|
-
|
19
|
-
const sparkPlugins = require('@spark-ui/tailwind-plugins')
|
20
|
-
|
21
|
-
module.exports = {
|
22
|
-
...,
|
23
|
-
plugins: [sparkPlugins.animations()],
|
24
|
-
}
|
25
|
-
|
26
|
-
```
|
27
|
-
|
28
|
-
## Usage
|
29
|
-
|
30
|
-
This plugin provides the following **animation-related** declaration properties that are missing by default in **Tailwind**:
|
31
|
-
|
32
|
-
- **animation-fill-mode**: `spark-anime-fill-{value}` (where `value` can be `forwards`, `backwards`, or `none`)
|
33
|
-
- **animation-duration**: `spark-anime-duration-{value}` (where `value` can be any keys of `theme.transitionDuration` or an arbitrary value like `spark-anime-duration-[458ms]`)
|
34
|
-
- **animation-delay**: `spark-anime-delay-{value}` (where `value` can be any keys of `theme.transitionDuration` or an arbitrary value like `spark-anime-delay-[458ms]`)
|
35
|
-
- **animation-direction**: `spark-anime-direction-{value}` (where `value` can be `normal`, `reverse`, `alternate`, `alternate-reverse`, `revert`, or `revert-layer`)
|
36
|
-
- **animation-iteration-count**: `spark-anime-iteration-{value}` (where `value` can be `1`, `2`, `3`, `infinite`, or an arbitrary value like `spark-anime-iteration-[12]`)
|
37
|
-
- **animation-play-running**: `spark-anime-play-{value}` (where `value` can be `running`, or `paused`)
|
38
|
-
- **animation-timing-function**: `spark-anime-easing-{value}` (where `value` can be, `linear`, `in`, `out`, `in-out`, `in-back`, `out-back`, `in-out-back` or an arbitrary value like `spark-anime-easing-[cubic-bezier(0.95,0.05,0.795,0.035)]`)
|
39
|
-
|
40
|
-
### @keyframes
|
41
|
-
|
42
|
-
This plugin also includes four animation keyframes:
|
43
|
-
|
44
|
-
- **animate-slide-top**: `animate-slide-top`
|
45
|
-
- **animate-slide-right**: `animate-slide-right`
|
46
|
-
- **animate-slide-bottom**: `animate-slide-bottom`
|
47
|
-
- **animate-slide-left**: `animate-slide-left`
|
48
|
-
|
49
|
-
## Configuration
|
50
|
-
|
51
|
-
<Callout kind="warning">
|
52
|
-
If you change the prefix, you may encounter issues when using Spark components since we use the
|
53
|
-
default prefix "spark-anime" in our codebase. Changing the prefix would mean that our class names
|
54
|
-
might not be generated in your application. Keep this in mind while making changes.
|
55
|
-
</Callout>
|
56
|
-
|
57
|
-
You can customize the **CSS class prefix** using the `prefixVariant` option.
|
58
|
-
|
59
|
-
By default, the prefix will be `spark-anime` (e.g. `spark-anime-fill-forwards`), but you can change it like so:
|
60
|
-
|
61
|
-
```js
|
62
|
-
// tailwind.config.js
|
63
|
-
|
64
|
-
const sparkPlugins = require('@spark-ui/tailwind-plugins')
|
65
|
-
|
66
|
-
module.exports = {
|
67
|
-
...,
|
68
|
-
plugins: [sparkPlugins.animations({ prefixVariant: 'bar' })],
|
69
|
-
}
|
70
|
-
|
71
|
-
```
|
72
|
-
|
73
|
-
This will change the prefix to `bar` (e.g. `bar-fill-forwards`).
|
package/index.doc.mdx
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
import { Meta } from '@storybook/blocks'
|
2
|
-
|
3
|
-
<Meta title="utils/Tailwind plugins/Index" />
|
4
|
-
|
5
|
-
# Tailwind plugins
|
6
|
-
|
7
|
-
Below there is a list of our Tailwind plugins:
|
8
|
-
|
9
|
-
- [spark config](?path=/docs/utils-tailwind-plugins-spark-config--docs)
|
10
|
-
- [spark theme](?path=/docs/utils-tailwind-plugins-spark-theme--docs)
|
11
|
-
- [animations](?path=/docs/utils-tailwind-plugins-animations--docs)
|
12
|
-
- [sizings](?path=/docs/utils-tailwind-plugins-sizings--docs)
|
package/sizings/index.doc.mdx
DELETED
@@ -1,72 +0,0 @@
|
|
1
|
-
import { Meta } from '@storybook/blocks'
|
2
|
-
|
3
|
-
<Meta title="utils/Tailwind plugins/sizings" />
|
4
|
-
|
5
|
-
# Tailwind sizing plugin
|
6
|
-
|
7
|
-
## Installation
|
8
|
-
|
9
|
-
To use our Tailwind sizing plugin, simply install the `@spark-ui/tailwind-plugins` package and add the animation plugin to your `tailwind.config.js` file
|
10
|
-
|
11
|
-
```bash
|
12
|
-
$ npm i @spark-ui/tailwind-plugins
|
13
|
-
```
|
14
|
-
|
15
|
-
```js
|
16
|
-
// tailwind.config.js
|
17
|
-
|
18
|
-
const sparkPlugins = require('@spark-ui/tailwind-plugins')
|
19
|
-
|
20
|
-
module.exports = {
|
21
|
-
...,
|
22
|
-
plugins: [sparkPlugins.sizings({ htmlFontSize: 16 // The base font size for your application (default: 16)
|
23
|
-
})],
|
24
|
-
}
|
25
|
-
|
26
|
-
```
|
27
|
-
|
28
|
-
## Usage
|
29
|
-
|
30
|
-
This plugin predefines a sizing range with the following pixel values:
|
31
|
-
|
32
|
-
```ts
|
33
|
-
const sizingRange = [
|
34
|
-
0, 1, 2, 4, 6, 8, 10, 12, 14, 16, 20, 24, 28, 32, 36, 40, 44, 48, 56, 64, 80, 96, 112, 128, 144,
|
35
|
-
160, 176, 192, 208, 224, 240, 256, 288, 320, 384, 400, 416, 432, 448, 464, 480, 512, 544, 576,
|
36
|
-
608, 640, 672, 704, 736, 768, 800, 832, 864,
|
37
|
-
]
|
38
|
-
```
|
39
|
-
|
40
|
-
These values are converted into rem units based on the specified **HTML font size** (see [configuration](#configuration)).
|
41
|
-
|
42
|
-
The plugin generates CSS variables for each size value, which can then be used for `width`, `height`, `max-width`, `max-height`, and `translate` properties.
|
43
|
-
|
44
|
-
## Example
|
45
|
-
|
46
|
-
To set the `width` of an element using the sizing plugin, use the `w-sz-{size}` class, where`{size}` is the desired pixel value from the predefined range:
|
47
|
-
|
48
|
-
```tsx
|
49
|
-
<div className="w-sz-10">...</div>
|
50
|
-
```
|
51
|
-
|
52
|
-
This will set the width of the element to **10px** (0.625rem, if `htmlFontSize` is 16) using the custom sizing scale provided by the plugin.
|
53
|
-
|
54
|
-
## Configuration
|
55
|
-
|
56
|
-
You can customize the **base html font size** using the `htmlFontSize` option.
|
57
|
-
|
58
|
-
By default, the base will be `16`, but you can change it like so:
|
59
|
-
|
60
|
-
```js
|
61
|
-
// tailwind.config.js
|
62
|
-
|
63
|
-
const sparkPlugins = require('@spark-ui/tailwind-plugins')
|
64
|
-
|
65
|
-
module.exports = {
|
66
|
-
...,
|
67
|
-
plugins: [sparkPlugins.sizings({ htmlFontSize: 10 })],
|
68
|
-
}
|
69
|
-
|
70
|
-
```
|
71
|
-
|
72
|
-
This will ensure that the `rem`-based values are accurately calculated according to your application's HTML font size.
|
package/spark-config.doc.mdx
DELETED
@@ -1,135 +0,0 @@
|
|
1
|
-
import { Meta } from '@storybook/blocks'
|
2
|
-
import { Callout } from '@docs/helpers/Callout'
|
3
|
-
|
4
|
-
<Meta title="utils/Tailwind plugins/spark config" />
|
5
|
-
|
6
|
-
# Tailwind spark config plugin
|
7
|
-
|
8
|
-
## Installation
|
9
|
-
|
10
|
-
To use our Tailwind spark theme plugin, simply install the `@spark-ui/tailwind-plugins` package and add the spark theme plugin to your `tailwind.config.js` file
|
11
|
-
|
12
|
-
```bash
|
13
|
-
$ npm i @spark-ui/tailwind-plugins
|
14
|
-
```
|
15
|
-
|
16
|
-
```js
|
17
|
-
// tailwind.config.js
|
18
|
-
|
19
|
-
const sparkPlugins = require('@spark-ui/tailwind-plugins')
|
20
|
-
|
21
|
-
module.exports = {
|
22
|
-
...,
|
23
|
-
plugins: [
|
24
|
-
...sparkPlugins.sparkConfig({
|
25
|
-
htmlFontSize: 16 // The base font size for your application (default: 16),
|
26
|
-
themes: {
|
27
|
-
default: yourDefaultTheme,
|
28
|
-
dark: yourDarkTheme,
|
29
|
-
foo: someOtherTheme,
|
30
|
-
...rest
|
31
|
-
} //
|
32
|
-
})],
|
33
|
-
}
|
34
|
-
|
35
|
-
```
|
36
|
-
|
37
|
-
## Usage
|
38
|
-
|
39
|
-
The plugin streamlines the setup process by wrapping the call to all our other plugins (plus some external ones) with the appropriate options applied.
|
40
|
-
|
41
|
-
This approach eliminates the need for manually calling each of our plugins. Here's a comparison:
|
42
|
-
|
43
|
-
**without the plugin:**
|
44
|
-
|
45
|
-
```js
|
46
|
-
const sparkPlugins = require('@spark-ui/tailwind-plugins')
|
47
|
-
|
48
|
-
/** @type {import('tailwindcss').Config} */
|
49
|
-
module.exports = {
|
50
|
-
content: ['./packages/**/*.{js,ts,jsx,tsx}', './documentation/**/*.{js,ts,jsx,tsx,mdx}'],
|
51
|
-
plugins: [
|
52
|
-
sparkPlugins.sparkTheme({
|
53
|
-
htmlFontSize: 10,
|
54
|
-
themes: {
|
55
|
-
default: themeUtils.defaultTheme,
|
56
|
-
dark: themeUtils.defaultThemeDark,
|
57
|
-
},
|
58
|
-
}),
|
59
|
-
sparkPlugins.sizings({ htmlFontSize: 10 }),
|
60
|
-
sparkPlugins.animations(),
|
61
|
-
...
|
62
|
-
],
|
63
|
-
}
|
64
|
-
```
|
65
|
-
|
66
|
-
**with the plugin:**
|
67
|
-
|
68
|
-
```js
|
69
|
-
const sparkPlugins = require('@spark-ui/tailwind-plugins')
|
70
|
-
|
71
|
-
/** @type {import('tailwindcss').Config} */
|
72
|
-
module.exports = {
|
73
|
-
content: ['./packages/**/*.{js,ts,jsx,tsx}', './documentation/**/*.{js,ts,jsx,tsx,mdx}'],
|
74
|
-
plugins: [
|
75
|
-
...sparkPlugins.sparkConfig({
|
76
|
-
htmlFontSize: 10,
|
77
|
-
themes: {
|
78
|
-
default: themeUtils.defaultTheme,
|
79
|
-
dark: themeUtils.defaultThemeDark,
|
80
|
-
},
|
81
|
-
}),
|
82
|
-
],
|
83
|
-
}
|
84
|
-
```
|
85
|
-
|
86
|
-
For more details about our other plugins, please refer to the [**Tailwind plugins documentation**](?path=/docs/utils-tailwind-plugins--docs).
|
87
|
-
|
88
|
-
## Configuration
|
89
|
-
|
90
|
-
This plugin can be customized by providing a configuration object with two fields, `themes` and `htmlFontSize`.
|
91
|
-
|
92
|
-
**themes**:
|
93
|
-
|
94
|
-
An object containing your themes. Each key in the object will be extracted to a `[data-theme]` attribute, and the values will be converted to CSS custom properties inside the `css` file generated by Tailwing. **Note that this object requires a key with a value of default**, which specifies the default theme for your project.
|
95
|
-
|
96
|
-
For example, if your `themes` object looks like this:
|
97
|
-
|
98
|
-
```js
|
99
|
-
|
100
|
-
sparkPlugins.sparkConfig({
|
101
|
-
themes: {
|
102
|
-
default: yourDefaultTheme,
|
103
|
-
alternative: someAlternativeTheme,
|
104
|
-
},
|
105
|
-
}),
|
106
|
-
```
|
107
|
-
|
108
|
-
Tailwind will generate the following CSS:
|
109
|
-
|
110
|
-
```css
|
111
|
-
:root {
|
112
|
-
/* ...tokens from yourDefaultTheme */
|
113
|
-
}
|
114
|
-
|
115
|
-
[data-theme='alternative'] {
|
116
|
-
/* ...tokens from someAlternativeTheme */
|
117
|
-
}
|
118
|
-
```
|
119
|
-
|
120
|
-
You can populate the `themes` object with as many themes as desired, with the only requirement being that they conform to our `Theme` interface. The Theme interface can be accessed through the [**@spark-ui/theme-utils**](?path=/docs/utils-theme--docs#theme) package.
|
121
|
-
|
122
|
-
**htmlFontSize (optional)**:
|
123
|
-
|
124
|
-
Spark uses a base font size of **16 pixels** as a standard value for calculating the sizes of all other font-related properties defined in the theme. For example, our `spacing.lg` value is defined as **1rem**, which is equal to 16 pixels (based on the default base font size of 16 pixels).
|
125
|
-
|
126
|
-
However, if your application uses a different base font size, such as **10 pixels** for example, this can cause issues with the sizing of elements in the application. To account for this, you can set the `htmlFontSize` to the appropriate value for your application's base font size. This will adjust the `rem` based values in Spark to be relative to the new base font size.
|
127
|
-
|
128
|
-
This will ensure that the `rem`-based values are accurately calculated according to your application's HTML font size.
|
129
|
-
|
130
|
-
<Callout>
|
131
|
-
To better understand what happens when you adjust `htmlFontSize`, it's useful to know that we use CSS custom properties to define the values of our design tokens, such as `spacing.lg`.
|
132
|
-
|
133
|
-
By default, the value for this token is expressed as `--spacing-lg: 1rem;`. However, when you define a `htmlFontSize` of 10, for example, this value will be updated to `--spacing-lg: 1.6rem;`
|
134
|
-
|
135
|
-
</Callout>
|
@@ -1,97 +0,0 @@
|
|
1
|
-
import { Meta } from '@storybook/blocks'
|
2
|
-
import { Callout } from '@docs/helpers/Callout'
|
3
|
-
|
4
|
-
<Meta title="utils/Tailwind plugins/spark theme" />
|
5
|
-
|
6
|
-
# Tailwind spark theme plugin
|
7
|
-
|
8
|
-
## Installation
|
9
|
-
|
10
|
-
To use our Tailwind spark theme plugin, simply install the `@spark-ui/tailwind-plugins` package and add the spark theme plugin to your `tailwind.config.js` file
|
11
|
-
|
12
|
-
```bash
|
13
|
-
$ npm i @spark-ui/tailwind-plugins
|
14
|
-
```
|
15
|
-
|
16
|
-
```js
|
17
|
-
// tailwind.config.js
|
18
|
-
|
19
|
-
const sparkPlugins = require('@spark-ui/tailwind-plugins')
|
20
|
-
|
21
|
-
module.exports = {
|
22
|
-
...,
|
23
|
-
plugins: [sparkPlugins.sparkTheme({
|
24
|
-
htmlFontSize: 16 // The base font size for your application (default: 16),
|
25
|
-
themes: {
|
26
|
-
default: yourDefaultTheme,
|
27
|
-
dark: yourDarkTheme,
|
28
|
-
foo: someOtherTheme,
|
29
|
-
...rest
|
30
|
-
} //
|
31
|
-
})],
|
32
|
-
}
|
33
|
-
|
34
|
-
```
|
35
|
-
|
36
|
-
## Usage
|
37
|
-
|
38
|
-
The plugin performs two main tasks:
|
39
|
-
|
40
|
-
- first, it converts every value within the objects inside the themes object into **CSS variables**, which is helpful for managing **multiple themes**.
|
41
|
-
|
42
|
-
- Second, it provides Tailwind with an internal mapping to retrieve these CSS variables This is necessary because, by default, Tailwind does not use CSS variables, but rather direct values.
|
43
|
-
|
44
|
-
Once the plugin is configured, all Spark custom classes become available for use.
|
45
|
-
|
46
|
-
```tsx
|
47
|
-
<div className="text-on-main... bg-main">...</div>
|
48
|
-
```
|
49
|
-
|
50
|
-
## Configuration
|
51
|
-
|
52
|
-
This plugin can be customized by providing a configuration object with two fields, `themes` and `htmlFontSize`.
|
53
|
-
|
54
|
-
**themes**:
|
55
|
-
|
56
|
-
An object containing your themes. Each key in the object will be extracted to a `[data-theme]` attribute, and the values will be converted to CSS custom properties inside the `css` file generated by Tailwing. **Note that this object requires a key with a value of default**, which specifies the default theme for your project.
|
57
|
-
|
58
|
-
For example, if your `themes` object looks like this:
|
59
|
-
|
60
|
-
```js
|
61
|
-
|
62
|
-
sparkPlugins.sparkTheme({
|
63
|
-
themes: {
|
64
|
-
default: yourDefaultTheme,
|
65
|
-
alternative: someAlternativeTheme,
|
66
|
-
},
|
67
|
-
}),
|
68
|
-
```
|
69
|
-
|
70
|
-
Tailwind will generate the following CSS:
|
71
|
-
|
72
|
-
```css
|
73
|
-
:root {
|
74
|
-
/* ...tokens from yourDefaultTheme */
|
75
|
-
}
|
76
|
-
|
77
|
-
[data-theme='alternative'] {
|
78
|
-
/* ...tokens from someAlternativeTheme */
|
79
|
-
}
|
80
|
-
```
|
81
|
-
|
82
|
-
You can populate the `themes` object with as many themes as desired, with the only requirement being that they conform to our `Theme` interface. The Theme interface can be accessed through the [**@spark-ui/theme-utils**](?path=/docs/utils-theme--docs#theme) package.
|
83
|
-
|
84
|
-
**htmlFontSize (optional)**:
|
85
|
-
|
86
|
-
Spark uses a base font size of **16 pixels** as a standard value for calculating the sizes of all other font-related properties defined in the theme. For example, our `spacing.lg` value is defined as **1rem**, which is equal to 16 pixels (based on the default base font size of 16 pixels).
|
87
|
-
|
88
|
-
However, if your application uses a different base font size, such as **10 pixels** for example, this can cause issues with the sizing of elements in the application. To account for this, you can set the `htmlFontSize` to the appropriate value for your application's base font size. This will adjust the `rem` based values in Spark to be relative to the new base font size.
|
89
|
-
|
90
|
-
This will ensure that the `rem`-based values are accurately calculated according to your application's HTML font size.
|
91
|
-
|
92
|
-
<Callout>
|
93
|
-
To better understand what happens when you adjust `htmlFontSize`, it's useful to know that we use CSS custom properties to define the values of our design tokens, such as `spacing.lg`.
|
94
|
-
|
95
|
-
By default, the value for this token is expressed as `--spacing-lg: 1rem;`. However, when you define a `htmlFontSize` of 10, for example, this value will be updated to `--spacing-lg: 1.6rem;`
|
96
|
-
|
97
|
-
</Callout>
|