Skip to content

Commit 01d1fcb

Browse files
authored
Merge pull request #184 from humanspeak/initial-creation
Enhancemenet: README update & Docs update
2 parents 5ec975b + 25cb24f commit 01d1fcb

File tree

12 files changed

+86
-17
lines changed

12 files changed

+86
-17
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,13 @@ This package carefully selects its dependencies to provide a robust and maintain
105105

106106
### Examples
107107

108-
| Motion | Demo / Route | REPL |
108+
| Motion | Demo / Route | Live Demo |
109109
| -------------------------------------------------------------------------------------------------------- | ---------------------------------------- | ---------------------------------------------------------------------------------------------- |
110110
| [React - Enter Animation](https://examples.motion.dev/react/enter-animation) | `/tests/motion/enter-animation` | [View Example](https://svelte.dev/playground/7f60c347729f4ea48b1a4590c9dedc02?version=5.38.10) |
111-
| [HTML Content (0→100 counter)](https://examples.motion.dev/react/html-content) | `/tests/motion/html-content` | [View Example](https://svelte.dev/playground/31cd72df4a3242b4b4589501a25e774f?version=5.38.10) |
111+
| [HTML Content (0→100 counter)](https://examples.motion.dev/react/html-content) | `/tests/motion/html-content` | [View Example](https://motion.svelte.page/examples/html-content) |
112112
| [Aspect Ratio](https://examples.motion.dev/react/aspect-ratio) | `/tests/motion/aspect-ratio` | [View Example](https://svelte.dev/playground/1bf60e745fae44f5becb4c830fde9b6e?version=5.38.10) |
113-
| [Hover + Tap (whileHover + whileTap)](https://motion.dev/docs/react?platform=react#hover-tap-animation) | `/tests/motion/hover-and-tap` | [View Example](https://svelte.dev/playground/674c7d58f2c740baa4886b01340a97ea?version=5.38.10) |
113+
| [Hover + Tap (whileHover + whileTap)](https://examples.motion.dev/react/gestures) | `/tests/motion/hover-and-tap` | [View Example](https://motion.svelte.page/examples/hover-and-tap) |
114+
| [Rotate](https://examples.motion.dev/react/rotate) | `/tests/motion/rotate` | [View Example](https://motion.svelte.page/examples/rotate) |
114115
| [Random - Shiny Button](https://www.youtube.com/watch?v=jcpLprT5F0I) by [@verse\_](https://x.com/verse_) | `/tests/random/shiny-button` | [View Example](https://svelte.dev/playground/96f9e0bf624f4396adaf06c519147450?version=5.38.10) |
115116
| [Fancy Like Button](https://github.com/DRlFTER/fancyLikeButton) | `/tests/random/fancy-like-button` | [View Example](https://svelte.dev/playground/c34b7e53d41c48b0ab1eaf21ca120c6e?version=5.38.10) |
116117
| [Keyframes (square → circle → square; scale 1→2→1)](https://motion.dev/docs/react-animation#keyframes) | `/tests/motion/keyframes` | [View Example](https://svelte.dev/playground/05595ce0db124c1cbbe4e74fda68d717?version=5.38.10) |

docs/scripts/generate-sitemap-manifest.mjs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,9 @@ async function updateExamplesPageTs(examples) {
105105
let content = await readFile(examplesPageTs, 'utf8')
106106

107107
// Find the examples object in the file and replace it
108-
const examplesObjectRegex = /const examples = \{[\s\S]*?\n {4}\}/
109-
const newExamplesObject = `const examples = ${JSON.stringify(examples, null, 8).replace(/^/gm, ' ')}`
108+
// More robust regex that matches the entire examples object declaration
109+
const examplesObjectRegex = /const examples\s*=\s*\{[\s\S]*?\n\s*\}(?=\s*\n\s*return)/
110+
const newExamplesObject = `const examples = ${JSON.stringify(examples, null, 4).replace(/^/gm, ' ')}`
110111

111112
if (examplesObjectRegex.test(content)) {
112113
content = content.replace(examplesObjectRegex, newExamplesObject)

docs/src/lib/components/general/Example.svelte

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
<script lang="ts">
22
import { motion } from '@humanspeak/svelte-motion'
33
import { cn } from '$lib/shadcn/utils'
4+
import type { Snippet } from 'svelte'
45
5-
const { children, isSmall = false } = $props()
6+
type ExampleProps = {
7+
children: Snippet
8+
isSmall?: boolean
9+
motionUrl?: string
10+
}
11+
12+
const { children, isSmall = false, motionUrl }: ExampleProps = $props()
613
714
let refreshId = $state(0)
815
const refreshMotion = () => {
@@ -21,6 +28,16 @@
2128
<div class="flex flex-1 items-center gap-4"></div>
2229
<div class="flex flex-1 items-center justify-center gap-4"></div>
2330
<div class="flex flex-1 items-center justify-end gap-4">
31+
{#if motionUrl}
32+
<motion.button
33+
onclick={() => window.open(motionUrl, '_blank')}
34+
whileTap={{ scale: 0.9 }}
35+
whileHover={{ scale: 1.1 }}
36+
class="inline-flex items-center justify-center rounded-md border border-border-muted px-2 py-1 text-sm text-text-muted transition-colors hover:border-border-mid hover:text-text-secondary"
37+
>
38+
Motion.dev
39+
</motion.button>
40+
{/if}
2441
<motion.button
2542
onclick={refreshMotion}
2643
whileTap={{ scale: 0.9 }}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<script lang="ts">
2+
import { motion, animate } from '@humanspeak/svelte-motion'
3+
import { onMount } from 'svelte'
4+
5+
let count = $state(0)
6+
7+
onMount(() => {
8+
const controls = animate(0, 100, {
9+
duration: 5,
10+
onUpdate: (latest: number) => {
11+
count = Math.round(latest)
12+
}
13+
}) as unknown as { stop: () => void }
14+
return () => controls.stop()
15+
})
16+
</script>
17+
18+
<motion.pre style="font-size: 64px; color: #8df0cc;">{count}</motion.pre>

docs/src/routes/examples/+page.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ export const load: PageLoad = async () => {
1414
description: 'Interactive hover and tap animation example using Svelte Motion.',
1515
sourceUrl: 'https://examples.motion.dev/react/gestures'
1616
},
17+
'html-content': {
18+
title: 'HTML Content',
19+
description: 'Interactive html content animation example using Svelte Motion.',
20+
sourceUrl: 'https://examples.motion.dev/react/html-content'
21+
},
1722
rotate: {
1823
title: 'Rotate',
1924
description: 'Interactive rotate animation example using Svelte Motion.',

docs/src/routes/examples/animated-button/+page.svelte

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import AnimatedButton from '$lib/examples/AnimatedButton.svelte'
55
66
// Placeholder canvas; hook up live example later.
7-
87
const breadcrumbs = $derived(getBreadcrumbContext())
98
$effect(() => {
109
if (breadcrumbs) {

docs/src/routes/examples/animated-button/+page.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import type { PageLoad } from './$types'
22

33
export const load: PageLoad = async () => {
44
return {
5-
title: 'Animated Button',
6-
sourceUrl: 'https://examples.motion.dev/react/animated-button?utm_source=embed'
5+
title: 'Animated Button'
76
}
87
}

docs/src/routes/examples/hover-and-tap/+page.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import HoverAndTap from '$lib/examples/HoverAndTap.svelte'
55
66
// Placeholder canvas; hook up live example later.
7-
7+
let { data } = $props()
88
const breadcrumbs = $derived(getBreadcrumbContext())
99
$effect(() => {
1010
if (breadcrumbs) {
@@ -16,6 +16,6 @@
1616
})
1717
</script>
1818

19-
<Example>
19+
<Example motionUrl={data.sourceUrl}>
2020
<HoverAndTap />
2121
</Example>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<script lang="ts">
2+
import { getBreadcrumbContext } from '$lib/components/contexts/Breadcrumb/Breadcrumb.context'
3+
import Example from '$lib/components/general/Example.svelte'
4+
import HTMLContent from '$lib/examples/HTMLContent.svelte'
5+
6+
// Placeholder canvas; hook up live example later.
7+
let { data } = $props()
8+
9+
const breadcrumbs = $derived(getBreadcrumbContext())
10+
$effect(() => {
11+
if (breadcrumbs) {
12+
breadcrumbs.breadcrumbs = [
13+
{ title: 'Examples', href: '/examples' },
14+
{ title: 'HTML Content' }
15+
]
16+
}
17+
})
18+
</script>
19+
20+
<Example motionUrl={data.sourceUrl}>
21+
<HTMLContent />
22+
</Example>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import type { PageLoad } from './$types'
2+
3+
export const load: PageLoad = async () => {
4+
return {
5+
title: 'HTML Content',
6+
sourceUrl: 'https://examples.motion.dev/react/html-content'
7+
}
8+
}

0 commit comments

Comments
 (0)