Skip to content

Commit 59c44b2

Browse files
committed
add icon to data-table cell
1 parent b7ce522 commit 59c44b2

File tree

2 files changed

+28
-5
lines changed

2 files changed

+28
-5
lines changed

ui/components/data-tables/advanced/example.jsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ const rows = [
3434
stage: 'Value Proposition',
3535
confidence: '30%',
3636
amount: '$25,000,000',
37-
contact: '[email protected]'
37+
contact: '[email protected]',
38+
amountScore: 'positive',
39+
amountScoreLabel: 'High'
3840
},
3941
{
4042
recordName: 'Acme - 200 Widgets',
@@ -52,7 +54,9 @@ const rows = [
5254
stage: 'Id. Decision Makers',
5355
confidence: '70%',
5456
amount: '$25,000',
55-
contact: '[email protected]'
57+
contact: '[email protected]',
58+
amountScore: 'negative',
59+
amountScoreLabel: 'Low'
5660
}
5761
];
5862

@@ -297,8 +301,8 @@ export let examples = [
297301

298302
export let examples = [
299303
{
300-
id: 'header-icon',
301-
label: 'Column Header Icon',
304+
id: 'header-and-cell-icon',
305+
label: 'Header and Cell Icon',
302306
element: (
303307
<Table>
304308
<Thead
@@ -318,6 +322,9 @@ export let examples = [
318322
confidence={rows[i].confidence}
319323
amount={rows[i].amount}
320324
contact={rows[i].contact}
325+
amountScore={rows[i].amountScore}
326+
amountScoreLabel={rows[i].amountScoreLabel}
327+
hasScores
321328
/>
322329
))}
323330
</tbody>

ui/components/data-tables/index.jsx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
} from '../input/base/example';
1414
import MediaObject from '../../utilities/media-objects/index.react';
1515
import { Ellie } from '../dynamic-icons/ellie/example';
16+
import { Score } from '../dynamic-icons/score/example';
1617
import SvgIcon from '../../shared/svg-icon';
1718

1819
export const InlineEditTableContainer = props => (
@@ -257,10 +258,13 @@ export const ErrorsTh = props => (
257258
* @param {*} props
258259
* @prop {boolean} actionableMode - Specifies whether the grid is in actionable or navigation mode
259260
* @prop {boolean} hasFocus - Specifies whether a specific cell is in focus
261+
* @prop {boolean} hasScore - Specifies whether a row has a score cell
260262
* @prop {boolean} rowSelected
261263
* @prop {integer} index - Row index in the Grid
262264
* @prop {string} accountName
263265
* @prop {string} amount
266+
* @prop {string} amountScore
267+
* @prop {string} amountScoreLabel
264268
* @prop {string} className - CSS classes for the tr element
265269
* @prop {string} closeDate
266270
* @prop {string} confidence
@@ -291,7 +295,19 @@ export const AdvancedDataTableTr = props => (
291295
<ReadOnlyTd cellText={props.closeDate} />
292296
<ReadOnlyTd cellText={props.stage} />
293297
<ReadOnlyTd cellText={props.confidence} />
294-
<ReadOnlyTd cellText={props.amount} />
298+
{props.hasScores && props.amountScore && props.amountScoreLabel ? (
299+
<AdvancedDataTableTd>
300+
<div className="slds-grid slds-grid_vertical-align-center">
301+
<div className="slds-truncate">{props.amount}</div>
302+
<div className="slds-icon_container slds-m-left_x-small slds-m-right_xx-small">
303+
<Score data-slds-state={props.amountScore} />
304+
</div>
305+
<div className="slds-truncate">{props.amountScoreLabel}</div>
306+
</div>
307+
</AdvancedDataTableTd>
308+
) : (
309+
<ReadOnlyTd cellText={props.amount} />
310+
)}
295311
<ReadOnlyTd
296312
actionableMode={props.actionableMode}
297313
cellLink="javascript:void(0);"

0 commit comments

Comments
 (0)