playbook_ui 12.14.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_avatar/_avatar.tsx +1 -1
- data/app/pb_kits/playbook/pb_avatar/avatar.html.erb +1 -1
- data/app/pb_kits/playbook/pb_avatar/avatar.rb +4 -0
- data/app/pb_kits/playbook/pb_avatar/avatar.test.js +14 -0
- data/app/pb_kits/playbook/pb_avatar/docs/_avatar_default.html.erb +0 -1
- 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_card/_card.scss +13 -0
- data/app/pb_kits/playbook/pb_card/_card.tsx +3 -2
- data/app/pb_kits/playbook/pb_card/card_header.rb +9 -1
- data/app/pb_kits/playbook/pb_card/docs/_card_header.html.erb +11 -0
- data/app/pb_kits/playbook/pb_card/docs/_card_header.jsx +169 -139
- 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_star_rating/{_star_rating.jsx → _star_rating.tsx} +18 -22
- data/app/pb_kits/playbook/pb_star_rating/star_rating.test.js +71 -0
- 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/app/pb_kits/playbook/utilities/_cursor.scss +141 -1
- data/app/pb_kits/playbook/utilities/globalProps.ts +5 -2
- data/lib/playbook/cursor.rb +2 -2
- data/lib/playbook/version.rb +2 -2
- metadata +19 -14
- data/app/pb_kits/playbook/pb_flex/_flex_item.jsx +0 -41
- data/app/pb_kits/playbook/pb_textarea/_textarea.jsx +0 -135
@@ -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,14 +1,12 @@
|
|
1
|
-
|
1
|
+
import React from "react"
|
2
|
+
import classnames from "classnames"
|
2
3
|
|
3
|
-
import
|
4
|
-
import classnames from 'classnames'
|
4
|
+
import { buildAriaProps, buildDataProps } from "../utilities/props"
|
5
5
|
|
6
|
-
import
|
7
|
-
|
8
|
-
import Icon from '../pb_icon/_icon'
|
6
|
+
import Icon from "../pb_icon/_icon"
|
9
7
|
|
10
8
|
type StarRatingProps = {
|
11
|
-
aria?:
|
9
|
+
aria?: {[key: string]: string},
|
12
10
|
className?: string,
|
13
11
|
data?: object,
|
14
12
|
fixedWidth?: boolean,
|
@@ -16,7 +14,7 @@ type StarRatingProps = {
|
|
16
14
|
icon?: string,
|
17
15
|
id?: string,
|
18
16
|
rating: number,
|
19
|
-
}
|
17
|
+
};
|
20
18
|
|
21
19
|
const StarRating = ({
|
22
20
|
aria = {},
|
@@ -29,15 +27,15 @@ const StarRating = ({
|
|
29
27
|
const ariaProps = buildAriaProps(aria)
|
30
28
|
const dataProps = buildDataProps(data)
|
31
29
|
const css = classnames([
|
32
|
-
|
30
|
+
"pb_star_rating_kit", className,
|
33
31
|
])
|
34
32
|
|
35
33
|
const starCount = () => (
|
36
|
-
[...Array(
|
34
|
+
[...Array(Math.floor(rating))]
|
37
35
|
)
|
38
36
|
|
39
37
|
const hasHalfStar = () => (
|
40
|
-
|
38
|
+
rating % 1 !== 0
|
41
39
|
)
|
42
40
|
|
43
41
|
return (
|
@@ -47,12 +45,11 @@ const StarRating = ({
|
|
47
45
|
className={css}
|
48
46
|
id={id}
|
49
47
|
>
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
48
|
+
{!hideRating && (
|
49
|
+
<div className="pb_star_rating_number">
|
50
|
+
{rating}
|
51
|
+
</div>
|
52
|
+
)}
|
56
53
|
<div className="pb_star_rating_wrapper">
|
57
54
|
<div className="pb_star_rating_highlight">
|
58
55
|
{starCount().map((_, index) => (
|
@@ -62,13 +59,12 @@ const StarRating = ({
|
|
62
59
|
key={index}
|
63
60
|
/>
|
64
61
|
))}
|
65
|
-
|
66
|
-
<If condition={hasHalfStar()}>
|
62
|
+
{hasHalfStar() && (
|
67
63
|
<Icon
|
68
|
-
|
69
|
-
|
64
|
+
fixedWidth={false}
|
65
|
+
icon="star-half"
|
70
66
|
/>
|
71
|
-
|
67
|
+
)}
|
72
68
|
</div>
|
73
69
|
|
74
70
|
<div className="pb_star_rating_base">
|
@@ -0,0 +1,71 @@
|
|
1
|
+
import React from "react";
|
2
|
+
import { render, screen } from "../utilities/test-utils";
|
3
|
+
|
4
|
+
import StarRating from "./_star_rating";
|
5
|
+
|
6
|
+
const testId = "star-rating-kit";
|
7
|
+
|
8
|
+
describe("Star Rating Kit", () => {
|
9
|
+
test("Expects to have correct classname", () => {
|
10
|
+
render(
|
11
|
+
<StarRating
|
12
|
+
data={{ testid: testId }}
|
13
|
+
rating={2}
|
14
|
+
/>
|
15
|
+
);
|
16
|
+
|
17
|
+
|
18
|
+
const kit = screen.getByTestId(testId);
|
19
|
+
expect(kit).toHaveClass("pb_star_rating_kit");
|
20
|
+
|
21
|
+
});
|
22
|
+
|
23
|
+
test('should render aria-label', () => {
|
24
|
+
render(
|
25
|
+
<StarRating
|
26
|
+
aria={{ label: testId }}
|
27
|
+
data={{ testid: testId }}
|
28
|
+
rating={2}
|
29
|
+
/>
|
30
|
+
);
|
31
|
+
|
32
|
+
const kit = screen.getByTestId(testId)
|
33
|
+
expect(kit).toHaveAttribute('aria-label', testId)
|
34
|
+
});
|
35
|
+
|
36
|
+
test("Displays two highlighted stars", () => {
|
37
|
+
render(
|
38
|
+
<StarRating
|
39
|
+
data={{ testid: testId }}
|
40
|
+
rating={2}
|
41
|
+
/>
|
42
|
+
);
|
43
|
+
|
44
|
+
|
45
|
+
const kit = screen.getByTestId(testId);
|
46
|
+
const highlight = kit.querySelector(".pb_star_rating_highlight");
|
47
|
+
const stars = highlight.querySelectorAll(".far.fa-star");
|
48
|
+
const count = stars.length;
|
49
|
+
|
50
|
+
expect(count).toBe(2);
|
51
|
+
});
|
52
|
+
|
53
|
+
test("Displays three highlighted stars and a half star", () => {
|
54
|
+
render(
|
55
|
+
<StarRating
|
56
|
+
data={{ testid: testId }}
|
57
|
+
rating={3.5}
|
58
|
+
/>
|
59
|
+
);
|
60
|
+
|
61
|
+
const kit = screen.getByTestId(testId);
|
62
|
+
const highlight = kit.querySelector(".pb_star_rating_highlight");
|
63
|
+
const stars = highlight.querySelectorAll(".far.fa-star");
|
64
|
+
const halfStars = highlight.querySelectorAll(".far.fa-star-half");
|
65
|
+
const starCount = stars.length;
|
66
|
+
const halfStarCount = halfStars.length;
|
67
|
+
|
68
|
+
expect(starCount).toBe(3);
|
69
|
+
expect(halfStarCount).toBe(1);
|
70
|
+
});
|
71
|
+
});
|
@@ -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>
|
@@ -0,0 +1,41 @@
|
|
1
|
+
<%= pb_rails("table", props: { size: "sm", margin_bottom: "lg" }) do %>
|
2
|
+
<thead>
|
3
|
+
<tr>
|
4
|
+
<th>Column 1</th>
|
5
|
+
<th>Column 2</th>
|
6
|
+
<th>Column 3</th>
|
7
|
+
</tr>
|
8
|
+
</thead>
|
9
|
+
<tbody>
|
10
|
+
<tr>
|
11
|
+
<td>Value 1</td>
|
12
|
+
<td>Value 2</td>
|
13
|
+
<td>Value 3</td>
|
14
|
+
</tr>
|
15
|
+
<%= pb_rails("background", props: { background_color: "error_subtle", tag: "tr" }) do %>
|
16
|
+
<td>Value 1</td>
|
17
|
+
<td>Value 2</td>
|
18
|
+
<td>Value 3</td>
|
19
|
+
<% end %>
|
20
|
+
<tr>
|
21
|
+
<td>Value 1</td>
|
22
|
+
<td>Value 2</td>
|
23
|
+
<td>Value 3</td>
|
24
|
+
</tr>
|
25
|
+
<tr>
|
26
|
+
<td>Value 1</td>
|
27
|
+
<td>Value 2</td>
|
28
|
+
<td>Value 3</td>
|
29
|
+
</tr>
|
30
|
+
<%= pb_rails("background", props: { background_color: "warning_subtle", tag: "tr" }) do %>
|
31
|
+
<td>Value 1</td>
|
32
|
+
<td>Value 2</td>
|
33
|
+
<td>Value 3</td>
|
34
|
+
<% end %>
|
35
|
+
<tr>
|
36
|
+
<td>Value 1</td>
|
37
|
+
<td>Value 2</td>
|
38
|
+
<td>Value 3</td>
|
39
|
+
</tr>
|
40
|
+
</tbody>
|
41
|
+
<% end %>
|