Skip to content

Commit

Permalink
Merge branch 'main' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
wre232114 authored Dec 27, 2024
2 parents 5e6dba1 + ee01493 commit b0c7940
Show file tree
Hide file tree
Showing 20 changed files with 258 additions and 90 deletions.
5 changes: 5 additions & 0 deletions .changeset/eight-forks-glow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@farmfe/js-plugin-tailwindcss": patch
---

use configResolve instead of config hooks
7 changes: 7 additions & 0 deletions bench/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# bench

## 1.0.35

### Patch Changes

- Updated dependencies [43e0ea06]
- @farmfe/core@1.6.2

## 1.0.34

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion bench/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bench",
"version": "1.0.34",
"version": "1.0.35",
"private": true,
"description": "",
"scripts": {},
Expand Down
3 changes: 1 addition & 2 deletions crates/compiler/src/update/handle_update_modules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@ fn resolve_watch_graph_paths(
.into_iter()
.flat_map(|(path, update_type)| {
let id = ModuleId::new(&path, "", &context.config.root);

if watch_graph.has_module(&id) {
let r: Vec<(String, UpdateType)> = watch_graph
.relation_roots(&id)
Expand All @@ -216,7 +215,7 @@ fn resolve_watch_graph_paths(
})
.collect();

if module_graph.has_module(&ModuleId::new(path.as_str(), "", &context.config.root)) {
if module_graph.has_module(&id) {
return [r, vec![(path, update_type)]].concat();
};

Expand Down
10 changes: 0 additions & 10 deletions crates/compiler/src/update/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,12 +287,6 @@ impl Compiler {
.push(id.resolved_path(&self.context.config.root));
};
}

watch_diff_result.remove.extend(
old_watch_extra_resources
.into_iter()
.map(|r| r.resolved_path(&self.context.config.root)),
);
}

// If the module type is not script, we should skip render and generate update resource.
Expand Down Expand Up @@ -409,10 +403,6 @@ impl Compiler {
mut module,
resolve_module_id_result,
}) => {
let mut graph_watch = context.watch_graph.write();
graph_watch.delete_module(&module.id);
drop(graph_watch);

if resolve_module_id_result.resolve_result.external {
// insert external module to the graph
let module_id: ModuleId = resolve_param.source.as_str().into();
Expand Down
6 changes: 6 additions & 0 deletions examples/tailwind-next/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @farmfe-examples/tailwind-next

## 0.0.4

### Patch Changes

- @farmfe/js-plugin-tailwindcss@0.0.3

## 0.0.3

### Patch Changes
Expand Down
21 changes: 2 additions & 19 deletions examples/tailwind-next/farm.config.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,9 @@
import type { UserConfig } from "@farmfe/core";
// import farmPostcssPlugin from '@farmfe/js-plugin-postcss';
import { defineConfig } from "@farmfe/core";
import tailwind from "@farmfe/js-plugin-tailwindcss";

function defineConfig(config: UserConfig) {
return config;
}

export default defineConfig({
compilation: {
input: {
index: "./index.html",
},
output: {
path: "./build",
},
sourcemap: false,
resolve: {
dedupe: ["tailwindcss"],
},
},
server: {
hmr: true,
persistentCache: false,
},
plugins: [
"@farmfe/plugin-react",
Expand Down
2 changes: 1 addition & 1 deletion examples/tailwind-next/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@farmfe-examples/tailwind-next",
"version": "0.0.3",
"version": "0.0.4",
"private": true,
"dependencies": {
"@farmfe/js-plugin-tailwindcss": "workspace:^",
Expand Down
97 changes: 97 additions & 0 deletions examples/tailwind-next/src/AnimatedComponents.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import React, { useState } from 'react'

export const WiggleButton = () => (
<button className="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded animate-wiggle">
Wiggle Me!
</button>
)

export const FloatingCard = () => (
<div className="bg-white p-6 rounded-lg shadow-lg animate-float">
<h2 className="text-xl font-bold mb-2">Floating Card</h2>
<p>This card gently floats up and down.</p>
</div>
)

export const FadeInText = () => {
const [show, setShow] = useState(false)
return (
<div>
<button
onClick={() => setShow(!show)}
className="bg-purple-500 text-white px-4 py-2 rounded mb-4"
>
Toggle Fade
</button>
{show && (
<p className="text-2xl font-bold text-purple-600 animate-fadeIn">
I fade in smoothly!
</p>
)}
</div>
)
}

export const SlideInPanel = () => {
const [show, setShow] = useState(false)
return (
<div>
<button
onClick={() => setShow(!show)}
className="bg-green-500 text-white px-4 py-2 rounded mb-4"
>
Toggle Slide
</button>
{show && (
<div className="bg-green-500 text-white p-4 rounded-lg animate-slideIn">
<h3 className="text-xl font-bold">Sliding Panel</h3>
<p>I slide in from the left!</p>
</div>
)}
</div>
)
}

export const PulsingIcon = () => (
<div className="w-12 h-12 rounded-full bg-red-500 animate-pulse"></div>
)

export const BouncingBall = () => (
<div className="w-12 h-12 rounded-full bg-yellow-500 animate-bounce"></div>
)

export const SpinningLoader = () => (
<div className="w-12 h-12 border-4 border-blue-500 border-t-transparent rounded-full animate-spin"></div>
)

export const PingingCircle = () => (
<span className="relative flex h-3 w-3">
<span className="animate-ping absolute inline-flex h-full w-full rounded-full bg-sky-400 opacity-75"></span>
<span className="relative inline-flex rounded-full h-3 w-3 bg-sky-500"></span>
</span>
)

export const ScalingSquare = () => (
<div className="w-12 h-12 bg-purple-500 animate-scale"></div>
)

export const ShakingInput = () => (
<input
type="text"
placeholder="Type and watch me shake!"
className="border-2 border-gray-300 p-2 rounded animate-shake"
/>
)

export const FlippingCard = () => (
<div className="w-32 h-32 bg-gradient-to-r from-cyan-500 to-blue-500 rounded-lg animate-rotateY"></div>
)

export const TypingText = () => (
<div className="w-64 overflow-hidden border-r-2 border-black">
<p className="font-mono text-lg whitespace-nowrap overflow-hidden animate-typing">
Welcome to animations!
</p>
</div>
)

71 changes: 40 additions & 31 deletions examples/tailwind-next/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,35 +1,44 @@
import React from 'react';
import logo from './logo.svg?url';
import { useState } from 'react';

const App = () => {
const [count, setCount] = useState(0);
import React from 'react'
import {
WiggleButton,
FloatingCard,
FadeInText,
SlideInPanel,
PulsingIcon,
BouncingBall,
SpinningLoader,
PingingCircle,
ScalingSquare,
ShakingInput,
FlippingCard,
TypingText
} from './AnimatedComponents'

export default function App() {
return (
<div className="text-center">
<header className="bg-slate-700 min-h-screen flex flex-col items-center justify-center text-[calc(10px + 2vmin)] text-white">
<img
src={logo}
className="animate-spin h-[20vmin] pointer-events-none"
alt="logo"
/>
<p>
Edit <code>src/App.tsx</code> and save to reload.
</p>
<a
className="text-red-600 text-[28px]"
href="https://github.com/tailwindcss/tailwindcss"
target="_blank"
rel="noopener noreferrer"
>
Learn Tailwindcss
</a>
<button className="mt-6" onClick={() => setCount(count + 1)}>
Count: {count}
</button>
</header>
<div className="min-h-screen bg-gray-100 py-12 px-4 sm:px-6 lg:px-8">
<div className="max-w-7xl mx-auto">
<h1 className="text-4xl font-bold text-center mb-12">12 Tailwind CSS Animations</h1>
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8">
<AnimationCard title="3. Fade In Text" component={<FadeInText />} />
<AnimationCard title="4. Slide In Panel" component={<SlideInPanel />} />
<AnimationCard title="5. Pulsing Icon" component={<PulsingIcon />} />
<AnimationCard title="6. Bouncing Ball" component={<BouncingBall />} />
<AnimationCard title="7. Spinning Loader" component={<SpinningLoader />} />
<AnimationCard title="8. Pinging Circle" component={<PingingCircle />} />
</div>
</div>
</div>
)
}

const AnimationCard = ({ title, component }: { title: string, component: React.ReactNode }) => (
<div className="bg-white p-6 rounded-lg shadow-md">
<h2 className="text-xl font-semibold mb-4">{title}</h2>
<div className="flex items-center justify-center h-40">
{component}
</div>
);
};
</div>
)


export default App;
2 changes: 1 addition & 1 deletion examples/tailwind-next/src/index.css
Original file line number Diff line number Diff line change
@@ -1 +1 @@
@import 'tailwindcss';
@import 'tailwindcss';
67 changes: 66 additions & 1 deletion examples/tailwind-next/tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,72 @@ export default {
"./src/**/*.{js,ts,jsx,tsx}",
],
theme: {
extend: {},
extend: {
keyframes: {
wiggle: {
'0%, 100%': { transform: 'rotate(-3deg)' },
'50%': { transform: 'rotate(3deg)' },
},
float: {
'0%, 100%': { transform: 'translateY(0)' },
'50%': { transform: 'translateY(-20px)' },
},
fadeIn: {
'0%': { opacity: '0' },
'100%': { opacity: '1' },
},
slideIn: {
'0%': { transform: 'translateX(-100%)' },
'100%': { transform: 'translateX(0)' },
},
pulse: {
'0%, 100%': { opacity: '1' },
'50%': { opacity: '0.5' },
},
bounce: {
'0%, 100%': { transform: 'translateY(-25%)' },
'50%': { transform: 'translateY(0)' },
},
spin: {
'0%': { transform: 'rotate(0deg)' },
'100%': { transform: 'rotate(360deg)' },
},
ping: {
'75%, 100%': { transform: 'scale(2)', opacity: '0' },
},
scale: {
'0%, 100%': { transform: 'scale(1)' },
'50%': { transform: 'scale(1.5)' },
},
shake: {
'0%, 100%': { transform: 'translateX(0)' },
'10%, 30%, 50%, 70%, 90%': { transform: 'translateX(-10px)' },
'20%, 40%, 60%, 80%': { transform: 'translateX(10px)' },
},
rotateY: {
'0%': { transform: 'rotateY(0deg)' },
'100%': { transform: 'rotateY(360deg)' },
},
typing: {
'0%': { width: '0' },
'100%': { width: '100%' },
},
},
animation: {
wiggle: 'wiggle 1s ease-in-out infinite',
float: 'float 3s ease-in-out infinite',
fadeIn: 'fadeIn 1s ease-out',
slideIn: 'slideIn 0.5s ease-out',
pulse: 'pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite',
bounce: 'bounce 1s infinite',
spin: 'spin 1s linear infinite',
ping: 'ping 1s cubic-bezier(0, 0, 0.2, 1) infinite',
scale: 'scale 2s ease-in-out infinite',
shake: 'shake 0.82s cubic-bezier(.36,.07,.19,.97) infinite',
rotateY: 'rotateY 2s linear infinite',
typing: 'typing 3.5s steps(40, end) infinite',
},
},
},
plugins: [],
}
Expand Down
4 changes: 2 additions & 2 deletions js-plugins/postcss/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"license": "MIT",
"devDependencies": {
"@farmfe/cli": "workspace:*",
"@farmfe/core": "workspace:^1.6.0",
"@farmfe/core": "workspace:*",
"@farmfe/js-plugin-dts": "workspace:*",
"@types/postcss-import": "^14.0.3",
"@types/postcss-url": "^10.0.4",
Expand All @@ -51,7 +51,7 @@
"postcss-url": "^10.1.3"
},
"peerDependencies": {
"@farmfe/core": "workspace:^1.6.0",
"@farmfe/core": "workspace:^1.6.2",
"postcss": ">=8.0.0"
}
}
2 changes: 1 addition & 1 deletion js-plugins/solid/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"solid-js": "^1.7.8"
},
"peerDependencies": {
"@farmfe/core": "workspace:^1.6.1"
"@farmfe/core": "workspace:^1.6.2"
},
"files": [
"build"
Expand Down
Loading

0 comments on commit b0c7940

Please sign in to comment.