playbook_ui 14.17.0.pre.alpha.PLAY1967bracketlayoutphase27221 → 14.17.0.pre.alpha.PLAY1967bracketlayoutphase27244
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/pb_background/_background.scss +26 -0
- data/app/pb_kits/playbook/pb_background/_background.tsx +5 -3
- data/app/pb_kits/playbook/pb_background/background.test.js +5 -0
- data/app/pb_kits/playbook/pb_background/docs/_background_overlay.jsx +35 -0
- data/app/pb_kits/playbook/pb_background/docs/_background_overlay.md +1 -0
- data/app/pb_kits/playbook/pb_background/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_background/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_layout/_layout.scss +23 -3
- data/app/pb_kits/playbook/pb_layout/_layout.tsx +27 -2
- data/app/pb_kits/playbook/pb_layout/docs/_layout_bracket.jsx +18 -14
- data/app/pb_kits/playbook/pb_layout/subcomponents/_game.tsx +18 -7
- data/app/pb_kits/playbook/pb_layout/subcomponents/_participant.tsx +12 -6
- data/app/pb_kits/playbook/pb_layout/subcomponents/_round.tsx +21 -4
- data/app/pb_kits/playbook/pb_table/docs/_table_with_header_style_borderless.html.erb +34 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_header_style_borderless_rails.md +1 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_header_style_floating.html.erb +36 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_header_style_floating_rails.md +1 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_header_style_floating_react.md +1 -1
- data/app/pb_kits/playbook/pb_table/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_table/table.rb +13 -1
- data/app/pb_kits/playbook/pb_table/table_header.rb +13 -1
- data/dist/chunks/{_typeahead-DZZ1n1Oe.js → _typeahead-BY6AFq1l.js} +1 -1
- data/dist/chunks/{_weekday_stacked-C-B5y5yN.js → _weekday_stacked-CHQAKYTa.js} +2 -2
- data/dist/chunks/vendor.js +1 -1
- data/dist/playbook-doc.js +1 -1
- data/dist/playbook-rails-react-bindings.js +1 -1
- data/dist/playbook-rails.js +1 -1
- data/dist/playbook.css +1 -1
- data/lib/playbook/version.rb +1 -1
- metadata +10 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 920da5818325a824d55eb4d6b91dc75f4fe4f8994265a92a1e660df7e2081456
|
4
|
+
data.tar.gz: b8378998b1aa55c7b7477276bf07cbce25e86fb8bcb69e1b79400b0ad4237118
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2da26fcf4102d726e24e7b72b107d9703baa91133e38ea76022feb961ae0d10a0b16c7df8631bc83494cdd7dfaa0dc256b1fb19eb801c08368428b7d5c4948e
|
7
|
+
data.tar.gz: 7b730b852a4e767544d72b2e570581e3c4fee1b83dc1725ab716eb602a5bdd400a93be542021b2c30ebee1341b5ab74a74005b52388d28c09957495e39cc9983
|
@@ -55,4 +55,30 @@ $background_colors: map-merge($additional_colors, $merge_kits7);
|
|
55
55
|
transition: 700ms ease-in;
|
56
56
|
}
|
57
57
|
}
|
58
|
+
|
59
|
+
&[class*=imageoverlay] {
|
60
|
+
position: relative;
|
61
|
+
|
62
|
+
&:before {
|
63
|
+
content: "";
|
64
|
+
position: absolute;
|
65
|
+
top: 0;
|
66
|
+
left: 0;
|
67
|
+
right: 0;
|
68
|
+
bottom: 0;
|
69
|
+
z-index: 1;
|
70
|
+
background-color: inherit;
|
71
|
+
}
|
72
|
+
|
73
|
+
* {
|
74
|
+
position: relative;
|
75
|
+
z-index: 2;
|
76
|
+
}
|
77
|
+
}
|
78
|
+
|
79
|
+
@each $key, $value in $opacity {
|
80
|
+
&.imageoverlay_#{$key}::before {
|
81
|
+
opacity: $value;
|
82
|
+
}
|
83
|
+
}
|
58
84
|
}
|
@@ -25,6 +25,7 @@ type BackgroundProps = {
|
|
25
25
|
backgroundPosition?: ResponsiveProp<string> | string,
|
26
26
|
backgroundRepeat?: ResponsiveProp<BackgroundRepeat> | BackgroundRepeat,
|
27
27
|
imageUrl?: ResponsiveProp<string> | string,
|
28
|
+
imageOverlay?: 'opacity_1' | 'opacity_2' | 'opacity_3' | 'opacity_4' | 'opacity_5' | 'opacity_6' | 'opacity_7' | 'opacity_8' | 'opacity_9' | 'opacity_10',
|
28
29
|
children?: React.ReactChild[] | React.ReactNode,
|
29
30
|
className?: string,
|
30
31
|
customColor?: string,
|
@@ -83,11 +84,12 @@ const Background = (props: BackgroundProps): React.ReactElement => {
|
|
83
84
|
data = {},
|
84
85
|
htmlOptions = {},
|
85
86
|
id,
|
87
|
+
imageOverlay,
|
86
88
|
imageUrl = '',
|
87
89
|
tag = 'div',
|
88
90
|
transition = '',
|
89
91
|
} = props
|
90
|
-
|
92
|
+
|
91
93
|
const [responsiveProps, setResponsiveProps] = useState({
|
92
94
|
backgroundSize: getResponsiveValue(backgroundSize),
|
93
95
|
backgroundPosition: getResponsiveValue(backgroundPosition),
|
@@ -132,6 +134,7 @@ const Background = (props: BackgroundProps): React.ReactElement => {
|
|
132
134
|
[`pb_background_color_${resBackgroundColor}`]: resBackgroundColor && !customColor,
|
133
135
|
[`pb_background_custom_color`]: !!customColor,
|
134
136
|
},
|
137
|
+
imageOverlay ? `imageoverlay_${imageOverlay}` : "",
|
135
138
|
className
|
136
139
|
);
|
137
140
|
|
@@ -155,7 +158,7 @@ const Background = (props: BackgroundProps): React.ReactElement => {
|
|
155
158
|
const ariaProps = buildAriaProps(aria);
|
156
159
|
const dataProps = buildDataProps(data);
|
157
160
|
const htmlProps = buildHtmlProps(htmlOptions);
|
158
|
-
|
161
|
+
|
159
162
|
return (
|
160
163
|
<Tag
|
161
164
|
{...ariaProps}
|
@@ -168,7 +171,6 @@ const Background = (props: BackgroundProps): React.ReactElement => {
|
|
168
171
|
>
|
169
172
|
{children}
|
170
173
|
</Tag>
|
171
|
-
|
172
174
|
)
|
173
175
|
}
|
174
176
|
|
@@ -37,3 +37,8 @@ test('backgroundSize = auto', () => {
|
|
37
37
|
const kit = renderKit(Background, props, { classname: "background-image", imageUrl: "https://images.unsplash.com/photo-1528459801416-a9e53bbf4e17?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1000&q=80", backgroundSize: 'auto' })
|
38
38
|
expect(kit).toHaveStyle('background-size: auto')
|
39
39
|
})
|
40
|
+
|
41
|
+
test('applies correct overlay class when imageOverlay prop is provided', () => {
|
42
|
+
const kit = renderKit(Background, props, { imageOverlay: 'opacity_6' });
|
43
|
+
expect(kit).toHaveClass('imageoverlay_opacity_6');
|
44
|
+
});
|
@@ -0,0 +1,35 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import Background from "../../pb_background/_background"
|
3
|
+
import Flex from "../../pb_flex/_flex"
|
4
|
+
import FlexItem from "../../pb_flex/_flex_item"
|
5
|
+
import Title from "../../pb_title/_title"
|
6
|
+
|
7
|
+
const BackgroundOverlay = (props) => {
|
8
|
+
return (
|
9
|
+
<Background
|
10
|
+
alt="colorful background"
|
11
|
+
backgroundColor="category_21"
|
12
|
+
className="background lazyload"
|
13
|
+
imageOverlay="opacity_2"
|
14
|
+
imageUrl="https://unsplash.it/500/400/?image=633"
|
15
|
+
{...props}
|
16
|
+
>
|
17
|
+
<Flex
|
18
|
+
orientation="column"
|
19
|
+
vertical="center"
|
20
|
+
{...props}
|
21
|
+
>
|
22
|
+
<FlexItem>
|
23
|
+
<Title
|
24
|
+
dark
|
25
|
+
padding="lg"
|
26
|
+
size={1}
|
27
|
+
text="Background Kit Image"
|
28
|
+
/>
|
29
|
+
</FlexItem>
|
30
|
+
</Flex>
|
31
|
+
</Background>
|
32
|
+
)
|
33
|
+
}
|
34
|
+
|
35
|
+
export default BackgroundOverlay
|
@@ -0,0 +1 @@
|
|
1
|
+
An overlay can be added to the background image by setting the `imageOverlay` prop and adding a `backgroundColor`. The `imageOverlay` prop can be set to any opacity ranging from `opacity_1` to `opacity_10`.
|
@@ -6,3 +6,4 @@ export { default as BackgroundStatus } from './_background_status.jsx'
|
|
6
6
|
export { default as BackgroundStatusSubtle } from './_background_status_subtle.jsx'
|
7
7
|
export { default as BackgroundCategory } from './_background_category.jsx'
|
8
8
|
export { default as BackgroundSize } from './_background_size.jsx'
|
9
|
+
export { default as BackgroundOverlay } from './_background_overlay.jsx'
|
@@ -228,19 +228,23 @@ $bracket-border-width: 4px;
|
|
228
228
|
|
229
229
|
.layout_participant,
|
230
230
|
.layout_participant_winner,
|
231
|
-
.layout_participant_self
|
231
|
+
.layout_participant_self,
|
232
|
+
.layout_participant_winner_self,
|
233
|
+
.layout_participant_winner_self_last {
|
232
234
|
height: 60px;
|
233
235
|
}
|
234
236
|
|
235
237
|
.layout_tbd {
|
236
|
-
height:
|
238
|
+
height: 140px;
|
237
239
|
display: flex;
|
238
240
|
flex-direction: column;
|
239
241
|
justify-content: center;
|
240
242
|
}
|
241
243
|
|
242
244
|
.layout_participant_winner,
|
243
|
-
.layout_participant_self
|
245
|
+
.layout_participant_self,
|
246
|
+
.layout_participant_winner_self,
|
247
|
+
.layout_participant_winner_self_last {
|
244
248
|
position: relative;
|
245
249
|
|
246
250
|
&::after {
|
@@ -262,6 +266,22 @@ $bracket-border-width: 4px;
|
|
262
266
|
background: $category_1;
|
263
267
|
}
|
264
268
|
|
269
|
+
.layout_participant_winner_self::after {
|
270
|
+
right: 0;
|
271
|
+
background: $product_6_highlight;
|
272
|
+
}
|
273
|
+
|
274
|
+
.layout_participant_winner_self_last::after {
|
275
|
+
left: 0;
|
276
|
+
background: $category_1;
|
277
|
+
}
|
278
|
+
|
279
|
+
.game_separator {
|
280
|
+
&::before, &::after {
|
281
|
+
height: 2px;
|
282
|
+
}
|
283
|
+
}
|
284
|
+
|
265
285
|
@media (max-width: $screen-md-max) {
|
266
286
|
flex-direction: column;
|
267
287
|
.layout_round_label {
|
@@ -177,13 +177,38 @@ const Layout = (props: LayoutPropTypes) => {
|
|
177
177
|
(child: React.ReactElement & {type: {displayName: string}}) => child.type?.displayName !== 'Side'
|
178
178
|
)
|
179
179
|
|
180
|
-
const numberOfRounds = Array.isArray(
|
180
|
+
const numberOfRounds = Array.isArray(children) ? React.Children.toArray(children).filter(
|
181
181
|
(child) => {
|
182
182
|
return (child as React.ReactElement).type === Layout.Round;
|
183
183
|
}
|
184
184
|
).length : 0
|
185
|
+
|
186
|
+
const lastRoundWithSelf = React.Children.toArray(children).filter((child) => {
|
187
|
+
if ((child as React.ReactElement).type !== Layout.Round) {
|
188
|
+
return false
|
189
|
+
}
|
190
|
+
|
191
|
+
const roundElement = child as React.ReactElement
|
192
|
+
|
193
|
+
const gameChildren = React.Children.toArray(roundElement.props.children)
|
194
|
+
|
195
|
+
const hasWinningSelfParticipant = gameChildren.some((gameChild) => {
|
196
|
+
const gameElement = gameChild as React.ReactElement
|
197
|
+
|
198
|
+
const participantChildren = React.Children.toArray(gameElement.props.children)
|
199
|
+
|
200
|
+
return participantChildren.some((participantChild) => {
|
201
|
+
const participantElement = participantChild as React.ReactElement
|
202
|
+
const { self } = participantElement.props
|
203
|
+
return self === true
|
204
|
+
})
|
205
|
+
})
|
206
|
+
|
207
|
+
return hasWinningSelfParticipant
|
208
|
+
}).length
|
209
|
+
|
185
210
|
const bracketChildren = nonSideChildren.map(child =>
|
186
|
-
React.isValidElement(child) ? React.cloneElement(child, { numberOfRounds }) : child
|
211
|
+
React.isValidElement(child) ? React.cloneElement(child, { numberOfRounds, lastRoundWithSelf }) : child
|
187
212
|
)
|
188
213
|
|
189
214
|
const filteredProps = {...props}
|
@@ -6,85 +6,85 @@ import SectionSeparator from '../../pb_section_separator/_section_separator'
|
|
6
6
|
|
7
7
|
const teamData = {
|
8
8
|
eagles: {
|
9
|
-
avatar:"https://
|
9
|
+
avatar:"https://images.unsplash.com/photo-1628703117067-fb7c9c20946e?w=500&auto=format&fit=crop&q=60&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxzZWFyY2h8Mnx8ZWFnbGVzfGVufDB8fDB8fHww",
|
10
10
|
name:"Eagles",
|
11
11
|
rank:"#1 NFC East",
|
12
12
|
territory:"PHI",
|
13
13
|
},
|
14
14
|
packers: {
|
15
|
-
avatar:"https://
|
15
|
+
avatar:"https://images.unsplash.com/photo-1486297678162-eb2a19b0a32d?q=80&w=500&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",
|
16
16
|
name:"Packers",
|
17
17
|
rank:"#3 NFC North",
|
18
18
|
territory:"GB",
|
19
19
|
},
|
20
20
|
vikings: {
|
21
|
-
avatar:"https://
|
21
|
+
avatar:"https://images.unsplash.com/photo-1525540796810-55f9fbc5592f?w=500&auto=format&fit=crop&q=60&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxzZWFyY2h8MTV8fHZpa2luZ3xlbnwwfHwwfHx8MA%3D%3D",
|
22
22
|
name:"Vikings",
|
23
23
|
rank:"#2 NFC North",
|
24
24
|
territory:"MIN",
|
25
25
|
},
|
26
26
|
rams: {
|
27
|
-
avatar:"https://
|
27
|
+
avatar:"https://images.unsplash.com/photo-1490739043913-239b6cdf4084?q=80&w=500&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",
|
28
28
|
name:"Rams",
|
29
29
|
rank:"#1 NFC West",
|
30
30
|
territory:"LAR",
|
31
31
|
},
|
32
32
|
lions: {
|
33
|
-
avatar:"https://
|
33
|
+
avatar:"https://images.unsplash.com/photo-1614027164847-1b28cfe1df60?q=80&w=500&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",
|
34
34
|
name:"Lions",
|
35
35
|
rank:"#1 NFC North",
|
36
36
|
territory:"DET",
|
37
37
|
},
|
38
38
|
commanders: {
|
39
|
-
avatar:"https://
|
39
|
+
avatar:"https://images.unsplash.com/photo-1501466044931-62695aada8e9?q=80&w=500&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",
|
40
40
|
name:"Commanders",
|
41
41
|
rank:"#2 NFC East",
|
42
42
|
territory:"WAS",
|
43
43
|
},
|
44
44
|
buccaneers: {
|
45
|
-
avatar:"https://
|
45
|
+
avatar:"https://images.unsplash.com/photo-1584116843008-46d529f04145?q=80&w=500&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",
|
46
46
|
name:"Buccaneers",
|
47
47
|
rank:"#1 NFC South",
|
48
48
|
territory:"TB",
|
49
49
|
},
|
50
50
|
chiefs: {
|
51
|
-
avatar:"https://
|
51
|
+
avatar:"https://plus.unsplash.com/premium_photo-1697729864667-57f5f29e946b?w=500&auto=format&fit=crop&q=60&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxzZWFyY2h8MXx8a2Fuc2FzJTIwY2l0eXxlbnwwfHwwfHx8MA%3D%3D",
|
52
52
|
name:"Chiefs",
|
53
53
|
rank:"#1 AFC West",
|
54
54
|
territory:"KC",
|
55
55
|
},
|
56
56
|
chargers: {
|
57
|
-
avatar:"https://
|
57
|
+
avatar:"https://images.unsplash.com/photo-1529310399831-ed472b81d589?q=80&w=500&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",
|
58
58
|
name:"Chargers",
|
59
59
|
rank:"#2 AFC West",
|
60
60
|
territory:"LAC",
|
61
61
|
},
|
62
62
|
texans: {
|
63
|
-
avatar:"https://
|
63
|
+
avatar:"https://images.unsplash.com/photo-1545345540-ea5d968030af?q=80&w=500&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",
|
64
64
|
name:"Texans",
|
65
65
|
rank:"#1 AFC South",
|
66
66
|
territory:"HOU",
|
67
67
|
},
|
68
68
|
broncos: {
|
69
|
-
avatar:"https://
|
69
|
+
avatar:"https://images.unsplash.com/photo-1553284965-83fd3e82fa5a?q=80&w=500&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",
|
70
70
|
name:"Broncos",
|
71
71
|
rank:"#3 AFC West",
|
72
72
|
territory:"DEN",
|
73
73
|
},
|
74
74
|
bills: {
|
75
|
-
avatar:"https://
|
75
|
+
avatar:"https://images.unsplash.com/photo-1575414914265-ebc9aa2637f4?q=80&w=500&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",
|
76
76
|
name:"Bills",
|
77
77
|
rank:"#1 AFC East",
|
78
78
|
territory:"BUF",
|
79
79
|
},
|
80
80
|
steelers: {
|
81
|
-
avatar:"https://
|
81
|
+
avatar:"https://plus.unsplash.com/premium_photo-1697730155764-cc8ca8f78cbe?w=500&auto=format&fit=crop&q=60&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxzZWFyY2h8MXx8cGl0dHNidXJnaHxlbnwwfHwwfHx8MA%3D%3D",
|
82
82
|
name:"Steelers",
|
83
83
|
rank:"#2 AFC North",
|
84
84
|
territory:"PIT",
|
85
85
|
},
|
86
86
|
ravens: {
|
87
|
-
avatar:"https://
|
87
|
+
avatar:"https://images.unsplash.com/photo-1433888376991-1297486ba3f5?w=500&auto=format&fit=crop&q=60&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxzZWFyY2h8Mnx8cmF2ZW58ZW58MHx8MHx8fDA%3D",
|
88
88
|
name:"Ravens",
|
89
89
|
rank:"#1 AFC North",
|
90
90
|
territory:"BAL",
|
@@ -121,6 +121,7 @@ const LayoutBracket = () => {
|
|
121
121
|
name={teamData.eagles.name}
|
122
122
|
points="22"
|
123
123
|
rank={teamData.eagles.rank}
|
124
|
+
self
|
124
125
|
territory={teamData.eagles.territory}
|
125
126
|
winner
|
126
127
|
/>
|
@@ -263,6 +264,7 @@ const LayoutBracket = () => {
|
|
263
264
|
name={teamData.eagles.name}
|
264
265
|
points="28"
|
265
266
|
rank={teamData.eagles.rank}
|
267
|
+
self
|
266
268
|
territory={teamData.eagles.territory}
|
267
269
|
winner
|
268
270
|
/>
|
@@ -337,6 +339,7 @@ const LayoutBracket = () => {
|
|
337
339
|
name={teamData.eagles.name}
|
338
340
|
points="55"
|
339
341
|
rank={teamData.eagles.rank}
|
342
|
+
self
|
340
343
|
territory={teamData.eagles.territory}
|
341
344
|
winner
|
342
345
|
/>
|
@@ -379,6 +382,7 @@ const LayoutBracket = () => {
|
|
379
382
|
rank={teamData.eagles.rank}
|
380
383
|
self
|
381
384
|
territory={teamData.eagles.territory}
|
385
|
+
winner
|
382
386
|
/>
|
383
387
|
</Layout.Game>
|
384
388
|
</Layout.Round>
|
@@ -13,12 +13,13 @@ type LayoutGameProps = {
|
|
13
13
|
className?: string,
|
14
14
|
numberOfRounds: number,
|
15
15
|
numberOfGames: number,
|
16
|
+
lastRoundWithSelf?: number,
|
16
17
|
isOdd: boolean,
|
17
18
|
} & GlobalProps
|
18
19
|
|
19
20
|
// Game component (modeled after Item)
|
20
21
|
const Game = (props: LayoutGameProps) => {
|
21
|
-
const { children, className, numberOfRounds, numberOfGames, isOdd } = props
|
22
|
+
const { children, className, numberOfRounds, numberOfGames, isOdd, lastRoundWithSelf } = props
|
22
23
|
const dynamicInlineProps = globalInlineProps(props)
|
23
24
|
|
24
25
|
const numberOfChildren = Array.isArray(children) ? children.length : 0
|
@@ -27,17 +28,27 @@ const Game = (props: LayoutGameProps) => {
|
|
27
28
|
|
28
29
|
let ratio = 0
|
29
30
|
let exponent
|
31
|
+
let currentRound = numberOfRounds
|
30
32
|
if (numberOfGames > 1) {
|
31
33
|
exponent = (numberOfRounds) - Math.log2(numberOfGames) - 1
|
32
34
|
ratio = 2 ** exponent
|
35
|
+
|
36
|
+
currentRound = exponent + 1
|
33
37
|
}
|
34
38
|
|
35
39
|
let hasWinner = false
|
40
|
+
const hasLastWinnerAndSelf = lastRoundWithSelf === currentRound
|
36
41
|
if (numberOfChildren === 2) {
|
37
|
-
const [
|
42
|
+
const [firstChildWithoutProps, secondChildWithoutProps] = React.Children.toArray(children)
|
43
|
+
|
44
|
+
const firstChild = React.isValidElement(firstChildWithoutProps) ? React.cloneElement(firstChildWithoutProps, { hasLastWinnerAndSelf }) : firstChildWithoutProps
|
45
|
+
const secondChild = React.isValidElement(secondChildWithoutProps) ? React.cloneElement(secondChildWithoutProps, { hasLastWinnerAndSelf }) : secondChildWithoutProps
|
38
46
|
|
39
47
|
if (React.isValidElement(firstChild) && React.isValidElement(secondChild)) {
|
40
|
-
if (
|
48
|
+
if (
|
49
|
+
firstChild?.props && typeof firstChild.props === 'object' && 'winner' in firstChild.props ||
|
50
|
+
secondChild?.props && typeof secondChild.props === 'object' && 'winner' in secondChild.props
|
51
|
+
) {
|
41
52
|
hasWinner = true
|
42
53
|
}
|
43
54
|
return (
|
@@ -52,7 +63,7 @@ const Game = (props: LayoutGameProps) => {
|
|
52
63
|
shadow="deep"
|
53
64
|
>
|
54
65
|
<Card.Body padding="none">{firstChild}</Card.Body>
|
55
|
-
<SectionSeparator />
|
66
|
+
<SectionSeparator className="game_separator"/>
|
56
67
|
<Card.Body padding="none">{secondChild}</Card.Body>
|
57
68
|
</Card>
|
58
69
|
{isOdd && numberOfGames > 1 &&
|
@@ -84,13 +95,13 @@ const Game = (props: LayoutGameProps) => {
|
|
84
95
|
shadow="deep"
|
85
96
|
>
|
86
97
|
<Card.Body padding="xs">
|
87
|
-
<Body color="
|
98
|
+
<Body color="light">
|
88
99
|
To be determined...
|
89
100
|
</Body>
|
90
101
|
</Card.Body>
|
91
|
-
<SectionSeparator />
|
102
|
+
<SectionSeparator className="game_separator"/>
|
92
103
|
<Card.Body padding="xs">
|
93
|
-
<Body color="
|
104
|
+
<Body color="light">
|
94
105
|
To be determined...
|
95
106
|
</Body>
|
96
107
|
</Card.Body>
|
@@ -23,9 +23,10 @@ type LayoutParticipantProps = {
|
|
23
23
|
} & GlobalProps
|
24
24
|
|
25
25
|
export const Participant = (props: LayoutParticipantProps) => {
|
26
|
-
const { className, name = 'To be determined...', territory = '', points, rank, avatar, winner, self } = props
|
26
|
+
const { className, name = 'To be determined...', territory = '', points, rank, avatar, winner, self, hasLastWinnerAndSelf } = props
|
27
27
|
const dynamicInlineProps = globalInlineProps(props)
|
28
|
-
const
|
28
|
+
const isLastWinnerAndSelf = hasLastWinnerAndSelf && self && winner
|
29
|
+
const classes = classnames(buildCss('layout_participant', winner ? 'winner' : '', self ? 'self' : '', isLastWinnerAndSelf ? 'last' : ''), globalProps(props), className)
|
29
30
|
return (
|
30
31
|
<Background
|
31
32
|
backgroundColor={winner ? "success_subtle" : "white"}
|
@@ -42,15 +43,20 @@ export const Participant = (props: LayoutParticipantProps) => {
|
|
42
43
|
/>
|
43
44
|
<Body flexGrow={1}>
|
44
45
|
<Flex justify="between">
|
45
|
-
<Body color={winner ? "success" : "default"}>{winner ? <strong>{name}</strong> : name}{self ? ' (You)' : ''}</Body>
|
46
46
|
<Body
|
47
|
-
color={winner ? "success" : "
|
47
|
+
color={winner && !isLastWinnerAndSelf ? "success" : "default"}
|
48
|
+
truncate={1}
|
49
|
+
>
|
50
|
+
{winner ? <strong>{name}{self ? ' (You)' : ''}</strong> : name + (self && !isLastWinnerAndSelf ? ' (You)' : '')}
|
51
|
+
</Body>
|
52
|
+
<Body
|
53
|
+
color={winner && !isLastWinnerAndSelf ? "success" : "light"}
|
48
54
|
display="flex"
|
49
55
|
>
|
50
56
|
{points && (<>
|
51
57
|
<strong>{points}</strong>
|
52
58
|
<Detail
|
53
|
-
color={winner ? "success" : "light"}
|
59
|
+
color={winner && !isLastWinnerAndSelf ? "success" : "light"}
|
54
60
|
text="pts"
|
55
61
|
/>
|
56
62
|
</>)}
|
@@ -61,7 +67,7 @@ export const Participant = (props: LayoutParticipantProps) => {
|
|
61
67
|
|
62
68
|
<Badge
|
63
69
|
text={rank}
|
64
|
-
variant={winner ? "success" : self ? "notification" : "neutral"}
|
70
|
+
variant={winner && !isLastWinnerAndSelf ? "success" : self ? "notification" : "neutral"}
|
65
71
|
/>
|
66
72
|
</Body>
|
67
73
|
</Body>
|
@@ -25,16 +25,33 @@ type LayoutRoundProps = {
|
|
25
25
|
children: React.ReactNode[] | React.ReactNode,
|
26
26
|
className?: string,
|
27
27
|
numberOfRounds: number,
|
28
|
+
lastRoundWithSelf: number,
|
28
29
|
} & GlobalProps
|
29
30
|
|
30
31
|
export const Round = (props: LayoutRoundProps) => {
|
31
|
-
const { children, className, numberOfRounds } = props
|
32
|
+
const { children, className, numberOfRounds, lastRoundWithSelf } = props
|
32
33
|
const dynamicInlineProps = globalInlineProps(props)
|
33
34
|
const numberOfChildren = Array.isArray(children) ? children.length : 0
|
34
35
|
|
35
|
-
const childrenWithProps = Array.isArray(children)
|
36
|
-
|
37
|
-
|
36
|
+
const childrenWithProps = Array.isArray(children)
|
37
|
+
? children.map((child, index) =>
|
38
|
+
React.isValidElement(child)
|
39
|
+
? React.cloneElement(child, {
|
40
|
+
numberOfRounds,
|
41
|
+
numberOfGames: numberOfChildren,
|
42
|
+
isOdd: index % 2 === 0,
|
43
|
+
key: `child_${index}`,
|
44
|
+
lastRoundWithSelf
|
45
|
+
})
|
46
|
+
: child
|
47
|
+
)
|
48
|
+
: React.isValidElement(children)
|
49
|
+
? React.cloneElement(children, {
|
50
|
+
numberOfRounds,
|
51
|
+
numberOfGames: numberOfChildren,
|
52
|
+
lastRoundWithSelf
|
53
|
+
})
|
54
|
+
: children
|
38
55
|
|
39
56
|
const rightConnectors = Array.from({ length: numberOfChildren / 2 }, (_, index) => (
|
40
57
|
<div
|
@@ -0,0 +1,34 @@
|
|
1
|
+
<%= pb_rails("table", props: { size: "sm", header_style: "borderless" }) do %>
|
2
|
+
<thead>
|
3
|
+
<tr>
|
4
|
+
<th>Column 1</th>
|
5
|
+
<th>Column 2</th>
|
6
|
+
<th>Column 3</th>
|
7
|
+
<th>Column 4</th>
|
8
|
+
<th>Column 5</th>
|
9
|
+
</tr>
|
10
|
+
</thead>
|
11
|
+
<tbody>
|
12
|
+
<tr>
|
13
|
+
<td>Value 1</td>
|
14
|
+
<td>Value 2</td>
|
15
|
+
<td>Value 3</td>
|
16
|
+
<td>Value 4</td>
|
17
|
+
<td>Value 5</td>
|
18
|
+
</tr>
|
19
|
+
<tr>
|
20
|
+
<td>Value 1</td>
|
21
|
+
<td>Value 2</td>
|
22
|
+
<td>Value 3</td>
|
23
|
+
<td>Value 4</td>
|
24
|
+
<td>Value 5</td>
|
25
|
+
</tr>
|
26
|
+
<tr>
|
27
|
+
<td>Value 1</td>
|
28
|
+
<td>Value 2</td>
|
29
|
+
<td>Value 3</td>
|
30
|
+
<td>Value 4</td>
|
31
|
+
<td>Value 5</td>
|
32
|
+
</tr>
|
33
|
+
</tbody>
|
34
|
+
<% end %>
|
@@ -0,0 +1 @@
|
|
1
|
+
Customize your header by removing the header borders with the `header_style: "borderless"` prop.
|
@@ -0,0 +1,36 @@
|
|
1
|
+
<%= pb_rails("card", props: { background: "light" }) do %>
|
2
|
+
<%= pb_rails("table", props: { size: "sm", header_style: "floating" }) do %>
|
3
|
+
<%= pb_rails("table/table_head") do %>
|
4
|
+
<%= pb_rails("background", props: { background_color: "light", tag: "tr" }) do %>
|
5
|
+
<%= pb_rails("table/table_header", props: { text: "Column 1"}) %>
|
6
|
+
<%= pb_rails("table/table_header", props: { text: "Column 2"}) %>
|
7
|
+
<%= pb_rails("table/table_header", props: { text: "Column 3"}) %>
|
8
|
+
<%= pb_rails("table/table_header", props: { text: "Column 4"}) %>
|
9
|
+
<%= pb_rails("table/table_header", props: { text: "Column 5"}) %>
|
10
|
+
<% end %>
|
11
|
+
<% end %>
|
12
|
+
<%= pb_rails("table/table_body") do %>
|
13
|
+
<%= pb_rails("table/table_row") do %>
|
14
|
+
<%= pb_rails("table/table_cell", props: { text: "Value 1"}) %>
|
15
|
+
<%= pb_rails("table/table_cell", props: { text: "Value 2"}) %>
|
16
|
+
<%= pb_rails("table/table_cell", props: { text: "Value 3"}) %>
|
17
|
+
<%= pb_rails("table/table_cell", props: { text: "Value 4"}) %>
|
18
|
+
<%= pb_rails("table/table_cell", props: { text: "Value 5"}) %>
|
19
|
+
<% end %>
|
20
|
+
<%= pb_rails("table/table_row") do %>
|
21
|
+
<%= pb_rails("table/table_cell", props: { text: "Value 1"}) %>
|
22
|
+
<%= pb_rails("table/table_cell", props: { text: "Value 2"}) %>
|
23
|
+
<%= pb_rails("table/table_cell", props: { text: "Value 3"}) %>
|
24
|
+
<%= pb_rails("table/table_cell", props: { text: "Value 4"}) %>
|
25
|
+
<%= pb_rails("table/table_cell", props: { text: "Value 5"}) %>
|
26
|
+
<% end %>
|
27
|
+
<%= pb_rails("table/table_row") do %>
|
28
|
+
<%= pb_rails("table/table_cell", props: { text: "Value 1"}) %>
|
29
|
+
<%= pb_rails("table/table_cell", props: { text: "Value 2"}) %>
|
30
|
+
<%= pb_rails("table/table_cell", props: { text: "Value 3"}) %>
|
31
|
+
<%= pb_rails("table/table_cell", props: { text: "Value 4"}) %>
|
32
|
+
<%= pb_rails("table/table_cell", props: { text: "Value 5"}) %>
|
33
|
+
<% end %>
|
34
|
+
<% end %>
|
35
|
+
<% end %>
|
36
|
+
<% end %>
|
@@ -0,0 +1 @@
|
|
1
|
+
Further customize your header by using the [table with background kit](https://playbook.powerapp.cloud/kits/table/rails#table-with-background-kit) logic to give your table header a custom background color. Use the `header_style: "floating"` prop to visually nest the borderless table within a card or collapsible with a matching background color (the `background_color` passed to Background kit should match the `background` or `background_color` for the element in which it is nested).
|
@@ -1 +1 @@
|
|
1
|
-
Further customize your header by using the [table with background kit](https://playbook.powerapp.cloud/kits/table/react#table-with-background-kit) logic to give your table header a custom background color. Use the `headerStyle="floating"` prop to visually nest the borderless table within a card or collapsible with a matching background color (the `backgroundColor` passed to Background kit should match the `backgroundColor` for the element in which it is nested).
|
1
|
+
Further customize your header by using the [table with background kit](https://playbook.powerapp.cloud/kits/table/react#table-with-background-kit) logic to give your table header a custom background color. Use the `headerStyle="floating"` prop to visually nest the borderless table within a card or collapsible with a matching background color (the `backgroundColor` passed to Background kit should match the `background` or `backgroundColor` for the element in which it is nested).
|
@@ -37,6 +37,8 @@ examples:
|
|
37
37
|
- table_with_collapsible_with_nested_table_rails: Table with Collapsible with Nested Table
|
38
38
|
- table_with_clickable_rows: Table with Clickable Rows
|
39
39
|
- table_with_selectable_rows: Table with Selectable Rows
|
40
|
+
- table_with_header_style_borderless: Header Style Borderless
|
41
|
+
- table_with_header_style_floating: Header Style Floating
|
40
42
|
|
41
43
|
react:
|
42
44
|
- table_sm: Small
|