@opentripplanner/from-to-location-picker 1.2.2-alpha.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/index.js DELETED
@@ -1,100 +0,0 @@
1
- import coreUtils from "@opentripplanner/core-utils";
2
- import LocationIcon from "@opentripplanner/location-icon";
3
- import PropTypes from "prop-types";
4
- import React, { Component } from "react";
5
-
6
- import { LocationPickerSpan, Button, FromToPickerSpan } from "./styled";
7
-
8
- const iconSize = "0.9em";
9
-
10
- class FromToLocationPicker extends Component {
11
- onFromClick = () => {
12
- const { location, onFromClick, setLocation } = this.props;
13
- if (onFromClick) {
14
- onFromClick();
15
- return;
16
- }
17
- setLocation({
18
- location,
19
- locationType: "from",
20
- reverseGeocode: false
21
- });
22
- };
23
-
24
- onToClick = () => {
25
- const { location, onToClick, setLocation } = this.props;
26
- if (onToClick) {
27
- onToClick();
28
- return;
29
- }
30
- setLocation({
31
- location,
32
- locationType: "to",
33
- reverseGeocode: false
34
- });
35
- };
36
-
37
- render() {
38
- const { fromText, showIcons, toText } = this.props;
39
- return (
40
- <FromToPickerSpan>
41
- <LocationPickerSpan>
42
- {showIcons && <LocationIcon type="from" size={iconSize} />}
43
- <Button onClick={this.onFromClick}>{fromText}</Button>
44
- </LocationPickerSpan>
45
- <LocationPickerSpan>
46
- {showIcons && <LocationIcon type="to" size={iconSize} />}
47
- <Button onClick={this.onToClick}>{toText}</Button>
48
- </LocationPickerSpan>
49
- </FromToPickerSpan>
50
- );
51
- }
52
- }
53
-
54
- FromToLocationPicker.propTypes = {
55
- /**
56
- * The text to display on the "from" button for setting the origin of a trip.
57
- */
58
- fromText: PropTypes.string,
59
- /**
60
- * A specific location to associate with this. This is only used when combined
61
- * with the setLocation prop.
62
- */
63
- location: coreUtils.types.locationType,
64
- /**
65
- * Triggered when the user clicks on the "from" button.
66
- */
67
- onFromClick: PropTypes.func,
68
- /**
69
- * Triggered when the user clicks on the "to" button.
70
- */
71
- onToClick: PropTypes.func,
72
- /**
73
- * The text to display on the "to" button for setting the destination of a trip.
74
- */
75
- toText: PropTypes.string,
76
- /**
77
- * Triggered when the user clicks either the "from" or "to" button and there
78
- * are no from/to specific handler functions defined as props.
79
- *
80
- * Passes an argument as follows:
81
- * { locationType: "from/to", location, reverseGeocode: false }
82
- */
83
- setLocation: PropTypes.func,
84
- /**
85
- * Determines whether icons are shown on the "from" and "to" buttons.
86
- */
87
- showIcons: PropTypes.bool
88
- };
89
-
90
- FromToLocationPicker.defaultProps = {
91
- fromText: "From here",
92
- location: null,
93
- onFromClick: null,
94
- onToClick: null,
95
- setLocation: null,
96
- showIcons: true,
97
- toText: "To here"
98
- };
99
-
100
- export default FromToLocationPicker;
@@ -1,37 +0,0 @@
1
- import React from "react";
2
- import { action } from "@storybook/addon-actions";
3
-
4
- import FromToLocationPicker from ".";
5
-
6
- import "../__mocks__/trimet-mock.css";
7
-
8
- export default {
9
- title: "From-To-Picker",
10
- component: FromToLocationPicker
11
- };
12
-
13
- const onFromClick = action("onFromClick");
14
- const onToClick = action("onToClick");
15
-
16
- export const fromTo = () => (
17
- <FromToLocationPicker onFromClick={onFromClick} onToClick={onToClick} />
18
- );
19
-
20
- export const smallTextSansSerif = () => (
21
- <span style={{ fontSize: "75%", fontFamily: "sans-serif" }}>
22
- Plan a trip:
23
- <FromToLocationPicker onFromClick={onFromClick} onToClick={onToClick} />
24
- </span>
25
- );
26
-
27
- export const otpAmbientStyle = () => (
28
- <div className="trimet-ambient">
29
- <FromToLocationPicker
30
- fromText="Start here"
31
- toText="Go here"
32
- showIcons={false}
33
- onFromClick={onFromClick}
34
- onToClick={onToClick}
35
- />
36
- </div>
37
- );