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

Docs for v2.0 #325

Merged
merged 28 commits into from
Dec 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
631726d
Empty commit for v2 branch
koba04 Aug 5, 2022
5647dac
docs: optimisticData can accept a function in v2 (#333)
koba04 Aug 13, 2022
e81afb7
docs: add mutate filter functions documentation in v2 (#340)
koba04 Aug 24, 2022
fa6488c
docs: add preload API documentation in v2 (#336)
koba04 Aug 30, 2022
f71822f
docs: add DevTools page in v2 (#337)
koba04 Aug 30, 2022
4c5b2b2
docs: SWRConfig value as a function (#335)
koba04 Aug 30, 2022
5a01793
Fetcher no longer accepts multiple arguments in v2 (#326)
koba04 Aug 30, 2022
602e161
docs: add an example for preload in effect (#345)
koba04 Aug 30, 2022
5567dd5
docs: add isLoading and keepPreviousData pages in v2 (#343)
koba04 Sep 4, 2022
afcfbba
add documentations for useSWRMutation (#348)
koba04 Sep 12, 2022
9e5a5f5
docs: add notes for Suspense on SSR and React v18 in SWR v2 (#334)
koba04 Sep 12, 2022
d5da143
sync and refine mutate page (#350)
koba04 Sep 14, 2022
fe0ae55
Note for the shape of keys in mutate filter functions (#353)
koba04 Sep 20, 2022
b12fd2c
make explicit the location of mutate (#354)
koba04 Sep 21, 2022
a910d81
v2 blog post (#351)
koba04 Sep 24, 2022
c1d2a80
use link for codesandbox example (#355)
huozhi Sep 24, 2022
dc28baf
sync translations (#356)
koba04 Sep 25, 2022
511b36c
Merge branch 'main' into v2
koba04 Sep 25, 2022
f8a093e
fix: typos in v2 docs (#357)
koba04 Sep 26, 2022
6babb6d
Add onDiscarded option (#371)
koba04 Nov 22, 2022
646077f
V2 docs improvements (#361)
shuding Nov 22, 2022
fb49dbb
docs: change the build target in the v2 blogdocs: (#381)
koba04 Nov 28, 2022
88eb9c2
Add functional rollbackOnError description (#377)
huozhi Nov 28, 2022
f1ba18f
docs: translate v2 blog into Japanese (#383)
koba04 Dec 6, 2022
f60df0b
docs: translate v2 updates in Japanese (#384)
koba04 Dec 6, 2022
0ab2971
Fix case for section title (#387)
huozhi Dec 8, 2022
0346914
Update card and description for the v2 blog post (#388)
shuding Dec 8, 2022
bd2f77e
Rename laggy ui to preserving previous state (#389)
huozhi Dec 8, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5,744 changes: 5,744 additions & 0 deletions components/excalidraw/state-machine.excalidraw

Large diffs are not rendered by default.

57 changes: 35 additions & 22 deletions components/video.js
Original file line number Diff line number Diff line change
@@ -1,52 +1,65 @@
import { useRef, useCallback, useEffect } from 'react'
import { useInView } from 'react-intersection-observer'
import 'intersection-observer'
import { useRef, useCallback, useEffect } from "react";
import { useInView } from "react-intersection-observer";
import "intersection-observer";

export default ({ src, caption, ratio }) => {
const [inViewRef, inView] = useInView({
threshold: 1,
})
const videoRef = useRef()
});
const videoRef = useRef();

const setRefs = useCallback(
(node) => {
// Ref's from useRef needs to have the node assigned to `current`
videoRef.current = node
videoRef.current = node;
// Callback refs, like the one from `useInView`, is a function that takes the node as an argument
inViewRef(node)
inViewRef(node);

if (node) {
node.addEventListener('click', function () {
node.addEventListener("click", function () {
if (this.paused) {
this.play()
this.play();
} else {
this.pause()
this.pause();
}
})
});
}
},
[inViewRef]
)
);

useEffect(() => {
if (!videoRef || !videoRef.current) {
return
return;
}

if (inView) {
videoRef.current.play()
videoRef.current.play();
} else {
videoRef.current.pause()
videoRef.current.pause();
}
}, [inView])
}, [inView]);

return (
<div style={{ position: 'relative', margin: '2rem 1rem' }}>
<div style={{ paddingBottom: ratio * 100 + '%' }}/>
<video style={{ position: 'absolute', top: 0, left: 0 }} loop muted autoPlay playsInline ref={setRefs}>
<div style={{ position: "relative", margin: "2rem 1rem" }}>
<div style={{ paddingBottom: ratio * 100 + "%" }} />
<video
style={{ position: "absolute", top: 0, left: 0 }}
loop
muted
autoPlay
playsInline
ref={setRefs}
>
<source src={src} type="video/mp4" />
</video>
{caption && <figcaption style={{ fontSize: '.9rem', textAlign: 'center' }}>{caption}</figcaption>}
{caption && (
<figcaption
style={{ fontSize: ".9rem", textAlign: "center", marginTop: "1em" }}
>
{caption}
</figcaption>
)}
</div>
)
}
);
};
5 changes: 5 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ module.exports = withNextra({
destination: "/docs/advanced/cache",
statusCode: 301,
},
{
source: "/docs/options",
destination: "/docs/api",
statusCode: 301
},
{
source: "/change-log",
destination: "/docs/change-log",
Expand Down
1 change: 1 addition & 0 deletions pages/blog/meta.en-US.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"swr-v2": "Announcing SWR 2.0",
"swr-v1": "Announcing SWR 1.0"
}
1 change: 1 addition & 0 deletions pages/blog/meta.es-ES.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"swr-v2": "Announcing SWR 2.0",
"swr-v1": "Announcing SWR 1.0"
}
1 change: 1 addition & 0 deletions pages/blog/meta.ja.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"swr-v2": "SWR 2.0 の発表",
"swr-v1": "SWR 1.0 の発表"
}
1 change: 1 addition & 0 deletions pages/blog/meta.ko.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"swr-v2": "Announcing SWR 2.0",
"swr-v1": "SWR 1.0 알림"
}
7 changes: 4 additions & 3 deletions pages/blog/meta.pt-BR.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"swr-v1": "Anunciando SWR 1.0"
}
{
"swr-v2": "Announcing SWR 2.0",
"swr-v1": "Anunciando SWR 1.0"
}
1 change: 1 addition & 0 deletions pages/blog/meta.ru.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"swr-v2": "Announcing SWR 2.0",
"swr-v1": "Представляем SWR 1.0"
}
1 change: 1 addition & 0 deletions pages/blog/meta.zh-CN.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"swr-v2": "Announcing SWR 2.0",
"swr-v1": "SWR 1.0 发布"
}