Skip to content

Commit 78b474b

Browse files
(Table): update classnames and markups
1 parent 9aea71e commit 78b474b

File tree

1 file changed

+27
-10
lines changed

1 file changed

+27
-10
lines changed

src/scripts/Table.tsx

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export const TableRow: FC<TableRowProps> = (props) => {
102102
}
103103
const rowClassName = classnames(
104104
className,
105-
header ? 'slds-text-title_caps' : 'slds-hint-parent'
105+
header ? 'slds-line-height_reset' : 'slds-hint-parent'
106106
);
107107
const style = selected
108108
? {
@@ -152,7 +152,6 @@ export const TableHeaderColumn: FC<TableHeaderColumnProps> = (props) => {
152152
const sortable = typeof sortable_ === 'undefined' ? rowSortable : sortable_;
153153
const oClassNames = classnames(
154154
className,
155-
'slds-text-title_caps slds-truncate',
156155
{
157156
'slds-is-sortable': sortable,
158157
'slds-is-resizable': resizable,
@@ -165,6 +164,13 @@ export const TableHeaderColumn: FC<TableHeaderColumnProps> = (props) => {
165164

166165
const icon = sortDir === 'DESC' ? 'arrowdown' : 'arrowup';
167166

167+
const content = typeof children === 'string' ? children : undefined;
168+
const cellContent = (
169+
<div className='slds-truncate' title={content}>
170+
{children}
171+
</div>
172+
);
173+
168174
return (
169175
<th {...pprops} className={oClassNames} scope='col' style={style}>
170176
{sortable ? (
@@ -178,11 +184,10 @@ export const TableHeaderColumn: FC<TableHeaderColumnProps> = (props) => {
178184
className='slds-th__action slds-text-link_reset'
179185
>
180186
<span className='slds-assistive-text'>Sort </span>
181-
<span className='slds-truncate'>{children}</span>
187+
{cellContent}
182188
<Icon
183189
className='slds-is-sortable__icon'
184190
textColor='default'
185-
container
186191
size='x-small'
187192
category='utility'
188193
icon={icon}
@@ -195,7 +200,7 @@ export const TableHeaderColumn: FC<TableHeaderColumnProps> = (props) => {
195200
/>
196201
</a>
197202
) : (
198-
children
203+
cellContent
199204
)}
200205
</th>
201206
);
@@ -213,17 +218,29 @@ export type TableRowColumnProps = {
213218
*
214219
*/
215220
export const TableRowColumn: FC<TableRowColumnProps> = (props) => {
216-
const { truncate = true, className, width, children, ...pprops } = props;
217-
const oClassNames = classnames(className, {
218-
'slds-truncate': truncate,
219-
});
221+
const {
222+
truncate = true,
223+
className: oClassNames,
224+
width,
225+
children,
226+
...pprops
227+
} = props;
220228
const style: CSSProperties = {};
221229
if (width !== undefined) style.width = width;
222230
if (!truncate) style.position = 'static';
223231

232+
const content = typeof children === 'string' ? children : undefined;
233+
const cellContent = truncate ? (
234+
<div className='slds-truncate' title={content}>
235+
{children}
236+
</div>
237+
) : (
238+
children
239+
);
240+
224241
return (
225242
<td role='gridcell' style={style} className={oClassNames} {...pprops}>
226-
{children}
243+
{cellContent}
227244
</td>
228245
);
229246
};

0 commit comments

Comments
 (0)