Skip to content

Commit 46ab8bd

Browse files
committedDec 16, 2024·
Add symbol part for #84 workaround
1 parent e626a3f commit 46ab8bd

File tree

4 files changed

+20
-7
lines changed

4 files changed

+20
-7
lines changed
 

‎.changeset/brown-oranges-beam.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
'number-flow': patch
3+
'@number-flow/react': patch
4+
'@number-flow/svelte': patch
5+
'@number-flow/vue': patch
6+
---
7+
8+
Add symbol part for styling all symbols

‎packages/number-flow/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ class Sym extends Char<KeyedSymbolPart> {
737737
createElement(
738738
'span',
739739
{
740-
part: type,
740+
part: `symbol ${type}`,
741741
className: `symbol`
742742
},
743743
[val]

‎packages/number-flow/src/styles.ts

+10-4
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,9 @@ const styles = css`
7373
display: inline-block;
7474
direction: ltr;
7575
white-space: nowrap;
76-
line-height: ${charHeight} !important;
7776
isolation: isolate; /* for .number z-index */
77+
/* Technically this is only needed on the .number, but applying it here makes the ::selection the same height for the whole element: */
78+
line-height: ${charHeight} !important;
7879
}
7980
8081
.number,
@@ -160,7 +161,6 @@ const styles = css`
160161
*/
161162
content: '\200b'; /* zero-width space */
162163
display: inline-block;
163-
padding: ${halfMaskHeight} 0;
164164
}
165165
166166
.section--justify-left {
@@ -184,12 +184,18 @@ const styles = css`
184184
--c: var(--current) + var(${deltaVar});
185185
}
186186
187+
.digit__num,
188+
.number .section::after {
189+
padding: ${halfMaskHeight} 0;
190+
}
191+
187192
.digit__num {
188193
display: inline-block;
189-
padding: ${halfMaskHeight} 0;
190194
/* Claude + https://buildui.com/recipes/animated-counter */
191195
--offset-raw: mod(var(--length) + var(--n) - mod(var(--c), var(--length)), var(--length));
192-
--offset: calc(var(--offset-raw) - var(--length) * round(down, var(--offset-raw) / (var(--length)/2), 1));
196+
--offset: calc(
197+
var(--offset-raw) - var(--length) * round(down, var(--offset-raw) / (var(--length) / 2), 1)
198+
);
193199
/* Technically we just need var(--offset)*100%, but clamping should reduce the layer size: */
194200
--y: clamp(-100%, var(--offset) * 100%, 100%);
195201
transform: translateY(var(--y));

‎site/src/pages/[...framework]/_Hero.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,7 @@ export default function Hero({ sandbox }: { sandbox: string }) {
8282
/>
8383
</div>
8484
<p className="~text-base/lg prose prose-muted dark:prose-invert text-balance">
85-
An animated number component. Dependency-free. Accessible.
86-
Customizable.
85+
An animated number component. Dependency-free. Accessible. Customizable.
8786
</p>
8887
<div className="~mt-3/5 flex w-full flex-wrap items-stretch justify-center gap-3">
8988
<button

0 commit comments

Comments
 (0)
Please sign in to comment.