Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.0.1 #73

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

Official [tsParticles](https://github.com/tsparticles/tsparticles) ReactJS component

[![Slack](https://particles.js.org/images/slack.png)](https://join.slack.com/t/tsparticles/shared_invite/enQtOTcxNTQxNjQ4NzkxLWE2MTZhZWExMWRmOWI5MTMxNjczOGE1Yjk0MjViYjdkYTUzODM3OTc5MGQ5MjFlODc4MzE0N2Q1OWQxZDc1YzI) [![Discord](https://particles.js.org/images/discord.png)](https://discord.gg/hACwv45Hme) [![Telegram](https://particles.js.org/images/telegram.png)](https://t.me/tsparticles)
[![Discord](https://particles.js.org/images/discord.png)](https://discord.gg/hACwv45Hme) [![Telegram](https://particles.js.org/images/telegram.png)](https://t.me/tsparticles)

[![tsParticles Product Hunt](https://api.producthunt.com/widgets/embed-image/v1/featured.svg?post_id=186113&theme=light)](https://www.producthunt.com/posts/tsparticles?utm_source=badge-featured&utm_medium=badge&utm_souce=badge-tsparticles") <a href="https://www.buymeacoffee.com/matteobruni"><img src="https://img.buymeacoffee.com/button-api/?text=Buy me a beer&emoji=🍺&slug=matteobruni&button_colour=5F7FFF&font_colour=ffffff&font_family=Arial&outline_colour=000000&coffee_colour=FFDD00"></a>

Expand Down
6 changes: 3 additions & 3 deletions apps/nextjs-beta/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
},
"dependencies": {
"@next/font": "^14.0.3",
"@tsparticles/configs": "^3.0.2",
"@tsparticles/engine": "^3.0.2",
"@tsparticles/configs": "^3.2.2",
"@tsparticles/engine": "^3.2.2",
"@tsparticles/react": "workspace:^",
"@types/node": "^20.10.4",
"@types/react": "^18.2.42",
Expand All @@ -22,7 +22,7 @@
"next": "^14.0.3",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"tsparticles": "^3.0.2",
"tsparticles": "^3.2.2",
"typescript": "^5.3.3"
}
}
5 changes: 3 additions & 2 deletions apps/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@
"lint": "next lint"
},
"dependencies": {
"@tsparticles/engine": "^3.0.2",
"@tsparticles/preset-big-circles": "^3.0.0",
"@tsparticles/configs": "^3.2.2",
"@tsparticles/engine": "^3.2.2",
"@tsparticles/react": "workspace:^",
"next": "^14.0.3",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"tsparticles": "^3.2.2",
"typescript": "^5.3.3"
},
"devDependencies": {
Expand Down
17 changes: 4 additions & 13 deletions apps/nextjs/pages/index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import Head from "next/head";
import Image from "next/image";
import Particles, { initParticlesEngine } from "@tsparticles/react";
import { loadBigCirclesPreset } from "@tsparticles/preset-big-circles";
import configs from "@tsparticles/configs";
import { loadFull } from "tsparticles";
import styles from "../styles/Home.module.css";
import { useCallback, useEffect, useMemo, useState } from "react";

export default function Home() {
const particlesInitCb = useCallback(async (engine) => {
console.log("callback");

await loadBigCirclesPreset(engine);
await loadFull(engine);
}, []);

const particlesLoaded = useCallback((container) => {
Expand All @@ -24,16 +25,6 @@ export default function Home() {
});
}, []);

const options = useMemo(
() => ({
preset: "bigCircles",
fullScreen: {
zIndex: -1,
},
}),
[]
);

return (
<div className={styles.container}>
<Head>
Expand Down Expand Up @@ -98,7 +89,7 @@ export default function Home() {
{init && (
<Particles
id="tsparticles"
options={options}
options={configs.basic}
particlesLoaded={particlesLoaded}
/>
)}
Expand Down
18 changes: 18 additions & 0 deletions apps/react-vite/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react-hooks/recommended',
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parser: '@typescript-eslint/parser',
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
}
24 changes: 24 additions & 0 deletions apps/react-vite/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
30 changes: 30 additions & 0 deletions apps/react-vite/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# React + TypeScript + Vite

This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.

Currently, two official plugins are available:

- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh

## Expanding the ESLint configuration

If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:

- Configure the top-level `parserOptions` property like this:

```js
export default {
// other rules...
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
project: ['./tsconfig.json', './tsconfig.node.json'],
tsconfigRootDir: __dirname,
},
}
```

- Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked`
- Optionally add `plugin:@typescript-eslint/stylistic-type-checked`
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list
13 changes: 13 additions & 0 deletions apps/react-vite/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React + TS</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
31 changes: 31 additions & 0 deletions apps/react-vite/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "test-react-particles-3",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview"
},
"dependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0",
"@tsparticles/react": "workspace:^",
"@tsparticles/engine": "^3.2.2",
"tsparticles": "^3.2.2"
},
"devDependencies": {
"@types/react": "^18.2.43",
"@types/react-dom": "^18.2.17",
"@typescript-eslint/eslint-plugin": "^6.14.0",
"@typescript-eslint/parser": "^6.14.0",
"@vitejs/plugin-react": "^4.2.1",
"eslint": "^8.55.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.5",
"typescript": "^5.2.2",
"vite": "^5.0.8"
}
}
1 change: 1 addition & 0 deletions apps/react-vite/public/vite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 42 additions & 0 deletions apps/react-vite/src/App.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#root {
max-width: 1280px;
margin: 0 auto;
padding: 2rem;
text-align: center;
}

.logo {
height: 6em;
padding: 1.5em;
will-change: filter;
transition: filter 300ms;
}
.logo:hover {
filter: drop-shadow(0 0 2em #646cffaa);
}
.logo.react:hover {
filter: drop-shadow(0 0 2em #61dafbaa);
}

@keyframes logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}

@media (prefers-reduced-motion: no-preference) {
a:nth-of-type(2) .logo {
animation: logo-spin infinite 20s linear;
}
}

.card {
padding: 2em;
}

.read-the-docs {
color: #888;
}
72 changes: 72 additions & 0 deletions apps/react-vite/src/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import { useCallback, useEffect, useState } from 'react'
import reactLogo from './assets/react.svg'
import viteLogo from '/vite.svg'
import Particles, { initParticlesEngine } from "@tsparticles/react";
import './App.css'
import { loadFull } from 'tsparticles';
import type { Container } from '@tsparticles/engine';

function App() {
const [ particlesInitialized, setParticlesInitialized ] = useState(false);

useEffect(() => {
initParticlesEngine(async (engine) => {
if (particlesInitialized) {
return;
}

await loadFull(engine);
}).then(() => {
setParticlesInitialized(true);
})
}, []);

const particlesLoaded = useCallback(async (container?: Container): Promise<void> => {
if (!container) {
return;
}

console.log("Particles loaded", container.actualOptions);
}, []);

return (
<>
<div>
<a href="https://vitejs.dev" target="_blank">
<img src={viteLogo} className="logo" alt="Vite logo"/>
</a>
<a href="https://react.dev" target="_blank">
<img src={reactLogo} className="logo react" alt="React logo"/>
</a>
</div>
<h1>Vite + React</h1>
{particlesInitialized && (
<Particles options={{
background: {
color: "#000"
},
particles: {
number: {
value: 100
},
links: {
enable: true
},
move: {
enable: true,
}
}
}} particlesLoaded={particlesLoaded}/>)}
<div className="card">
<p>
Edit <code>src/App.tsx</code> and save to test HMR
</p>
</div>
<p className="read-the-docs">
Click on the Vite and React logos to learn more
</p>
</>
)
}

export default App
1 change: 1 addition & 0 deletions apps/react-vite/src/assets/react.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading