Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/list-touch-hit-area.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@astryxdesign/core': patch
---

[feat] Under a finger (a coarse primary pointer), an interactive `List` row's hit target grows toward 44px where its neighbors leave room: the shared touch hit area measures each row and stops at half the gap to the nearest neighboring row or control. Rows look and lay out exactly as before, and a mouse is unchanged. Under a finger a list row's `::after` is that invisible layer, so decorate a row with a child instead. An `Item` that stops delegating to a nested control now drops its pressable-container marker, so a clickable card around it gets a mouse click in the row's padding again. `InfoTip`'s button takes taps through the same layer: it still grows toward 44px where its neighbors leave room, and waits for motion around it to end before it grows; it clears when it stops taking taps. A labelled `CheckboxInput` and a `RadioListItem` option keep their band's insets through the same hook, so the insets clear when the control stops taking taps.

@vjeux
33 changes: 33 additions & 0 deletions apps/storybook/stories/InfoTip.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import type {Meta, StoryObj} from '@storybook/react';
import {InfoTip} from '@astryxdesign/core/InfoTip';
import {HStack} from '@astryxdesign/core/Layout';
import {List, ListItem} from '@astryxdesign/core/List';
import {Text} from '@astryxdesign/core/Text';

const meta: Meta<typeof InfoTip> = {
Expand Down Expand Up @@ -72,3 +73,35 @@ export const Sizes: Story = {
</div>
),
};

/**
* Info buttons at the end of divided List rows. Under a finger each button
* takes taps out toward 44 px, as anywhere else. The row's divider never
* widens that reach.
*/
export const InADividedList: Story = {
render: () => (
<div style={{maxWidth: 360}}>
<List hasDividers>
<ListItem
label="Rolling average"
endContent={
<InfoTip
content="30-day rolling average, recomputed nightly."
label="About rolling average"
/>
}
/>
<ListItem
label="Peak"
endContent={
<InfoTip
content="The highest daily value this month."
label="About peak"
/>
}
/>
</List>
</div>
),
};
73 changes: 73 additions & 0 deletions apps/storybook/stories/List.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ import type {Meta, StoryObj} from '@storybook/react';
import {List, ListItem} from '@astryxdesign/core/List';
import {Avatar} from '@astryxdesign/core/Avatar';
import {Badge} from '@astryxdesign/core/Badge';
import {Button} from '@astryxdesign/core/Button';
import {Card} from '@astryxdesign/core/Card';
import {Icon} from '@astryxdesign/core/Icon';
import {Switch} from '@astryxdesign/core/Switch';
import {Heading, Text} from '@astryxdesign/core/Text';
import {VStack} from '@astryxdesign/core/Layout';
import {rtlStyles} from '@astryxdesign/core/utils';
import {
Cog6ToothIcon,
BellIcon,
Expand Down Expand Up @@ -257,6 +259,77 @@ export const Links: Story = {
),
};

function EndControlsDemo() {
const [isWifiOn, setIsWifiOn] = useState(true);
return (
// The button after the list sits 4 px below its last row.
<div style={{display: 'flex', flexDirection: 'column', gap: 4}}>
<List
density="compact"
hasDividers
header={
<div
style={{
display: 'flex',
alignItems: 'center',
justifyContent: 'space-between',
}}>
<Text type="label" size="lg">
Connections
</Text>
<Button label="Edit" variant="ghost" size="sm" />
</div>
}>
<ListItem
label="Network"
onClick={() => {}}
endContent={
<Icon icon={ChevronRightIcon} xstyle={rtlStyles.mirror} />
}
swipeActions={{trailing: [{label: 'Forget', onActivate: () => {}}]}}
/>
<ListItem
label="Wi-Fi"
endContent={
<Switch
label="Wi-Fi"
isLabelHidden
value={isWifiOn}
onChange={checked => setIsWifiOn(checked)}
/>
}
/>
<ListItem
label="Bluetooth"
onClick={() => {}}
endContent={
<Icon icon={ChevronRightIcon} xstyle={rtlStyles.mirror} />
}
/>
</List>
<Button label="Load more" variant="secondary" />
</div>
);
}

export const WithEndControls: Story = {
render: () => <EndControlsDemo />,
parameters: {
docs: {
description: {
story:
'A compact row whose end content is its own control, a switch, ' +
'between two interactive rows (the first one swipeable), under a ' +
'header with its own button ' +
'and above a button 4 px after the list. Under a finger, the ' +
'interactive rows grow ' +
'their touch targets only where nothing is near, never into the ' +
"control's row, and a tap on the switch stays the switch's.",
},
},
},
};

export const OrderedList: Story = {
render: args => (
<List listStyle="decimal" {...args}>
Expand Down
Loading
Loading