Skip to content

Commit c53fc2a

Browse files
committed
feat(lab): PageControl — UIPageControl's indicators, one page per tap
1 parent fadaecc commit c53fc2a

20 files changed

Lines changed: 1181 additions & 0 deletions
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@astryxdesign/cli': patch
3+
---
4+
5+
[feat] `astryx discover` lists the experimental PageControl component from `@astryxdesign/lab`.
6+
7+
@vjeux
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@astryxdesign/core': patch
3+
---
4+
5+
[chore] `@astryxdesign/core/utils` exports `isRtlElement`, core's one writing-direction check, so `@astryxdesign/lab` components read the direction the same way instead of copying it.
6+
7+
@vjeux
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@astryxdesign/core': patch
3+
---
4+
5+
[experimental] The UIKit constants table read through `@astryxdesign/core/motion/experimental` gains `uikit.pageControl`: UIPageControl's measured indicator geometry, height and width cap, default indicator alphas and tap rule, each with its source. Nothing else changes.
6+
7+
@vjeux
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// Copyright (c) Meta Platforms, Inc. and affiliates.
2+
3+
import {useState} from 'react';
4+
import type {Meta, StoryObj} from '@storybook/react';
5+
import * as stylex from '@stylexjs/stylex';
6+
import {PageControl} from '@astryxdesign/lab';
7+
import {
8+
colorVars,
9+
radiusVars,
10+
spacingVars,
11+
typographyVars,
12+
} from '@astryxdesign/core/theme/tokens.stylex';
13+
14+
const styles = stylex.create({
15+
stack: {
16+
display: 'flex',
17+
flexDirection: 'column',
18+
alignItems: 'center',
19+
gap: spacingVars['--spacing-3'],
20+
padding: spacingVars['--spacing-6'],
21+
fontFamily: typographyVars['--font-family-body'],
22+
},
23+
page: {
24+
width: 280,
25+
height: 160,
26+
display: 'grid',
27+
placeItems: 'center',
28+
borderRadius: radiusVars['--radius-element'],
29+
backgroundColor: colorVars['--color-background-muted'],
30+
color: colorVars['--color-text-primary'],
31+
fontSize: 20,
32+
fontWeight: 600,
33+
},
34+
});
35+
36+
const meta: Meta<typeof PageControl> = {
37+
title: 'Lab/PageControl',
38+
component: PageControl,
39+
parameters: {layout: 'centered'},
40+
};
41+
42+
export default meta;
43+
type Story = StoryObj<typeof PageControl>;
44+
45+
function Paged({count, start = 0}: {count: number; start?: number}) {
46+
const [page, setPage] = useState(start);
47+
return (
48+
<div {...stylex.props(styles.stack)}>
49+
<div {...stylex.props(styles.page)} data-testid="page">
50+
Page {page + 1}
51+
</div>
52+
<PageControl count={count} value={page} onChange={setPage} />
53+
</div>
54+
);
55+
}
56+
57+
export const Default: Story = {
58+
render: () => <Paged count={5} start={2} />,
59+
};
60+
61+
export const ManyPages: Story = {
62+
name: 'Many Pages (50)',
63+
render: () => <Paged count={50} start={25} />,
64+
};
65+
66+
export const SinglePageHidden: Story = {
67+
name: 'Single Page (hidesForSinglePage)',
68+
render: () => (
69+
<PageControl count={1} value={0} onChange={() => {}} hidesForSinglePage />
70+
),
71+
};

