Skip to content

Commit

Permalink
feat: container query layout
Browse files Browse the repository at this point in the history
  • Loading branch information
skinread committed Feb 3, 2025
1 parent 30a0634 commit 6e6545c
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 13 deletions.
6 changes: 6 additions & 0 deletions .changeset/khaki-dragons-remember.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@autoguru/overdrive': minor
---

Introduces DateTimePicker (beta) to help users book a service drop-off time. May
be extended for additional use cases.
7 changes: 2 additions & 5 deletions lib/components/DateTimePicker/CalendarGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type { CalendarState } from 'react-stately';
import { odStyle } from '../../styles/sprinkles.css';
import { dataAttrs } from '../../utils/dataAttrs';

import { styledCell } from './DateTimePicker.css';
import { calendarGridStyle, styledCell } from './DateTimePicker.css';

interface CalendarCellProps extends AriaCalendarCellProps {
state: CalendarState;
Expand Down Expand Up @@ -69,10 +69,7 @@ export const CalendarGrid = ({ state, ...props }: CalendarGridProps) => {
);

return (
<table
{...gridProps}
className={odStyle({ width: { mobile: '100%', tablet: 'auto' } })}
>
<table {...gridProps} className={calendarGridStyle}>
<thead {...headerProps}>
<tr>
{weekDays.map((day, index) => (
Expand Down
28 changes: 28 additions & 0 deletions lib/components/DateTimePicker/DateTimePicker.css.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,35 @@
import { createContainer, style } from '@vanilla-extract/css';
import { recipe } from '@vanilla-extract/recipes';

import { focusOutline } from '../../styles/focusOutline.css';
import { odStyle } from '../../styles/sprinkles.css';
import { tokens } from '../../themes/base/tokens';
import { breakpoints } from '../../themes/makeTheme';

// === Container styles
export const queryContainer = createContainer();
export const queryContainerStyle = style({
containerName: queryContainer,
containerType: 'inline-size',
});

export const layoutStyle = style({
'@container': {
[`${queryContainer} (min-width: ${breakpoints.tablet})`]: {
display: 'flex',
gap: tokens.space[7],
},
},
});

export const calendarGridStyle = style({
width: '100%',
'@container': {
[`${queryContainer} (min-width: ${breakpoints.tablet})`]: {
width: 'auto',
},
},
});

// == Cell styles
export const styledCell = recipe({
Expand Down
9 changes: 3 additions & 6 deletions lib/components/DateTimePicker/DateTimePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {

import { CalendarButton } from './CalendarButton';
import { CalendarGrid } from './CalendarGrid';
import { layoutStyle, queryContainerStyle } from './DateTimePicker.css';

const defaultEnglish = {
dateLabel: 'Date',
Expand Down Expand Up @@ -183,6 +184,7 @@ export const DateTimePicker = <D extends DateValue>({
<div
role="group"
aria-labelledby={titleId}
className={queryContainerStyle}
{...dataAttrs({ 'test-id': testId })}
>
{title && (
Expand All @@ -193,12 +195,7 @@ export const DateTimePicker = <D extends DateValue>({
{title}
</h2>
)}
<div
className={odStyle({
display: { tablet: 'flex' },
gap: '7',
})}
>
<div className={layoutStyle}>
<div className={odStyle({ flexShrink: 0 })}>
<h3
className={odStyle({
Expand Down
4 changes: 2 additions & 2 deletions lib/components/SearchBar/SearchBar.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { expect, fn, within, userEvent } from '@storybook/test';
import { SearchBar } from './SearchBar';

const meta: Meta = {
title: 'Forms & Input Fields/Search Input',
title: 'Forms & Input Fields/Search Bar',
component: SearchBar,
args: {
placeholder: 'Search for tasks',
Expand All @@ -24,7 +24,7 @@ type Story = StoryObj<typeof SearchBar>;

const testPhrase = 'Test search phrase';

export const SearchInput: Story = {
export const TaskSearch: Story = {
play: async ({ args, canvasElement, step }) => {
const canvas = within(canvasElement);
const field = canvas.getAllByRole('searchbox')[0];
Expand Down

0 comments on commit 6e6545c

Please sign in to comment.