@spark-ui/tailwind-plugins 2.7.1 → 2.9.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 CHANGED
@@ -3,6 +3,18 @@
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
+ # [2.9.0](https://github.com/adevinta/spark/compare/@spark-ui/tailwind-plugins@2.8.0...@spark-ui/tailwind-plugins@2.9.0) (2023-04-24)
7
+
8
+ ### Features
9
+
10
+ - **tailwind-plugins:** update transition theme values to match figma ([92f37c2](https://github.com/adevinta/spark/commit/92f37c23e89d5b491a8feef9cf8764c0dc4c1b66)), closes [#642](https://github.com/adevinta/spark/issues/642)
11
+
12
+ # [2.8.0](https://github.com/adevinta/spark/compare/@spark-ui/tailwind-plugins@2.7.1...@spark-ui/tailwind-plugins@2.8.0) (2023-04-21)
13
+
14
+ ### Features
15
+
16
+ - **tailwind-plugins:** update default prefix in tw animation plugin ([2c147cb](https://github.com/adevinta/spark/commit/2c147cb0342ea801d22f1a69c9cea4ffac74b46f))
17
+
6
18
  ## [2.7.1](https://github.com/adevinta/spark/compare/@spark-ui/tailwind-plugins@2.7.0...@spark-ui/tailwind-plugins@2.7.1) (2023-04-19)
7
19
 
8
20
  **Note:** Version bump only for package @spark-ui/tailwind-plugins
@@ -1,4 +1,5 @@
1
1
  import { Meta } from '@storybook/blocks'
2
+ import { Callout } from '@docs/helpers/Callout'
2
3
 
3
4
  <Meta title="utils/Tailwind plugins/animations" />
4
5
 
@@ -28,13 +29,13 @@ module.exports = {
28
29
 
29
30
  This plugin provides the following **animation-related** declaration properties that are missing by default in **Tailwind**:
30
31
 
31
- - **animation-fill-mode**: `sp-anime-fill-{value}` (where `value` can be `forwards`, `backwards`, or `none`)
32
- - **animation-duration**: `sp-anime-duration-{value}` (where `value` can be any keys of `theme.transitionDuration` or an arbitrary value like `sp-anime-duration-[458ms]`)
33
- - **animation-delay**: `sp-anime-delay-{value}` (where `value` can be any keys of `theme.transitionDuration` or an arbitrary value like `sp-anime-delay-[458ms]`)
34
- - **animation-direction**: `sp-anime-direction-{value}` (where `value` can be `normal`, `reverse`, `alternate`, `alternate-reverse`, `revert`, or `revert-layer`)
35
- - **animation-iteration-count**: `sp-anime-iteration-{value}` (where `value` can be `1`, `2`, `3`, `infinite`, or an arbitrary value like `sp-iteration-[12]`)
36
- - **animation-play-running**: `sp-anime-play-{value}` (where `value` can be `running`, or `paused`)
37
- - **animation-timing-function**: `sp-anime-easing-{value}` (where `value` can be, `linear`, `in`, `out`, `in-out`, `in-back`, `out-back`, `in-out-back` or an arbitrary value like `sp-anime-easing-[cubic-bezier(0.95,0.05,0.795,0.035)]`)
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)]`)
38
39
 
39
40
  ### @keyframes
40
41
 
@@ -47,9 +48,15 @@ This plugin also includes four animation keyframes:
47
48
 
48
49
  ## Configuration
49
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
+
50
57
  You can customize the **CSS class prefix** using the `prefixVariant` option.
51
58
 
52
- By default, the prefix will be `anime-sp` (e.g. `sp-anime-fill-forwards`), but you can change it like so:
59
+ By default, the prefix will be `spark-anime` (e.g. `spark-anime-fill-forwards`), but you can change it like so:
53
60
 
54
61
  ```js
55
62
  // tailwind.config.js
@@ -16,19 +16,13 @@ const fillModes = ['none', 'forwards', 'backwards', 'both']
16
16
  const directions = ['normal', 'reverse', 'alternate', 'alternate-reverse']
17
17
  const playStates = ['running', 'paused']
18
18
 
19
- const easingLookup = {
20
- 'in-back': 'cubic-bezier(0.36, 0, 0.66, -0.56)',
21
- 'out-back': 'cubic-bezier(0.34, 1.56, 0.64, 1)',
22
- 'in-out-back': 'cubic-bezier(0.68, -0.6, 0.32, 1.6)',
23
- }
19
+ const commonValuesObj = arrToObj(commonValues)
24
20
 
25
- const durationLookup = {
26
- 1500: '1.5s',
27
- 2000: '2s',
28
- 3000: '3s',
29
- }
21
+ function removeKeyFromObj(obj, key) {
22
+ const { [key]: _, ...rest } = obj
30
23
 
31
- const commonValuesObj = arrToObj(commonValues)
24
+ return rest
25
+ }
32
26
 
33
27
  module.exports = plugin.withOptions(
34
28
  /**
@@ -38,14 +32,14 @@ module.exports = plugin.withOptions(
38
32
 
39
33
  /**
40
34
  * @param {Object} options The options for the plugin.
41
- * @param {string} [options.variantPrefix="sp-anime"] The prefix to use for the animation variants.
35
+ * @param {string} [options.variantPrefix="spark-anime"] The prefix to use for the animation variants.
42
36
  * @returns {Function} The PostCSS plugin function.
43
37
  */
44
38
  options =>
45
39
  ({ addUtilities, addVariant, matchUtilities, theme }) => {
46
40
  const opts = options || {}
47
41
 
48
- const { variantPrefix = 'sp-anime' } = opts
42
+ const { variantPrefix = 'spark-anime' } = opts
49
43
 
50
44
  matchUtilities(
51
45
  {
@@ -53,7 +47,12 @@ module.exports = plugin.withOptions(
53
47
  animationDuration: value,
54
48
  }),
55
49
  },
56
- { values: { ...theme('transitionDuration'), ...durationLookup, ...commonValuesObj } }
50
+ {
51
+ values: {
52
+ ...removeKeyFromObj(theme('transitionDuration'), 'DEFAULT'),
53
+ ...commonValuesObj,
54
+ },
55
+ }
57
56
  )
58
57
 
59
58
  matchUtilities(
@@ -62,7 +61,12 @@ module.exports = plugin.withOptions(
62
61
  animationDelay: value,
63
62
  }),
64
63
  },
65
- { values: { ...theme('transitionDuration'), ...durationLookup, ...commonValuesObj } }
64
+ {
65
+ values: {
66
+ ...removeKeyFromObj(theme('transitionDuration'), 'DEFAULT'),
67
+ ...commonValuesObj,
68
+ },
69
+ }
66
70
  )
67
71
 
68
72
  matchUtilities(
@@ -80,7 +84,12 @@ module.exports = plugin.withOptions(
80
84
  animationTimingFunction: value,
81
85
  }),
82
86
  },
83
- { values: { ...theme('transitionTimingFunction'), ...easingLookup, ...commonValuesObj } }
87
+ {
88
+ values: {
89
+ ...removeKeyFromObj(theme('transitionTimingFunction'), 'DEFAULT'),
90
+ ...commonValuesObj,
91
+ },
92
+ }
84
93
  )
