File tree Expand file tree Collapse file tree 4 files changed +77
-3
lines changed Expand file tree Collapse file tree 4 files changed +77
-3
lines changed Original file line number Diff line number Diff line change 44 "author" : " Adam Plesnik <adam@adamplesnik.com>" ,
55 "scripts" : {
66 "dev-docs" : " npm run --workspace=docs dev" ,
7- "build" : " swc ./src/index.ts --out-dir ./dist"
7+ "build" : " swc ./src/index.ts --out-dir ./dist" ,
8+ "test" : " vitest"
89 },
910 "workspaces" : [
1011 " docs"
2122 "devDependencies" : {
2223 "@swc/cli" : " ^0.3.10" ,
2324 "@swc/core" : " ^1.4.11" ,
25+ "@types/jest" : " ^29.5.12" ,
2426 "prettier" : " ^3.2.5" ,
2527 "swcify" : " ^1.0.1" ,
2628 "tailwindcss" : " ^0.0.0-insiders.3ba51d1" ,
27- "typescript" : " ^5.4.3"
29+ "typescript" : " ^5.4.3" ,
30+ "vitest" : " ^1.5.0"
2831 },
2932 "description" : " A plugin for Tailwind CSS v3.4+ that provides utilities for scroll-driven animations." ,
3033 "files" : [
Original file line number Diff line number Diff line change 11import plugin from 'tailwindcss/plugin'
22
33export = plugin (
4- function ( { matchUtilities, addVariant, theme } ) {
4+ function scrollDrivenAnimations ( { matchUtilities, addVariant, theme } ) {
55 matchUtilities (
66 {
77 timeline : ( value , { modifier } ) => ( {
Original file line number Diff line number Diff line change 1+ import { expect , test } from 'vitest'
2+ import { css , html , run } from './utils'
3+
4+ test ( 'Test' , async ( ) => {
5+ let config = {
6+ content : [
7+ {
8+ raw : html `
9+ <div>
10+ <div class= "timeline" > </ div>
11+ <div class= "timeline-auto" > </ div>
12+ <div class= "timeline-none" > </ div>
13+ <div class= "timeline-scroll-x" > </ div>
14+ <div class= "timeline-view" > </ div>
15+ <div class= "timeline/test" > </ div>
16+ </ div>
17+ ` ,
18+ } ,
19+ ] ,
20+ theme : { } ,
21+ corePlugins : { preflight : false } ,
22+ }
23+
24+ let input = `
25+ @tailwind utilities;
26+ `
27+
28+ const result = await run ( input , config )
29+ expect ( result . css ) . toMatch ( css `
30+ .timeline {
31+ animation-timeline : scroll (y);
32+ }
33+ .timeline-auto {
34+ animation-timeline : auto;
35+ }
36+ .timeline-none {
37+ animation-timeline : none;
38+ }
39+ .timeline-scroll-x {
40+ animation-timeline : scroll (x);
41+ }
42+ .timeline-view {
43+ animation-timeline : view ();
44+ }
45+ .timeline\/test {
46+ animation-timeline : --test ;
47+ }
48+ ` )
49+ } )
Original file line number Diff line number Diff line change 1+ import path from 'path'
2+ import postcss from 'postcss'
3+ import tailwind , { Config } from 'tailwindcss'
4+ import { expect } from 'vitest'
5+ import scrollDrivenAnimations from '../src/index'
6+
7+ export let css = String . raw
8+ export let html = String . raw
9+ export let javascript = String . raw
10+
11+ export function run ( input : string , config : Config , plugin = tailwind ) {
12+ let { currentTestName } = expect . getState ( )
13+
14+ config . plugins ??= [ ]
15+ if ( ! config . plugins . includes ( scrollDrivenAnimations ) ) {
16+ config . plugins . push ( scrollDrivenAnimations )
17+ }
18+
19+ return postcss ( plugin ( config ) ) . process ( input , {
20+ from : `${ path . resolve ( __filename ) } ?test=${ currentTestName } ` ,
21+ } )
22+ }
You can’t perform that action at this time.
0 commit comments