Skip to content

Commit a5b09b0

Browse files
committed
chore: Better dev environment, docs, landing, and tests.
1 parent d64f886 commit a5b09b0

File tree

12 files changed

+93
-136
lines changed

12 files changed

+93
-136
lines changed

.prettierrc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
"tabWidth": 2,
44
"printWidth": 100,
55
"plugins": ["prettier-plugin-tailwindcss"],
6-
"semi": false,
6+
"semi": true,
77
"singleQuote": true,
88
"useTabs": false,
9-
"arrowParens": "avoid",
109
"bracketSpacing": true
1110
}

bun.lockb

6.3 KB
Binary file not shown.

dev/index.html

Lines changed: 0 additions & 18 deletions
This file was deleted.

dev/index.tsx

Lines changed: 0 additions & 6 deletions
This file was deleted.

dev/pages/+Layout.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { FlowProps } from 'solid-js'
2+
import '../styles.css'
3+
4+
export default function Layout(props: FlowProps) {
5+
return <>{props.children}</>
6+
}
Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
import type { Component } from 'solid-js'
2-
3-
import NumberFlow from '../src'
1+
import NumberFlow, { useCanAnimate } from '../../src';
42

53
// @ts-ignore
6-
import Usage from './markdown/usage.md'
4+
import Usage from '../markdown/usage.md';
75
// @ts-ignore
8-
import NPMInstall from './markdown/npm-install.md'
6+
import NPMInstall from '../markdown/npm-install.md';
7+
8+
export default function HomePage() {
9+
const [value, cycle] = useCycle([398.43, -3243.5, 1435237]);
910

10-
const App: Component = () => {
11-
const [value, cycle] = useCycle([398.43, -3243.5, 1435237])
1211
return (
1312
<div class="min-h-screen bg-zinc-950 text-white">
1413
<div class="mx-auto flex w-full max-w-4xl flex-col items-center gap-y-5 px-8 py-20">
@@ -21,7 +20,7 @@ const App: Component = () => {
2120
<button
2221
class="flex items-center gap-x-2 rounded-full bg-neutral-900 px-6 py-3 active:scale-95"
2322
onClick={() => {
24-
cycle()
23+
cycle();
2524
}}
2625
>
2726
<IconShuffle />
@@ -40,46 +39,43 @@ const App: Component = () => {
4039
</a>
4140
</p>
4241

43-
<div class="w-full max-w-xl overflow-hidden rounded-md border border-zinc-500 bg-[#121212] bg-zinc-800 p-5">
42+
<div class="w-full max-w-xl overflow-hidden rounded-md border border-zinc-500 bg-[#121212] p-5">
4443
<Markdown children={<NPMInstall />} />
4544
</div>
4645

47-
<div class="w-full max-w-xl overflow-hidden rounded-md border border-zinc-500 bg-[#121212] bg-zinc-800 p-5">
48-
{/* <SolidMarkdown /> */}
46+
<div class="w-full max-w-xl overflow-hidden rounded-md border border-zinc-500 bg-[#121212] p-5">
4947
<Markdown children={<Usage />} />
5048
</div>
5149
</div>
5250
</div>
53-
)
51+
);
5452
}
5553

56-
export default App
57-
58-
import { createMemo, createSignal } from 'solid-js'
59-
import { IconShuffle } from './icons/shuffle'
60-
import { IconSolidJS } from './icons/solidjs'
61-
import { Markdown } from './markdown'
54+
import { createEffect, createMemo, createSignal } from 'solid-js';
55+
import { IconShuffle } from '../icons/shuffle';
56+
import { IconSolidJS } from '../icons/solidjs';
57+
import { Markdown } from '../markdown';
6258

6359
/**
6460
* A hook that toggles between two or multiple values (by implementing a common state pattern).
6561
*
6662
* Forked from https://github.com/Blankeos/bagon-hooks/blob/main/src/use-toggle/use-toggle.ts
6763
*/
68-
export function useCycle<T = boolean>(options: readonly T[] = [false, true] as any) {
69-
const [_options, _setOptions] = createSignal<typeof options>(options)
64+
function useCycle<T = boolean>(options: readonly T[] = [false, true] as any) {
65+
const [_options, _setOptions] = createSignal<typeof options>(options);
7066

7167
function toggle() {
72-
const value = _options()[0]!
73-
const index = Math.abs(_options()!.indexOf(value))
68+
const value = _options()[0]!;
69+
const index = Math.abs(_options()!.indexOf(value));
7470

7571
_setOptions(
7672
_options()!
7773
.slice(index + 1)
7874
.concat(value),
79-
)
75+
);
8076
}
8177

82-
const currentOption = createMemo(() => _options()[0]!)
78+
const currentOption = createMemo(() => _options()[0]!);
8379

84-
return [currentOption, toggle] as const
80+
return [currentOption, toggle] as const;
8581
}

dev/pages/+config.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import config from 'vike-solid/config';
2+
import type { Config } from 'vike/types';
3+
4+
// Default config (can be overridden by pages)
5+
export default {
6+
extends: [config],
7+
ssr: true,
8+
} satisfies Config;

dev/pages/_error/+Page.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { Show } from "solid-js";
2+
import { usePageContext } from "vike-solid/usePageContext";
3+
4+
export default function Page() {
5+
const { is404 } = usePageContext();
6+
return (
7+
<Show
8+
when={is404}
9+
fallback={
10+
<>
11+
<h1>500 Internal Server Error</h1>
12+
<p>Something went wrong.</p>
13+
</>
14+
}
15+
>
16+
<h1>404 Page Not Found</h1>
17+
<p>This page could not be found.</p>
18+
</Show>
19+
);
20+
}

dev/vite.config.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
import path from 'node:path'
2-
import solidMarkedPlugin from 'unplugin-solid-marked'
3-
import { defineConfig } from 'vite'
4-
import solidPlugin from 'vite-plugin-solid'
1+
import path from 'node:path';
2+
import solidMarkedPlugin from 'unplugin-solid-marked';
3+
import { defineConfig } from 'vite';
4+
5+
// Vike
6+
import vikeSolid from 'vike-solid/vite';
7+
import vike from 'vike/plugin';
58

69
export default defineConfig({
710
resolve: {
@@ -11,12 +14,11 @@ export default defineConfig({
1114
},
1215
plugins: [
1316
solidMarkedPlugin.vite({}),
14-
solidPlugin(),
1517
{
1618
name: 'Reaplace env variables',
1719
transform(code, id) {
1820
if (id.includes('node_modules')) {
19-
return code
21+
return code;
2022
}
2123
return code
2224
.replace(/process\.env\.SSR/g, 'false')
@@ -26,14 +28,16 @@ export default defineConfig({
2628
.replace(/import\.meta\.env\.SSR/g, 'false')
2729
.replace(/import\.meta\.env\.DEV/g, 'true')
2830
.replace(/import\.meta\.env\.PROD/g, 'false')
29-
.replace(/import\.meta\.env\.NODE_ENV/g, '"development"')
31+
.replace(/import\.meta\.env\.NODE_ENV/g, '"development"');
3032
},
3133
},
34+
vike({}),
35+
vikeSolid(),
3236
],
3337
server: {
3438
port: 3000,
3539
},
3640
build: {
3741
target: 'esnext',
3842
},
39-
})
43+
});

package.json

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
"scripts": {
4444
"dev": "vite serve dev",
4545
"build": "tsup",
46+
"build:site": "vite build dev",
4647
"test": "concurrently bun:test:*",
4748
"test:client": "vitest",
4849
"test:ssr": "bun run test:client --mode ssr",
@@ -69,20 +70,22 @@
6970
"esbuild-plugin-solid": "^0.6.0",
7071
"eslint": "^8.56.0",
7172
"eslint-plugin-eslint-comments": "^3.2.0",
72-
"eslint-plugin-no-only-tests": "^3.1.0",
73+
"eslint-plugin-no-only-tests": "^3.3.0",
7374
"jsdom": "^24.0.0",
7475
"postcss": "^8.4.47",
75-
"prettier": "3.0.0",
76+
"prettier": "3.3.3",
7677
"prettier-plugin-tailwindcss": "^0.6.8",
7778
"shikiji": "^0.10.2",
78-
"solid-js": "^1.8.17",
79+
"solid-js": "^1.9.2",
7980
"solid-marked": "^0.6.3",
8081
"tailwindcss": "^3.4.14",
81-
"tsup": "^8.0.2",
82+
"tsup": "^8.3.0",
8283
"tsup-preset-solid": "^2.2.0",
83-
"typescript": "^5.4.5",
84+
"typescript": "^5.6.3",
8485
"unplugin-solid-marked": "^0.6.3",
85-
"vite": "^5.2.11",
86+
"vike": "^0.4.199",
87+
"vike-solid": "^0.7.6",
88+
"vite": "^5.4.9",
8689
"vite-plugin-solid": "^2.10.2",
8790
"vitest": "^1.6.0"
8891
},

0 commit comments

Comments
 (0)