Skip to content

Commit 5fdf3c7

Browse files
authored
Merge pull request #5 from Blankeos/feat/v0.5.3
Feat/v0.5.3
2 parents b5c0118 + 040cd79 commit 5fdf3c7

File tree

14 files changed

+391
-222
lines changed

14 files changed

+391
-222
lines changed

.changeset/orange-singers-glow.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'solid-number-flow': patch
3+
---
4+
5+
chore: Improved linting.

.changeset/two-coins-perform.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'solid-number-flow': minor
3+
---
4+
5+
feat: Upgraded compatibility with v0.5.3 number-flow.

.eslintrc

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

bun.lockb

13.6 KB
Binary file not shown.

dev/components/demos/base-demo.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import {
33
children,
44
ComponentProps,
55
createSignal,
6-
createUniqueId,
76
FlowProps,
87
JSX,
98
mergeProps,
@@ -66,14 +65,16 @@ function Demo(props: FlowProps<Props>) {
6665
const [knowsToClick, setKnowsToClick] = createSignal(false);
6766
const [active, setActive] = createSignal(_props.defaultValue);
6867

69-
const id = createUniqueId();
70-
7168
function handleClick() {
69+
if (!_props.onClick) return;
70+
7271
setKnowsToClick(true);
7372
_props?.onClick?.();
7473
}
7574

7675
const handleMouseDown: JSX.EventHandler<HTMLElement, MouseEvent> = (event) => {
76+
if (!_props.onClick) return;
77+
7778
// Prevent selection of text:
7879
// https://stackoverflow.com/a/43321596
7980
if (event.detail > 1) {
@@ -109,7 +110,7 @@ function Demo(props: FlowProps<Props>) {
109110
style={{ 'border-radius': '999' }}
110111
// layout
111112
// layoutId={`${id}active`}
112-
></div>
113+
/>
113114
</Show>
114115
Preview
115116
</Tabs.Trigger>
@@ -127,7 +128,7 @@ function Demo(props: FlowProps<Props>) {
127128
style={{ 'border-radius': '999' }}
128129
// layout
129130
// layoutId={`${id}active`}
130-
></div>
131+
/>
131132
</Show>
132133
Code
133134
</Tabs.Trigger>
@@ -147,8 +148,8 @@ function Demo(props: FlowProps<Props>) {
147148

148149
<div
149150
class={clsx(_props.minHeight, 'flex flex-col items-center justify-center p-5 pb-6')}
150-
onClick={_props?.onClick && handleClick}
151-
onMouseDown={_props?.onClick && handleMouseDown}
151+
onClick={handleClick}
152+
onMouseDown={handleMouseDown}
152153
>
153154
{_props.children}
154155
{_props?.onClick && (

dev/components/demos/continuous.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,33 @@
11
import Demo, { DemoSwitch, type DemoProps } from 'dev/components/demos/base-demo';
22

33
import { useCycle } from 'dev/hooks/use-cycle';
4+
import { continuous } from 'number-flow';
45
import { createSignal } from 'solid-js';
56
import NumberFlow from 'src';
67

78
const NUMBERS = [120, 140];
89

910
export default function ContinuousDemo(props: Omit<DemoProps, 'children' | 'code'>) {
1011
const [value, cycleValue] = useCycle(NUMBERS);
11-
const [continuous, setContinuous] = createSignal(false);
12+
const [isContinuous, setContinuous] = createSignal(false);
1213

1314
return (
1415
<>
1516
<Demo
1617
{...props}
1718
title={
18-
<DemoSwitch checked={continuous()} onChange={setContinuous}>
19+
<DemoSwitch checked={isContinuous()} onChange={setContinuous}>
1920
<code class="font-semibold">continuous</code>
2021
</DemoSwitch>
2122
}
2223
onClick={cycleValue}
2324
>
2425
<div class="~text-xl/4xl flex items-center gap-4">
2526
<NumberFlow
26-
continuous={continuous()}
2727
style={{ '--number-flow-char-height': '0.85em' }}
2828
value={value()}
2929
class="text-4xl font-semibold"
30+
plugins={isContinuous() ? [continuous] : undefined}
3031
/>
3132
</div>
3233
</Demo>

dev/icons/github.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { FlowProps, JSX, VoidProps } from 'solid-js';
1+
import { JSX, VoidProps } from 'solid-js';
22

33
export function IconGithub(props: VoidProps<JSX.HTMLAttributes<SVGSVGElement>>) {
44
return (

dev/icons/shuffle.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export function IconShuffle(props: VoidProps<JSX.HTMLAttributes<SVGSVGElement>>)
88
clip-rule="evenodd"
99
d="M2.72876 6.42462C3.40596 4.15488 5.51032 2.5 8.00002 2.5C10.0902 2.5 11.9092 3.66566 12.8405 5.38592L13.1975 6.04548L14.5166 5.33138L14.1596 4.67183C12.9767 2.48677 10.6625 1 8.00002 1C5.05453 1 2.53485 2.81872 1.50122 5.39447V3.75V3H0.0012207V3.75V7.17462C0.0012207 7.58883 0.337007 7.92462 0.751221 7.92462H4.17584H4.92584V6.42462H4.17584H2.72876ZM13.2713 9.57538H11.8243H11.0743V8.07538H11.8243H15.2489C15.6631 8.07538 15.9989 8.41117 15.9989 8.82538V12.25V13H14.4989V12.25V10.6053C13.4653 13.1812 10.9456 15 8.00002 15C5.35065 15 3.04619 13.5279 1.85809 11.3605L1.49757 10.7029L2.8129 9.98181L3.17342 10.6395C4.10882 12.3458 5.92017 13.5 8.00002 13.5C10.4897 13.5 12.5941 11.8451 13.2713 9.57538Z"
1010
fill="currentColor"
11-
></path>
11+
/>
1212
</svg>
1313
);
1414
}

dev/pages/test/+Page.tsx

Lines changed: 52 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,59 @@
1+
import { continuous } from 'number-flow';
12
import { createSignal, onMount } from 'solid-js';
3+
// import { NumberFlow } from 'src/NumberFlow';
24
import NumberFlow from 'src';
35

46
export default function Page() {
7+
const [toggle, setToggle] = createSignal(false);
58
const [value1, setValue1] = createSignal(123);
69
const [value2, setValue2] = createSignal(0);
710
const [value3, setValue3] = createSignal(123);
811
const [value4, setValue4] = createSignal(0);
12+
const [value5, setValue5] = createSignal(0);
13+
14+
function triggerChange(useAlternateValues: boolean = false) {
15+
const defaultValues = {
16+
value1: 500,
17+
value2: 1.42,
18+
value3: 500,
19+
value4: 1_500_540,
20+
value5: 88,
21+
};
22+
23+
const alternateValues = {
24+
value1: 100,
25+
value2: 1203,
26+
value3: 7298,
27+
value4: 12.1,
28+
value5: 50,
29+
};
30+
31+
const values = useAlternateValues ? alternateValues : defaultValues;
932

10-
onMount(() => {
1133
setTimeout(() => {
12-
setValue1(500);
34+
setValue1(values.value1);
1335
}, 500);
1436
setTimeout(() => {
15-
setValue2(1.42);
37+
setValue2(values.value2);
1638
}, 800);
1739
setTimeout(() => {
18-
setValue3(7298);
40+
setValue3(values.value3);
1941
}, 1000);
2042
setTimeout(() => {
21-
setValue4(1_500_540);
43+
setValue4(values.value4);
2244
}, 1500);
45+
setTimeout(() => {
46+
setValue5(values.value5);
47+
}, 1500);
48+
}
49+
50+
onMount(() => {
51+
triggerChange();
2352
});
2453

2554
return (
2655
<div class="flex min-h-screen flex-col items-center justify-center gap-y-3 bg-zinc-950 text-white">
27-
<NumberFlow value={value1()} locales="en-US" />
56+
<NumberFlow value={value1()} locales="en-US" plugins={[continuous]} willChange />
2857
<NumberFlow
2958
value={value2()}
3059
locales="en-US"
@@ -40,8 +69,24 @@ export default function Page() {
4069
style: 'currency',
4170
currency: 'USD',
4271
}}
72+
prefix=""
73+
/>
74+
<NumberFlow
75+
value={value5()}
76+
format={{ style: 'currency', currency: 'USD', trailingZeroDisplay: 'stripIfInteger' }}
77+
suffix="/mo"
4378
/>
44-
<a href="/">Back /</a>
79+
80+
<button
81+
onClick={() => {
82+
setToggle(!toggle());
83+
triggerChange(toggle());
84+
}}
85+
>
86+
Change
87+
</button>
88+
89+
<a href="/">Back to Home</a>
4590
</div>
4691
);
4792
}

dev/pages/test/+config.ts

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

0 commit comments

Comments
 (0)