playbook_ui 10.19.0.pre.lightbox → 10.19.0.pre.popover.alpha1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/_playbook.scss +0 -1
  3. data/app/pb_kits/playbook/data/menu.yml +0 -1
  4. data/app/pb_kits/playbook/index.js +1 -2
  5. data/app/pb_kits/playbook/pb_button/_button.jsx +3 -3
  6. data/app/pb_kits/playbook/pb_button/_button.scss +17 -0
  7. data/app/pb_kits/playbook/pb_button/button.rb +6 -3
  8. data/app/pb_kits/playbook/pb_button/button.test.js +13 -0
  9. data/app/pb_kits/playbook/pb_button/docs/_button_size.html.erb +3 -0
  10. data/app/pb_kits/playbook/pb_button/docs/_button_size.jsx +26 -0
  11. data/app/pb_kits/playbook/pb_button/docs/_button_size.md +1 -0
  12. data/app/pb_kits/playbook/pb_button/docs/example.yml +2 -0
  13. data/app/pb_kits/playbook/pb_button/docs/index.js +1 -0
  14. data/app/pb_kits/playbook/pb_popover/_popover.jsx +2 -4
  15. data/app/pb_kits/playbook/pb_popover/docs/_popover_close.html.erb +7 -7
  16. data/app/pb_kits/playbook/pb_popover/index.js +4 -9
  17. data/app/pb_kits/playbook/pb_popover/popover.html.erb +1 -1
  18. data/app/pb_kits/playbook/pb_text_input/_text_input.scss +3 -3
  19. data/app/pb_kits/playbook/pb_title/title.html.erb +3 -2
  20. data/app/pb_kits/playbook/playbook-doc.js +0 -2
  21. data/lib/playbook/version.rb +1 -1
  22. metadata +5 -21
  23. data/app/pb_kits/playbook/pb_lightbox/Carousel/Slide.jsx +0 -53
  24. data/app/pb_kits/playbook/pb_lightbox/Carousel/Slides.jsx +0 -54
  25. data/app/pb_kits/playbook/pb_lightbox/Carousel/Thumbnail.jsx +0 -39
  26. data/app/pb_kits/playbook/pb_lightbox/Carousel/Thumbnails.jsx +0 -82
  27. data/app/pb_kits/playbook/pb_lightbox/Carousel/index.jsx +0 -54
  28. data/app/pb_kits/playbook/pb_lightbox/Carousel/styles.scss +0 -110
  29. data/app/pb_kits/playbook/pb_lightbox/Carousel/useSlides.js +0 -66
  30. data/app/pb_kits/playbook/pb_lightbox/Carousel/useUnscrollableBody.js +0 -11
  31. data/app/pb_kits/playbook/pb_lightbox/_lightbox.jsx +0 -81
  32. data/app/pb_kits/playbook/pb_lightbox/docs/_lightbox_default.jsx +0 -65
  33. data/app/pb_kits/playbook/pb_lightbox/docs/_lightbox_default.md +0 -1
  34. data/app/pb_kits/playbook/pb_lightbox/docs/_lightbox_multiple.jsx +0 -65
  35. data/app/pb_kits/playbook/pb_lightbox/docs/example.yml +0 -6
  36. data/app/pb_kits/playbook/pb_lightbox/docs/index.js +0 -2
  37. data/app/pb_kits/playbook/pb_lightbox/hooks/useToggler.js +0 -10
  38. data/app/pb_kits/playbook/pb_lightbox/hooks/useVisibility.js +0 -21
  39. data/app/pb_kits/playbook/pb_lightbox/hooks/useWindowSize.js +0 -25
  40. data/app/pb_kits/playbook/pb_lightbox/lightbox.scss +0 -92
  41. data/app/pb_kits/playbook/pb_lightbox/lightbox.test.jsx +0 -30
