-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* change from framer-motion to motion * impl preact signals * fix motion imports
- Loading branch information
1 parent
d9d01f8
commit 25a1170
Showing
17 changed files
with
492 additions
and
435 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
'use client' | ||
|
||
import { signal, computed, effect } from '@preact/signals-react' | ||
|
||
const gLcount = signal(0) | ||
const gLdouble = computed(() => gLcount.value * 2) | ||
|
||
effect(() => { | ||
console.log('Count:', gLcount.value) | ||
console.log('Double:', gLdouble.value) | ||
}) | ||
|
||
export default function GlobalContent() { | ||
console.log('Render') | ||
|
||
return ( | ||
<> | ||
<p>Count: {gLcount}</p> | ||
<p>Double: {gLdouble}</p> | ||
<div className="flex"> | ||
<button | ||
className="btn-secondary" | ||
onClick={() => { | ||
gLcount.value++ | ||
}} | ||
> | ||
Increment | ||
</button> | ||
<button | ||
className="btn-secondary" | ||
onClick={() => { | ||
gLcount.value-- | ||
}} | ||
> | ||
Decrement | ||
</button> | ||
<button | ||
className="btn-secondary" | ||
onClick={() => { | ||
gLcount.value = 0 | ||
}} | ||
> | ||
Reset | ||
</button> | ||
<button | ||
className="btn-secondary" | ||
onClick={() => { | ||
gLcount.value = 5 | ||
}} | ||
> | ||
Set 5 | ||
</button> | ||
</div> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
'use client' | ||
|
||
// import { signal, computed, effect } from 'lib/hooks/signals' | ||
// import { useSignals } from '@preact/signals-react/runtime' | ||
import { useSignal, useComputed, useSignalEffect } from '@preact/signals-react' | ||
// import { signal, computed, effect } from '@preact/signals-core' | ||
|
||
export default function LocalContent() { | ||
const count = useSignal(0) | ||
const double = useComputed(() => count.value * 2) | ||
console.log('Render') | ||
|
||
useSignalEffect(() => { | ||
console.log('Count:', count.value) | ||
console.log('Double:', double.value) | ||
}) | ||
|
||
return ( | ||
<> | ||
<h2>Counter</h2> | ||
<p>Count: {count}</p> | ||
<p>Double: {double}</p> | ||
<div className="flex"> | ||
<button | ||
className="btn-secondary" | ||
onClick={() => { | ||
count.value++ | ||
}} | ||
> | ||
Increment | ||
</button> | ||
<button | ||
className="btn-secondary" | ||
onClick={() => { | ||
count.value-- | ||
}} | ||
> | ||
Decrement | ||
</button> | ||
<button | ||
className="btn-secondary" | ||
onClick={() => { | ||
count.value = 0 | ||
}} | ||
> | ||
Reset | ||
</button> | ||
<button | ||
className="btn-secondary" | ||
onClick={() => { | ||
count.value = 5 | ||
}} | ||
> | ||
Set 5 | ||
</button> | ||
</div> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import type { PropsWithChildren } from 'react' | ||
|
||
export const metadata = { | ||
title: 'Signals', | ||
description: 'Preact Signals in Next.js', | ||
} | ||
|
||
export default function Layout({ children }: PropsWithChildren<unknown>) { | ||
return children | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,39 @@ | ||
import Content from './Content' | ||
import Section from '@/components/Section' | ||
import Content from '@/components/Content' | ||
import GlobalContent from './GlobalContent' | ||
import LocalContent from './LocalContent' | ||
|
||
export default function Page() { | ||
return <Content /> | ||
return ( | ||
<Content> | ||
<Section size="normal"> | ||
<h1 className="sr-only">Signals</h1> | ||
<div className="grid gap-8"> | ||
<div> | ||
<h2 className="heading2">Local</h2> | ||
<div className="grid gap-3"> | ||
<div> | ||
<LocalContent /> | ||
</div> | ||
<div> | ||
<LocalContent /> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div> | ||
<h2 className="heading2">Global 1</h2> | ||
<div className="grid gap-3"> | ||
<div> | ||
<GlobalContent /> | ||
</div> | ||
<div> | ||
<GlobalContent /> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</Section> | ||
</Content> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.