Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 | 1x 4x 1x 1x 7x 6x 1x 1x 7x 7x 7x 7x 14x 14x 14x 14x 14x 4x 2x 14x 16x 28x 1x 1x 5x 4x 1x 1x | import React, { Component, Fragment } from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import { Button } from '../buttons/base/example';
import ButtonIcon from '../button-icons';
import SvgIcon from '../../shared/svg-icon';
import RecordDetail from '../form-element/record-detail';
/**
* @name Path - Path container element
* @param {*} props
* @prop {boolean} hasCoaching - set to true if the Path has a Coaching section
* @prop {coachingOpen} - set to true if the Path coaching should display in an open state
*
*/
export const Path = props => (
<div
className={classNames('slds-path', {
'slds-path_has-coaching': props.hasCoaching,
'slds-is-expanded': props.coachingOpen
})}
>
{props.children}
</div>
);
Path.propTypes = {
hasCoaching: PropTypes.bool,
coachingOpen: PropTypes.bool
};
Path.defaultProps = {
hasCoaching: false,
coachingOpen: false
};
/**
* @name PathTrack - Track container for Path Steps
* @param {*} props
* @prop {boolean} hasCaoching - When true, adds the Coaching Button Toggle and preps Path Track for coaching support
* @prop {boolean} coachingOpen - When true, displays the Coaching Button Toggle in an active state
* @prop {boolean} hasOverflow - When true, presents the Path Steps in a scroller wrapper with control buttons
* @prop {string} coachingId - Id of Coaching container element
* @prop {string} stageName - Visible name of the current stage
* @prop {node} actionButtonLabel - Visible content of the Action Button
*/
export const PathTrack = props => {
const {
hasCoaching,
coachingOpen,
hasOverflow,
coachingId,
stageName,
actionButtonLabel
} = props;
return (
<div
className={classNames('slds-grid slds-path__track', {
'slds-has-overflow': hasOverflow
})}
>
<div className="slds-grid slds-path__scroller-container">
{hasCoaching ? (
<ButtonIcon
symbol="chevronright"
theme="neutral"
className={classNames('slds-path__trigger', {
'slds-path__trigger_open': coachingOpen
})}
assistiveText="Show Details"
title="Toggle Sales Coaching"
aria-expanded={coachingOpen}
aria-controls={coachingId}
/>
) : null}
<div className="slds-path__scroller">
<div className="slds-path__scroller_inner">
<ul
className="slds-path__nav"
role="listbox"
aria-orientation="horizontal"
aria-labelledby="slds-path__stage-name"
>
{props.children}
</ul>
{hasOverflow ? (
<div className="slds-path__scroll-controls">
<ButtonIcon
symbol="left"
theme="neutral"
assistiveText="Scroll left"
title="Scroll left"
tabIndex="-1"
/>
<ButtonIcon
symbol="right"
theme="neutral"
assistiveText="Scroll right"
title="Scroll right"
tabIndex="-1"
/>
</div>
) : null}
</div>
</div>
</div>
<div className="slds-grid slds-path__action">
<span id="slds-path__stage-name" className="slds-path__stage-name">Stage: {stageName}</span>
<Button isBrand className="slds-path__mark-complete">
{actionButtonLabel}
</Button>
{hasCoaching ? (
<Button
isNeutral
className="slds-path__trigger-coaching-content"
aria-expanded={coachingOpen}
aria-controls={coachingId}
>
{coachingOpen ? 'Show Less' : 'Show More'}
</Button>
) : null}
</div>
</div>
);
};
PathTrack.propTypes = {
hasCoaching: PropTypes.bool,
coachingOpen: PropTypes.bool,
hasOverflow: PropTypes.bool,
coachingId: PropTypes.string,
stageName: PropTypes.string,
actionButtonLabel: PropTypes.node
};
PathTrack.defaultProps = {
hasCoaching: false,
coachingOpen: false,
hasOverflow: false,
coachingId: '',
stageName: 'Unqualified',
actionButtonLabel: (
<Fragment>
<SvgIcon
className="slds-button__icon slds-button__icon_left"
sprite="utility"
symbol="check"
aria-hidden="true"
/>
Mark Status as Complete
</Fragment>
)
};
/**
* @name PathStep - Individual Path Step
* @param {*} props
* @prop {string} label - Visible label for Path Step
* @prop {array} stepState - Array of states for the current step
* @prop {integer} index - unique index for the step
*/
export class PathStep extends Component {
constructor() {
super();
this.state = {
itemRef: null
};
}
componentDidUpdate(prevProps, prevState) {
const { setTooltipRef } = this.props;
const { itemRef } = this.state;
if (setTooltipRef && itemRef !== prevState.itemRef) {
setTooltipRef(itemRef);
}
}
render() {
const { label, stepState, index } = this.props;
const isActive = stepState.indexOf('active') > -1;
const isComplete = stepState.indexOf('complete') > -1;
const isCurrent = stepState.indexOf('current') > -1;
let stageAssistiveText = null;
if (isComplete) {
stageAssistiveText = 'Stage Complete';
} else if (isCurrent) {
stageAssistiveText = 'Current Stage:';
}
return (
<li
className={classNames(
'slds-path__item',
stepState.map(stateClass => `slds-is-${stateClass}`)
)}
role="presentation"
ref={itemRef => {
if (!this.state.itemRef) this.setState({ itemRef });
}}
>
<a
aria-selected={isActive}
className="slds-path__link"
href="#"
onClick={e => e.preventDefault()}
id={`path-${index}`}
role="option"
tabIndex={isActive ? 0 : -1}
>
<span className="slds-path__stage">
<SvgIcon
className="slds-icon slds-icon_x-small"
sprite="utility"
symbol="check"
/>
{stageAssistiveText ? (
<span className="slds-assistive-text">{stageAssistiveText}</span>
) : null}
</span>
<span className="slds-path__title">{label}</span>
</a>
</li>
);
}
}
PathStep.propTypes = {
label: PropTypes.string,
stepState: PropTypes.arrayOf(PropTypes.string),
index: PropTypes.number
};
PathStep.defaultProps = {
label: 'Undefined',
stepState: ['incomplete'],
index: 0
};
/**
* @name PathCoaching - Example Coaching Section
* @param {*} props
* @prop {string} coachingId - ID attribute for the coaching container.
* @prop {boolean} isHidden - visibility state of the Path Coaching section.
*/
export const PathCoaching = props => {
const { coachingId, isHidden, coachingData, pathGuidance } = props;
return (
<div
className={classNames('slds-path__content', {
'slds-is-collapsed': isHidden
})}
id={coachingId}
>
<div className="slds-path__coach slds-grid">
<div className="slds-path__keys">
<div className="slds-grid slds-grid_align-spread slds-path__coach-title">
<h2>Key Fields This Stage</h2>
<Button className="slds-path__coach-edit slds-text-body_small">
Edit
</Button>
</div>
<RecordDetail
direction="stacked"
snapshot={coachingData}
isViewMode
/>
</div>
<div className="slds-path__guidance">
<h2 className="slds-path__coach-title">Guidance for Success</h2>
<div className="slds-text-longform slds-path__guidance-content">
{pathGuidance}
</div>
</div>
</div>
</div>
);
};
PathCoaching.propTypes = {
coachingId: PropTypes.string,
isHidden: PropTypes.bool,
coachingData: PropTypes.object,
pathGuidance: PropTypes.arrayOf(PropTypes.node)
};
PathCoaching.defaultProps = {
coachingId: null,
isHidden: false,
coachingData: {
rows: [
{
fields: [
{
type: 'text',
label: 'Expected Budget',
value: '$10,000'
}
]
},
{
fields: [
{
type: 'text',
label: 'Lead Source',
value: 'Marketing and Web Referral'
}
]
},
{
fields: [
{
type: 'text',
label: 'Support Engineer',
value: 'Jane Authur'
}
]
}
]
},
pathGuidance: [
<p key="guidance-1">
Regularly cross-sell related products using{' '}
<a href="#" onClick={e => e.preventDefault()}>
cross-sell tactics and principles
</a>
.
</p>,
<p key="guidance-2">
Prepare demo deck using the{' '}
<a href="#" onClick={e => e.preventDefault()}>
latest template
</a>{' '}
and review with Marketing and Sales teams. Review demo copy with Legal and
Doc team.
</p>,
<p key="guidance-3">
Look up{' '}
<a href="#" onClick={e => e.preventDefault()}>
needs analysis principles
</a>{' '}
and review selling plan with Sales Engineer.
</p>
]
};
|