-
Notifications
You must be signed in to change notification settings - Fork 429
/
Copy pathlink.jsx
81 lines (76 loc) · 1.95 KB
/
link.jsx
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
/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */
/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */
// Implements the [Visual Picker Link design pattern](https://lightningdesignsystem.com/components/visual-picker/) in React.
// Based on SLDS v2.4.5
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import { VISUAL_PICKER_LINK } from '../../utilities/constants';
const propTypes = {
/**
* HTML id for component.
*/
id: PropTypes.string,
/**
* CSS classes to be added to tag with `.slds-form-element`. Uses `classNames` [API](https://github.com/JedWatson/classnames).
*/
className: PropTypes.oneOfType([
PropTypes.array,
PropTypes.object,
PropTypes.string,
]),
/**
* URL for the Link
*/
href: PropTypes.string,
/**
* Icon node for the Link
*/
icon: PropTypes.node,
/**
* Title for the Link
*/
title: PropTypes.string,
/**
* Description for the Link
*/
description: PropTypes.string,
};
/**
* Visual Picker Link Component
*/
class VisualPickerLink extends React.Component {
render() {
return (
<a
href={this.props.href}
id={this.props.id}
className={classNames(
'slds-box',
'slds-box_link',
'slds-theme_default',
'slds-box_x-small',
'slds-media',
'slds-visual-picker_vertical',
this.props.className
)}
>
<div className="slds-media__figure slds-media__figure_fixed-width slds-align_absolute-center slds-m-left_xx-small">
{this.props.icon}
</div>
<div className="slds-media__body slds-border_left slds-p-around_small">
<h2
className="slds-truncate slds-text-heading_small"
title={this.props.title}
>
{this.props.title}
</h2>
<p className="slds-m-top_small">{this.props.description}</p>
</div>
</a>
);
}
}
VisualPickerLink.displayName = VISUAL_PICKER_LINK;
VisualPickerLink.propTypes = propTypes;
export default VisualPickerLink;