playbook_ui 8.1.0 → 8.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -0
- data/app/pb_kits/playbook/_playbook.scss +1 -0
- data/app/pb_kits/playbook/data/menu.yml +2 -1
- data/app/pb_kits/playbook/index.js +1 -0
- data/app/pb_kits/playbook/pb_avatar/_avatar.jsx +14 -2
- data/app/pb_kits/playbook/pb_avatar/avatar.html.erb +1 -1
- data/app/pb_kits/playbook/pb_avatar/avatar.rb +5 -2
- data/app/pb_kits/playbook/pb_avatar/avatar.test.js +5 -2
- data/app/pb_kits/playbook/pb_avatar/docs/_avatar_default.html.erb +5 -0
- data/app/pb_kits/playbook/pb_avatar/docs/_avatar_default.jsx +5 -0
- data/app/pb_kits/playbook/pb_avatar/docs/_avatar_status.html.erb +4 -0
- data/app/pb_kits/playbook/pb_avatar/docs/_avatar_status.jsx +4 -0
- data/app/pb_kits/playbook/pb_avatar_action_button/_avatar_action_button.jsx +6 -0
- data/app/pb_kits/playbook/pb_avatar_action_button/avatar_action_button.html.erb +2 -1
- data/app/pb_kits/playbook/pb_avatar_action_button/avatar_action_button.rb +2 -0
- data/app/pb_kits/playbook/pb_avatar_action_button/docs/_avatar_action_button_actions.html.erb +4 -0
- data/app/pb_kits/playbook/pb_avatar_action_button/docs/_avatar_action_button_actions.jsx +4 -0
- data/app/pb_kits/playbook/pb_avatar_action_button/docs/_avatar_action_button_default.html.erb +2 -0
- data/app/pb_kits/playbook/pb_avatar_action_button/docs/_avatar_action_button_default.jsx +2 -0
- data/app/pb_kits/playbook/pb_avatar_action_button/docs/_avatar_action_button_on_click.jsx +2 -0
- data/app/pb_kits/playbook/pb_avatar_action_button/docs/_avatar_action_button_onclick.html.erb +2 -0
- data/app/pb_kits/playbook/pb_avatar_action_button/docs/_avatar_action_button_placement.html.erb +8 -0
- data/app/pb_kits/playbook/pb_avatar_action_button/docs/_avatar_action_button_placement.jsx +8 -0
- data/app/pb_kits/playbook/pb_avatar_action_button/docs/_avatar_action_button_tooltip.html.erb +2 -0
- data/app/pb_kits/playbook/pb_avatar_action_button/pb_avatar_action_button.test.js +31 -0
- data/app/pb_kits/playbook/pb_button/_button.jsx +6 -0
- data/app/pb_kits/playbook/pb_button/button.test.js +91 -0
- data/app/pb_kits/playbook/pb_button/docs/_button_default.jsx +0 -1
- data/app/pb_kits/playbook/pb_button_toolbar/button_toolbar.test.js +46 -0
- data/app/pb_kits/playbook/pb_caption/_caption.jsx +3 -2
- data/app/pb_kits/playbook/pb_caption/caption.rb +1 -1
- data/app/pb_kits/playbook/pb_card/_card.jsx +18 -3
- data/app/pb_kits/playbook/pb_card/card.html.erb +1 -1
- data/app/pb_kits/playbook/pb_card/card.rb +3 -0
- data/app/pb_kits/playbook/pb_card/docs/_card_tag.html.erb +25 -0
- data/app/pb_kits/playbook/pb_card/docs/_card_tag.jsx +59 -0
- data/app/pb_kits/playbook/pb_card/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_card/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_checkbox/_checkbox.jsx +31 -9
- data/app/pb_kits/playbook/pb_checkbox/_checkbox.scss +28 -19
- data/app/pb_kits/playbook/pb_checkbox/checkbox.html.erb +11 -3
- data/app/pb_kits/playbook/pb_checkbox/checkbox.rb +6 -1
- data/app/pb_kits/playbook/pb_checkbox/checkbox.test.js +94 -0
- data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_custom.jsx +0 -1
- data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_indeterminate.html.erb +7 -0
- data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_indeterminate.jsx +16 -0
- data/app/pb_kits/playbook/pb_checkbox/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_checkbox/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_circle_icon_button/circle_icon_button.test.js +17 -0
- data/app/pb_kits/playbook/pb_dashboard/commonSettings.js +2 -2
- data/app/pb_kits/playbook/pb_dashboard/pbChartsLightTheme.js +2 -2
- data/app/pb_kits/playbook/pb_dialog/_close_icon.jsx +23 -0
- data/app/pb_kits/playbook/pb_dialog/_dialog.html.erb +10 -0
- data/app/pb_kits/playbook/pb_dialog/_dialog.jsx +142 -0
- data/app/pb_kits/playbook/pb_dialog/_dialog.scss +133 -0
- data/app/pb_kits/playbook/pb_dialog/_dialog_context.jsx +3 -0
- data/app/pb_kits/playbook/pb_dialog/child_kits/_dialog_body.jsx +21 -0
- data/app/pb_kits/playbook/pb_dialog/child_kits/_dialog_footer.jsx +36 -0
- data/app/pb_kits/playbook/pb_dialog/child_kits/_dialog_header.jsx +68 -0
- data/app/pb_kits/playbook/pb_dialog/dialog.rb +47 -0
- data/app/pb_kits/playbook/pb_dialog/dialog.test.jsx +23 -0
- data/app/pb_kits/playbook/pb_dialog/dialog_header.rb +31 -0
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_compound_components.jsx +53 -0
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_compound_components.md +2 -0
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_default.jsx +27 -0
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_scrollable.jsx +27 -0
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_scrollable.md +2 -0
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_separators.jsx +119 -0
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_separators.md +2 -0
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_should_close_on_overlay.jsx +28 -0
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_should_close_on_overlay.md +2 -0
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_sizes.jsx +93 -0
- data/app/pb_kits/playbook/pb_dialog/docs/example.yml +10 -0
- data/app/pb_kits/playbook/pb_dialog/docs/index.js +6 -0
- data/app/pb_kits/playbook/pb_form/_form.scss +5 -1
- data/app/pb_kits/playbook/pb_form/form_builder.rb +4 -2
- data/app/pb_kits/playbook/pb_form/form_builder/action_area.rb +14 -7
- data/app/pb_kits/playbook/pb_form/simple_form.html.erb +2 -4
- data/app/pb_kits/playbook/pb_form/simple_form.rb +4 -0
- data/app/pb_kits/playbook/pb_online_status/_online_status.jsx +2 -0
- data/app/pb_kits/playbook/pb_online_status/online_status.html.erb +1 -1
- data/app/pb_kits/playbook/pb_user_badge/_user_badge.jsx +1 -1
- data/app/pb_kits/playbook/plugins/pb_chart.js +1 -1
- data/app/pb_kits/playbook/react_rails_kits.js +4 -0
- data/app/pb_kits/playbook/tokens/_border_radius.scss +0 -10
- data/app/pb_kits/playbook/tokens/_colors.scss +0 -25
- data/app/pb_kits/playbook/tokens/_line_height.scss +0 -9
- data/app/pb_kits/playbook/tokens/_opacity.scss +0 -9
- data/app/pb_kits/playbook/tokens/_positioning.scss +0 -9
- data/app/pb_kits/playbook/tokens/_screen_sizes.scss +0 -9
- data/app/pb_kits/playbook/tokens/_shadows.scss +0 -9
- data/app/pb_kits/playbook/tokens/_spacing.scss +0 -10
- data/app/pb_kits/playbook/tokens/_typography.scss +0 -25
- data/app/pb_kits/playbook/tokens/exports/_border_radius.scss +10 -0
- data/app/pb_kits/playbook/tokens/exports/_colors.scss +26 -0
- data/app/pb_kits/playbook/tokens/exports/_line_height.scss +10 -0
- data/app/pb_kits/playbook/tokens/exports/_opacity.scss +10 -0
- data/app/pb_kits/playbook/tokens/exports/_positioning.scss +10 -0
- data/app/pb_kits/playbook/tokens/exports/_screen_sizes.scss +10 -0
- data/app/pb_kits/playbook/tokens/exports/_shadows.scss +10 -0
- data/app/pb_kits/playbook/tokens/exports/_spacing.scss +10 -0
- data/app/pb_kits/playbook/tokens/exports/_typography.scss +24 -0
- data/app/pb_kits/playbook/utilities/test-utils.js +6 -0
- data/dist/reset.css +1 -0
- data/lib/playbook/version.rb +2 -1
- metadata +54 -14
- data/app/pb_kits/playbook/pb_form/form_builder/action_area.html.erb +0 -3
@@ -0,0 +1,59 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import { Card } from '../../'
|
3
|
+
|
4
|
+
const CardTag = (props) => {
|
5
|
+
return (
|
6
|
+
<div>
|
7
|
+
<Card
|
8
|
+
tag="section"
|
9
|
+
{...props}
|
10
|
+
>
|
11
|
+
{'section'}
|
12
|
+
</Card>
|
13
|
+
<br />
|
14
|
+
<Card
|
15
|
+
tag="footer"
|
16
|
+
{...props}
|
17
|
+
>
|
18
|
+
{'footer'}
|
19
|
+
</Card>
|
20
|
+
<br />
|
21
|
+
<Card
|
22
|
+
tag="header"
|
23
|
+
{...props}
|
24
|
+
>
|
25
|
+
{'header'}
|
26
|
+
</Card>
|
27
|
+
<br />
|
28
|
+
<Card
|
29
|
+
tag="article"
|
30
|
+
{...props}
|
31
|
+
>
|
32
|
+
{'article'}
|
33
|
+
</Card>
|
34
|
+
<br />
|
35
|
+
<Card
|
36
|
+
tag="aside"
|
37
|
+
{...props}
|
38
|
+
>
|
39
|
+
{'aside'}
|
40
|
+
</Card>
|
41
|
+
<br />
|
42
|
+
<Card
|
43
|
+
tag="main"
|
44
|
+
{...props}
|
45
|
+
>
|
46
|
+
{'main'}
|
47
|
+
</Card>
|
48
|
+
<br />
|
49
|
+
<Card
|
50
|
+
tag="nav"
|
51
|
+
{...props}
|
52
|
+
>
|
53
|
+
{'nav'}
|
54
|
+
</Card>
|
55
|
+
</div>
|
56
|
+
)
|
57
|
+
}
|
58
|
+
|
59
|
+
export default CardTag
|
@@ -4,6 +4,7 @@ examples:
|
|
4
4
|
- card_highlight: Highlight Cards
|
5
5
|
- card_header: Header Cards
|
6
6
|
- card_selected: Selected
|
7
|
+
- card_tag: HTML Tag
|
7
8
|
- card_padding: Padding Size
|
8
9
|
- card_shadow: Shadow Size
|
9
10
|
- card_content: Content Size
|
@@ -15,6 +16,7 @@ examples:
|
|
15
16
|
- card_highlight: Highlight Cards
|
16
17
|
- card_header: Header Cards
|
17
18
|
- card_selected: Selected
|
19
|
+
- card_tag: HTML Tag
|
18
20
|
- card_padding: Padding Size
|
19
21
|
- card_shadow: Shadow Size
|
20
22
|
- card_content: Content Size
|
@@ -2,6 +2,7 @@ export { default as CardLight } from './_card_light.jsx'
|
|
2
2
|
export { default as CardHighlight } from './_card_highlight.jsx'
|
3
3
|
export { default as CardHeader } from './_card_header.jsx'
|
4
4
|
export { default as CardSelected } from './_card_selected.jsx'
|
5
|
+
export { default as CardTag } from './_card_tag.jsx'
|
5
6
|
export { default as CardPadding } from './_card_padding.jsx'
|
6
7
|
export { default as CardShadow } from './_card_shadow.jsx'
|
7
8
|
export { default as CardContent } from './_card_content.jsx'
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/* @flow */
|
2
2
|
|
3
|
-
import React from 'react'
|
3
|
+
import React, { useEffect, useRef } from 'react'
|
4
4
|
import Body from '../pb_body/_body.jsx'
|
5
5
|
import Icon from '../pb_icon/_icon.jsx'
|
6
6
|
import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
|
@@ -16,6 +16,7 @@ type CheckboxProps = {
|
|
16
16
|
data?: object,
|
17
17
|
error?: boolean,
|
18
18
|
id?: string,
|
19
|
+
indeterminate?: boolean,
|
19
20
|
name: string,
|
20
21
|
onChange: (boolean) => void,
|
21
22
|
tabIndex: number,
|
@@ -33,6 +34,7 @@ const Checkbox = (props: CheckboxProps) => {
|
|
33
34
|
data = {},
|
34
35
|
error = false,
|
35
36
|
id,
|
37
|
+
indeterminate = false,
|
36
38
|
name = '',
|
37
39
|
onChange = () => {},
|
38
40
|
tabIndex,
|
@@ -40,14 +42,21 @@ const Checkbox = (props: CheckboxProps) => {
|
|
40
42
|
value = '',
|
41
43
|
} = props
|
42
44
|
|
45
|
+
const checkRef = useRef()
|
43
46
|
const dataProps = buildDataProps(data)
|
44
47
|
const ariaProps = buildAriaProps(aria)
|
45
48
|
const classes = classnames(
|
46
|
-
buildCss('pb_checkbox_kit', { checked, error }),
|
49
|
+
buildCss('pb_checkbox_kit', { checked, error, indeterminate }),
|
47
50
|
globalProps(props),
|
48
51
|
className
|
49
52
|
)
|
50
53
|
|
54
|
+
useEffect(() => {
|
55
|
+
if (checkRef.current) {
|
56
|
+
checkRef.current.indeterminate = indeterminate
|
57
|
+
}
|
58
|
+
}, [indeterminate])
|
59
|
+
|
51
60
|
return (
|
52
61
|
<label
|
53
62
|
{...ariaProps}
|
@@ -62,19 +71,32 @@ const Checkbox = (props: CheckboxProps) => {
|
|
62
71
|
defaultChecked={checked}
|
63
72
|
name={name}
|
64
73
|
onChange={onChange}
|
74
|
+
ref={checkRef}
|
65
75
|
tabIndex={tabIndex}
|
66
76
|
type="checkbox"
|
67
77
|
value={value}
|
68
78
|
/>
|
69
79
|
</If>
|
80
|
+
<If condition={!indeterminate}>
|
81
|
+
<span className="pb_checkbox_checkmark">
|
82
|
+
<Icon
|
83
|
+
className="check_icon"
|
84
|
+
fixedWidth
|
85
|
+
icon="check"
|
86
|
+
/>
|
87
|
+
</span>
|
88
|
+
</If>
|
89
|
+
|
90
|
+
<If condition={indeterminate}>
|
91
|
+
<span className="pb_checkbox_indeterminate">
|
92
|
+
<Icon
|
93
|
+
className="indeterminate_icon"
|
94
|
+
fixedWidth
|
95
|
+
icon="minus"
|
96
|
+
/>
|
97
|
+
</span>
|
98
|
+
</If>
|
70
99
|
|
71
|
-
<span className="pb_checkbox_checkmark">
|
72
|
-
<Icon
|
73
|
-
className="check_icon"
|
74
|
-
fixedWidth
|
75
|
-
icon="check"
|
76
|
-
/>
|
77
|
-
</span>
|
78
100
|
<Body
|
79
101
|
className="pb_checkbox_label"
|
80
102
|
dark={dark}
|
@@ -12,24 +12,31 @@ $transition: $transition_cubic;
|
|
12
12
|
font-size: $text_lt_default;
|
13
13
|
user-select: none;
|
14
14
|
}
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
15
|
+
|
16
|
+
.pb_checkbox_checkmark,
|
17
|
+
.pb_checkbox_indeterminate {
|
18
|
+
align-items: center;
|
19
19
|
border: solid $border_light 2px;
|
20
20
|
border-radius: $border_rad_light;
|
21
|
+
height: 22px;
|
22
|
+
position: relative;
|
21
23
|
transition: background $transition_default ease, border-color $transition_default ease;
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
top: -2px;
|
26
|
-
left: 1px;
|
27
|
-
height: 16px;
|
28
|
-
width:16px;
|
24
|
+
width: 22px;
|
25
|
+
.check_icon,
|
26
|
+
.indeterminate_icon {
|
29
27
|
color: $white;
|
30
|
-
|
28
|
+
height: 16px;
|
29
|
+
left: 1px;
|
30
|
+
position: relative;
|
31
|
+
display: flex;
|
32
|
+
opacity: 0;
|
33
|
+
width: 16px;
|
34
|
+
&.hidden {
|
35
|
+
display: none;
|
36
|
+
}
|
31
37
|
}
|
32
38
|
}
|
39
|
+
|
33
40
|
@media (hover:hover) {
|
34
41
|
&:hover input ~ .pb_checkbox_checkmark {
|
35
42
|
border-color: $primary_action;
|
@@ -37,29 +44,31 @@ $transition: $transition_cubic;
|
|
37
44
|
}
|
38
45
|
|
39
46
|
input {
|
40
|
-
position: relative;
|
41
|
-
opacity: 0;
|
42
47
|
cursor: pointer;
|
48
|
+
display: flex;
|
43
49
|
height: 0;
|
50
|
+
opacity: 0;
|
51
|
+
position: relative;
|
44
52
|
width: 0;
|
45
53
|
left: $offscreen;
|
46
54
|
&:focus ~ .pb_checkbox_checkmark {
|
47
55
|
border-color: $primary_action;
|
48
56
|
}
|
49
|
-
&:checked ~ .pb_checkbox_checkmark
|
57
|
+
&:checked ~ .pb_checkbox_checkmark,
|
58
|
+
& ~ .pb_checkbox_indeterminate {
|
50
59
|
background-color: $primary_action;
|
51
60
|
border-color: $primary_action;
|
52
61
|
}
|
53
|
-
&:checked ~ .pb_checkbox_checkmark
|
62
|
+
&:checked ~ .pb_checkbox_checkmark,
|
63
|
+
& ~ .pb_checkbox_indeterminate {
|
54
64
|
display: inline-block;
|
55
|
-
.check_icon
|
65
|
+
.check_icon,
|
66
|
+
.indeterminate_icon {
|
56
67
|
opacity: $opacity_10;
|
57
68
|
}
|
58
69
|
}
|
59
70
|
}
|
60
71
|
|
61
|
-
|
62
|
-
|
63
72
|
&[class*=_dark] {
|
64
73
|
input:checked ~ .pb_checkbox_checkmark {
|
65
74
|
background-color: $primary_action;
|
@@ -3,9 +3,17 @@
|
|
3
3
|
data: object.data,
|
4
4
|
class: object.classname) do %>
|
5
5
|
<%= content.presence || object.input %>
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
<% if object.indeterminate %>
|
7
|
+
<span class="pb_checkbox_indeterminate">
|
8
|
+
<%= pb_rails("icon", props: { icon: "minus", classname: "indeterminate_icon", fixed_width: true}) %>
|
9
|
+
<%= pb_rails("icon", props: { icon: "check", classname: "check_icon hidden", fixed_width: true}) %>
|
10
|
+
</span>
|
11
|
+
<% else %>
|
12
|
+
<span class="pb_checkbox_checkmark">
|
13
|
+
<%= pb_rails("icon", props: { icon: "check", classname: "check_icon", fixed_width: true}) %>
|
14
|
+
<%= pb_rails("icon", props: { icon: "minus", classname: "indeterminate_icon hidden", fixed_width: true}) %>
|
15
|
+
</span>
|
16
|
+
<% end %>
|
9
17
|
<span class="pb_checkbox_label">
|
10
18
|
<%= pb_rails("body", props: { status: object.checkbox_label_status, text: object.text, dark: object.dark, margin_right: object.form_spacing ? "xs" : "" }) %>
|
11
19
|
</span>
|
@@ -5,6 +5,7 @@ module Playbook
|
|
5
5
|
class Checkbox < Playbook::KitBase
|
6
6
|
prop :error, type: Playbook::Props::Boolean, default: false
|
7
7
|
prop :checked, type: Playbook::Props::Boolean, default: false
|
8
|
+
prop :indeterminate, type: Playbook::Props::Boolean, default: false
|
8
9
|
prop :text
|
9
10
|
prop :value
|
10
11
|
prop :name
|
@@ -21,7 +22,7 @@ module Playbook
|
|
21
22
|
end
|
22
23
|
|
23
24
|
def classname
|
24
|
-
generate_classname("pb_checkbox_kit", checked_class) + error_class
|
25
|
+
generate_classname("pb_checkbox_kit", checked_class) + indeterminate_class + error_class
|
25
26
|
end
|
26
27
|
|
27
28
|
def input
|
@@ -41,6 +42,10 @@ module Playbook
|
|
41
42
|
def checked_class
|
42
43
|
checked ? "on" : "off"
|
43
44
|
end
|
45
|
+
|
46
|
+
def indeterminate_class
|
47
|
+
indeterminate ? " indeterminate" : ""
|
48
|
+
end
|
44
49
|
end
|
45
50
|
end
|
46
51
|
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import { render, screen } from '../utilities/test-utils'
|
3
|
+
|
4
|
+
import Checkbox from './_checkbox'
|
5
|
+
|
6
|
+
const testId = 'checkbox1',
|
7
|
+
kitClass = 'pb_checkbox_kit'
|
8
|
+
|
9
|
+
test('returns namespaced class name', () => {
|
10
|
+
render(
|
11
|
+
<Checkbox
|
12
|
+
data={{ testid: testId }}
|
13
|
+
name="checkbox-name"
|
14
|
+
text="Checkbox"
|
15
|
+
value="check-box value"
|
16
|
+
/>
|
17
|
+
)
|
18
|
+
|
19
|
+
const kit = screen.getByTestId(testId)
|
20
|
+
expect(kit).toHaveClass(kitClass)
|
21
|
+
})
|
22
|
+
|
23
|
+
test('returns dark class name', () => {
|
24
|
+
render(
|
25
|
+
<Checkbox
|
26
|
+
dark
|
27
|
+
data={{ testid: testId }}
|
28
|
+
name="checkbox-name"
|
29
|
+
text="Checkbox"
|
30
|
+
value="check-box value"
|
31
|
+
/>
|
32
|
+
)
|
33
|
+
|
34
|
+
const kit = screen.getByTestId(testId)
|
35
|
+
expect(kit).toHaveClass(`${kitClass} dark`)
|
36
|
+
})
|
37
|
+
|
38
|
+
test('returns indeterminate class name', () => {
|
39
|
+
render(
|
40
|
+
<Checkbox
|
41
|
+
data={{ testid: testId }}
|
42
|
+
indeterminate
|
43
|
+
name="checkbox-name"
|
44
|
+
text="Checkbox"
|
45
|
+
value="check-box value"
|
46
|
+
/>
|
47
|
+
)
|
48
|
+
|
49
|
+
const kit = screen.getByTestId(testId)
|
50
|
+
expect(kit).toHaveClass(`${kitClass}_indeterminate`)
|
51
|
+
})
|
52
|
+
|
53
|
+
test('has name attribute', () => {
|
54
|
+
render(
|
55
|
+
<Checkbox
|
56
|
+
data={{ testid: testId }}
|
57
|
+
name="checkbox-name"
|
58
|
+
text="Checkbox"
|
59
|
+
value="check-box value"
|
60
|
+
/>
|
61
|
+
)
|
62
|
+
|
63
|
+
const kit = screen.getByTestId(testId)
|
64
|
+
expect(kit.getElementsByTagName('input')[0]).toHaveAttribute('name', 'checkbox-name')
|
65
|
+
})
|
66
|
+
|
67
|
+
test('has value attribute', () => {
|
68
|
+
render(
|
69
|
+
<Checkbox
|
70
|
+
data={{ testid: testId }}
|
71
|
+
name="checkbox-name"
|
72
|
+
text="Checkbox"
|
73
|
+
value="checkbox value"
|
74
|
+
/>
|
75
|
+
)
|
76
|
+
|
77
|
+
const kit = screen.getByTestId(testId)
|
78
|
+
expect(kit.getElementsByTagName('input')[0]).toHaveAttribute('value', 'checkbox value')
|
79
|
+
})
|
80
|
+
|
81
|
+
test('has checked attribute', () => {
|
82
|
+
render(
|
83
|
+
<Checkbox
|
84
|
+
checked
|
85
|
+
data={{ testid: testId }}
|
86
|
+
name="checkbox-name"
|
87
|
+
text="Checkbox"
|
88
|
+
value="check-box value"
|
89
|
+
/>
|
90
|
+
)
|
91
|
+
|
92
|
+
const kit = screen.getByTestId(testId)
|
93
|
+
expect(kit.getElementsByTagName('input')[0]).toHaveAttribute('checked')
|
94
|
+
})
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import { Checkbox } from '../..'
|
3
|
+
|
4
|
+
const CheckboxIndeterminate = (props) => {
|
5
|
+
return (
|
6
|
+
<Checkbox
|
7
|
+
indeterminate
|
8
|
+
name="checkbox-name"
|
9
|
+
text="Indeterminate State"
|
10
|
+
value="check-box value"
|
11
|
+
{...props}
|
12
|
+
/>
|
13
|
+
)
|
14
|
+
}
|
15
|
+
|
16
|
+
export default CheckboxIndeterminate
|
@@ -5,9 +5,11 @@ examples:
|
|
5
5
|
- checkbox_custom: Custom Checkbox
|
6
6
|
- checkbox_error: Default w/ Error
|
7
7
|
- checkbox_options: Checkbox w/ Options
|
8
|
+
- checkbox_indeterminate: Indeterminate Checkbox
|
8
9
|
|
9
10
|
react:
|
10
11
|
- checkbox_default: Default
|
11
12
|
- checkbox_checked: Load as checked
|
12
13
|
- checkbox_custom: Custom Checkbox
|
13
14
|
- checkbox_error: Default w/ Error
|
15
|
+
- checkbox_indeterminate: Indeterminate Checkbox
|