85
94
 
86
95
  fillModes.forEach(mode => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spark-ui/tailwind-plugins",
3
- "version": "2.7.1",
3
+ "version": "2.9.0",
4
4
  "description": "Spark Tailwind plugins",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -18,5 +18,5 @@
18
18
  "url": "git@github.com:adevinta/spark.git",
19
19
  "directory": "packages/utils/tailwind-plugins"
20
20
  },
21
- "gitHead": "6ac8a30fcc1b265923a881263c6de954202a8d24"
21
+ "gitHead": "59d89564ec85b0af42fa8619f5d3025c4994dac4"
22
22
  }
@@ -10,6 +10,30 @@ const unassignedColors = {
10
10
  transparent: 'transparent',
11
11
  }
12
12
 
13
+ const transitionDurationLookup = {
14
+ 0: '0ms',
15
+ 50: '50ms',
16
+ 100: '100ms',
17
+ 200: '200ms',
18
+ 300: '300ms',
19
+ 400: '400ms',
20
+ 500: '500ms',
21
+ 600: '600ms',
22
+ 800: '800ms',
23
+ }
24
+
25
+ const transitionTimingFunctionLookup = {
26
+ 'in-back': 'cubic-bezier(0.3, -0.05, 0.7, -0.5)',
27
+ 'out-back': 'cubic-bezier(0.45, 1.45, 0.8, 1)',
28
+ 'in-out-back': 'cubic-bezier(0.42, 0, 0.58, 1)',
29
+ }
30
+
13
31
  const DEFAULT_KEY = 'DEFAULT'
14
32
 
15
- module.exports = { tailwindCategoryKeys, unassignedColors, DEFAULT_KEY }
33
+ module.exports = {
34
+ tailwindCategoryKeys,
35
+ unassignedColors,
36
+ transitionDurationLookup,
37
+ transitionTimingFunctionLookup,
38
+ DEFAULT_KEY,
39
+ }
@@ -1,5 +1,11 @@
1
1
  /* eslint-disable @typescript-eslint/no-var-requires */
2
- const { DEFAULT_KEY, tailwindCategoryKeys, unassignedColors } = require('./constants')
2
+ const {
3
+ DEFAULT_KEY,
4
+ tailwindCategoryKeys,
5
+ transitionDurationLookup,
6
+ transitionTimingFunctionLookup,
7
+ unassignedColors,
8
+ } = require('./constants')
3
9
  const {
4
10
  doubleHyphensRegex,
5
11
  hasNumber,
@@ -105,7 +111,14 @@ function getCSSVariableReferences(_theme) {
105
111
 
106
112
  traverse(themeCpy)
107
113
 
108
- return { ...themeCpy, colors: { ...themeCpy.colors, ...unassignedColors } }
114
+ return {
115
+ ...themeCpy,
116
+ colors: { ...themeCpy.colors, ...unassignedColors },
117
+ transitionDuration: transitionDurationLookup,
118
+ extend: {
119
+ transitionTimingFunction: transitionTimingFunctionLookup,
120
+ },
121
+ }
109
122
  }
110
123
 
111
124
  module.exports = { getCSSVariableReferences }