playbook_ui 10.20.0 → 10.21.0.pre.alpha.lightbox.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/_playbook.scss +1 -0
  3. data/app/pb_kits/playbook/data/menu.yml +1 -0
  4. data/app/pb_kits/playbook/index.js +2 -1
  5. data/app/pb_kits/playbook/pb_avatar/_avatar.jsx +1 -1
  6. data/app/pb_kits/playbook/pb_avatar/_avatar.scss +2 -2
  7. data/app/pb_kits/playbook/pb_avatar/avatar.rb +1 -1
  8. data/app/pb_kits/playbook/pb_avatar/avatar.test.js +1 -1
  9. data/app/pb_kits/playbook/pb_bar_graph/_bar_graph.jsx +4 -0
  10. data/app/pb_kits/playbook/pb_bar_graph/bar_graph.rb +1 -0
  11. data/app/pb_kits/playbook/pb_button/_button.jsx +3 -3
  12. data/app/pb_kits/playbook/pb_button/_button.scss +18 -1
  13. data/app/pb_kits/playbook/pb_button/button.rb +11 -3
  14. data/app/pb_kits/playbook/pb_button/button.test.js +13 -0
  15. data/app/pb_kits/playbook/pb_button/docs/_button_size.html.erb +3 -0
  16. data/app/pb_kits/playbook/pb_button/docs/_button_size.jsx +26 -0
  17. data/app/pb_kits/playbook/pb_button/docs/_button_size.md +1 -0
  18. data/app/pb_kits/playbook/pb_button/docs/example.yml +2 -0
  19. data/app/pb_kits/playbook/pb_button/docs/index.js +1 -0
  20. data/app/pb_kits/playbook/pb_circle_chart/_circle_chart.jsx +3 -0
  21. data/app/pb_kits/playbook/pb_circle_chart/circle_chart.rb +1 -0
  22. data/app/pb_kits/playbook/pb_dashboard/pbChartsDarkTheme.js +215 -0
  23. data/app/pb_kits/playbook/pb_file_upload/_file_upload.jsx +17 -10
  24. data/app/pb_kits/playbook/pb_file_upload/fileupload.test.js +40 -0
  25. data/app/pb_kits/playbook/pb_gauge/_gauge.jsx +3 -0
  26. data/app/pb_kits/playbook/pb_gauge/gauge.rb +1 -0
  27. data/app/pb_kits/playbook/pb_image/_image.jsx +1 -1
  28. data/app/pb_kits/playbook/pb_image/_image.scss +3 -3
  29. data/app/pb_kits/playbook/pb_image/image.rb +1 -1
  30. data/app/pb_kits/playbook/pb_image/image.test.js +1 -1
  31. data/app/pb_kits/playbook/pb_lightbox/Carousel/Slide.jsx +53 -0
  32. data/app/pb_kits/playbook/pb_lightbox/Carousel/Slides.jsx +53 -0
  33. data/app/pb_kits/playbook/pb_lightbox/Carousel/Thumbnail.jsx +38 -0
  34. data/app/pb_kits/playbook/pb_lightbox/Carousel/Thumbnails.jsx +78 -0
  35. data/app/pb_kits/playbook/pb_lightbox/Carousel/index.jsx +58 -0
  36. data/app/pb_kits/playbook/pb_lightbox/Carousel/useSlides.js +66 -0
  37. data/app/pb_kits/playbook/pb_lightbox/_lightbox.jsx +112 -0
  38. data/app/pb_kits/playbook/pb_lightbox/_lightbox_context.jsx +3 -0
  39. data/app/pb_kits/playbook/pb_lightbox/_lightbox_header.jsx +71 -0
  40. data/app/pb_kits/playbook/pb_lightbox/_lightbox_header_icon.jsx +26 -0
  41. data/app/pb_kits/playbook/pb_lightbox/docs/_lightbox_compound_component.jsx +95 -0
  42. data/app/pb_kits/playbook/pb_lightbox/docs/_lightbox_default.jsx +64 -0
  43. data/app/pb_kits/playbook/pb_lightbox/docs/_lightbox_default.md +1 -0
  44. data/app/pb_kits/playbook/pb_lightbox/docs/_lightbox_multiple.jsx +64 -0
  45. data/app/pb_kits/playbook/pb_lightbox/docs/example.yml +7 -0
  46. data/app/pb_kits/playbook/pb_lightbox/docs/index.js +3 -0
  47. data/app/pb_kits/playbook/pb_lightbox/hooks/useVisibility.js +21 -0
  48. data/app/pb_kits/playbook/pb_lightbox/hooks/useWindowSize.js +25 -0
  49. data/app/pb_kits/playbook/pb_lightbox/lightbox.scss +202 -0
  50. data/app/pb_kits/playbook/pb_lightbox/lightbox.test.jsx +30 -0
  51. data/app/pb_kits/playbook/pb_line_graph/_line_graph.jsx +4 -0
  52. data/app/pb_kits/playbook/pb_line_graph/line_graph.rb +1 -0
  53. data/app/pb_kits/playbook/pb_popover/_popover.jsx +2 -4
  54. data/app/pb_kits/playbook/pb_popover/docs/_popover_close.html.erb +7 -7
  55. data/app/pb_kits/playbook/pb_popover/index.js +4 -9
  56. data/app/pb_kits/playbook/pb_popover/popover.html.erb +1 -1
  57. data/app/pb_kits/playbook/pb_rich_text_editor/_rich_text_editor.jsx +4 -0
  58. data/app/pb_kits/playbook/pb_text_input/_text_input.scss +2 -2
  59. data/app/pb_kits/playbook/pb_text_input/text_input.test.js +14 -0
  60. data/app/pb_kits/playbook/playbook-doc.js +2 -0
  61. data/app/pb_kits/playbook/plugins/pb_chart.js +8 -4
  62. data/lib/playbook/version.rb +1 -1
  63. metadata +29 -4
