Skip to content

Commit 687b978

Browse files
authored
feat(simpleTable): Demo clickable rows, remove internal <InteractionStateLayer /> (#94454)
![Screenshot 2025-06-26 at 10 50 17 AM](https://github.com/user-attachments/assets/6c1b024c-f632-48a4-89e1-3e929727e592)
1 parent de00695 commit 687b978

File tree

2 files changed

+60
-1
lines changed

2 files changed

+60
-1
lines changed

static/app/components/tables/simpleTable/index.stories.tsx

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import {Fragment, useState} from 'react';
22
import styled from '@emotion/styled';
33
import moment from 'moment-timezone';
44

5+
import InteractionStateLayer from 'sentry/components/core/interactionStateLayer';
6+
import Link from 'sentry/components/links/link';
57
import {SimpleTable} from 'sentry/components/tables/simpleTable';
68
import {TimeAgoCell} from 'sentry/components/workflowEngine/gridCell/timeAgoCell';
79
import {t} from 'sentry/locale';
@@ -135,6 +137,64 @@ export default Storybook.story('SimpleTable', story => {
135137
);
136138
});
137139

140+
story('Clickable rows', () => {
141+
return (
142+
<Fragment>
143+
<p>
144+
If you want to make a row clickable then you can wrap it in a{' '}
145+
<Storybook.JSXNode name="Link" /> or a raw <Storybook.JSXNode name="button" />,
146+
but be sure to set <code>display: contents; pointer: cursor;</code> in the css
147+
</p>
148+
<SimpleTableWithColumns>
149+
<SimpleTable.Header>
150+
{headers.map(header => (
151+
<SimpleTable.HeaderCell key={header.key}>
152+
{header.label}
153+
</SimpleTable.HeaderCell>
154+
))}
155+
</SimpleTable.Header>
156+
<SimpleTable.Row>
157+
<Link
158+
to="#"
159+
onClick={e => {
160+
// eslint-disable-next-line no-console
161+
console.log('clicked a link');
162+
e.preventDefault();
163+
}}
164+
style={{display: 'contents', cursor: 'pointer'}}
165+
>
166+
<InteractionStateLayer />
167+
<SimpleTable.RowCell>
168+
Clickable <Storybook.JSXNode name="Link" />
169+
</SimpleTable.RowCell>
170+
<SimpleTable.RowCell>123</SimpleTable.RowCell>
171+
<SimpleTable.RowCell>123</SimpleTable.RowCell>
172+
<SimpleTable.RowCell>123</SimpleTable.RowCell>
173+
</Link>
174+
</SimpleTable.Row>
175+
<SimpleTable.Row>
176+
<button
177+
onClick={e => {
178+
// eslint-disable-next-line no-console
179+
console.log('clicked a button');
180+
e.preventDefault();
181+
}}
182+
style={{display: 'contents', cursor: 'pointer'}}
183+
>
184+
<InteractionStateLayer />
185+
<SimpleTable.RowCell>
186+
Clickable <Storybook.JSXNode name="button" />
187+
</SimpleTable.RowCell>
188+
<SimpleTable.RowCell>123</SimpleTable.RowCell>
189+
<SimpleTable.RowCell>123</SimpleTable.RowCell>
190+
<SimpleTable.RowCell>123</SimpleTable.RowCell>
191+
</button>
192+
</SimpleTable.Row>
193+
</SimpleTableWithColumns>
194+
</Fragment>
195+
);
196+
});
197+
138198
story('Custom widths and hidden columns', () => {
139199
const tableContent = (
140200
<Fragment>

static/app/components/tables/simpleTable/index.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ function HeaderCell({
6969
function Row({children, variant = 'default', ...props}: RowProps) {
7070
return (
7171
<StyledRow variant={variant} role="row" {...props}>
72-
<InteractionStateLayer />
7372
{children}
7473
</StyledRow>
7574
);

0 commit comments

Comments
 (0)