@@ -2,6 +2,8 @@ import {Fragment, useState} from 'react';
22import styled from '@emotion/styled' ;
33import moment from 'moment-timezone' ;
44
5+ import InteractionStateLayer from 'sentry/components/core/interactionStateLayer' ;
6+ import Link from 'sentry/components/links/link' ;
57import { SimpleTable } from 'sentry/components/tables/simpleTable' ;
68import { TimeAgoCell } from 'sentry/components/workflowEngine/gridCell/timeAgoCell' ;
79import { 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 >
0 commit comments