@@ -0,0 +1,95 @@
1
+ /* @flow */
2
+ /* eslint-disable jsx-control-statements/jsx-use-if-tag */
3
+ import React, { useState } from 'react'
4
+ import { Caption, Flex, FlexItem, Image, Title } from '../../'
5
+ import Lightbox from '../_lightbox'
6
+
7
+ const LightboxCompoundComponent = (props) => {
8
+ const photos = [
9
+ 'https://images.unsplash.com/photo-1638727228877-d2a79ab75e68?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2668&q=80',
10
+ 'https://images.unsplash.com/photo-1501045337096-542a73dafa4f?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2052&q=80',
11
+ 'https://images.unsplash.com/photo-1563693998336-93c10e5d8f91?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1470&q=80,',
12
+ ]
13
+ const [selectedPhoto, setSelectedPhoto] = useState(photos[0])
14
+ const [showLightbox, toggleShowLightbox] = useState(false)
15
+
16
+ const handleCloseLightbox = () => {
17
+ toggleShowLightbox(!showLightbox)
18
+ setSelectedPhoto(null)
19
+ }
20
+
21
+ const onPhotoClick = (photo) => {
22
+ toggleShowLightbox(!showLightbox)
23
+ setSelectedPhoto(photo)
24
+ }
25
+
26
+ return (
27
+ <>
28
+ <div>
29
+ {showLightbox ? (
30
+ <Lightbox
31
+ icon="times"
32
+ iconSize="2x"
33
+ initialPhoto={selectedPhoto}
34
+ onClose={handleCloseLightbox}
35
+ photos={photos}
36
+ {...props}
37
+ >
38
+ <Lightbox.Header>
39
+ <FlexItem flex={5}>
40
+ <Flex justify="center">
41
+ <Flex
42
+ align="center"
43
+ orientation="column"
44
+ >
45
+ <Title
46
+ dark
47
+ paddingBottom="xs"
48
+ size={4}
49
+ text="Windows, Sidings, & Gutters"
50
+ />
51
+
52
+ <Caption dark>{'Dyamic Count goes here.'}</Caption>
53
+ </Flex>
54
+ </Flex>
55
+ </FlexItem>
56
+ <FlexItem flex={1}>
57
+ <Flex justify="end">
58
+ <Title
59
+ dark
60
+ size={4}
61
+ text="All Photos"
62
+ />
63
+ </Flex>
64
+ </FlexItem>
65
+ </Lightbox.Header>
66
+ </Lightbox>
67
+ ) : (
68
+ <div className="PhotoViewer">
69
+ <Flex>
70
+ {photos.map((photo, index) => {
71
+ return (
72
+ <div
73
+ key={photo[index]}
74
+ onClick={() => onPhotoClick(photo)}
75
+ >
76
+ <Image
77
+ marginRight="xl"
78
+ rounded
79
+ size="lg"
80
+ url={photo}
81
+ />
82
+
83
+ <div className="overlay" />
84
+ </div>
85
+ )
86
+ })}
87
+ </Flex>
88
+ </div>
89
+ )}
90
+ </div>
91
+ </>
92
+ )
93
+ }
94
+
95
+ export default LightboxCompoundComponent
@@ -0,0 +1,64 @@
1
+ /* @flow */
2
+ /* eslint-disable jsx-control-statements/jsx-use-if-tag */
3
+ import React, { useState } from 'react'
4
+ import { Flex, Image } from '../../'
5
+ import Lightbox from '../_lightbox'
6
+
7
+ const LightboxDefault = (props) => {
8
+ const photos = [
9
+ 'https://images.unsplash.com/photo-1638727228877-d2a79ab75e68?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2668&q=80',
10
+ ]
11
+ const [selectedPhoto, setSelectedPhoto] = useState(photos[0])
12
+ const [showLightbox, toggleShowLightbox] = useState(false)
13
+
14
+ const handleCloseLightbox = () => {
15
+ toggleShowLightbox(!showLightbox)
16
+ setSelectedPhoto(null)
17
+ }
18
+
19
+ const onPhotoClick = (photo) => {
20
+ toggleShowLightbox(!showLightbox)
21
+ setSelectedPhoto(photo)
22
+ }
23
+
24
+ return (
25
+ <>
26
+ <div>
27
+ {showLightbox ? (
28
+ <Lightbox
29
+ icon="times"
30
+ iconSize="2x"
31
+ initialPhoto={selectedPhoto}
32
+ onClose={handleCloseLightbox}
33
+ photos={photos}
34
+ {...props}
35
+ />
36
+ ) : (
37
+ <div className="PhotoViewer">
38
+ <Flex>
39
+ {photos.map((photo, index) => {
40
+ return (
41
+ <div
42
+ key={photo[index]}
43
+ onClick={() => onPhotoClick(photo)}
44
+ >
45
+ <Image
46
+ marginRight="xl"
47
+ rounded
48
+ size="lg"
49
+ url={photo}
50
+ />
51
+
52
+ <div className="overlay" />
53
+ </div>
54
+ )
55
+ })}
56
+ </Flex>
57
+ </div>
58
+ )}
59
+ </div>
60
+ </>
61
+ )
62
+ }
63
+
64
+ export default LightboxDefault
@@ -0,0 +1 @@
1
+ Lightbox contains 5 props: `photos` (an array of urls), `initialPhoto` (a number ), an `onClose` callback function, an `icon` prop that matches to our `Icon` kit, and an `iconSize` prop that also corresponds to our icon kit.
@@ -0,0 +1,64 @@
1
+ /* @flow */
2
+ /* eslint-disable jsx-control-statements/jsx-use-if-tag */
3
+ import React, { useState } from 'react'
4
+ import { Flex, Image } from '../../'
5
+ import Lightbox from '../_lightbox.jsx'
6
+
7
+ const LightboxMultiple = (props) => {
8
+ const photos = [
9
+ 'https://images.unsplash.com/photo-1638727228877-d2a79ab75e68?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2668&q=80',
10
+ 'https://images.unsplash.com/photo-1526657782461-9fe13402a841?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1984&q=80',
11
+ 'https://images.unsplash.com/photo-1523057530100-383d7fbc77a1?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2669&q=80',
12
+ ]
13
+ const [selectedPhoto, setSelectedPhoto] = useState(photos[0])
14
+ const [light, toggleLight] = useState(false)
15
+
16
+ const handleCloseLightbox = () => {
17
+ toggleLight(!light)
18
+ setSelectedPhoto(null)
19
+ }
20
+
21
+ const onPhotoClick = (photo) => {
22
+ toggleLight(!light)
23
+ setSelectedPhoto(photo)
24
+ }
25
+
26
+ return (
27
+ <div>
28
+ {light ? (
29
+ <Lightbox
30
+ icon="times"
31
+ iconSize="2x"
32
+ initialPhoto={selectedPhoto}
33
+ onClose={handleCloseLightbox}
34
+ photos={photos}
35
+ {...props}
36
+ />
37
+ ) : (
38
+ <div className="PhotoViewer">
39
+ <Flex>
40
+ {photos.map((photo, index) => {
41
+ return (
42
+ <div
43
+ key={photos[index]}
44
+ onClick={() => onPhotoClick(photo)}
45
+ >
46
+ <Image
47
+ marginRight="xl"
48
+ rounded
49
+ size="lg"
50
+ url={photo}
51
+ />
52
+
53
+ <div className="overlay" />
54
+ </div>
55
+ )
56
+ })}
57
+ </Flex>
58
+ </div>
59
+ )}
60
+ </div>
61
+ )
62
+ }
63
+
64
+ export default LightboxMultiple
@@ -0,0 +1,7 @@
1
+ examples:
2
+
3
+ react:
4
+ - lightbox_default: Default
5
+ - lightbox_multiple: Multiple
6
+ - lightbox_compound_component: Compound Component
7
+
@@ -0,0 +1,3 @@
1
+ export { default as LightboxDefault } from './_lightbox_default.jsx'
2
+ export { default as LightboxMultiple } from './_lightbox_multiple.jsx'
3
+ export { default as LightboxCompoundComponent } from './_lightbox_compound_component.jsx'
@@ -0,0 +1,21 @@
1
+ import { debounce } from 'lodash'
2
+ import { useCallback, useMemo, useState } from 'react'
3
+
4
+ export default function useVisibility(initialState = false) {
5
+ const [visible, setVisible] = useState(initialState)
6
+ const hide = useCallback(() => setVisible(false), [])
7
+ const show = useCallback(({ afterDelay = 0 } = {}) => {
8
+ debounce(() => setVisible(true), afterDelay)()
9
+ }, [])
10
+ const toggle = useCallback(() => setVisible((current) => !current), [])
11
+
12
+ return useMemo(
13
+ () => ({
14
+ hide,
15
+ show,
16
+ toggle,
17
+ visible,
18
+ }),
19
+ [hide, show, toggle, visible]
20
+ )
21
+ }
@@ -0,0 +1,25 @@
1
+ import { useEffect, useState } from 'react'
2
+
3
+ export const useWindowSize = () => {
4
+ const [size, setSize] = useState({
5
+ width: window.innerWidth,
6
+ height: window.innerHeight,
7
+ })
8
+
9
+ useEffect(() => {
10
+ const handleResize = () => {
11
+ setSize({
12
+ width: window.innerWidth,
13
+ height: window.innerHeight,
14
+ })
15
+ }
16
+
17
+ window.addEventListener('resize', handleResize)
18
+
19
+ handleResize()
20
+
21
+ return () => window.removeEventListener('resize', handleResize)
22
+ }, [])
23
+
24
+ return size
25
+ }
@@ -0,0 +1,202 @@
1
+ @import "../tokens/spacing";
2
+
3
+ .carousel {
4
+ .home-tour-main-content {
5
+ overflow-y: hidden;
6
+ }
7
+
8
+ .image-gallery-slide-wrapper {
9
+ width: 1024px;
10
+ height: 686px;
11
+ }
12
+
13
+ .image-gallery-slide div {
14
+ height: auto;
15
+ }
16
+
17
+ .image-gallery-slide .image-gallery-image {
18
+ max-height: 100% !important;
19
+ max-width: 100% !important;
20
+ height: 692px !important;
21
+ width: 100% !important;
22
+ object-fit: cover;
23
+ }
24
+
25
+ .image-gallery-left-nav .image-gallery-svg, .image-gallery-right-nav .image-gallery-svg {
26
+ height: 120px;
27
+ width: 30px;
28
+ opacity: 0.4;
29
+ }
30
+ .image-gallery-thumbnails {
31
+ overflow-x: auto;
32
+ }
33
+
34
+ .image-gallery-thumbnails-container {
35
+ width: 1024px;
36
+ padding-left: 4px;
37
+ }
38
+
39
+ .image-gallery-thumbnails {
40
+ padding-top: 3px;
41
+ background: #000;
42
+ }
43
+
44
+ .image-gallery-thumbnail-image {
45
+ height: 64px;
46
+ width: 93px;
47
+ }
48
+
49
+ .image-gallery-thumbnail + .image-gallery-thumbnail {
50
+ margin-left: 2px;
51
+ margin-top: 2px;
52
+ }
53
+
54
+ .carousel-header {
55
+ background: rgb(0, 0, 0);
56
+ border-radius: 0px;
57
+ min-height: 51px;
58
+ width: 100%;
59
+ position: fixed;
60
+ top: 0;
61
+ left: 0;
62
+ z-index: 2;
63
+ align-items: center;
64
+ padding: $space-sm;
65
+ transition: all .5s;
66
+
67
+ .close-icon {
68
+ color: white;
69
+ margin-left: 16px;
70
+ top: 16px;
71
+ }
72
+ }
73
+ }
74
+
75
+ .photo-cards {
76
+ .overlay {
77
+ width: 100% !important;
78
+ height: 50% !important;
79
+ bottom: 0;
80
+ position: absolute !important;
81
+ border-radius: 0px 0px 5px 5px;
82
+ background: linear-gradient(-180deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.77) 100%);
83
+ }
84
+
85
+ .overlay,
86
+ .overlay ~ .key-photo-icon,
87
+ .overlay ~ .tag-counter {
88
+ pointer-events: none;
89
+ }
90
+ }
91
+
92
+
93
+ .Lightbox {
94
+ width: 100vw;
95
+ height: 100vh;
96
+ position: fixed;
97
+ left: 0;
98
+ top: 0;
99
+ display: flex;
100
+ align-items: center;
101
+ flex-direction: column;
102
+ background-color: black;
103
+ z-index: 1;
104
+ overflow: hidden;
105
+ }
106
+
107
+ .Slides {
108
+ display: flex;
109
+ flex-grow: 1;
110
+ height: calc(100% - 100px);
111
+ width: 100%;
112
+ z-index: 1;
113
+
114
+ [class^="react-transform-wrapper"] {
115
+ flex-shrink: 0;
116
+ width: 100%;
117
+ height: 100%;
118
+ }
119
+
120
+ [class^="react-transform-content"] {
121
+ width: 100%;
122
+ height: 100%;
123
+ }
124
+ }
125
+
126
+ .Slide,
127
+ .Thumbnail {
128
+ flex-shrink: 0;
129
+ border: none;
130
+ margin: 0;
131
+ padding: 0;
132
+ cursor: pointer;
133
+ background-color: transparent;
134
+ }
135
+
136
+ .Slide {
137
+ display: flex;
138
+ justify-content: center;
139
+ align-items: center;
140
+ width: 100%;
141
+ height: 100%;
142
+ overflow: hidden;
143
+
144
+ img {
145
+ width: 100vw;
146
+ height: 100vh;
147
+ object-fit: contain;
148
+ }
149
+ }
150
+
151
+ .BackBtn,
152
+ .NextBtn {
153
+ z-index: 2;
154
+ color: black;
155
+ position: absolute;
156
+ width: 50px;
157
+ height: 50px;
158
+ top: calc(50vh - 5px);
159
+ border: none;
160
+ border-radius: 50%;
161
+ background-color: white;
162
+ }
163
+
164
+ .BackBtn::before,
165
+ .NextBtn::before {
166
+ content: "▸";
167
+ }
168
+
169
+ .BackBtn {
170
+ left: 30px;
171
+ transform: rotate(180deg);
172
+ }
173
+
174
+ .NextBtn {
175
+ right: 30px;
176
+ }
177
+
178
+ .Thumbnails {
179
+ display: flex;
180
+ padding: 3px;
181
+ }
182
+
183
+ .Thumbnails.draggable {
184
+ align-self: flex-start;
185
+ }
186
+
187
+ .Thumbnail {
188
+ padding: 3px;
189
+ height: 100%;
190
+
191
+ img {
192
+ width: 100%;
193
+ height: 100%;
194
+ }
195
+ }
196
+
197
+ .Thumbnail.active {
198
+ padding: 6px;
199
+ background-color: white;
200
+ box-shadow: 0 0 6px white;
201
+ }
202
+
@@ -0,0 +1,30 @@
1
+ import React from 'react'
2
+ import { render, screen } from '../utilities/test-utils'
3
+
4
+ import { Lightbox } from '../'
5
+
6
+ const testId = 'customId',
7
+ kitClass = 'pb_lightbox_kit'
8
+
9
+ test('Lightbox Test', () => {
10
+ render(
11
+ <Lightbox
12
+ className="customClass"
13
+ data={{ testid: testId }}
14
+ icon="close"
15
+ iconSize="3x"
16
+ id="test1"
17
+ initialPhoto="https://images.unsplash.com/photo-1518791841217-8f162f1e1131?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=60"
18
+ onClose={() => {}}
19
+ photos={[
20
+ 'https://images.unsplash.com/photo-1518791841217-8f162f1e1131?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=60',
21
+ 'https://images.unsplash.com/photo-1518791841217-8f162f1e1131?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=60',
22
+ 'https://images.unsplash.com/photo-1518791841217-8f162f1e1131?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=60',
23
+ 'https://images.unsplash.com/photo-1518791841217-8f162f1e1131?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=60',
24
+ ]}
25
+ />
26
+ )
27
+ const kit = screen.getByTestId(testId)
28
+ expect(kit).toHaveClass(`${kitClass} customClass`)
29
+ expect(kit).toBeInTheDocument()
30
+ })
@@ -8,6 +8,7 @@ import pbChart from '../plugins/pb_chart'
8
8
 
