Skip to content

Commit 5d2d818

Browse files
authored
Merge pull request #3076 from salesforce-ux/feature/welcome-mat
feat(welcome-mat): add welcome mat component, docs, and tests
2 parents 73989b0 + d8eee45 commit 5d2d818

28 files changed

+7146
-18
lines changed
97.1 KB
Loading
8.59 KB
Loading

test/__tests__/__snapshots__/Welcome_Mat_Base.json

Lines changed: 1408 additions & 0 deletions
Large diffs are not rendered by default.

test/__tests__/__snapshots__/Welcome_Mat_Partially_Completed_Steps.json

Lines changed: 1408 additions & 0 deletions
Large diffs are not rendered by default.

test/__tests__/__snapshots__/Welcome_Mat_Trailhead.json

Lines changed: 1528 additions & 0 deletions
Large diffs are not rendered by default.

test/__tests__/__snapshots__/Welcome_Mat_Trailhead_Complete.json

Lines changed: 1470 additions & 0 deletions
Large diffs are not rendered by default.

ui/components/_index.scss

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,4 +239,8 @@
239239
'regions/base/index',
240240

241241
// Vertical Tabs
242-
'vertical-tabs/base/index';
242+
'vertical-tabs/base/index',
243+
244+
// Welcome Mat
245+
'welcome-mat/base/index',
246+
'welcome-mat/trailhead-connected/index';

ui/components/visual-picker/link/example.jsx

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,37 @@ import { UtilityIcon } from '../../icons/base/example';
1010
// Partial(s)
1111
/// ////////////////////////////////////////
1212

13-
export let VisualPickerMediaObject = props => (
14-
<a
15-
href="javascript:void(0);"
16-
className={classNames(
17-
'slds-box slds-box_link slds-box_x-small slds-media',
18-
props.className
19-
)}
20-
>
21-
<div className="slds-media__figure slds-media__figure_fixed-width slds-align_absolute-center slds-m-left_xx-small">
22-
<UtilityIcon className="slds-icon-text-default" symbol="knowledge_base" />
23-
</div>
24-
<div className="slds-media__body slds-border_left slds-p-around_small">
25-
{props.children}
26-
</div>
27-
</a>
28-
);
13+
export let VisualPickerMediaObject = props => {
14+
const symbol = props.symbol || 'knowledge_base';
15+
const iconContent = props.icon || (
16+
<UtilityIcon className="slds-icon-text-default" symbol={symbol} />
17+
);
18+
19+
return (
20+
<a
21+
href="javascript:void(0);"
22+
className={classNames(
23+
'slds-box slds-box_link slds-box_x-small slds-media',
24+
props.className
25+
)}
26+
>
27+
<div className="slds-media__figure slds-media__figure_fixed-width slds-align_absolute-center slds-m-left_xx-small">
28+
{iconContent}
29+
</div>
30+
<div className="slds-media__body slds-border_left slds-p-around_small">
31+
{props.children}
32+
</div>
33+
</a>
34+
);
35+
};
2936

3037
/// ////////////////////////////////////////
3138
// Export
3239
/// ////////////////////////////////////////
3340

