playbook_ui 12.14.0.pre.alpha.lightboxcurrentphotoprop460 → 12.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/pb_lightbox/_lightbox.tsx +1 -6
- data/app/pb_kits/playbook/pb_lightbox/docs/example.yml +0 -1
- data/app/pb_kits/playbook/pb_lightbox/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_lightbox/lightbox.test.jsx +2 -2
- data/lib/playbook/version.rb +2 -2
- metadata +7 -9
- data/app/pb_kits/playbook/pb_lightbox/docs/_lightbox_current_photo.jsx +0 -115
- data/app/pb_kits/playbook/pb_lightbox/docs/_lightbox_current_photo.md +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a42d45fa9c0cb3563d9253c5c676edcd535e813873bca8f31162258372554bb9
|
4
|
+
data.tar.gz: 162a8abeed8d622e81d218e90c6a1d693a17d068d489234cbd0fb39f2c50ac7e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de1b0f03c8ca91aedae5581617fab0920bde4bfbaa034137021a0f3fe87932a6cb963231f9add0470a606046341d3c5a0b8d3819803ae7eb34af9415f4c340b6
|
7
|
+
data.tar.gz: e5f9702e6a3f812e3ae0080cc604406fbc7f115f2b1fcf7f83e2537e9502a833d93436abe3f3c9c0795d013791f62ba43631be32298891143a8fbf58728f2ef4
|
@@ -12,7 +12,6 @@ type LightboxType = {
|
|
12
12
|
aria?: {[key: string]: string},
|
13
13
|
children: React.ReactNode[] | React.ReactNode | string,
|
14
14
|
className?: string,
|
15
|
-
currentPhoto?: number,
|
16
15
|
data?: {[key: string]: string | number},
|
17
16
|
description?: string | any,
|
18
17
|
id?: string,
|
@@ -32,7 +31,6 @@ const Lightbox = (props: LightboxType): React.ReactNode => {
|
|
32
31
|
aria = {},
|
33
32
|
children,
|
34
33
|
className,
|
35
|
-
currentPhoto,
|
36
34
|
data = {},
|
37
35
|
description,
|
38
36
|
id = '',
|
@@ -47,14 +45,11 @@ const Lightbox = (props: LightboxType): React.ReactNode => {
|
|
47
45
|
} = props
|
48
46
|
|
49
47
|
const [activePhoto, setActivePhoto] = useState(initialPhoto)
|
48
|
+
|
50
49
|
useEffect(() => {
|
51
50
|
onChange(activePhoto)
|
52
51
|
},[activePhoto])
|
53
52
|
|
54
|
-
useEffect(() => {
|
55
|
-
setActivePhoto(currentPhoto)
|
56
|
-
},[currentPhoto])
|
57
|
-
|
58
53
|
const ariaProps = buildAriaProps(aria)
|
59
54
|
const dataProps = buildDataProps(data)
|
60
55
|
const classes = classnames(
|
@@ -2,4 +2,3 @@ export { default as LightboxDefault } from './_lightbox_default.jsx'
|
|
2
2
|
export { default as LightboxMultiple } from './_lightbox_multiple.jsx'
|
3
3
|
export { default as LightboxCompoundComponent } from './_lightbox_compound_component.jsx'
|
4
4
|
export { default as LightboxCustomHeader } from './_lightbox_custom_header'
|
5
|
-
export { default as LightboxCurrentPhoto } from './_lightbox_current_photo'
|
@@ -35,7 +35,7 @@ test('Shows selected images', () => {
|
|
35
35
|
data={{ testid: testId }}
|
36
36
|
icon="close"
|
37
37
|
id="test1"
|
38
|
-
initialPhoto={
|
38
|
+
initialPhoto={1}
|
39
39
|
onClose={() => {}}
|
40
40
|
photos={TEST_PHOTOS}
|
41
41
|
/>
|
@@ -43,7 +43,7 @@ test('Shows selected images', () => {
|
|
43
43
|
const kit = screen.getByTestId(testId)
|
44
44
|
const slide = kit.getElementsByClassName('Slide')[0]
|
45
45
|
const image = slide.getElementsByTagName('img')[0]
|
46
|
-
expect(image).toHaveAttribute('src', TEST_PHOTOS[
|
46
|
+
expect(image).toHaveAttribute('src', TEST_PHOTOS[1])
|
47
47
|
|
48
48
|
const thumbnails = kit.getElementsByClassName('Thumbnail')
|
49
49
|
|
data/lib/playbook/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: playbook_ui
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 12.14.0
|
4
|
+
version: 12.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Power UX
|
8
8
|
- Power Devs
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2023-04-
|
12
|
+
date: 2023-04-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: actionpack
|
@@ -1333,8 +1333,6 @@ files:
|
|
1333
1333
|
- app/pb_kits/playbook/pb_lightbox/docs/_description.md
|
1334
1334
|
- app/pb_kits/playbook/pb_lightbox/docs/_lightbox_compound_component.jsx
|
1335
1335
|
- app/pb_kits/playbook/pb_lightbox/docs/_lightbox_compound_component.md
|
1336
|
-
- app/pb_kits/playbook/pb_lightbox/docs/_lightbox_current_photo.jsx
|
1337
|
-
- app/pb_kits/playbook/pb_lightbox/docs/_lightbox_current_photo.md
|
1338
1336
|
- app/pb_kits/playbook/pb_lightbox/docs/_lightbox_custom_header.jsx
|
1339
1337
|
- app/pb_kits/playbook/pb_lightbox/docs/_lightbox_custom_header.md
|
1340
1338
|
- app/pb_kits/playbook/pb_lightbox/docs/_lightbox_default.jsx
|
@@ -2467,7 +2465,7 @@ homepage: http://playbook.powerapp.cloud
|
|
2467
2465
|
licenses:
|
2468
2466
|
- ISC
|
2469
2467
|
metadata: {}
|
2470
|
-
post_install_message:
|
2468
|
+
post_install_message:
|
2471
2469
|
rdoc_options: []
|
2472
2470
|
require_paths:
|
2473
2471
|
- lib
|
@@ -2478,12 +2476,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
2478
2476
|
version: '0'
|
2479
2477
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
2480
2478
|
requirements:
|
2481
|
-
- - "
|
2479
|
+
- - ">="
|
2482
2480
|
- !ruby/object:Gem::Version
|
2483
|
-
version:
|
2481
|
+
version: '0'
|
2484
2482
|
requirements: []
|
2485
2483
|
rubygems_version: 3.3.7
|
2486
|
-
signing_key:
|
2484
|
+
signing_key:
|
2487
2485
|
specification_version: 4
|
2488
2486
|
summary: Playbook Design System
|
2489
2487
|
test_files: []
|
@@ -1,115 +0,0 @@
|
|
1
|
-
/* @flow */
|
2
|
-
/* eslint-disable jsx-control-statements/jsx-use-if-tag */
|
3
|
-
import React, { useState } from 'react'
|
4
|
-
import { Flex, Image, Button } from '../../'
|
5
|
-
import Lightbox from '../_lightbox.tsx'
|
6
|
-
|
7
|
-
const LightboxCurrentPhoto = (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
|
-
'https://images.unsplash.com/photo-1638727228877-d2a79ab75e68?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2668&q=80',
|
13
|
-
'https://images.unsplash.com/photo-1526657782461-9fe13402a841?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1984&q=80',
|
14
|
-
'https://images.unsplash.com/photo-1523057530100-383d7fbc77a1?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2669&q=80',
|
15
|
-
'https://images.unsplash.com/photo-1638727228877-d2a79ab75e68?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2668&q=80',
|
16
|
-
'https://images.unsplash.com/photo-1526657782461-9fe13402a841?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1984&q=80',
|
17
|
-
'https://images.unsplash.com/photo-1523057530100-383d7fbc77a1?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2669&q=80',
|
18
|
-
'https://images.unsplash.com/photo-1638727228877-d2a79ab75e68?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2668&q=80',
|
19
|
-
'https://images.unsplash.com/photo-1526657782461-9fe13402a841?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1984&q=80',
|
20
|
-
'https://images.unsplash.com/photo-1523057530100-383d7fbc77a1?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2669&q=80',
|
21
|
-
'https://images.unsplash.com/photo-1638727228877-d2a79ab75e68?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2668&q=80',
|
22
|
-
'https://images.unsplash.com/photo-1526657782461-9fe13402a841?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1984&q=80',
|
23
|
-
'https://images.unsplash.com/photo-1523057530100-383d7fbc77a1?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2669&q=80',
|
24
|
-
'https://images.unsplash.com/photo-1638727228877-d2a79ab75e68?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2668&q=80',
|
25
|
-
'https://images.unsplash.com/photo-1526657782461-9fe13402a841?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1984&q=80',
|
26
|
-
'https://images.unsplash.com/photo-1523057530100-383d7fbc77a1?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2669&q=80',
|
27
|
-
'https://images.unsplash.com/photo-1523057530100-383d7fbc77a1?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2669&q=80',
|
28
|
-
'https://images.unsplash.com/photo-1638727228877-d2a79ab75e68?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2668&q=80',
|
29
|
-
'https://images.unsplash.com/photo-1526657782461-9fe13402a841?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1984&q=80',
|
30
|
-
'https://images.unsplash.com/photo-1523057530100-383d7fbc77a1?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2669&q=80',
|
31
|
-
]
|
32
|
-
const [selectedPhoto, setSelectedPhoto] = useState(0)
|
33
|
-
const [light, toggleLight] = useState(false)
|
34
|
-
//Setting state with the index of the current slide exposed by the onChange prop
|
35
|
-
const [active, setActive] = useState(selectedPhoto)
|
36
|
-
//Setting state for the current photo to pass to the kit
|
37
|
-
const [currentPhoto, setCurrentPhoto] = useState(active)
|
38
|
-
|
39
|
-
const handleCloseLightbox = () => {
|
40
|
-
toggleLight(!light)
|
41
|
-
setSelectedPhoto(null)
|
42
|
-
}
|
43
|
-
|
44
|
-
const onPhotoClick = (photo) => {
|
45
|
-
toggleLight(!light)
|
46
|
-
setSelectedPhoto(photo)
|
47
|
-
}
|
48
|
-
|
49
|
-
const exampleStyles = {
|
50
|
-
width: "100%",
|
51
|
-
overflow: "auto"
|
52
|
-
}
|
53
|
-
|
54
|
-
return (
|
55
|
-
<div>
|
56
|
-
{light ? (
|
57
|
-
<>
|
58
|
-
<div style={{width: '200px', height: '50px', position: 'fixed', top: 0, right: 0, zIndex: 1000000000000000}}>
|
59
|
-
<div style={{position: 'absolute',right: '100px'}}>
|
60
|
-
<Button
|
61
|
-
onClick={()=> setCurrentPhoto(active > 0 ? active - 1 : 0)}
|
62
|
-
>
|
63
|
-
Back
|
64
|
-
</Button>
|
65
|
-
</div>
|
66
|
-
<div style={{position: 'absolute', right: 0}}>
|
67
|
-
<Button
|
68
|
-
onClick={() => setCurrentPhoto(active < photos.length - 1 ? active + 1 : photos.length - 1)}
|
69
|
-
>
|
70
|
-
Next
|
71
|
-
</Button>
|
72
|
-
</div>
|
73
|
-
</div>
|
74
|
-
<Lightbox
|
75
|
-
currentPhoto={currentPhoto}
|
76
|
-
icon="times"
|
77
|
-
initialPhoto={selectedPhoto}
|
78
|
-
onChange={(index) => setActive(index)}
|
79
|
-
onClose={handleCloseLightbox}
|
80
|
-
photos={photos}
|
81
|
-
{...props}
|
82
|
-
/>
|
83
|
-
</>
|
84
|
-
) : (
|
85
|
-
<div
|
86
|
-
className="PhotoViewer"
|
87
|
-
style={exampleStyles}
|
88
|
-
>
|
89
|
-
<Flex>
|
90
|
-
{photos.map((photo, index) => {
|
91
|
-
return (
|
92
|
-
<div
|
93
|
-
key={index}
|
94
|
-
onClick={() => onPhotoClick(index)}
|
95
|
-
>
|
96
|
-
<Image
|
97
|
-
cursor="pointer"
|
98
|
-
marginRight="xl"
|
99
|
-
rounded
|
100
|
-
size="lg"
|
101
|
-
url={photo}
|
102
|
-
/>
|
103
|
-
|
104
|
-
<div className="overlay" />
|
105
|
-
</div>
|
106
|
-
)
|
107
|
-
})}
|
108
|
-
</Flex>
|
109
|
-
</div>
|
110
|
-
)}
|
111
|
-
</div>
|
112
|
-
)
|
113
|
-
}
|
114
|
-
|
115
|
-
export default LightboxCurrentPhoto
|
@@ -1 +0,0 @@
|
|
1
|
-
The `currentPhoto` prop allows the user to pass a number to the lightbox that will set the current slide by index. This can be leveraged if the user wants to change slides using custom buttons. To do this, the user must also make use of the current slide's index that is exposed by the `onChange` prop.
|