playbook_ui 12.15.0 → 12.16.0.pre.alpha.lightboxcurrentphotoprop531
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_background/_background.tsx +1 -1
- data/app/pb_kits/playbook/pb_background/background.rb +1 -1
- data/app/pb_kits/playbook/pb_badge/_badge.scss +1 -0
- data/app/pb_kits/playbook/pb_badge/_badge.tsx +1 -1
- data/app/pb_kits/playbook/pb_badge/badge.rb +5 -1
- data/app/pb_kits/playbook/pb_badge/badge.test.js +16 -1
- data/app/pb_kits/playbook/pb_body/_body_mixins.scss +3 -3
- data/app/pb_kits/playbook/pb_caption/_caption_mixin.scss +2 -2
- data/app/pb_kits/playbook/pb_enhanced_element/index.ts +1 -1
- data/app/pb_kits/playbook/pb_icon_stat_value/_icon_stat_value.tsx +5 -5
- data/app/pb_kits/playbook/pb_icon_stat_value/icon_stat_value.html.erb +1 -1
- data/app/pb_kits/playbook/pb_lightbox/Carousel/index.tsx +0 -1
- data/app/pb_kits/playbook/pb_lightbox/_lightbox.tsx +7 -4
- data/app/pb_kits/playbook/pb_lightbox/docs/_lightbox_compound_component.jsx +1 -5
- data/app/pb_kits/playbook/pb_lightbox/docs/_lightbox_current_photo.jsx +121 -0
- data/app/pb_kits/playbook/pb_lightbox/docs/_lightbox_current_photo.md +1 -0
- data/app/pb_kits/playbook/pb_lightbox/docs/_lightbox_custom_header.jsx +1 -5
- data/app/pb_kits/playbook/pb_lightbox/docs/_lightbox_default.jsx +1 -5
- data/app/pb_kits/playbook/pb_lightbox/docs/_lightbox_default.md +1 -1
- data/app/pb_kits/playbook/pb_lightbox/docs/_lightbox_multiple.jsx +1 -5
- data/app/pb_kits/playbook/pb_lightbox/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_lightbox/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_lightbox/lightbox.test.jsx +1 -5
- data/app/pb_kits/playbook/pb_phone_number_input/_phone_number_input.scss +0 -5
- data/app/pb_kits/playbook/pb_phone_number_input/phone_number_input.rb +0 -4
- data/app/pb_kits/playbook/pb_table/{_table.jsx → _table.tsx} +9 -11
- data/app/pb_kits/playbook/pb_table/{_table_row.jsx → _table_row.tsx} +7 -8
- data/app/pb_kits/playbook/pb_table/docs/_table_with_background_kit.html.erb +41 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_background_kit.jsx +62 -0
- data/app/pb_kits/playbook/pb_table/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_table/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_table/{index.js → index.ts} +4 -4
- data/app/pb_kits/playbook/pb_textarea/_textarea.tsx +129 -0
- data/app/pb_kits/playbook/pb_textarea/{index.js → index.tsx} +2 -0
- data/app/pb_kits/playbook/pb_textarea/textarea.test.js +213 -0
- data/app/pb_kits/playbook/tokens/_colors.scss +16 -1
- data/lib/playbook/version.rb +2 -2
- metadata +17 -13
- data/app/pb_kits/playbook/pb_flex/_flex_item.jsx +0 -41
- data/app/pb_kits/playbook/pb_textarea/_textarea.jsx +0 -135
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: accf792d3ae05665b499210171ab0a2401b7d89109b53f18904bbb23a73a7d5a
|
4
|
+
data.tar.gz: 5d2ceb2031b2a4fcc38245e5584dcd94da4a97b61a5eb6fe4324163a91938b30
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f44a2e628700f4579afa50346aa506b6a57e43ddbc50e30685b5b977f81f49c9fcfb864df1e08adc27788d487316ae475cf740f7522ebe9ceca4c829d3ac567
|
7
|
+
data.tar.gz: dc0ee866dd0e92ba69c8688fb331535a743d6f4f362de42ed5641d3151a5485533cbb05b6296ba665360385df839322f59d38fa76d2763a5c2a43c8fe3e1ec88
|
@@ -24,7 +24,7 @@ type BackgroundProps = {
|
|
24
24
|
id?: string,
|
25
25
|
imageUrl?: string,
|
26
26
|
padding?: 'none' | 'xs' | 'sm' | 'md' | 'lg' | 'xl',
|
27
|
-
tag?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'p' | 'span' | 'div',
|
27
|
+
tag?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'p' | 'span' | 'div' | 'tr' | 'th' | 'td',
|
28
28
|
transition?: 'fade' | 'blur' | 'scale',
|
29
29
|
} & GlobalProps
|
30
30
|
|
@@ -42,7 +42,7 @@ const Badge = (props: BadgeProps) => {
|
|
42
42
|
const ariaProps = buildAriaProps(aria)
|
43
43
|
const dataProps = buildDataProps(data)
|
44
44
|
const css = classnames(
|
45
|
-
buildCss('pb_badge_kit', variant, rounded ? 'rounded' : null),
|
45
|
+
buildCss('pb_badge_kit', variant === "success" ? "success_sm" : variant, rounded ? 'rounded' : null),
|
46
46
|
globalProps(props),
|
47
47
|
className
|
48
48
|
)
|
@@ -10,11 +10,15 @@ module Playbook
|
|
10
10
|
default: "neutral"
|
11
11
|
|
12
12
|
def classname
|
13
|
-
generate_classname("pb_badge_kit",
|
13
|
+
generate_classname("pb_badge_kit", variant_class, rounded_class)
|
14
14
|
end
|
15
15
|
|
16
16
|
private
|
17
17
|
|
18
|
+
def variant_class
|
19
|
+
variant === "success" ? "success_sm" : variant
|
20
|
+
end
|
21
|
+
|
18
22
|
def rounded_class
|
19
23
|
rounded ? "rounded" : nil
|
20
24
|
end
|
@@ -60,7 +60,6 @@ test('displays rounded corners', () => {
|
|
60
60
|
|
61
61
|
test('displays color variants', () => {
|
62
62
|
[
|
63
|
-
"success",
|
64
63
|
"warning",
|
65
64
|
"error",
|
66
65
|
"info"
|
@@ -78,3 +77,19 @@ test('displays color variants', () => {
|
|
78
77
|
cleanup()
|
79
78
|
})
|
80
79
|
})
|
80
|
+
|
81
|
+
test('displays success variant', () => {
|
82
|
+
render(
|
83
|
+
<Badge
|
84
|
+
data={{ testid: testId }}
|
85
|
+
text={"success"}
|
86
|
+
variant={"success"}
|
87
|
+
/>
|
88
|
+
)
|
89
|
+
const kit = screen.getByTestId(testId)
|
90
|
+
expect(kit).toHaveClass(`pb_badge_kit_success_sm
|
91
|
+
`)
|
92
|
+
|
93
|
+
cleanup()
|
94
|
+
|
95
|
+
})
|
@@ -8,7 +8,7 @@ $pb_body_colors: (
|
|
8
8
|
lighter: $text_lt_lighter,
|
9
9
|
link: $primary,
|
10
10
|
error: $error,
|
11
|
-
success: $
|
11
|
+
success: $text_lt_success_sm,
|
12
12
|
);
|
13
13
|
|
14
14
|
$pb_dark_body_colors: (
|
@@ -16,7 +16,7 @@ $pb_dark_body_colors: (
|
|
16
16
|
light: $text_dk_light,
|
17
17
|
lighter: $text_dk_lighter,
|
18
18
|
error: $error,
|
19
|
-
success: $
|
19
|
+
success: $text_dk_success_sm,
|
20
20
|
);
|
21
21
|
|
22
22
|
// Order is important here!
|
@@ -24,7 +24,7 @@ $pb_body_status: (
|
|
24
24
|
default: $text_lt_default,
|
25
25
|
negative: $error,
|
26
26
|
dark_error: $error_dark_body,
|
27
|
-
positive: $
|
27
|
+
positive: $text_lt_success_sm,
|
28
28
|
);
|
29
29
|
|
30
30
|
@mixin pb_body($color: $text_lt_default) {
|
@@ -6,7 +6,7 @@ $pb_caption_colors: (
|
|
6
6
|
light: $text_lt_light,
|
7
7
|
link: $primary,
|
8
8
|
lighter: $text_lt_lighter,
|
9
|
-
success: $
|
9
|
+
success: $text_lt_success_sm,
|
10
10
|
error: $error,
|
11
11
|
);
|
12
12
|
|
@@ -14,7 +14,7 @@ $pb_dark_caption_colors: (
|
|
14
14
|
default: $text_dk_default,
|
15
15
|
light: $text_dk_light,
|
16
16
|
link: $primary,
|
17
|
-
success: $
|
17
|
+
success: $text_dk_success_sm,
|
18
18
|
error: $error,
|
19
19
|
);
|
20
20
|
|
@@ -94,13 +94,13 @@ const IconStatValue = (props: IconStatValueProps) => {
|
|
94
94
|
|
95
95
|
<div>
|
96
96
|
<Flex
|
97
|
-
|
97
|
+
align="baseline"
|
98
98
|
>
|
99
|
-
|
99
|
+
{titleSize(size)}
|
100
100
|
|
101
|
-
|
102
|
-
|
103
|
-
|
101
|
+
<Body
|
102
|
+
text={unit}
|
103
|
+
/>
|
104
104
|
</Flex>
|
105
105
|
<Caption text={text} />
|
106
106
|
</div>
|
@@ -12,11 +12,11 @@ type LightboxType = {
|
|
12
12
|
aria?: {[key: string]: string},
|
13
13
|
children: React.ReactNode[] | React.ReactNode | string,
|
14
14
|
className?: string,
|
15
|
+
currentPhotoIndex?: number,
|
15
16
|
data?: {[key: string]: string | number},
|
16
17
|
description?: string | any,
|
17
18
|
id?: string,
|
18
19
|
photos: [],
|
19
|
-
initialPhoto?: number,
|
20
20
|
onChange?: (index: number)=> {},
|
21
21
|
onClickRight?: () => void,
|
22
22
|
onClose?: () => void,
|
@@ -31,10 +31,10 @@ const Lightbox = (props: LightboxType): React.ReactNode => {
|
|
31
31
|
aria = {},
|
32
32
|
children,
|
33
33
|
className,
|
34
|
+
currentPhotoIndex,
|
34
35
|
data = {},
|
35
36
|
description,
|
36
37
|
id = '',
|
37
|
-
initialPhoto = 0,
|
38
38
|
photos,
|
39
39
|
onChange = ()=>{},
|
40
40
|
onClose,
|
@@ -44,12 +44,15 @@ const Lightbox = (props: LightboxType): React.ReactNode => {
|
|
44
44
|
title,
|
45
45
|
} = props
|
46
46
|
|
47
|
-
const [activePhoto, setActivePhoto] = useState(
|
48
|
-
|
47
|
+
const [activePhoto, setActivePhoto] = useState(0)
|
49
48
|
useEffect(() => {
|
50
49
|
onChange(activePhoto)
|
51
50
|
},[activePhoto])
|
52
51
|
|
52
|
+
useEffect(() => {
|
53
|
+
setActivePhoto(currentPhotoIndex)
|
54
|
+
},[currentPhotoIndex])
|
55
|
+
|
53
56
|
const ariaProps = buildAriaProps(aria)
|
54
57
|
const dataProps = buildDataProps(data)
|
55
58
|
const classes = classnames(
|
@@ -10,17 +10,14 @@ const LightboxCompoundComponent = (props) => {
|
|
10
10
|
'https://images.unsplash.com/photo-1501045337096-542a73dafa4f?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2052&q=80',
|
11
11
|
'https://images.unsplash.com/photo-1563693998336-93c10e5d8f91?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1470&q=80,',
|
12
12
|
]
|
13
|
-
const [selectedPhoto, setSelectedPhoto] = useState(0)
|
14
13
|
const [showLightbox, toggleShowLightbox] = useState(false)
|
15
14
|
|
16
15
|
const handleCloseLightbox = () => {
|
17
16
|
toggleShowLightbox(!showLightbox)
|
18
|
-
setSelectedPhoto(null)
|
19
17
|
}
|
20
18
|
|
21
|
-
const onPhotoClick = (
|
19
|
+
const onPhotoClick = () => {
|
22
20
|
toggleShowLightbox(!showLightbox)
|
23
|
-
setSelectedPhoto(photo)
|
24
21
|
}
|
25
22
|
|
26
23
|
const exampleStyles = {
|
@@ -34,7 +31,6 @@ const LightboxCompoundComponent = (props) => {
|
|
34
31
|
{showLightbox ? (
|
35
32
|
<Lightbox
|
36
33
|
description='Description Content Goes Here.'
|
37
|
-
initialPhoto={selectedPhoto}
|
38
34
|
onClose={handleCloseLightbox}
|
39
35
|
photos={photos}
|
40
36
|
title='Windows, Sidings, & Gutters'
|
@@ -0,0 +1,121 @@
|
|
1
|
+
/* @flow */
|
2
|
+
/* eslint-disable jsx-control-statements/jsx-use-if-tag */
|
3
|
+
import React, { useState } from 'react'
|
4
|
+
import { Flex, Image, Button, Body, FlexItem } 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 [light, toggleLight] = useState(false)
|
33
|
+
//Setting state with the index of the current slide exposed by the onChange prop
|
34
|
+
const [active, setActive] = useState(0)
|
35
|
+
//Setting state for the current photo to pass to the kit
|
36
|
+
const [currentPhoto, setCurrentPhoto] = useState(active)
|
37
|
+
|
38
|
+
const handleCloseLightbox = () => {
|
39
|
+
toggleLight(!light)
|
40
|
+
}
|
41
|
+
|
42
|
+
const onPhotoClick = () => {
|
43
|
+
toggleLight(!light)
|
44
|
+
}
|
45
|
+
|
46
|
+
const exampleStyles = {
|
47
|
+
width: "100%",
|
48
|
+
overflow: "auto"
|
49
|
+
}
|
50
|
+
|
51
|
+
return (
|
52
|
+
<div className="lightbox_doc_example_custom">
|
53
|
+
{light ? (
|
54
|
+
<>
|
55
|
+
<Flex alignItems="center"
|
56
|
+
className='custom_lightbox_sidebar'
|
57
|
+
justifyContent="center"
|
58
|
+
>
|
59
|
+
<Flex margin='lg'
|
60
|
+
orientation='column'
|
61
|
+
>
|
62
|
+
<Body marginBottom='md'>
|
63
|
+
This UI is for demonstration purposes only to demonstrate how external buttons can be used to change the slides.
|
64
|
+
</Body>
|
65
|
+
<FlexItem alignSelf="center">
|
66
|
+
<Flex justifyContent="center">
|
67
|
+
<Button
|
68
|
+
onClick={()=> setCurrentPhoto(active > 0 ? active - 1 : 0)}
|
69
|
+
>
|
70
|
+
Back
|
71
|
+
</Button>
|
72
|
+
<Button marginLeft='sm'
|
73
|
+
onClick={() => setCurrentPhoto(active < photos.length - 1 ? active + 1 : photos.length - 1)}
|
74
|
+
>
|
75
|
+
Next
|
76
|
+
</Button>
|
77
|
+
</Flex>
|
78
|
+
</FlexItem>
|
79
|
+
</Flex>
|
80
|
+
</Flex>
|
81
|
+
<Lightbox
|
82
|
+
currentPhotoIndex={currentPhoto}
|
83
|
+
icon="times"
|
84
|
+
onChange={(index) => setActive(index)}
|
85
|
+
onClose={handleCloseLightbox}
|
86
|
+
photos={photos}
|
87
|
+
{...props}
|
88
|
+
/>
|
89
|
+
</>
|
90
|
+
) : (
|
91
|
+
<div
|
92
|
+
className="PhotoViewer"
|
93
|
+
style={exampleStyles}
|
94
|
+
>
|
95
|
+
<Flex>
|
96
|
+
{photos.map((photo, index) => {
|
97
|
+
return (
|
98
|
+
<div
|
99
|
+
key={index}
|
100
|
+
onClick={() => onPhotoClick(index)}
|
101
|
+
>
|
102
|
+
<Image
|
103
|
+
cursor="pointer"
|
104
|
+
marginRight="xl"
|
105
|
+
rounded
|
106
|
+
size="lg"
|
107
|
+
url={photo}
|
108
|
+
/>
|
109
|
+
|
110
|
+
<div className="overlay" />
|
111
|
+
</div>
|
112
|
+
)
|
113
|
+
})}
|
114
|
+
</Flex>
|
115
|
+
</div>
|
116
|
+
)}
|
117
|
+
</div>
|
118
|
+
)
|
119
|
+
}
|
120
|
+
|
121
|
+
export default LightboxCurrentPhoto
|
@@ -0,0 +1 @@
|
|
1
|
+
The `currentPhotoIndex` 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.
|
@@ -10,17 +10,14 @@ const LightboxCustomHeader = (props) => {
|
|
10
10
|
"https://images.unsplash.com/photo-1501045337096-542a73dafa4f?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2052&q=80",
|
11
11
|
"https://images.unsplash.com/photo-1563693998336-93c10e5d8f91?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1470&q=80,",
|
12
12
|
];
|
13
|
-
const [selectedPhoto, setSelectedPhoto] = useState(0);
|
14
13
|
const [showLightbox, toggleShowLightbox] = useState(false);
|
15
14
|
|
16
15
|
const handleCloseLightbox = () => {
|
17
16
|
toggleShowLightbox(!showLightbox);
|
18
|
-
setSelectedPhoto(null);
|
19
17
|
};
|
20
18
|
|
21
|
-
const onPhotoClick = (
|
19
|
+
const onPhotoClick = () => {
|
22
20
|
toggleShowLightbox(!showLightbox);
|
23
|
-
setSelectedPhoto(photo);
|
24
21
|
};
|
25
22
|
|
26
23
|
const exampleStyles = {
|
@@ -55,7 +52,6 @@ const LightboxCustomHeader = (props) => {
|
|
55
52
|
{showLightbox ? (
|
56
53
|
<Lightbox
|
57
54
|
description={customDescription}
|
58
|
-
initialPhoto={selectedPhoto}
|
59
55
|
navRight="All Photos"
|
60
56
|
onClickRight={()=> alert("Clicked!")}
|
61
57
|
onClose={handleCloseLightbox}
|
@@ -8,17 +8,14 @@ const LightboxDefault = (props) => {
|
|
8
8
|
const photos = [
|
9
9
|
'https://images.unsplash.com/photo-1638727228877-d2a79ab75e68?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2668&q=80',
|
10
10
|
]
|
11
|
-
const [selectedPhoto, setSelectedPhoto] = useState(0)
|
12
11
|
const [showLightbox, toggleShowLightbox] = useState(false)
|
13
12
|
|
14
13
|
const handleCloseLightbox = () => {
|
15
14
|
toggleShowLightbox(!showLightbox)
|
16
|
-
setSelectedPhoto(null)
|
17
15
|
}
|
18
16
|
|
19
|
-
const onPhotoClick = (
|
17
|
+
const onPhotoClick = () => {
|
20
18
|
toggleShowLightbox(!showLightbox)
|
21
|
-
setSelectedPhoto(photoIndex)
|
22
19
|
}
|
23
20
|
|
24
21
|
return (
|
@@ -27,7 +24,6 @@ const LightboxDefault = (props) => {
|
|
27
24
|
{showLightbox ? (
|
28
25
|
<Lightbox
|
29
26
|
icon="times"
|
30
|
-
initialPhoto={selectedPhoto}
|
31
27
|
onClose={handleCloseLightbox}
|
32
28
|
photos={photos}
|
33
29
|
{...props}
|
@@ -1 +1 @@
|
|
1
|
-
Lightbox contains several props: `photos` (an array of urls), `
|
1
|
+
Lightbox contains several props: `photos` (an array of urls), `onClickLeft` (an optional callback function for top left close button), `title` and `description` (string or custom components), `icon` ( optional prop for the close button in the top left of the header), `navRight` (optional prop that renders clickable text in the top right section of the header), `onClickRight` (optional callback function of navRight) and `onChange` (optional event handler prop exposing index of current photo).
|
@@ -29,17 +29,14 @@ const LightboxMultiple = (props) => {
|
|
29
29
|
'https://images.unsplash.com/photo-1526657782461-9fe13402a841?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1984&q=80',
|
30
30
|
'https://images.unsplash.com/photo-1523057530100-383d7fbc77a1?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2669&q=80',
|
31
31
|
]
|
32
|
-
const [selectedPhoto, setSelectedPhoto] = useState(0)
|
33
32
|
const [light, toggleLight] = useState(false)
|
34
33
|
|
35
34
|
const handleCloseLightbox = () => {
|
36
35
|
toggleLight(!light)
|
37
|
-
setSelectedPhoto(null)
|
38
36
|
}
|
39
37
|
|
40
|
-
const onPhotoClick = (
|
38
|
+
const onPhotoClick = () => {
|
41
39
|
toggleLight(!light)
|
42
|
-
setSelectedPhoto(photo)
|
43
40
|
}
|
44
41
|
|
45
42
|
const exampleStyles = {
|
@@ -52,7 +49,6 @@ const LightboxMultiple = (props) => {
|
|
52
49
|
{light ? (
|
53
50
|
<Lightbox
|
54
51
|
icon="times"
|
55
|
-
initialPhoto={selectedPhoto}
|
56
52
|
onChange={(index) => console.log(`current photo index: ${index}`)}
|
57
53
|
onClose={handleCloseLightbox}
|
58
54
|
photos={photos}
|
@@ -2,3 +2,4 @@ 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'
|
@@ -18,7 +18,6 @@ test('Kit renders', () => {
|
|
18
18
|
data={{ testid: testId }}
|
19
19
|
icon="close"
|
20
20
|
id="test1"
|
21
|
-
initialPhoto={1}
|
22
21
|
onClose={() => {}}
|
23
22
|
photos={TEST_PHOTOS}
|
24
23
|
/>
|
@@ -35,7 +34,6 @@ test('Shows selected images', () => {
|
|
35
34
|
data={{ testid: testId }}
|
36
35
|
icon="close"
|
37
36
|
id="test1"
|
38
|
-
initialPhoto={1}
|
39
37
|
onClose={() => {}}
|
40
38
|
photos={TEST_PHOTOS}
|
41
39
|
/>
|
@@ -43,7 +41,7 @@ test('Shows selected images', () => {
|
|
43
41
|
const kit = screen.getByTestId(testId)
|
44
42
|
const slide = kit.getElementsByClassName('Slide')[0]
|
45
43
|
const image = slide.getElementsByTagName('img')[0]
|
46
|
-
expect(image).toHaveAttribute('src', TEST_PHOTOS[
|
44
|
+
expect(image).toHaveAttribute('src', TEST_PHOTOS[0])
|
47
45
|
|
48
46
|
const thumbnails = kit.getElementsByClassName('Thumbnail')
|
49
47
|
|
@@ -77,7 +75,6 @@ test('Closes on escape key', async () => {
|
|
77
75
|
data={{ testid: testId }}
|
78
76
|
icon="close"
|
79
77
|
id="test1"
|
80
|
-
initialPhoto={0}
|
81
78
|
onClose={mockClose}
|
82
79
|
photos={TEST_PHOTOS}
|
83
80
|
/>
|
@@ -106,7 +103,6 @@ test('Closes on close button', async () => {
|
|
106
103
|
data={{ testid: testId }}
|
107
104
|
icon="close"
|
108
105
|
id="test1"
|
109
|
-
initialPhoto={0}
|
110
106
|
onClose={mockClose}
|
111
107
|
photos={TEST_PHOTOS}
|
112
108
|
/>
|
@@ -1,7 +1,6 @@
|
|
1
1
|
@import "../tokens/colors";
|
2
2
|
|
3
3
|
$transform-rotate-deg: 135deg;
|
4
|
-
$input-max-width: 284px;
|
5
4
|
$dropdown-min-width: 340px;
|
6
5
|
$flag-min-resolution: 192dpi;
|
7
6
|
|
@@ -10,10 +9,6 @@ $flag-min-resolution: 192dpi;
|
|
10
9
|
color: $focus_input_light;
|
11
10
|
}
|
12
11
|
|
13
|
-
.text_input {
|
14
|
-
max-width: $input-max-width;
|
15
|
-
}
|
16
|
-
|
17
12
|
.dropdown_open {
|
18
13
|
.text_input {
|
19
14
|
border-color: $primary !important;
|
@@ -7,12 +7,10 @@ module Playbook
|
|
7
7
|
default: false
|
8
8
|
prop :initial_country, type: Playbook::Props::String,
|
9
9
|
default: ""
|
10
|
-
prop :is_valid
|
11
10
|
prop :label, type: Playbook::Props::String,
|
12
11
|
default: ""
|
13
12
|
prop :name, type: Playbook::Props::String,
|
14
13
|
default: ""
|
15
|
-
prop :onchange
|
16
14
|
prop :only_countries, type: Playbook::Props::Array,
|
17
15
|
default: []
|
18
16
|
prop :preferred_countries, type: Playbook::Props::Array,
|
@@ -30,10 +28,8 @@ module Playbook
|
|
30
28
|
dark: dark,
|
31
29
|
disabled: disabled,
|
32
30
|
initialCountry: initial_country,
|
33
|
-
isValid: is_valid,
|
34
31
|
label: label,
|
35
32
|
name: name,
|
36
|
-
onChange: onchange,
|
37
33
|
onlyCountries: only_countries,
|
38
34
|
preferredCountries: preferred_countries,
|
39
35
|
value: value,
|
@@ -1,19 +1,17 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
import React, { useEffect, type Node } from 'react'
|
1
|
+
import React, { useEffect } from 'react'
|
4
2
|
import classnames from 'classnames'
|
5
3
|
import { buildAriaProps, buildDataProps } from '../utilities/props'
|
6
4
|
import { globalProps } from '../utilities/globalProps'
|
7
|
-
import PbTable from '
|
5
|
+
import PbTable from '.'
|
8
6
|
|
9
7
|
type TableProps = {
|
10
|
-
aria?:
|
11
|
-
children:
|
8
|
+
aria?: { [key: string]: string },
|
9
|
+
children: React.ReactNode[] | React.ReactNode,
|
12
10
|
className: string,
|
13
11
|
collapse?: "sm" | "md" | "lg",
|
14
12
|
container: boolean,
|
15
13
|
dark?: boolean,
|
16
|
-
data?:
|
14
|
+
data?: { [key: string]: string },
|
17
15
|
dataTable: boolean,
|
18
16
|
disableHover: boolean,
|
19
17
|
id?: string,
|
@@ -52,9 +50,9 @@ const Table = (props: TableProps) => {
|
|
52
50
|
|
53
51
|
return (
|
54
52
|
<table
|
55
|
-
|
56
|
-
|
57
|
-
|
53
|
+
{...ariaProps}
|
54
|
+
{...dataProps}
|
55
|
+
className={classnames(
|
58
56
|
'pb_table',
|
59
57
|
`table-${size}`,
|
60
58
|
`table-responsive-${responsive}`,
|
@@ -70,7 +68,7 @@ const Table = (props: TableProps) => {
|
|
70
68
|
tableCollapseCss,
|
71
69
|
className
|
72
70
|
)}
|
73
|
-
|
71
|
+
id={id}
|
74
72
|
>
|
75
73
|
{children}
|
76
74
|
</table>
|
@@ -1,14 +1,13 @@
|
|
1
|
-
/* @flow */
|
2
1
|
import React from 'react'
|
3
2
|
import classnames from 'classnames'
|
4
3
|
import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
|
5
4
|
import { globalProps } from '../utilities/globalProps'
|
6
5
|
|
7
6
|
type TableRowPropTypes = {
|
8
|
-
aria?:
|
9
|
-
children:
|
7
|
+
aria?: { [key: string]: string },
|
8
|
+
children: React.ReactNode[] | React.ReactNode,
|
10
9
|
className: string,
|
11
|
-
data?:
|
10
|
+
data?: { [key: string]: string },
|
12
11
|
id?: string,
|
13
12
|
sideHighlightColor: string,
|
14
13
|
}
|
@@ -31,10 +30,10 @@ const TableRow = (props: TableRowPropTypes) => {
|
|
31
30
|
|
32
31
|
return (
|
33
32
|
<tr
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
33
|
+
{...ariaProps}
|
34
|
+
{...dataProps}
|
35
|
+
className={classes}
|
36
|
+
id={id}
|
38
37
|
>
|
39
38
|
{children}
|
40
39
|
</tr>
|