3441
export default (
3542
<div className="demo-only" style={{ width: '24rem' }}>
36-
<VisualPickerMediaObject symbol="user">
43+
<VisualPickerMediaObject symbol="knowledge_base">
3744
<h2
3845
className="slds-truncate slds-text-heading_small"
3946
title="Share the knowledge"
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// Copyright (c) 2015-present, salesforce.com, inc. All rights reserved
2+
// Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license
3+
4+
import React from 'react';
5+
import PropTypes from 'prop-types';
6+
import { ProgressBar } from '../progress-bar/base/example';
7+
8+
class WelcomeMatContent extends React.Component {
9+
render() {
10+
const { complete, total, labelId } = this.props;
11+
const completePercent = complete / total * 100;
12+
13+
return (
14+
<div>
15+
<h2 id={labelId} className="slds-welcome-mat__info-title">
16+
Empower Your Agents with Service Cloud
17+
</h2>
18+
<p className="slds-welcome-mat__info-description">
19+
Your 30-day trial is under way. Learn how easy it is to use and set up
20+
Lightning Service Desk. You'll be your company's service expert by the
21+
time you're done!
22+
</p>
23+
24+
<div className="slds-welcome-mat__info-progress">
25+
<p>
26+
<strong>
27+
{complete}/{total} Walkthroughs completed
28+
</strong>
29+
</p>
30+
</div>
31+
<ProgressBar
32+
value={completePercent}
33+
className="slds-progress-bar_circular"
34+
/>
35+
</div>
36+
);
37+
}
38+
}
39+
40+
WelcomeMatContent.propTypes = {
41+
complete: PropTypes.number.isRequired,
42+
total: PropTypes.number.isRequired,
43+
labelId: PropTypes.string.isRequired
44+
};
45+
46+
WelcomeMatContent.defaultProps = {
47+
complete: 0,
48+
total: 5,
49+
labelId: 'welcome-mat-label-1'
50+
};
51+
52+
export default WelcomeMatContent;
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
// Copyright (c) 2015-present, salesforce.com, inc. All rights reserved
2+
// Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license
3+
4+
import React from 'react';
5+
import classNames from 'classnames';
6+
import PropTypes from 'prop-types';
7+
8+
import { ProgressBar } from '../progress-bar/base/example';
9+
import { Button } from '../buttons/base/example';
10+
import { ActionIcon } from '../icons/action/example';
11+
12+
class WelcomeMatContentTrailhead extends React.Component {
13+
render() {
14+
const { complete, total, labelId } = this.props;
15+
const completePercent = complete / total * 100;
16+
const isComplete = completePercent === 100;
17+
18+
const badgeProgressMessage = isComplete ? (
19+
<p>Cha-ching! You earned the badge.</p>
20+
) : (
21+
<p>
22+
{complete} of {total} modules completed
23+
</p>
24+
);
25+
26+
return (
27+
<div>
28+
<h2 id={labelId} className="slds-welcome-mat__info-title">
29+
Hey there, Trailblazer!
30+
</h2>
31+
<p className="slds-welcome-mat__info-description">
32+
Your 30-day trial is under way. Learn how easy it is to use and set up
33+
Lightning Service Desk. You'll be your company's service expert by the
34+
time you're done!
35+
</p>
36+
37+
<div
38+
className={classNames('slds-welcome-mat__info-progress', {
39+
'slds-welcome-mat__info-progress_complete': isComplete
40+
})}
41+
>
42+
<div className="slds-welcome-mat__info-badge-container">
43+
<img
44+
className="slds-welcome-mat__info-badge"
45+
src="/assets/images/welcome-mat/[email protected]"
46+
width="50"
47+
height="50"
48+
alt=""
49+
/>
50+
<ActionIcon
51+
title="Completed"
52+
assistiveText="Completed"
53+
className="slds-welcome-mat__icon-check slds-icon_xx-small"
54+
symbol="check"
55+
/>
56+
</div>
57+
<p>
58+
<strong>Essentials Explorer</strong>
59+
</p>
60+
{badgeProgressMessage}
61+
</div>
62+
63+
{isComplete ? (
64+
<Button className="slds-button slds-button_brand">
65+
View on your Trailblazer Profile
66+
</Button>
67+
) : (
68+
<ProgressBar
69+
value={completePercent}
70+
className="slds-progress-bar_circular"
71+
/>
72+
)}
73+
</div>
74+
);
75+
}
76+
}
77+
78+
WelcomeMatContentTrailhead.propTypes = {
79+
complete: PropTypes.number.isRequired,
80+
total: PropTypes.number.isRequired,
81+
labelId: PropTypes.string.isRequired
82+
};
83+
84+
WelcomeMatContentTrailhead.defaultProps = {
85+
complete: 0,
86+
total: 5,
87+
labelId: 'welcome-mat-label-1'
88+
};
89+
90+
export default WelcomeMatContentTrailhead;

0 commit comments

Comments
 (0)