playbook_ui 12.4.0.pre.alpha.devdocstest1 → 12.4.0.pre.alpha.map1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3663b6779408f8388e9eaf0cf9f6ff48d0e98e5f6ac6abc11c75c5360b6b5f76
4
- data.tar.gz: 809146bf7a2354e0010a59f6672e36daf0dd547eedf5525dc584abb9c0fa0961
3
+ metadata.gz: cfb56ccfe4d074f937f3852aca075561d3c1bfcc5d17dba3387cd7c83d65e2d3
4
+ data.tar.gz: 782e95a4369e896264d23ed06aa3abd7b51ac4998cf88a0b196964ccdf95c7b5
5
5
  SHA512:
6
- metadata.gz: 30fb6ffcbc0b0b0fe04cd8c5400ffa31ad39756ed9e9eb53a46b464898a9c4cdea4cf6784a9091b4f17b151b1e245672d5a7431ccaa9e02558acd62b5d9d0bc1
7
- data.tar.gz: 71fe5fdce4763e7ef7fe6600a59549bfb2b74532460ef9bb29bcfb99aa8fe5d86de6585a3f44de9fb09827c410477f4e2200ce53b3a91d4614e7db8c4c5644c7
6
+ metadata.gz: e568396ef02503818d31e36846f0bb92c69e0857dd7a7c10b4c8d7de0187cf5adf29c87092f4fc29804efaaa5816e0d08198699843bb6755bedcff83220dd205
7
+ data.tar.gz: 746452d8c6cffee0eec29e9864283b81d6fc63df8218eee2f5ed5c320916026ca63076f7add17ef57b51a1a0e16dbf600d1ae2dfa5e393e2e4c256c675304bc0
@@ -53,6 +53,7 @@ export { default as LabelPill } from './pb_label_pill/_label_pill'
53
53
  export { default as LabelValue } from './pb_label_value/_label_value'
54
54
  export { default as Layout } from './pb_layout/_layout'
55
55
  export { default as Legend } from './pb_legend/_legend'
56
+ export { default as Lightbox } from './pb_lightbox/_lightbox'
56
57
  export { default as LineGraph } from './pb_line_graph/_line_graph'
57
58
  export { default as List } from './pb_list/_list'
58
59
  export { default as ListItem } from './pb_list/_list_item'
@@ -122,4 +123,7 @@ export { default as PbTable } from './pb_table'
122
123
  export { default as PbTextarea } from './pb_textarea'
123
124
  export { default as PbTooltip } from './pb_tooltip'
124
125
  export { default as PbTypeahead } from './pb_typeahead'
125
- export { default as dialogHelper } from './pb_dialog/dialogHelper'
126
+ export { default as dialogHelper } from './pb_dialog/dialogHelper'
127
+
128
+ //Theming
129
+ export {default as mapTheme} from './pb_map/pbMapTheme'
@@ -27,9 +27,9 @@ type ButtonPropTypes = {
27
27
  size?: 'sm' | 'md' | 'lg',
28
28
  text?: string,
29
29
  type?: 'inline' | null,
30
- htmlType: 'submit' | 'reset' | 'button' | undefined,
30
+ htmlType?: 'submit' | 'reset' | 'button' | undefined,
31
31
  value?: string | null,
32
- variant: 'primary' | 'secondary' | 'link',
32
+ variant?: 'primary' | 'secondary' | 'link',
33
33
  wrapperClass?: string,
34
34
  } & GlobalProps
35
35
 
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable jsx-control-statements/jsx-use-if-tag */
2
- import React from 'react'
2
+ import React, { useEffect } from 'react'
3
3
  import Slides from './Slides'
4
4
  import Thumbnails from './Thumbnails'
5
5
 
