diff --git a/README.md b/README.md index 84e8946..e86265f 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ A `mask-image` plugin for [Tailwind CSS](https://tailwindcss.com). -[](https://play.tailwindcss.com/5nqePqTxTt) +[](https://play.tailwindcss.com/LF91xWKHl7) --- @@ -73,6 +73,17 @@ The `opacity` values are taken from your theme specified in the `tailwind.config > **Note** > You don't have to specify **all** the stops, because the default values (100% for the start and 0% for the end point) still work. +##### Stops positions + +In addition to setting the opacity of the stops, you can also set the **position** using `mask-point`. + +```html +
+ +``` +![stops' points example](examples/mask-linear-stops-points.png) + +This utility don't accept any default value, so use arbitrary values. ### `radial` @@ -129,11 +140,12 @@ You can also use arbitrary values: #### Stops > **Note** -> The opacity stops are the same as [the ones described for `mask-linear`](#opacity-stops). +> The opacity stops for `mask-radial` are the same as [the ones described for `mask-linear`](#opacity-stops), including [points API](#stops-positions). ```html + ``` ![mask-radial stops' example](examples/mask-radial-stops.png) diff --git a/examples/arbitary-conic-gradient.png b/examples/arbitrary-conic-gradient.png similarity index 100% rename from examples/arbitary-conic-gradient.png rename to examples/arbitrary-conic-gradient.png diff --git a/examples/arbitary-image.png b/examples/arbitrary-image.png similarity index 100% rename from examples/arbitary-image.png rename to examples/arbitrary-image.png diff --git a/examples/mask-linear-stops-points.png b/examples/mask-linear-stops-points.png new file mode 100644 index 0000000..1f587a1 Binary files /dev/null and b/examples/mask-linear-stops-points.png differ diff --git a/examples/mask-radial-stops.png b/examples/mask-radial-stops.png index 01d0c93..31cef34 100644 Binary files a/examples/mask-radial-stops.png and b/examples/mask-radial-stops.png differ diff --git a/examples/mask-size-arbitary.png b/examples/mask-size-arbitrary.png similarity index 100% rename from examples/mask-size-arbitary.png rename to examples/mask-size-arbitrary.png diff --git a/index.js b/index.js index 1c5aa75..f4d672f 100644 --- a/index.js +++ b/index.js @@ -22,9 +22,11 @@ module.exports = plugin(({ theme, addUtilities, matchUtilities }) => { // stops '--tw-mask-from-opacity': '1', - '--tw-mask-from': 'rgba(0,0,0,var(--tw-mask-from-opacity))', + '--tw-mask-point-from': '', + '--tw-mask-from': 'rgba(0,0,0,var(--tw-mask-from-opacity)) var(--tw-mask-point-from)', '--tw-mask-to-opacity': '0', - '--tw-mask-to': 'rgba(0,0,0,var(--tw-mask-to-opacity))', + '--tw-mask-point-to': '', + '--tw-mask-to': 'rgba(0,0,0,var(--tw-mask-to-opacity)) var(--tw-mask-point-to)', '--tw-mask-stops': 'var(--tw-mask-from), var(--tw-mask-to)', }), }, @@ -124,7 +126,7 @@ module.exports = plugin(({ theme, addUtilities, matchUtilities }) => { } ) - // - stops + // - stops' colors // NOTE: Can accept custom opacity as an arbitrary value, e.g. `mask-dir-[0.25]` matchUtilities( { @@ -135,9 +137,23 @@ module.exports = plugin(({ theme, addUtilities, matchUtilities }) => { '--tw-mask-to-opacity': value, }), 'mask-via': (value) => ({ - '--tw-mask-stops': `var(--tw-mask-from), rgba(0,0,0,${value}), var(--tw-mask-to)`, + '--tw-mask-point-via': '', + '--tw-mask-stops': `var(--tw-mask-from), rgba(0,0,0,${value}) var(--tw-mask-point-via), var(--tw-mask-to)`, }), }, { values: theme('opacity') } ) + + // - stops' points + matchUtilities({ + 'mask-point-from': (value) => ({ + '--tw-mask-point-from': value, + }), + 'mask-point-to': (value) => ({ + '--tw-mask-point-to': value, + }), + 'mask-point-via': (value) => ({ + '--tw-mask-point-via': value, + }), + }) }) diff --git a/playground/README.md b/playground/README.md index 9724e85..767ac55 100644 --- a/playground/README.md +++ b/playground/README.md @@ -3,4 +3,4 @@ You can past them in the [Tailwind Play](https://play.tailwindcss.com) and have > The shared playground is here: > -> [](https://play.tailwindcss.com/5nqePqTxTt) +> [](https://play.tailwindcss.com/LF91xWKHl7) diff --git a/playground/index.html b/playground/index.html index bb23b1a..f20bfef 100644 --- a/playground/index.html +++ b/playground/index.html @@ -30,6 +30,15 @@