‎internal/shadcn-registry/routes.lock.json‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,11 @@
625625
"path": "components/lab/mobile-tokenizer",
626626
"aliases": []
627627
},
628+
{
629+
"name": "component-lab-page-control",
630+
"path": "components/lab/page-control",
631+
"aliases": []
632+
},
628633
{
629634
"name": "component-lab-radial-chart",
630635
"path": "components/lab/radial-chart",

‎packages/cli/assets/discover/official-packages.json‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,10 @@
152152
"kind": "component",
153153
"name": "MobileTokenizer"
154154
},
155+
{
156+
"kind": "component",
157+
"name": "PageControl"
158+
},
155159
{
156160
"kind": "component",
157161
"name": "RadialChart"

‎packages/core/src/motion/README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ from the package entry point; components import it by path.
1717
| `uikit/timing.ts` | Non-spring clocks and curves: press highlight, Core Animation's named curves, keyboard, Reduced Motion cross-fade. |
1818
| `uikit/navigation.ts` | UINavigationController: push velocity, parallax, dimming, transition clock, interactive pop finish rule. |
1919
| `uikit/gestures.ts` | Gesture recognizer thresholds, the velocity filter and the haptic stand-ins, as typed entries the gesture system reads. |
20+
| `uikit/pageControl.ts` | UIPageControl: indicator geometry, the control's height and width cap, default indicator alphas, the tap rule. |
2021
| `roles.ts` | Motion roles: each spring, duration and curve of a registered table, named by its path, and its CSS variable. |
2122
| `resolveMotion.ts` | A role's value under an element's theme, read once when a motion starts. |
2223
| `MEASUREMENTS.md` | The UIKit reference captures each unconfirmed value still needs. |

‎packages/core/src/motion/uikit/index.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export {
2929
type SourcedGestureConstant,
3030
} from './gestures';
3131
export {navigation} from './navigation';
32+
export {pageControl} from './pageControl';
3233
export {scroll} from './scroll';
3334
export {springs} from './springs';
3435
export {timing} from './timing';
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
// Copyright (c) Meta Platforms, Inc. and affiliates.
2+
3+
/**
4+
* @file pageControl.ts
5+
* @input Nothing; data only
6+
* @output Exports `pageControl`: UIPageControl's measured geometry, its
7+
* default indicator alphas and its tap rule
8+
* @position The page-control domain of the UIKit constants table
9+
* (motion/uikit); read by the lab PageControl
10+
*
11+
* Every value was read from a stock UIPageControl (default style, default
12+
* tint) on the iOS 26.2 simulator, iPhone 17 Pro: its frames,
13+
* `intrinsicContentSize`, `size(forNumberOfPages:)`, the indicator images'
14+
* rendered pixels, and `valueChanged` under HID touches. Geometry is in
15+
* points.
16+
*
17+
* Every leaf carries one or more `@source`; uikit.test.ts enforces it.
18+
*
19+
* SYNC: When modified, update:
20+
* - /packages/lab/src/PageControl/pageControlModel.ts
21+
* - /packages/core/src/motion/README.md (domain list)
22+
*/
23+
24+
/**
25+
* UIPageControl on iOS 26.
26+
* @experimental
27+
*/
28+
export const pageControl = {
29+
/**
30+
* Diameter of one page indicator.
31+
* @source measured: UIKit lab, iOS 26.2 simulator, iPhone 17 Pro, a
32+
* 5-page control: indicator dots 9.67 pt (2026-10-23)
33+
*/
34+
indicatorSize: 9.67,
35+
/**
36+
* Space between neighbouring indicators.
37+
* @source measured: UIKit lab, iOS 26.2 simulator, iPhone 17 Pro, a
38+
* 5-page control: the indicator strip is 80.3 pt wide, 5 × 9.67 + 4 × 8
39+
* (2026-10-23)
40+
*/
41+
indicatorSpacing: 8,
42+
/**
43+
* Space between the strip and the control's leading and trailing edges.
44+
* @source measured: UIKit lab, iOS 26.2 simulator, iPhone 17 Pro, a
45+
* 5-page control 108.3 pt wide around an 80.3 pt strip (2026-10-23)
46+
*/
47+
horizontalPadding: 14,
48+
/**
49+
* The control's height.
50+
* @source measured: UIKit lab, iOS 26.2 simulator, iPhone 17 Pro,
51+
* intrinsicContentSize 108.3 × 25.67 at 5 pages and 161.3 × 25.67 at 50
52+
* (2026-10-23)
53+
*/
54+
height: 25.67,
55+
/**
56+
* The control is never wider than this, however many pages: past it the
57+
* indicators scroll in a window (size(forNumberOfPages: 50) is 903.3 pt).
58+
* @source measured: UIKit lab, iOS 26.2 simulator, iPhone 17 Pro,
59+
* intrinsicContentSize capped at 161.3 pt wide at 50 pages (2026-10-23)
60+
*/
61+
maxWidth: 161.3,
62+
/**
63+
* Opacity of the current page's indicator, of the indicator colour.
64+
* @source measured: UIKit lab, iOS 26.2 simulator, iPhone 17 Pro, the
65+
* default tint renders the current indicator white α 1 in light and dark
66+
* (#FFFFFF over black) (2026-10-23)
67+
*/
68+
currentIndicatorAlpha: 1,
69+
/**
70+
* Opacity of every other page's indicator, of the indicator colour.
71+
* @source measured: UIKit lab, iOS 26.2 simulator, iPhone 17 Pro, the
72+
* default tint renders the other indicators white α 0.45 in light and
73+
* dark (#737373 over black) (2026-10-23)
74+
*/
75+
otherIndicatorAlpha: 0.45,
76+
/**
77+
* A tap on the trailing side of the current page's indicator moves one
78+
* page forward, on the leading side one back; the change is reported when
79+
* the finger lifts.
80+
* @source measured: UIKit lab, iOS 26.2 simulator, iPhone 17 Pro, HID taps
81+
* on a 5-page control: valueChanged at the lift, about 70–90 ms after the
82+
* touch, one page per tap (2026-10-23)
83+
*/
84+
tapStep: 1,
85+
} as const;

‎packages/core/src/utils/index.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@ export {rtlStyles} from './rtlStyles';
110110
// rtlStyles is: a style that must be identical across packages, not copied.
111111
export {focusOutlineStyles, focusOutlineProps} from './focusOutline.stylex';
112112

113+
// The one writing-direction check (design:bidirectionality DR13), exported
114+
// for @astryxdesign/lab for the same reason: one implementation, not copies.
115+
export {isRtlElement} from '../hooks/isRtlElement';
116+
113117
export {isImeKeyEvent} from './ime';
114118

115119
// The touch press model's one composable: the shared hover and pressed overlay

0 commit comments

Comments
 (0)