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 | 1x 1x 1x 4x 36x 1x 36x 1x 4x 9x 9x 5x 5x | // Copyright (c) 2015-present, salesforce.com, inc. All rights reserved
// Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license
import React, { Component } from 'react';
import { StandardIcon } from '../icons/standard/example';
import {
Modal,
ModalHeader,
ModalContent,
ModalFooter
} from '../modals/base/example';
import classNames from 'classnames';
import { data } from './data';
/**
* Vars
*/
const modalHeadingId = 'modal-heading-id-01';
const modalContentId = 'modal-content-id-01';
/**
* Coordinates List Sub Component
*/
export const CoordinatesList = props => (
<div className="slds-coordinates">
<div className="slds-coordinates__header">
<h2 className="slds-coordinates__title">{props.heading}</h2>
</div>
<ul className="slds-coordinates__list">
{data.map((item, key) => (
<li className="slds-coordinates__item" key={key}>
<span className="slds-assistive-text" aria-live="polite">
{parseInt(props.selection, 0) === key
? item.title + ' is currently selected'
: null}
</span>
<Coordinate
title={item.title}
address={item.address}
selected={parseInt(props.selection, 0) === key}
/>
</li>
))}
</ul>
</div>
);
/**
* Coordinate Item Sub Component
*/
export const Coordinate = props => (
<button
className="slds-coordinates__item-action slds-button_reset slds-media"
aria-pressed={props.selected}
>
<span className="slds-media__figure">
<StandardIcon symbol="account" />
</span>
<span className="slds-media__body">
<span className="slds-text-link">{props.title}</span>
<span>{props.address}</span>
</span>
</button>
);
/**
* Map Footer Sub Component
*/
const MapFooter = () => (
<ModalFooter>
<button className="slds-button slds-button_brand">
Open in Google Maps
</button>
</ModalFooter>
);
/**
* Map
*/
export const GoogleMap = props => {
return (
<div className="slds-map">
{/*
For background, this component blueprint and the actual Lightning component differ in markup. The Lightning component consists of nested iframes that load different HTML files. For our purposes, the markup below works but may require some extra partnering if/when CSS changes are requested.
For any external customers, they can replace this iframe with the map of their choice and are not required to have nested iframes.
*/}
{!props.hideMap && (
<iframe
id="GoogleMapID"
title="Google Maps iframe"
src="https://sfdc-map.surge.sh/"
/>
)}
</div>
);
};
export const MapContainer = props => {
return (
<div
className={classNames(
'slds-grid',
props.multipleCoordinates && 'slds-has-coordinates'
)}
>
<div className="slds-map_container">
<GoogleMap hideMap={props.hideMap} />
</div>
{props.multipleCoordinates && (
<CoordinatesList heading={props.heading} selection={props.selection} />
)}
</div>
);
};
class Map extends Component {
render() {
const {
heading,
multipleCoordinates,
selection,
hideMap,
footer
} = this.props;
return (
<Modal
className="slds-modal_medium"
aria-labelledby={modalHeadingId}
>
<ModalHeader>
<h1
id={modalHeadingId}
className="slds-text-heading_medium slds-hyphenate"
>
{heading}
</h1>
</ModalHeader>
<ModalContent id={modalContentId}>
<MapContainer
multipleCoordinates={multipleCoordinates}
heading={heading}
selection={selection}
hideMap={hideMap}
/>
</ModalContent>
{footer && <MapFooter />}
</Modal>
);
}
}
export default Map;
|