9
9
  type LineGraphProps = {
10
10
  axisTitle?: string,
11
+ dark?: Boolean,
11
12
  xAxisCategories: array,
12
13
  yAxisMin: number,
13
14
  yAxisMax: number,
@@ -31,6 +32,7 @@ type LineGraphProps = {
31
32
  export default class LineGraph extends React.Component<LineGraphProps> {
32
33
  static defaultProps = {
33
34
  className: 'pb_bar_graph',
35
+ dark: false,
34
36
  gradient: false,
35
37
  type: 'line',
36
38
  legend: false,
@@ -40,6 +42,7 @@ export default class LineGraph extends React.Component<LineGraphProps> {
40
42
  componentDidMount() {
41
43
  const {
42
44
  axisTitle,
45
+ dark,
43
46
  xAxisCategories,
44
47
  yAxisMin,
45
48
  yAxisMax,
@@ -60,6 +63,7 @@ export default class LineGraph extends React.Component<LineGraphProps> {
60
63
  axisTitle: axisTitle,
61
64
  chartData: chartData,
62
65
  colors: colors,
66
+ dark,
63
67
  id: id,
64
68
  pointStart: pointStart,
65
69
  subtitle: subTitle,
@@ -32,6 +32,7 @@ module Playbook
32
32
  id: id,
33
33
  className: classname,
34
34
  chartData: chart_data,
35
+ dark: dark ? "dark" : "",
35
36
  type: chart_type,
36
37
  title: title,
37
38
  subtitle: subtitle,
@@ -150,16 +150,14 @@ export default class PbReactPopover extends React.Component<PbPopoverProps> {
150
150
  const targetIsReference =
151
151
  target.closest('.pb_popover_reference_wrapper') !== null
152
152
 
153
- if (targetIsReference) return
154
-
155
153
  switch (closeOnClick) {
156
154
  case 'outside':
157
- if (!targetIsPopover) {
155
+ if (!targetIsPopover || targetIsReference) {
158
156
  shouldClosePopover(true)
159
157
  }
160
158
  break
161
159
  case 'inside':
162
- if (targetIsPopover) {
160
+ if (targetIsPopover || targetIsReference) {
163
161
  shouldClosePopover(true)
164
162
  }
165
163
  break
@@ -1,23 +1,23 @@
1
1
  <%= pb_rails("flex", props: {classname: "flex-container", spacing: "between"}) do %>
2
2
  <span>
3
- <%= pb_rails("button", props: { text: "Click Inside", variant: "secondary", id: 'inside-popover-1' }) %>
3
+ <%= pb_rails("button", props: { text: "Click Inside", variant: "secondary", id: "inside-popover-1" }) %>
4
4
  <%= pb_rails("popover", props: {
5
5
  close_on_click: "inside",
6
6
  trigger_element_id: "inside-popover-1",
7
7
  tooltip_id: "inside-tooltip-1",
8
- position: 'bottom',
8
+ position: "bottom",
9
9
  offset: true
10
10
  }) do %>
11
11
  Click on me!
12
12
  <% end %>
13
13
  </span>
14
14
  <span>
15
- <%= pb_rails("button", props: { text: "Click Outside", variant: "secondary", id: 'outside-popover-1' }) %>
15
+ <%= pb_rails("button", props: { text: "Click Outside", variant: "secondary", id: "outside-popover-1" }) %>
16
16
  <%= pb_rails("popover", props: {
17
17
  close_on_click: "outside",
18
18
  trigger_element_id: "outside-popover-1",
19
19
  tooltip_id: "outside-tooltip-1",
20
- position: 'left',
20
+ position: "left",
21
21
  offset: true
22
22
  }) do %>
23
23
  Click anywhere but me!
@@ -27,16 +27,16 @@
27
27
  <%= pb_rails("button", props: {
28
28
  text: "Click Anywhere",
29
29
  variant: "secondary",
30
- id: 'any-popover-1'
30
+ id: "any-popover-1"
31
31
  }) %>
32
32
  <%= pb_rails("popover", props: {
33
33
  close_on_click: "any",
34
34
  trigger_element_id: "any-popover-1",
35
35
  tooltip_id: "any-tooltip-1",
36
- position: 'top',
36
+ position: "top",
37
37
  offset: true
38
38
  }) do %>
39
39
  Click anything!
40
40
  <% end %>
41
41
  </span>
42
- <% end %>
42
+ <% end %>
@@ -36,15 +36,14 @@ export default class PbPopover extends PbEnhancedElement {
36
36
  }
37
37
 
38
38
  setTimeout(() => {
39
- this.popper.update()
40
39
  this.toggleTooltip()
40
+ this.popper.update()
41
41
  }, 0)
42
42
  })
43
43
  }
44
44
 
45
45
  checkCloseTooltip() {
46
46
  document.querySelector('body').addEventListener('click', ({ target }) => {
47
- const isTriggerElement = target.closest(`#${this.triggerElementId}`) !== null
48
47
  const isTooltipElement = target.closest(`#${this.tooltipId}`) !== null
49
48
 
50
49
  switch (this.closeOnClick) {
@@ -52,21 +51,17 @@ export default class PbPopover extends PbEnhancedElement {
52
51
  this.hideTooltip()
53
52
  break
54
53
  case 'outside':
55
- if (isTooltipElement) {
56
- this.checkCloseTooltip()
57
- } else {
54
+ if (!isTooltipElement) {
58
55
  this.hideTooltip()
59
56
  }
60
57
  break
61
58
  case 'inside':
62
- if (isTooltipElement || isTriggerElement) {
59
+ if (isTooltipElement) {
63
60
  this.hideTooltip()
64
- } else {
65
- this.checkCloseTooltip()
66
61
  }
67
62
  break
68
63
  }
69
- }, { once: true })
64
+ }, true)
70
65
  }
71
66
 
72
67
  hideTooltip() {
@@ -3,7 +3,7 @@
3
3
  class: object.classname,
4
4
  data: object.data,
5
5
  id: object.id) do %>
6
- <div class="pb_popover_tooltip" id="<%= object.tooltip_id %>" role="tooltip" style="<%= object.z_index_helper %>">
6
+ <div class="pb_popover_tooltip hide" id="<%= object.tooltip_id %>" role="tooltip" style="<%= object.z_index_helper %>">
7
7
  <div class="pb_popover_body <%= object.width_height_class_helper %> <%= object.popover_spacing_helper %>" style="<%= object.width_height_helper %>">
8
8
  <%= content.presence %>
9
9
  </div>