Skip to content

Commit

Permalink
update: example/demo (#2585)
Browse files Browse the repository at this point in the history
* update: example/demo

- fix eslint config and lint issues
- fix react key issue
- remove children passed as props
- remove unused variables and imports
- "encodings_fragment" is deprecated, replaced it with "colorspace_fragment"

* update: remove --fix
  • Loading branch information
sunil-sharma-999 authored Jun 6, 2024
1 parent 88ef340 commit 3b90e1c
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 30 deletions.
16 changes: 6 additions & 10 deletions examples/demo/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
/* eslint-env node */

module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:react/recommended',
'plugin:react/jsx-runtime',
'plugin:react-hooks/recommended',
],
extends: ['eslint:recommended', 'plugin:react/recommended', 'plugin:react/jsx-runtime', 'plugin:react-hooks/recommended'],
parserOptions: { ecmaVersion: 'latest', sourceType: 'module' },
settings: { react: { version: '18.2' } },
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
'react-refresh/only-export-components': ['warn', { allowConstantExport: true }],
'react/prop-types': 0,
'import/extensions': ['off'],
'react/no-unknown-property': ['off'],
},
}
14 changes: 7 additions & 7 deletions examples/demo/.prettierrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"semi": false,
"trailingComma": "all",
"singleQuote": true,
"tabWidth": 2,
"printWidth": 140,
"jsxBracketSameLine": true
}
"semi": false,
"trailingComma": "all",
"singleQuote": true,
"tabWidth": 2,
"printWidth": 140,
"jsxBracketSameLine": true
}
4 changes: 2 additions & 2 deletions examples/demo/src/components/CodePreview.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ export default function CodePreview() {
// position is set to relative so the copy button can align to bottom right
<pre className={className} style={{ ...style, position: 'relative' }}>
{tokens.map((line, i) => (
<div {...getLineProps({ line, key: i })}>
<div {...getLineProps({ line })} key={i}>
{line.map((token, key) => (
<span {...getTokenProps({ token, key })} />
<span {...getTokenProps({ token })} key={key} />
))}
</div>
))}
Expand Down
12 changes: 8 additions & 4 deletions examples/demo/src/components/Details.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@ export default function Details() {
return (
<>
<nav className="nav">
<a href="https://docs.pmnd.rs/zustand" children="Documentation" />
<a href="https://github.com/pmndrs/zustand" children="Github" />
<a href="https://docs.pmnd.rs/zustand">Documentation</a>
<a href="https://github.com/pmndrs/zustand">Github</a>
</nav>
<div className="bottom">
<a href="https://github.com/pmndrs/zustand/tree/main/examples/demo" className="bottom-right" children="<Source />" />
<a href="https://www.instagram.com/tina.henschel/" className="bottom-left" children="Illustrations @ Tina Henschel" />
<a href="https://github.com/pmndrs/zustand/tree/main/examples/demo" className="bottom-right">
{'<Source />'}
</a>
<a href="https://www.instagram.com/tina.henschel/" className="bottom-left">
Illustrations @ Tina Henschel
</a>
</div>
<span className="header-left">Zustand</span>
</>
Expand Down
6 changes: 3 additions & 3 deletions examples/demo/src/components/Fireflies.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Vector3, CatmullRomCurve3 } from 'three'
import React, { useRef, useMemo } from 'react'
import { useRef, useMemo } from 'react'
import { extend, useFrame } from '@react-three/fiber'
import * as meshline from 'meshline'

extend(meshline)

const r = () => Math.max(0.2, Math.random())

function Fatline({ curve, width, color }) {
function Fatline({ curve, color }) {
const material = useRef()
useFrame((state, delta) => (material.current.uniforms.dashOffset.value -= delta / 100))
return (
Expand All @@ -21,7 +21,7 @@ function Fatline({ curve, width, color }) {
export default function Fireflies({ count, colors, radius = 10 }) {
const lines = useMemo(
() =>
new Array(count).fill().map((_, index) => {
new Array(count).fill().map(() => {
const pos = new Vector3(Math.sin(0) * radius * r(), Math.cos(0) * radius * r(), 0)
const points = new Array(30).fill().map((_, index) => {
const angle = (index / 20) * Math.PI * 2
Expand Down
4 changes: 2 additions & 2 deletions examples/demo/src/components/Scene.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Mesh, PlaneGeometry, Group, Vector3, MathUtils } from 'three'
import React, { useRef, useState, useLayoutEffect } from 'react'
import { memo, useRef, useState, useLayoutEffect } from 'react'
import { createRoot, events, extend, useFrame } from '@react-three/fiber'
import { Plane, useAspect, useTexture } from '@react-three/drei'
import { EffectComposer, DepthOfField, Vignette } from '@react-three/postprocessing'
Expand Down Expand Up @@ -106,7 +106,7 @@ function Canvas({ children }) {
window.addEventListener('resize', resize)
root.current.render(children)
return () => window.removeEventListener('resize', resize)
}, [])
}, [children])

return <canvas ref={canvas} style={{ position: 'relative', width: '100%', height: '100%', overflow: 'hidden', display: 'block' }} />
}
4 changes: 2 additions & 2 deletions examples/demo/src/materials/layerMaterial.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const LayerMaterial = shaderMaterial(
mat3 m = mat3(c, 0, s, 0, 1, 0, -s, 0, c);
transformed = transformed * m;
vNormal = vNormal * m;
}
}
gl_Position = projectionMatrix * modelViewMatrix * vec4(transformed, 1.);
}`,
` uniform float time;
Expand All @@ -38,7 +38,7 @@ const LayerMaterial = shaderMaterial(
if (color.a < 0.1) discard;
gl_FragColor = vec4(color.rgb, .1);
#include <tonemapping_fragment>
#include <encodings_fragment>
#include <colorspace_fragment>
}`,
)

Expand Down

0 comments on commit 3b90e1c

Please sign in to comment.