@@ -24,13 +24,13 @@ export default function Carousel({
24
24
  onChange = ()=>{},
25
25
  setIndex,
26
26
  }: CarouselType): React.ReactElement {
27
- // useEffect(() => {
28
- // document.body.style.overflow = 'hidden'
27
+ useEffect(() => {
28
+ document.body.style.overflow = 'hidden'
29
29
 
30
- // return () => {
31
- // document.body.style.overflow = 'initial'
32
- // }
33
- // }, [])
30
+ return () => {
31
+ document.body.style.overflow = 'initial'
32
+ }
33
+ }, [])
34
34
 
35
35
  const handleChange = (index: number) => {
36
36
  onChange(index)
@@ -1,8 +1,120 @@
1
1
  @import "../tokens/typography";
2
- @import "../tokens/colors";
2
+ @import "../tokens/colors";
3
3
  @import "../tokens/shadows";
4
+ @import "../tokens/border_radius";
4
5
 
5
- .pb_map {
6
+ [class*="pb_map"] {
6
7
  font-family: $font_family_base !important;
7
8
 
9
+ .maplibregl-ctrl-attrib-button {
10
+ &:focus {
11
+ box-shadow: unset;
12
+ }
13
+ &:focus-visible {
14
+ box-shadow: 0 0 0 1px $primary_action;
15
+ }
16
+ &:hover {
17
+ box-shadow: $shadow_deep;
18
+ }
19
+ }
20
+ .custom-nav-control {
21
+ position: absolute;
22
+ right: $space_xs + 2;
23
+ top: $space_xs + 2;
24
+ z-index: 2;
25
+
26
+ .custom-nav-control-zoom {
27
+ border-radius: $border_radius_md;
28
+ box-shadow: $shadow_deep;
29
+ background: $card_light;
30
+ .map-zoom-in-button {
31
+ border-bottom-left-radius: unset;
32
+ border-bottom-right-radius: unset;
33
+ border-bottom: transparent;
34
+ }
35
+ .map-zoom-out-button {
36
+ border-top-left-radius: unset;
37
+ border-top-right-radius: unset;
38
+ }
39
+ }
40
+
41
+ .map-zoom-in-button,
42
+ .map-zoom-out-button,
43
+ .map-flyto-button {
44
+ border: solid 1px $border_light;
45
+ cursor: pointer;
46
+ padding: $space_xs + 2;
47
+ text-align: center;
48
+ color: $text_lt_light;
49
+ background-color: $card_light;
50
+
51
+ display: flex;
52
+ justify-content: center;
53
+ align-items: center;
54
+
55
+ svg {
56
+ width: $space_xs + 4;
57
+ height: $space_sm;
58
+ display: flex;
59
+ }
60
+
61
+ &:hover {
62
+ background-color: darken($bg_light, 2%);
63
+ }
64
+
65
+ &:focus-visible {
66
+ border: solid 1px $primary_action;
67
+ box-shadow: unset;
68
+ }
69
+ }
70
+
71
+ .map-flyto-button {
72
+ border-radius: $border_radius_md;
73
+ margin-top: $space_xs;
74
+ box-shadow: $shadow_deep;
75
+ background-color: $card_light;
76
+ }
77
+ }
78
+
79
+ .maplibregl-popup-content {
80
+ padding: $space_sm;
81
+ background-color: $card_light;
82
+ box-shadow: $shadow_deeper;
83
+ }
84
+
85
+ &.dark {
86
+ .maplibregl-canvas {
87
+ filter: invert(100%) brightness(175%) contrast(80%) sepia(50%) saturate(2)
88
+ hue-rotate(185deg);
89
+ }
90
+
91
+ .pb_section_separator_kit_card_horizontal::after {
92
+ background: $border_dark;
93
+ }
94
+ .custom-nav-control-zoom {
95
+ border: solid 1px #0a0527;
96
+ background: $bg_dark;
97
+ }
98
+
99
+ .maplibregl-popup-content {
100
+ background-color: $bg_dark;
101
+ color: $text_dk_default;
102
+ }
103
+
104
+ .mapboxgl-popup-anchor-bottom .mapboxgl-popup-tip,
105
+ .maplibregl-popup-anchor-bottom .maplibregl-popup-tip {
106
+ border-top-color: $bg_dark;
107
+ }
108
+ .map-zoom-in-button,
109
+ .map-zoom-out-button,
110
+ .map-flyto-button {
111
+ color: $text_dk_default;
112
+ background-color: $bg_dark;
113
+ border-color: $border_dark;
114
+
115
+ &:hover {
116
+ background-color: #221e3d;
117
+ }
118
+ }
119
+ }
8
120
  }
@@ -1,8 +1,11 @@
1
1
  import React from 'react'
2
2
  import classnames from 'classnames'
3
3
  import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
4
- import { globalProps } from '../utilities/globalProps'
4
+ import { globalProps, GlobalProps } from '../utilities/globalProps'
5
5
 
6
+ import Flex from "../pb_flex/_flex"
7
+ import Icon from '../pb_icon/_icon'
8
+ import Button from '../pb_button/_button'
6
9
 
7
10
  type MapProps = {
8
11
  aria?: { [key: string]: string },
@@ -10,7 +13,12 @@ type MapProps = {
10
13
  className?: string,
11
14
  data?: { [key: string]: string },
12
15
  id?: string,
13
- }
16
+ zoomBtns?: boolean,
17
+ flyTo?: boolean,
18
+ zoomInClick?: () => {},
19
+ zoomOutClick?: () => {},
20
+ flyToClick?: () => {},
21
+ } & GlobalProps
14
22
 
15
23
  const Map = (props: MapProps) => {
16
24
  const {
@@ -19,6 +27,11 @@ const Map = (props: MapProps) => {
19
27
  className,
20
28
  data = {},
21
29
  id,
30
+ zoomBtns = false,
31
+ flyTo = false,
32
+ zoomInClick,
33
+ zoomOutClick,
34
+ flyToClick
22
35
  } = props
23
36
 
24
37
  const ariaProps = buildAriaProps(aria)
@@ -32,6 +45,33 @@ const Map = (props: MapProps) => {
32
45
  className={classes}
33
46
  id={id}
34
47
  >
48
+ {
49
+ zoomBtns ? (
50
+ <Flex className="custom-nav-control" orientation='column'>
51
+ <div className="custom-nav-control-zoom">
52
+ <Button className='map-zoom-in-button'
53
+ onClick={zoomInClick}
54
+ >
55
+ <Icon icon="plus"/>
56
+ </Button>
57
+ <Button className='map-zoom-out-button'
58
+ onClick={zoomOutClick}
59
+ >
60
+ <Icon icon="minus"/>
61
+ </Button>
62
+ </div>
63
+ {
64
+ flyTo ? (
65
+ <Button className='map-flyto-button'
66
+ onClick={flyToClick}
67
+ >
68
+ <Icon icon="eye"/>
69
+ </Button>
70
+ ) : null
71
+ }
72
+ </Flex>
73
+ ) : null
74
+ }
35
75
  {children}
36
76
  </div>
37
77
  )
@@ -1,40 +1,64 @@
1
- import React, { useRef, useEffect } from 'react'
1
+ import React, { useRef, useEffect, useState } from 'react'
2
2
  import { Map } from '../../'
3
-
3
+ import "maplibre-gl/dist/maplibre-gl.css"
4
4
  import maplibregl from 'maplibre-gl'
5
+ import mapTheme from '../pbMapTheme'
5
6
 
6
- const MapDefault = () => {
7
+ const MapDefault = (props) => {
7
8
 
9
+ //set Map instance to access from outside useEffect
10
+ const [mapInstance, setMapInstance] = useState(null)
8
11
  const mapContainerRef = useRef(null)
9
12
 
10
- useEffect(() => {
11
- if (!maplibregl.supported()) {
12
- alert('Your browser does not support MapLibre GL');
13
- } else {
14
- const map = new maplibregl.Map({
15
- container: mapContainerRef.current,
16
- style: 'https://basemaps.cartocdn.com/gl/positron-gl-style/style.json',
17
- center: [-75.379143, 39.831200],
18
- zoom: 13,
19
- })
13
+ //Set default position
14
+ const defaultPosition = [-75.379143, 39.831200]
15
+
16
+ // linking Maplibre methods to PB custom zoom in, zoom out, and fly to buttons
17
+ const handleZoomIn = (map) => {map.zoomIn({...mapTheme.zoomConfig})}
18
+ const handleZoomOut = (map) => {map.zoomOut({...mapTheme.zoomConfig})}
19
+ const handleFlyTo = (map) => {map.flyTo({
20
+ center: defaultPosition,
21
+ ... mapTheme.flyToConfig
22
+ });}
23
+
24
+ //This function is called by the useEffect when map instance first loads
25
+ const loadMap = ( { target: map }) => {
20
26
  //set marker/pin
21
- /* eslint-disable-next-line */
22
- const marker = new maplibregl.Marker({
23
- color: "#0056CF",
24
- }).setLngLat([-75.379143, 39.831200])
25
- .setPopup(new maplibregl.Popup({className: 'map_popup', closeButton: false}).setHTML(`<h4 class="pb_title_kit_size_4">Hello World!</h4>`)) // add popup
27
+ new maplibregl.Marker({
28
+ color: mapTheme.marker,
29
+ }).setLngLat(defaultPosition)
30
+ .setPopup(new maplibregl.Popup({closeButton: false}).setHTML(`<h4 class="pb_title_kit_size_4">Hello World!</h4>`)) // add popup
26
31
  .addTo(map);
27
32
 
28
- //add zoom controls
29
- map.addControl(new maplibregl.NavigationControl({showCompass: false}))
30
-
31
33
  // disable map zoom when using scroll
32
34
  map.scrollZoom.disable();
35
+
36
+ //add attributioncontrols
37
+ map.addControl(new maplibregl.AttributionControl({
38
+ compact: true
39
+ }));
40
+
41
+ //set map instance
42
+ setMapInstance(map)
43
+ }
44
+
45
+ useEffect(() => {
46
+ new maplibregl.Map({
47
+ container: mapContainerRef.current,
48
+ center: defaultPosition,
49
+ ...mapTheme.mapConfig
50
+ }).on('load', loadMap)
33
51
 
34
- }
35
52
  }, [])
53
+
36
54
  return (
37
- <Map>
55
+ <Map flyTo
56
+ flyToClick={()=> {handleFlyTo(mapInstance)}}
57
+ zoomBtns
58
+ zoomInClick={() => {handleZoomIn(mapInstance)}}
59
+ zoomOutClick={()=> {handleZoomOut(mapInstance)}}
60
+ {...props}
61
+ >
38
62
  <div
39
63
  ref={mapContainerRef}
40
64
  style={{
@@ -44,7 +68,7 @@ return (
44
68
  top: 0,
45
69
  bottom: 0,
46
70
  }}
47
- />
71
+ />
48
72
  </Map>
49
73
  )
50
74
  }
@@ -2,12 +2,12 @@ This kit provides a wrapping class to place around the MapLibre library. Complet
2
2
 
3
3
  Basic setup to start using MapLibre:
4
4
  - Install the npm package using `yarn add maplibre-gl`
5
- - Include a link to the CSS file as a CDN in your stylesheet using the following syntax:
6
- `@import url("https://unpkg.com/maplibre-gl@2.4.0/dist/maplibre-gl.css");`
7
- or include it as a link in the <head> tag `<link href='https://unpkg.com/maplibre-gl@2.4.0/dist/maplibre-gl.css' rel='stylesheet' />`
5
+ - import the maplibre-gl CSS using `import "maplibre-gl/dist/maplibre-gl.css"` OR include a link to the CSS file as a CDN in your stylesheet using the following syntax: `@import url("https://unpkg.com/maplibre-gl@2.4.0/dist/maplibre-gl.css");`
6
+ OR include it as a link in the <head> tag `<link href='https://unpkg.com/maplibre-gl@2.4.0/dist/maplibre-gl.css' rel='stylesheet' />`
8
7
  - To use Maplibre, you must also set a height on the containing div.
9
8
  - You can now use MapLibre within the Map Kit as shown in this example.
10
9
 
11
10
  __Notes__ :
12
- - The MapLibre Marker allows us to pass it a HEX value as a color prop. In these doc examples we are using our primary color for the Marker.
11
+ - The MapLibre Marker allows us to pass it a HEX value as a color prop but for Playbook styling we recommend importing our `MapTheme` file and passing `mapTheme.marker` to the Marker color prop.
12
+ - To enable custom buttons, set `zoomBtns` and `flyTo` to true and pass in `zoomInClick`, `zoomOutClick` and `flyToClick` as shown in this doc example.
13
13
  - `scrollZoom` has been disabled in these doc examples for page usability
@@ -2,25 +2,19 @@ import React, { useRef, useEffect } from 'react'
2
2
  import { Map } from '../../'
3
3
  import maplibregl from 'maplibre-gl'
4
4
  import MapboxDraw from "@mapbox/mapbox-gl-draw";
5
+ import '@mapbox/mapbox-gl-draw/dist/mapbox-gl-draw.css'
6
+ import mapTheme from '../pbMapTheme'
5
7
 
6
- const MapWithPlugin = () => {
8
+ const MapWithPlugin = (props) => {
7
9
 
8
10
  const mapContainerRef = useRef(null)
9
11
 
10
- useEffect(() => {
11
- if (!maplibregl.supported()) {
12
- alert('Your browser does not support MapLibre GL');
13
- } else {
14
- const map = new maplibregl.Map({
15
- container: mapContainerRef.current,
16
- style: 'https://basemaps.cartocdn.com/gl/positron-gl-style/style.json',
17
- center: [-75.379143, 39.831200],
18
- zoom: 13,
19
- })
12
+ //This function should contain all maplibre related code
13
+ const loadMap = ( { target: map }) => {
20
14
  //set marker/pin
21
15
  /* eslint-disable-next-line */
22
16
  const marker = new maplibregl.Marker({
23
- color: "#0056CF",
17
+ color: mapTheme.marker,
24
18
  }).setLngLat([-75.379143, 39.831200])
25
19
  .setPopup(new maplibregl.Popup({className: 'map_popup', closeButton: false}).setHTML(`<h4 class="pb_title_kit_size_4">Hello World!</h4>`)) // add popup
26
20
  .addTo(map);
@@ -40,13 +34,21 @@ const MapWithPlugin = () => {
40
34
  }
41
35
  });
42
36
  map.addControl(draw);
43
- }
37
+ }
38
+
39
+ useEffect(() => {
40
+ new maplibregl.Map({
41
+ container: mapContainerRef.current,
42
+ style: 'https://basemaps.cartocdn.com/gl/positron-gl-style/style.json',
43
+ center: [-75.379143, 39.831200],
44
+ zoom: 13,
45
+ }).on('load', loadMap)
44
46
  }, [])
45
47
 
46
48
 
47
49
 
48
50
  return (
49
- <Map>
51
+ <Map {...props} >
50
52
  <div
51
53
  ref={mapContainerRef}
52
54
  style={{
@@ -4,4 +4,3 @@ examples:
4
4
  react:
5
5
  - map_default: Default
6
6
  - map_with_plugin: Map With Polygon Draw Plugin
7
-
@@ -0,0 +1,23 @@
1
+ import colors from '../tokens/exports/_colors.scss'
2
+
3
+ const mapTheme = {
4
+ marker : colors.primary_action,
5
+ maptiles: 'https://basemaps.cartocdn.com/gl/positron-gl-style/style.json',
6
+ flyToConfig: {
7
+ zoom: 13,
8
+ bearing: 0,
9
+ curve: 1.42, // change the speed at which it zooms
10
+ easing: function (t: any) {
11
+ return t;
12
+ },
13
+ essential: true
14
+ },
15
+ zoomConfig: { duration:1000 },
16
+ mapConfig: {
17
+ style: 'https://basemaps.cartocdn.com/gl/positron-gl-style/style.json',
18
+ zoom: 13,
19
+ attributionControl: false,
20
+ }
21
+ }
22
+
23
+ export default mapTheme
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Playbook
4
4
  PREVIOUS_VERSION = "12.4.0"
5
- VERSION = "12.4.0.pre.alpha.devdocstest1"
5
+ VERSION = "12.4.0.pre.alpha.map1"
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: playbook_ui
3
3
  version: !ruby/object:Gem::Version
4
- version: 12.4.0.pre.alpha.devdocstest1
4
+ version: 12.4.0.pre.alpha.map1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Power UX
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-02-22 00:00:00.000000000 Z
12
+ date: 2023-02-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: actionpack
@@ -1398,6 +1398,7 @@ files:
1398
1398
  - app/pb_kits/playbook/pb_map/docs/example.yml
1399
1399
  - app/pb_kits/playbook/pb_map/docs/index.js
1400
1400
  - app/pb_kits/playbook/pb_map/map.test.jsx
1401
+ - app/pb_kits/playbook/pb_map/pbMapTheme.ts
1401
1402
  - app/pb_kits/playbook/pb_message/_message.jsx
1402
1403
  - app/pb_kits/playbook/pb_message/_message.scss
1403
1404
  - app/pb_kits/playbook/pb_message/_message_mixins.scss