Skip to content

Commit 97e2a02

Browse files
committed
added useOrdinal to headless
1 parent 27c87c6 commit 97e2a02

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

packages/kit-headless/src/components/carousel/carousel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
useId,
1010
useStylesScoped$,
1111
} from '@builder.io/qwik';
12-
import { useOrdinal } from '@qwik-ui/utils';
12+
import { useOrdinal } from '../../utils/use-ordinal';
1313

1414
import stylesButtons from './styles/buttons.css?inline';
1515
import stylesControl from './styles/control.css?inline';

packages/kit-headless/src/components/slider/slider.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
useSignal,
1010
useVisibleTask$,
1111
} from '@builder.io/qwik';
12-
import { OmitSignalClass } from '@qwik-ui/utils';
1312

1413
export const getPercentage = (value: number, min = 0, max = 100) => {
1514
return ((value - min) * 100) / (max - min);
@@ -25,7 +24,7 @@ interface SliderContextService {
2524

2625
export const sliderContext = createContextId<SliderContextService>('slider');
2726

28-
export type SliderProps = OmitSignalClass<QwikIntrinsicElements['div']> & {
27+
export type SliderProps = QwikIntrinsicElements['div'] & {
2928
value: number;
3029
min: number;
3130
max: number;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { NoSerialize, noSerialize } from '@builder.io/qwik';
2+
3+
export const useOrdinal: () => NoSerialize<(n: number) => string> = () => {
4+
return noSerialize((n) => {
5+
const pr = new Intl.PluralRules('en-GB', { type: 'ordinal' });
6+
const suffixes = new Map([
7+
['one', 'st'],
8+
['two', 'nd'],
9+
['few', 'rd'],
10+
['other', 'th'],
11+
]);
12+
return `${n}${suffixes.get(pr.select(n))}`;
13+
});
14+
};

0 commit comments

Comments
 (0)