@@ -2,6 +2,8 @@ import {Fragment, useState} from 'react';
2
2
import styled from '@emotion/styled' ;
3
3
import moment from 'moment-timezone' ;
4
4
5
+ import InteractionStateLayer from 'sentry/components/core/interactionStateLayer' ;
6
+ import Link from 'sentry/components/links/link' ;
5
7
import { SimpleTable } from 'sentry/components/tables/simpleTable' ;
6
8
import { TimeAgoCell } from 'sentry/components/workflowEngine/gridCell/timeAgoCell' ;
7
9
import { t } from 'sentry/locale' ;
@@ -135,6 +137,64 @@ export default Storybook.story('SimpleTable', story => {
135
137
) ;
136
138
} ) ;
137
139
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
+
138
198
story ( 'Custom widths and hidden columns' , ( ) => {
139
199
const tableContent = (
140
200
< Fragment >
0 commit comments