Skip to content

Commit cf9fa4b

Browse files
skinreadCopilot
andauthored
feat: DateTimeField beta (#1275)
* chore: renames DateTimePicker to BookingDateTime * wip: draft DateTimeInput * wip: DateTimeInput interaction and styling * refactor: more consistent text default handling, type export * wip: handle default unselected date * wip: DateTimeInput * fix: Calendar fluid layout * feat: adjust date formatting display * wip: DateTimeInput * wip: DateTimeInput * wip: useDateTimeInput hook * wip: DateTimeInput ref forwarding * wip: adds disabled, invalid and loading states to DateTimeInput * chore: disabling lint-staged for now * test: DateTimeInput spec and play function * chore: agent file * refactor: breaking down the DateTimeInput composite into modules * refactor: DateTimeInput into DateSelector child component * feat: allow PopoverTrigger to accept external ref * chore: rename sub-components, tidy up dateFormat * feat: improver interactions in the DateField * feat: extract useCalendarPopover hook for reuse * wip: documenting * fix: DateField states * fix: TimeField value handling, DateTimeInput spec * test: DateTimeInput stories * refactor: DatePicker uses shared hook * chore: renames to DateTimeField * Update lib/components/DateTimeField/DateTimeField.tsx Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update AGENTS.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update AGENTS.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * refactor: minor DatePicker clean up * chore: removed the unused BookingDateTime beta component use Calendar and OptionGrid directly instead * fix: consistent mock date for Calendar visual regression --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 2087e19 commit cf9fa4b

30 files changed

+1438
-771
lines changed

.changeset/bitter-suits-jog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@autoguru/overdrive': minor
3+
---
4+
5+
**DateTimeField** beta: New component available for vertically stacked date and
6+
time selection.

.changeset/ten-mice-dream.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@autoguru/overdrive': patch
3+
---
4+
5+
**Removed**: BookingDateTime beta component as it is unused. Preferred to
6+
combine Calendar with OptionGrid directly.

.husky/pre-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
yarn run format
2-
yarn dlx lint-staged
2+
# yarn dlx lint-staged

AGENTS.md

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
# Overdrive Design System Rules
2+
3+
Rules for building accessible, reusable React components in AutoGuru's design
4+
system. Use MUST/SHOULD/NEVER to guide decisions.
5+
6+
## Architecture
7+
8+
- MUST: Compose from primitives (useBox, Text, FlexStack) rather than creating
9+
new base elements **or** an equivalent styling helper functions listed below
10+
- NEVER: Add new dependencies without approval - use existing dependencies only
11+
- SHOULD: Use React Aria for new components to ensure accessibility
12+
- SHOULD: Extend `TestId` interface for all components to receive `testId` prop
13+
- SHOULD: Set `displayName` on all components for debugging
14+
- SHOULD: Set `odComponent` prop to component name on Box for composite
15+
components
16+
17+
## Styling
18+
19+
- MUST: Use Vanilla Extract CSS-in-TypeScript for all styling
20+
- MUST: Use design tokens from `/lib/themes/theme.css.ts` - no hardcoded values
21+
- MUST: Prefer style functions (`elementStyles`/`sprinkles`/`textStyles`) over
22+
`<Box>` component
23+
- NEVER: Use inline styles or magic numbers
24+
- SHOULD: Use `dataAttrs` helper for state-based styling via data attributes
25+
- SHOULD: Use `sprinkles` function for responsive and utility styles
26+
- SHOULD: Wrap all component styles in `cssLayerComponent` CSS layer
27+
28+
## Development Commands
29+
30+
```bash
31+
yarn test run ComponentName # Run specific component tests
32+
yarn format # Format the project consistently
33+
yarn lint # Run ESLint and TypeScript checks
34+
yarn plop component # Generate new component scaffold
35+
```
36+
37+
### Directory Structure
38+
39+
```
40+
lib/
41+
├── components/ # All UI components
42+
├── hooks/ # Reusable React hooks
43+
├── styles/ # Vanilla Extract styling system
44+
├── themes/ # Design tokens and themes
45+
├── utils/ # Utility functions
46+
└── types/ # TypeScript type definitions
47+
```
48+
49+
## Component Structure
50+
51+
```
52+
lib/components/ComponentName/
53+
├── ComponentName.tsx # Component logic
54+
├── ComponentName.css.ts # Vanilla Extract styles
55+
├── ComponentName.stories.tsx # Storybook stories
56+
├── ComponentName.spec.tsx # Unit tests
57+
└── index.ts # Exports
58+
```
59+
60+
## Props & TypeScript
61+
62+
- MUST: Define comprehensive TypeScript props with JSDoc comments and export
63+
them
64+
- MUST: Prefer extending exisiting interfaces/types, keep names consistent
65+
- MUST: Use kebab-case for prop values that mirror CSS (e.g., `flex-end`)
66+
- NEVER: Use `any` types - use `unknown` or proper types
67+
68+
## Sprinkles Usage
69+
70+
- MUST: Use responsive patterns: arrays `['block', 'flex']` or objects
71+
`{mobile: 'block', tablet: 'flex'}`
72+
- MUST: Use design system breakpoints:
73+
`mobile | tablet | desktop | largeDesktop`
74+
- SHOULD: Use `color` (American) for new design system tokens
75+
- SHOULD: Use `colour` (British) for legacy palette when needed
76+
- SHOULD: Use space tokens (`'1'` to `'9'`) for dimensions and spacing
77+
78+
## Testing & Storybook
79+
80+
- MUST: Create Storybook stories for all components (primary testing method)
81+
- MUST: Use existing top-level categories
82+
- MUST: Use `getAllByRole` and take first item instead of `getByRole` in
83+
Storybook play functions
84+
- MUST: Test 1 story per component: Interaction Test
85+
- MUST: Use semantic queries in tests instead of test IDs
86+
- SHOULD: Create unit tests only for primitives with complex internal logic
87+
- SHOULD: Organise story play functions into smaller tests with `step` funtions
88+
89+
## Quality Standards
90+
91+
- MUST: Use semantic HTML and proper ARIA attributes
92+
- MUST: Fix all ESLint and TypeScript errors before committing
93+
- MUST: Run `yarn lint` and `yarn test:ci` to verify code quality
94+
- NEVER: Leave unused imports, console statements, or missing displayNames
95+
96+
## Accessibility
97+
98+
- MUST: Full keyboard support per
99+
[WAI-ARIA APG](https://www.w3.org/WAI/ARIA/apg/patterns/)
100+
- MUST: Visible focus rings and proper focus management
101+
- MUST: Ensure visible focus indicators with `:focus-visible`
102+
- MUST: Support screen readers with proper ARIA attributes
103+
- MUST: Provide accessible names and hide decorative elements with `aria-hidden`
104+
105+
## Performance
106+
107+
- MUST: Minimise re-renders
108+
- SHOULD: Rely on React 19's automatic compiler optimizations where possible
109+
- SHOULD: Manual optimization only for heavy computations, complex
110+
transformations, and expensive renders

CLAUDE.md

Lines changed: 15 additions & 161 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,17 @@ UI components.
1212

1313
## Common Development Commands
1414

15-
### Development and Testing
16-
17-
- `yarn start` or `yarn storybook` - Start Storybook dev server on port 6006
18-
- `yarn test` - Run unit tests with Vitest
19-
- `yarn test:ci` - Run tests with coverage for CI
20-
- `yarn test:a11y` - Run accessibility tests via Storybook
21-
2215
### Building and Quality Checks
2316

2417
- `yarn build` - Build the library for distribution
25-
- `yarn lint` - Run ESLint and TypeScript checks
26-
- `yarn lint:eslint` - Run ESLint only
27-
- `yarn lint:tsc` - Run TypeScript type checking only
2818
- `yarn format` - Format code with Prettier
19+
- `yarn lint` - Run ESLint and TypeScript checks
20+
21+
### Key Testing Commands
22+
23+
- `yarn test run ComponentName` - Run specific component tests
24+
- `yarn test run ComponentName -u` - Update snapshots if needed
25+
- `yarn test:a11y` - Run accessibility tests via Storybook
2926

3027
### Storybook
3128

@@ -41,160 +38,17 @@ Note: The Vitest configuration uses the modern `test.projects` field in
4138
`vite.config.ts` for workspace configuration, replacing the deprecated
4239
`vitest.workspace.ts` file.
4340

44-
## Architecture and Code Structure
45-
46-
### Directory Structure
47-
48-
```
49-
lib/
50-
├── components/ # All UI components
51-
├── hooks/ # Reusable React hooks
52-
├── styles/ # Vanilla Extract styling system
53-
├── themes/ # Design tokens and themes
54-
├── utils/ # Utility functions
55-
└── types/ # TypeScript type definitions
56-
```
57-
58-
### Component Architecture
59-
60-
Components follow a consistent structure:
61-
62-
```
63-
lib/components/ComponentName/
64-
├── ComponentName.tsx # Component logic
65-
├── ComponentName.css.ts # Vanilla Extract styles
66-
├── ComponentName.stories.tsx # Storybook stories
67-
├── ComponentName.spec.tsx # Unit tests (for internals only)
68-
└── index.ts # Exports
69-
```
41+
## Architecture, Design System Rules, Testing Strategy and Code Quality Standards
7042

71-
### Styling System
43+
Key requirements:
7244

73-
- **Vanilla Extract** for all styling via CSS-in-TypeScript
74-
- **Sprinkles** utility system for consistent spacing, colors, and responsive
75-
design
76-
- **Design tokens** from `/lib/themes/theme.css.ts` must be used for all values
77-
- State-based styling uses data attributes with the `dataAttrs` helper utility
78-
79-
### Component Composition Patterns
80-
81-
- Build from primitives: Box, Text, Icon, Stack, etc.
82-
- All components extend `TestId` to receive `testId` prop
83-
- Composite components set `odComponent` prop to component name on Box
84-
- Use React Aria for interactive components to ensure accessibility
85-
- Components must have `displayName` set
86-
- **Component styles**: `style` function properties should always be wrapped in
87-
the `cssLayerComponent` css layer
88-
89-
## Critical Development Rules
90-
91-
1. **NO new dependencies** - use existing dependencies only
92-
2. **Always use design tokens** from themes - no hardcoded values
93-
3. **Compose from primitives** rather than creating new base elements
94-
4. **Style functions preferred** such as `elementStyles`/`sprinkles` or the
95-
`useBox` hook or in the className, rather than using the <Box> component
96-
5. **Fix all linting/TypeScript errors** in modified files before committing
97-
6. **Set displayName** on all components
98-
7. **Use React Aria** for interactive elements to ensure accessibility
99-
8. **State affects UI via data attributes** managed by `dataAttrs` helper
100-
9. **Storybook play functions** for interaction testings are always organised
101-
using `step` annotations
102-
103-
## Performance Considerations
104-
105-
React 19's compiler handles most memoization automatically. Manual optimization
106-
still needed for:
107-
108-
- Heavy computational functions inside components
109-
- Complex object/array transformations
110-
- Event handlers passed to many children
111-
- Expensive child component renders with stable props
112-
113-
## Testing Strategy
114-
115-
### When to Create Tests
116-
117-
- **Unit tests (.spec.tsx)**: Only for primitives with complex internal logic,
118-
significant state management, or critical accessibility features
119-
- **Storybook stories (.stories.tsx)**: Primary testing method - required for
120-
all components
121-
122-
### Testing Commands
123-
124-
- `yarn test ComponentName` - Run specific component tests
125-
- `yarn test ComponentName -u` - Update snapshots if needed
126-
- `yarn test:a11y` - Run accessibility tests via Storybook
45+
- Fix all ESLint and TypeScript errors before committing
46+
- Use JSDoc comments on props and consistent naming conventions
47+
- No hardcoded values - use design tokens only
12748

128-
### Storybook Stories Requirements
129-
130-
- Focus on user-facing behavior over implementation details
131-
- Aim for ~5 stories per component: Standard, Variants, Interactive States, Edge
132-
Cases, Accessibility
133-
- Use story categories: `Primitives/`, `Layout/`, `Forms/`, `Navigation/`,
134-
`Feedback/`, `Overlays/`, `Data Display/`
135-
- Include play functions for interactive components, and always query with
136-
`getAllbyRole` and take first item in array instead of `getByRole` or any
137-
other variety of get
138-
- Use `composeStories` in spec files instead of testing components directly
139-
- Use `sprinkles` function for styling in stories, never `style` prop
140-
- Use `valueArrays` to populate argTypes, don't add custom `control` or
141-
`description`
142-
143-
### Story Enhancement Patterns
144-
145-
```typescript
146-
// Stories with play functions
147-
import { expect, userEvent, within } from 'storybook/test';
148-
149-
export const Interactive: Story = {
150-
args: {
151-
/* story args */
152-
},
153-
play: async ({ canvasElement }) => {
154-
const canvas = within(canvasElement);
155-
const user = userEvent.setup();
156-
157-
// Test interaction
158-
await user.click(canvas.getByRole('button'));
159-
160-
// Verify result
161-
expect(canvas.getByRole('button')).toHaveAttribute('aria-pressed', 'true');
162-
},
163-
};
164-
```
165-
166-
### Accessibility Testing Requirements
167-
168-
- Keyboard navigation (Tab, Enter, Space, Escape, Arrow keys)
169-
- Screen reader compatibility (proper ARIA attributes)
170-
- Focus management and visual focus indicators
171-
- Color contrast requirements
172-
- Test using semantic queries (`getAllByRole`, `getAllByLabelText`) over test
173-
IDs
174-
175-
### Testing Patterns
176-
177-
- Use `@testing-library/user-event` for interactions
178-
- Prefer decorators over custom render functions in stories
179-
- Test stories first via `composeStories`, then component-specific logic
180-
- Mock external dependencies appropriately
181-
- Use snapshot testing sparingly
182-
183-
## Code Quality Standards
184-
185-
All modified files must be free of:
186-
187-
- ESLint errors
188-
- TypeScript errors
189-
- Unused imports
190-
- Console statements
191-
- Missing displayName on components
192-
- Inline styles (use Vanilla Extract)
193-
- Magic numbers (use design tokens)
194-
- `any` types (use `unknown` or proper types)
195-
196-
Components require JSDoc comments on props and consistent naming conventions
197-
following the existing codebase patterns.
49+
**For complete design system rules, patterns, and best practices, testing
50+
guidelines, accessibility requirements, and Storybook patterns see
51+
[AGENTS.md](./AGENTS.md)**
19852

19953
## Vanilla Extract Sprinkles Reference
20054

lib/components/Calendar/Calendar.css.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,11 @@ export const calendarStyle = style([
2929
export const cellStyle = style([
3030
sprinkles({
3131
alignItems: 'center',
32+
borderRadius: 'md',
3233
display: 'flex',
34+
mx: 'auto',
3335
justifyContent: 'center',
3436
size: '7',
35-
borderRadius: 'md',
3637
}),
3738
{
3839
'@layer': {
@@ -113,7 +114,6 @@ export const thStyle = style({
113114

114115
export const tdStyle = sprinkles({
115116
padding: '1',
116-
textAlign: 'center',
117117
});
118118

119119
// === Heading styles

0 commit comments

Comments
 (0)