@@ -1,54 +0,0 @@
1
- /* eslint-disable jsx-control-statements/jsx-use-if-tag */
2
- /* @flow */
3
-
4
- import { noop } from 'lodash'
5
- import React, { useState } from 'react'
6
-
7
- import Slides from './Slides'
8
- import Thumbnails from './Thumbnails'
9
- import useUnscrollableBody from './useUnscrollableBody'
10
-
11
- import styles from './styles.scss'
12
-
13
- type CarouselType = {
14
- initialPhoto: string,
15
- onClose: Function,
16
- icon: string,
17
- iconSize: number,
18
- current: number,
19
- photos: Array<string>,
20
- onChange: (index: number) => void,
21
- onClick: (index: number) => void,
22
- }
23
-
24
- export default function Carousel({
25
- current = 0,
26
- photos,
27
- onClick = noop,
28
- onChange = noop,
29
- }: CarouselType) {
30
- useUnscrollableBody()
31
- const [currentIndex, setCurrentIndex] = useState(current)
32
- const handleChange = (index) => {
33
- setCurrentIndex(index)
34
- onChange(index)
35
- }
36
-
37
- return (
38
- <div className={styles.Lightbox}>
39
- <Slides
40
- current={currentIndex}
41
- onChange={handleChange}
42
- onClick={onClick}
43
- urls={photos.map((photo) => photo.url)}
44
- />
45
- {photos.length > 1 ? (
46
- <Thumbnails
47
- current={currentIndex}
48
- onChange={handleChange}
49
- urls={photos.map((photo) => photo.thumbnail)}
50
- />
51
- ) : null}
52
- </div>
53
- )
54
- }
@@ -1,110 +0,0 @@
1
- .Lightbox {
2
- width: 100vw;
3
- height: 100vh;
4
- position: fixed;
5
- left: 0;
6
- top: 0;
7
- display: flex;
8
- align-items: center;
9
- flex-direction: column;
10
- background-color: black;
11
- z-index: 1;
12
- overflow: hidden;
13
- }
14
-
15
- .Slides {
16
- display: flex;
17
- flex-grow: 1;
18
- height: calc(100% - 100px);
19
- width: 100%;
20
- z-index: 1;
21
-
22
- [class^="react-transform-wrapper"] {
23
- flex-shrink: 0;
24
- width: 100%;
25
- height: 100%;
26
- }
27
-
28
- [class^="react-transform-content"] {
29
- width: 100%;
30
- height: 100%;
31
- }
32
- }
33
-
34
- .Slide,
35
- .Thumbnail {
36
- flex-shrink: 0;
37
- border: none;
38
- margin: 0;
39
- padding: 0;
40
- cursor: pointer;
41
- background-color: transparent;
42
- }
43
-
44
- .Slide {
45
- display: flex;
46
- justify-content: center;
47
- align-items: center;
48
- width: 100%;
49
- height: 100%;
50
- overflow: hidden;
51
-
52
- img {
53
- width: 100vw;
54
- height: 100vh;
55
- object-fit: contain;
56
- }
57
- }
58
-
59
- .BackBtn,
60
- .NextBtn {
61
- z-index: 2;
62
- color: black;
63
- position: absolute;
64
- width: 50px;
65
- height: 50px;
66
- top: calc(50vh - 5px);
67
- border: none;
68
- border-radius: 50%;
69
- background-color: white;
70
- }
71
-
72
- .BackBtn::before,
73
- .NextBtn::before {
74
- content: "▸";
75
- }
76
-
77
- .BackBtn {
78
- left: 30px;
79
- transform: rotate(180deg);
80
- }
81
-
82
- .NextBtn {
83
- right: 30px;
84
- }
85
-
86
- .Thumbnails {
87
- display: flex;
88
- padding: 3px;
89
- }
90
-
91
- .Thumbnails.draggable {
92
- align-self: flex-start;
93
- }
94
-
95
- .Thumbnail {
96
- padding: 3px;
97
- height: 100%;
98
-
99
- img {
100
- width: 100%;
101
- height: 100%;
102
- }
103
- }
104
-
105
- .Thumbnail.active {
106
- padding: 6px;
107
- background-color: white;
108
- box-shadow: 0 0 6px white;
109
- }
110
-
@@ -1,66 +0,0 @@
1
- // @flow
2
-
3
- import { noop } from 'lodash'
4
- import { useEffect, useState } from 'react'
5
- import { useAnimation } from 'framer-motion/dist/framer-motion'
6
- import { useWindowSize } from '../hooks/useWindowSize'
7
-
8
- const cycleIndex = (current: number, min: number, max: number): number => {
9
- if (current < min) return max
10
- if (current > max) return min
11
- return current
12
- }
13
-
14
- const swipeConfidenceThreshold = 10000
15
- const swipePower = (offset: number, velocity: number) => {
16
- return Math.abs(offset) * velocity
17
- }
18
-
19
- export default function useSlides({
20
- current = 0,
21
- pagesCount = 0,
22
- onChange = noop,
23
- }) {
24
- const controls = useAnimation()
25
- const viewportSize = useWindowSize()
26
- const [currentIndex, setCurrentIndex] = useState(current)
27
- const dragConstraints = {
28
- left: -viewportSize.width * (pagesCount - 1),
29
- right: 0,
30
- }
31
-
32
- const paginate = (newDirection: number) => {
33
- const nextIndex = currentIndex + newDirection
34
- const cycledNextIndex = cycleIndex(nextIndex, 0, pagesCount - 1)
35
- setCurrentIndex(cycledNextIndex)
36
- return cycledNextIndex
37
- }
38
-
39
- const handleDragEnd = (e, { offset, velocity }) => {
40
- let nextIndex = currentIndex
41
- const swipe = swipePower(offset.x, velocity.x)
42
-
43
- if (swipe < -swipeConfidenceThreshold) {
44
- nextIndex = paginate(1)
45
- } else if (swipe > swipeConfidenceThreshold) {
46
- nextIndex = paginate(-1)
47
- }
48
-
49
- controls.start({ x: -viewportSize.width * nextIndex })
50
-
51
- if (nextIndex !== currentIndex) {
52
- onChange(nextIndex)
53
- }
54
- }
55
-
56
- useEffect(() => {
57
- controls.set({ x: -viewportSize.width * current })
58
- setCurrentIndex(current)
59
- }, [controls, current, viewportSize.width])
60
-
61
- return {
62
- controls,
63
- dragConstraints,
64
- handleDragEnd,
65
- }
66
- }
@@ -1,11 +0,0 @@
1
- import { useEffect } from 'react'
2
-
3
- export default function useUnscrollableBody() {
4
- useEffect(() => {
5
- document.body.style.overflow = 'hidden'
6
-
7
- return () => {
8
- document.body.style.overflow = 'initial'
9
- }
10
- }, [])
11
- }
@@ -1,81 +0,0 @@
1
- /* eslint-disable no-unused-vars */
2
- /* @flow */
3
-
4
- import React, { useState } from 'react'
5
- import classnames from 'classnames'
6
- import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props.js'
7
- import { globalProps } from '../utilities/globalProps.js'
8
- import Icon from '../pb_icon/_icon'
9
-
10
- import Carousel from './Carousel/index.jsx'
11
-
12
- type LightboxType = {
13
- aria?: object,
14
- className?: string,
15
- data?: object,
16
- id?: string,
17
- photos: [],
18
- initialPhoto: string,
19
- onClose: Function,
20
- icon: string,
21
- iconSize: number,
22
- }
23
-
24
- const Lightbox = (props: LightboxType) => {
25
- const {
26
- aria = {},
27
- className,
28
- data = {},
29
- id = '',
30
- photos,
31
- initialPhoto,
32
- onClose,
33
- icon,
34
- iconSize,
35
- } = props
36
- const [activePhoto, setActivePhoto] = useState(initialPhoto)
37
-
38
- const ariaProps = buildAriaProps(aria)
39
- const dataProps = buildDataProps(data)
40
- const classes = classnames(
41
- buildCss('pb_lightbox_kit'),
42
- globalProps(props),
43
- className
44
- )
45
- const handleOnSlide = (index) => {
46
- setActivePhoto(photos[index])
47
- }
48
- return (
49
- <div
50
- {...ariaProps}
51
- {...dataProps}
52
- className={classes}
53
- id={id}
54
- >
55
- <div className="carousel">
56
- <div className="carousel-header">
57
- <div
58
- className="close-icon"
59
- onClick={onClose}
60
- >
61
- <Icon
62
- icon={icon}
63
- size={iconSize}
64
- />
65
- </div>
66
- <div className="active-photo-overlay" />
67
- </div>
68
- <Carousel
69
- current={photos.indexOf(initialPhoto)}
70
- onChange={handleOnSlide}
71
- photos={photos.map((photo) => ({
72
- url: photo,
73
- thumbnail: photo,
74
- }))}
75
- />
76
- </div>
77
- </div>
78
- )
79
- }
80
-
81
- export default Lightbox
@@ -1,65 +0,0 @@
1
- /* @flow */
2
- /* eslint-disable jsx-control-statements/jsx-use-if-tag */
3
- import React, { useState } from 'react'
4
- import { useToggler } from '../hooks/useToggler.js'
5
- import { Flex, Image } from '../../'
6
- import Lightbox from '../_lightbox'
7
-
8
- const LightboxDefault = (props) => {
9
- const photos = [
10
- 'https://images.unsplash.com/photo-1638727228877-d2a79ab75e68?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2668&q=80',
11
- ]
12
- const [selectedPhoto, setSelectedPhoto] = useState(photos[0])
13
- const [showLightbox, toggleShowLightbox] = useToggler()
14
-
15
- const handleCloseLightbox = () => {
16
- toggleShowLightbox()
17
- setSelectedPhoto(null)
18
- }
19
-
20
- const onPhotoClick = (photo) => {
21
- toggleShowLightbox()
22
- setSelectedPhoto(photo)
23
- }
24
-
25
- return (
26
- <>
27
- <div>
28
- {showLightbox ? (
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={photo[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
-
65
- export default LightboxDefault
@@ -1 +0,0 @@
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.
@@ -1,65 +0,0 @@
1
- /* @flow */
2
- /* eslint-disable jsx-control-statements/jsx-use-if-tag */
3
- import React, { useState } from 'react'
4
- import { useToggler } from '../hooks/useToggler.js'
5
- import { Flex, Image } from '../../'
6
- import Lightbox from '../_lightbox.jsx'
7
-
8
- const LightboxMultiple = (props) => {
9
- const photos = [
10
- 'https://images.unsplash.com/photo-1638727228877-d2a79ab75e68?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2668&q=80',
11
- 'https://images.unsplash.com/photo-1526657782461-9fe13402a841?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1984&q=80',
12
- 'https://images.unsplash.com/photo-1523057530100-383d7fbc77a1?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2669&q=80',
13
- ]
14
- const [selectedPhoto, setSelectedPhoto] = useState(photos[0])
15
- const [light, toggleLight] = useToggler()
16
-
17
- const handleCloseLightbox = () => {
18
- toggleLight()
19
- setSelectedPhoto(null)
20
- }
21
-
22
- const onPhotoClick = (photo) => {
23
- toggleLight()
24
- setSelectedPhoto(photo)
25
- }
26
-
27
- return (
28
- <div>
29
- {light ? (
30
- <Lightbox
31
- icon="times"
32
- iconSize="2x"
33
- initialPhoto={selectedPhoto}
34
- onClose={handleCloseLightbox}
35
- photos={photos}
36
- {...props}
37
- />
38
- ) : (
39
- <div className="PhotoViewer">
40
- <Flex>
41
- {photos.map((photo, index) => {
42
- return (
43
- <div
44
- key={photos[index]}
45
- onClick={() => onPhotoClick(photo)}
46
- >
47
- <Image
48
- marginRight="xl"
49
- rounded
50
- size="lg"
51
- url={photo}
52
- />
53
-
54
- <div className="overlay" />
55
- </div>
56
- )
57
- })}
58
- </Flex>
59
- </div>
60
- )}
61
- </div>
62
- )
63
- }
64
-
65
- export default LightboxMultiple
@@ -1,6 +0,0 @@
1
- examples:
2
-
3
- react:
4
- - lightbox_default: Default
5
- - lightbox_multiple: Multiple
6
-
@@ -1,2 +0,0 @@
1
- export { default as LightboxDefault } from './_lightbox_default.jsx'
2
- export { default as LightboxMultiple } from './_lightbox_multiple.jsx'
@@ -1,10 +0,0 @@
1
- /* @flow */
2
-
3
- import { useState } from 'react'
4
-
5
- export const useToggler = (startValue: boolean = false) => {
6
- const [show, toggle] = useState(startValue)
7
- const toggler = () => toggle(!show)
8
-
9
- return [show, toggler]
10
- }
@@ -1,21 +0,0 @@
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
- }
@@ -1,25 +0,0 @@
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
- }
@@ -1,92 +0,0 @@
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
- display: flex;
64
- align-items: center;
65
- padding: $space-sm;
66
- transition: all .5s;
67
-
68
- .close-icon {
69
- color: white;
70
- margin-left: 16px;
71
- top: 16px;
72
- position: absolute;
73
- }
74
- }
75
- }
76
-
77
- .photo-cards {
78
- .overlay {
79
- width: 100% !important;
80
- height: 50% !important;
81
- bottom: 0;
82
- position: absolute !important;
83
- border-radius: 0px 0px 5px 5px;
84
- background: linear-gradient(-180deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.77) 100%);
85
- }
86
-
87
- .overlay,
88
- .overlay ~ .key-photo-icon,
89
- .overlay ~ .tag-counter {
90
- pointer-events: none;
91
- }
92
- }
@@ -1,30 +0,0 @@
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
- })