Skip to content

Commit b4685f0

Browse files
authored
feat: add examples page (pmndrs#2021)
1 parent 1d0b384 commit b4685f0

40 files changed

+1508
-286
lines changed

.codesandbox/ci.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"/demo/src/sandboxes/list-reordering",
1818
"/demo/src/sandboxes/masonry",
1919
"/demo/src/sandboxes/multistage-transition",
20+
"/demo/src/sandboxes/noise",
2021
"/demo/src/sandboxes/notification-hub",
2122
"/demo/src/sandboxes/parallax",
2223
"/demo/src/sandboxes/parallax-sticky",
@@ -32,5 +33,5 @@
3233
"/demo/src/sandboxes/viewpager",
3334
"/demo/src/sandboxes/webgl-switch"
3435
],
35-
"node": "14"
36+
"node": "16"
3637
}

demo/CONTRIBUTING.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Contributing a new demo
2+
3+
## Preface
4+
5+
Thanks for being interested in contributing a demo! Before you read more, have you read the [contribution guide](https://github.com/pmndrs/react-spring/blob/master/CONTRIBUTING.md) for the repo? If not, give it a look first!
6+
7+
## What is required
8+
9+
All our demos are based on codesandbox templates for react-typescript. If you're going to contribute a
10+
demo, you can either copy an existing demo and tweak it or create a new one in codesandbox, export the
11+
code and add it to the repo.
12+
13+
You should ensure your demo follows the same structure as the other ones:
14+
15+
```
16+
- public
17+
- src
18+
- - App.tsx
19+
- - index.tsx
20+
- .pretterrc
21+
- package.json
22+
- tsconfig.json // I would copy this from an existing one
23+
- thumbnail.png
24+
```
25+
26+
This is the minimum we require as the `App.tsx` is used to integrate with our demo hub via vite in the repo.
27+
28+
A few other things to remember
29+
30+
### Thumbnail
31+
32+
This should be included to showcase your work best! Make sure it's a 16:9 ratio.
33+
34+
### Package.json
35+
36+
Ensure there's a clear name and description as these appear on the website. You should also use `tags` to highlight keywords
37+
especially the `react-spring` hooks you've used.
38+
39+
## When you're ready
40+
41+
When you've finished adding your code, open a PR explaining the example, why you think it should be included
42+
and most importantly, include a sandbox link so it can be looked at and admired!

demo/src/App.jsx

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import AnimatingAuto from './sandboxes/animating-auto/src/App'
99
import Card from './sandboxes/card/src/App'
1010
import CardsStack from './sandboxes/cards-stack/src/App'
1111
import Chain from './sandboxes/chain/src/App'
12+
import CssGradients from './sandboxes/css-gradients/src/App'
1213
import CssKeyframes from './sandboxes/css-keyframes/src/App'
1314
import CssVariables from './sandboxes/css-variables/src/App'
1415

@@ -30,6 +31,7 @@ import Masonry from './sandboxes/masonry/src/App'
3031
import MultiStageTransition from './sandboxes/multistage-transition/src/App'
3132

3233
import NotificationHub from './sandboxes/notification-hub/src/App'
34+
import Noise from './sandboxes/noise/src/App'
3335

3436
import Parallax from './sandboxes/parallax/src/App'
3537
import ParallaxVert from './sandboxes/parallax-vert/src/App'
@@ -57,9 +59,9 @@ const links = {
5759
card: Card,
5860
'cards-stack': CardsStack,
5961
chain: Chain,
62+
'css-gradients': CssGradients,
6063
'css-keyframes': CssKeyframes,
6164
'css-variables': CssVariables,
62-
'decay-rocket': DecayRocket,
6365
'draggable-list': DraggableList,
6466
'exit-before-enter': ExitBeforeEnter,
6567
'flip-card': FlipCard,
@@ -69,18 +71,20 @@ const links = {
6971
'list-reordering': ListReordering,
7072
masonry: Masonry,
7173
'multistage-transition': MultiStageTransition,
74+
noise: Noise,
7275
'notification-hub': NotificationHub,
7376
parallax: Parallax,
74-
'parallax-vert': ParallaxVert,
7577
'parallax-sticky': ParallaxSticky,
78+
'parallax-vert': ParallaxVert,
79+
'rocket-decay': DecayRocket,
7680
'simple-transition': SimpleTransition,
7781
slide: Slide,
7882
'smile-grid': SmileGrid,
79-
'spring-boxes': SpringBoxes,
83+
'springy-boxes': SpringBoxes,
8084
'svg-filter': SvgFilter,
8185
trail: Trail,
82-
viewpager: Viewpager,
8386
tree: Tree,
87+
viewpager: Viewpager,
8488
'webgl-switch': WebGlSwitch,
8589
}
8690

@@ -104,17 +108,36 @@ export default function App() {
104108
<div className={styles.page}>
105109
<h1>React Spring demos</h1>
106110
<h2>Sandboxes</h2>
107-
<div className={styles.linkList}>
111+
<ul className={styles.linkList}>
108112
{Object.keys(links).map(link => (
109-
<Link key={link} href={`/${link}`}>
110-
{/*eslint-disable-next-line jsx-a11y/anchor-is-valid */}
111-
<a className={styles.link}>{link}</a>
112-
</Link>
113+
<li key={link}>
114+
<DemoCard link={link}>{link}</DemoCard>
115+
</li>
113116
))}
114-
</div>
117+
</ul>
115118
</div>
116119
</Route>
117120
<Route path="/:link">{params => <Example link={params.link} />}</Route>
118121
</>
119122
)
120123
}
124+
125+
const DemoCard = ({ children, link }) => {
126+
return (
127+
<Link key={link} href={`/${link}`}>
128+
<a>
129+
<figure className={styles.card}>
130+
<div className={styles['image-container']}>
131+
<img
132+
src={`https://raw.githubusercontent.com/pmndrs/react-spring/master/demo/src/sandboxes/${link}/thumbnail.png`}
133+
placeholder="empty"
134+
loading="lazy"
135+
alt={children}
136+
/>
137+
</div>
138+
<figcaption className={styles.title}>{children}</figcaption>
139+
</figure>
140+
</a>
141+
</Link>
142+
)
143+
}
-110 KB
Binary file not shown.

demo/src/sandboxes/noise/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@
3131
"not ie <= 11",
3232
"not op_mini all"
3333
]
34-
}
34+
}
Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
<!DOCTYPE html>
22
<html lang="en">
3-
4-
<head>
5-
<meta charset="utf-8">
6-
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
7-
<meta name="theme-color" content="#000000">
8-
<!--
3+
<head>
4+
<meta charset="utf-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
6+
<meta name="theme-color" content="#000000" />
7+
<!--
98
manifest.json provides metadata used when your web app is added to the
109
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
1110
-->
12-
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
13-
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
14-
<!--
11+
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
12+
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" />
13+
<!--
1514
Notice the use of %PUBLIC_URL% in the tags above.
1615
It will be replaced with the URL of the `public` folder during the build.
1716
Only files inside the `public` folder can be referenced from the HTML.
@@ -20,15 +19,13 @@
2019
work correctly both with client-side routing and a non-root public URL.
2120
Learn how to configure a non-root public URL by running `npm run build`.
2221
-->
23-
<title>React App</title>
24-
</head>
22+
<title>React App</title>
23+
</head>
2524

26-
<body>
27-
<noscript>
28-
You need to enable JavaScript to run this app.
29-
</noscript>
30-
<div id="root"></div>
31-
<!--
25+
<body>
26+
<noscript> You need to enable JavaScript to run this app. </noscript>
27+
<div id="root"></div>
28+
<!--
3229
This HTML file is a template.
3330
If you open it directly in the browser, you will see an empty page.
3431
@@ -38,6 +35,5 @@
3835
To begin the development, run `npm start` or `yarn start`.
3936
To create a production bundle, use `npm run build` or `yarn build`.
4037
-->
41-
</body>
42-
43-
</html>
38+
</body>
39+
</html>

demo/src/sandboxes/noise/src/App.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import * as React from 'react'
12
import { animated, useSpring, easings } from '@react-spring/web'
23

34
import styles from './styles.module.css'
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { StrictMode } from "react";
2-
import { createRoot } from "react-dom/client";
3-
import "./index.css";
1+
import { StrictMode } from 'react'
2+
import { createRoot } from 'react-dom/client'
3+
import './index.css'
44

5-
import App from "./App";
5+
import App from './App'
66

7-
const rootElement = document.getElementById("root")!;
7+
const rootElement = document.getElementById('root')!
88
createRoot(rootElement).render(
99
<StrictMode>
1010
<App />
1111
</StrictMode>
12-
);
12+
)

demo/src/sandboxes/noise/src/styles.module.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@
1414
position: absolute;
1515
background-size: 256px 256px;
1616
background-repeat: repeat;
17-
background: url("https://framerusercontent.com/images/rR6HYXBrMmX4cRpXfXUOvpvpB0.png");
17+
background: url('https://framerusercontent.com/images/rR6HYXBrMmX4cRpXfXUOvpvpB0.png');
1818
}
1.71 MB
Loading

0 commit comments

Comments
 (0)