playbook_ui 8.0.1 → 8.2.0.pre.alpha2
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/README.md +9 -0
- data/app/pb_kits/playbook/_playbook.scss +8 -7
- data/app/pb_kits/playbook/data/menu.yml +1 -0
- data/app/pb_kits/playbook/index.js +1 -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_card/card_header.rb +7 -7
- data/app/pb_kits/playbook/pb_circle_icon_button/circle_icon_button.test.js +17 -0
- data/app/pb_kits/playbook/pb_collapsible/_collapsible.jsx +84 -0
- data/app/pb_kits/playbook/pb_collapsible/_collapsible.scss +15 -0
- data/app/pb_kits/playbook/pb_collapsible/child_kits/CollapsibleContent.jsx +40 -0
- data/app/pb_kits/playbook/pb_collapsible/child_kits/CollapsibleMain.jsx +59 -0
- data/app/pb_kits/playbook/pb_collapsible/collapsible.html.erb +7 -0
- data/app/pb_kits/playbook/pb_collapsible/collapsible.rb +11 -0
- data/app/pb_kits/playbook/pb_collapsible/collapsible.test.js +50 -0
- data/app/pb_kits/playbook/pb_collapsible/collapsible_content.html.erb +7 -0
- data/app/pb_kits/playbook/pb_collapsible/collapsible_content.rb +17 -0
- data/app/pb_kits/playbook/pb_collapsible/collapsible_main.html.erb +16 -0
- data/app/pb_kits/playbook/pb_collapsible/collapsible_main.rb +15 -0
- data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_default.html.erb +10 -0
- data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_default.jsx +19 -0
- data/app/pb_kits/playbook/pb_collapsible/docs/example.yml +9 -0
- data/app/pb_kits/playbook/pb_collapsible/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_collapsible/index.js +79 -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_date_time_stacked/_date_time_stacked.jsx +6 -2
- data/app/pb_kits/playbook/pb_date_time_stacked/date_time_stacked.html.erb +1 -1
- data/app/pb_kits/playbook/pb_docs/kit_example.rb +1 -1
- data/app/pb_kits/playbook/pb_form/_form.scss +5 -1
- data/app/pb_kits/playbook/pb_nav/_item.jsx +2 -0
- data/app/pb_kits/playbook/pb_nav/_nav.jsx +2 -2
- data/app/pb_kits/playbook/pb_nav/item.html.erb +2 -2
- data/app/pb_kits/playbook/pb_nav/nav.html.erb +1 -1
- data/app/pb_kits/playbook/pb_progress_simple/_progress_simple.jsx +1 -1
- data/app/pb_kits/playbook/pb_progress_simple/_progress_simple.scss +5 -0
- data/app/pb_kits/playbook/pb_progress_simple/docs/_progress_simple_variants.html.erb +5 -0
- data/app/pb_kits/playbook/pb_progress_simple/docs/_progress_simple_variants.jsx +7 -0
- data/app/pb_kits/playbook/pb_progress_simple/docs/_progress_simple_variants.md +1 -1
- data/app/pb_kits/playbook/pb_progress_simple/progress_simple.rb +1 -1
- data/app/pb_kits/playbook/pb_time_stacked/_time_stacked.jsx +43 -26
- data/app/pb_kits/playbook/pb_time_stacked/_time_stacked.scss +18 -0
- data/app/pb_kits/playbook/pb_time_stacked/docs/_time_stacked_default.html.erb +18 -5
- data/app/pb_kits/playbook/pb_time_stacked/docs/_time_stacked_default.jsx +10 -5
- data/app/pb_kits/playbook/pb_time_stacked/time_stacked.html.erb +7 -3
- data/app/pb_kits/playbook/pb_time_stacked/time_stacked.rb +8 -30
- data/app/pb_kits/playbook/pb_time_stacked/time_stacked.test.js +33 -0
- data/app/pb_kits/playbook/pb_tooltip/_tooltip.scss +4 -3
- data/app/pb_kits/playbook/plugins/pb_chart.js +1 -1
- 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/app/pb_kits/playbook/vendor.js +3 -0
- data/dist/reset.css +1 -0
- data/lib/playbook/props/base.rb +1 -1
- data/lib/playbook/version.rb +1 -1
- metadata +40 -10
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c6d260fd8cb3c808cd647ea9150feb6c68ddaefef55e69cdb28986d8689ea7ad
|
|
4
|
+
data.tar.gz: be549c62b03d8e89c5746a8cfeb4ccceedf4da2dbe7e1ff27dc609c2d574224b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d3d1a839484d63aafb17d2e2c03daa56781bae403120e652dc5d20af205c857d92c0e2ef2a6b9116dad6f19fb1514f657e949d774ab096ed13d6bcf14566097e
|
|
7
|
+
data.tar.gz: a57ea0a32d351f774cdf73ef1fe572199b7207be7e1cf863538c09d68617ce9d3b352d34a111695b3a2b91f93c1fbb9c73775a08e6254d5321c878a14323e02b
|
data/README.md
CHANGED
|
@@ -42,6 +42,15 @@ See [docs/upgrade-guide](./docs/upgrade-guide)
|
|
|
42
42
|
|
|
43
43
|
* [Common Errors & Solutions](https://github.com/powerhome/playbook/wiki/Common-Errors-&-Solutions)
|
|
44
44
|
|
|
45
|
+
### Reset.css
|
|
46
|
+
|
|
47
|
+
Playbook provides it's own `reset.css` boilerplate for optional use in your application. You can either:
|
|
48
|
+
|
|
49
|
+
1. Import the `dist/reset.css` from the playbook_ui gem into your Rails view: `@import "reset.css"` (note: your path may vary depending on your application's asset paths)
|
|
50
|
+
2. Import or include the file via the npm package: `import 'reset.css'` (note: your path may vary depending on your application's node-sass `includePaths`)
|
|
51
|
+
|
|
52
|
+
This asset aims to provide a commonly styles base for supported browsers.
|
|
53
|
+
|
|
45
54
|
### Building Playbook Kits
|
|
46
55
|
|
|
47
56
|
* [Generating a Kit](https://github.com/powerhome/playbook/wiki/Generating-a-Kit)
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
@import
|
|
2
|
-
@import
|
|
3
|
-
@import
|
|
4
|
-
@import
|
|
1
|
+
@import 'tokens/fonts';
|
|
2
|
+
@import 'pb_background/background';
|
|
3
|
+
@import 'pb_body/body';
|
|
4
|
+
@import 'pb_button/button';
|
|
5
5
|
@import 'pb_button_toolbar/button_toolbar';
|
|
6
|
-
@import
|
|
7
|
-
@import
|
|
8
|
-
@import
|
|
6
|
+
@import 'pb_caption/caption';
|
|
7
|
+
@import 'pb_card/card';
|
|
8
|
+
@import 'pb_title/title';
|
|
9
9
|
@import 'pb_avatar/avatar';
|
|
10
10
|
@import 'pb_avatar_action_button/avatar_action_button';
|
|
11
11
|
@import 'pb_badge/badge';
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
@import 'pb_checkbox/checkbox';
|
|
14
14
|
@import 'pb_circle_chart/circle_chart';
|
|
15
15
|
@import 'pb_circle_icon_button/circle_icon_button';
|
|
16
|
+
@import 'pb_collapsible/collapsible';
|
|
16
17
|
@import 'pb_contact/contact';
|
|
17
18
|
@import 'pb_currency/currency';
|
|
18
19
|
@import 'pb_dashboard_value/dashboard_value';
|
|
@@ -17,6 +17,7 @@ export Card from './pb_card/_card.jsx'
|
|
|
17
17
|
export Checkbox from './pb_checkbox/_checkbox.jsx'
|
|
18
18
|
export CircleChart from './pb_circle_chart/_circle_chart.jsx'
|
|
19
19
|
export CircleIconButton from './pb_circle_icon_button/_circle_icon_button.jsx'
|
|
20
|
+
export Collapsible from './pb_collapsible/_collapsible.jsx'
|
|
20
21
|
export Contact from './pb_contact/_contact.jsx'
|
|
21
22
|
export Currency from './pb_currency/_currency.jsx'
|
|
22
23
|
export DashboardValue from './pb_dashboard_value/_dashboard_value.jsx'
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import React from 'react'
|
|
4
4
|
import classnames from 'classnames'
|
|
5
|
+
import { buildDataProps } from '../utilities/props'
|
|
5
6
|
import { globalProps } from '../utilities/globalProps.js'
|
|
6
7
|
|
|
7
8
|
import Icon from '../pb_icon/_icon.jsx'
|
|
@@ -13,6 +14,7 @@ type ButtonPropTypes = {
|
|
|
13
14
|
},
|
|
14
15
|
children?: array<React.ReactChild>,
|
|
15
16
|
className?: string | array<string>,
|
|
17
|
+
data?: object,
|
|
16
18
|
disabled?: boolean,
|
|
17
19
|
fixedWidth?: boolean,
|
|
18
20
|
fullWidth?: boolean,
|
|
@@ -69,6 +71,7 @@ const Button = (props: ButtonPropTypes) => {
|
|
|
69
71
|
const {
|
|
70
72
|
children,
|
|
71
73
|
className,
|
|
74
|
+
data = {},
|
|
72
75
|
disabled,
|
|
73
76
|
icon = null,
|
|
74
77
|
id,
|
|
@@ -82,6 +85,7 @@ const Button = (props: ButtonPropTypes) => {
|
|
|
82
85
|
} = props
|
|
83
86
|
|
|
84
87
|
const buttonAria = buttonAriaProps(props)
|
|
88
|
+
const dataProps = buildDataProps(data)
|
|
85
89
|
const css = classnames(
|
|
86
90
|
buttonClassName(props),
|
|
87
91
|
globalProps(props),
|
|
@@ -111,6 +115,7 @@ const Button = (props: ButtonPropTypes) => {
|
|
|
111
115
|
<If condition={link !== null}>
|
|
112
116
|
<a
|
|
113
117
|
{...buttonAria}
|
|
118
|
+
{...dataProps}
|
|
114
119
|
className={css}
|
|
115
120
|
href={link}
|
|
116
121
|
id={id}
|
|
@@ -122,6 +127,7 @@ const Button = (props: ButtonPropTypes) => {
|
|
|
122
127
|
<Else />
|
|
123
128
|
<button
|
|
124
129
|
{...buttonAria}
|
|
130
|
+
{...dataProps}
|
|
125
131
|
className={css}
|
|
126
132
|
disabled={disabled}
|
|
127
133
|
id={id}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import { appendAlert, fireEvent, render, screen, waitFor } from '../utilities/test-utils'
|
|
4
|
+
|
|
5
|
+
import Button from './_button'
|
|
6
|
+
|
|
7
|
+
// Primary Test Variables
|
|
8
|
+
const htmlType = 'submit',
|
|
9
|
+
text = 'Button Text',
|
|
10
|
+
value = '1234'
|
|
11
|
+
|
|
12
|
+
test('passes type, text, and value props to button', () => {
|
|
13
|
+
render(
|
|
14
|
+
<>
|
|
15
|
+
<Button
|
|
16
|
+
data={{ testid: 'primary-test' }}
|
|
17
|
+
htmlType={htmlType}
|
|
18
|
+
text={text}
|
|
19
|
+
value={value}
|
|
20
|
+
/>
|
|
21
|
+
</>
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
const kit = screen.getByTestId('primary-test')
|
|
25
|
+
const content = screen.getByText(text)
|
|
26
|
+
|
|
27
|
+
expect(kit).toHaveClass('pb_button_kit_primary_inline_enabled')
|
|
28
|
+
expect(kit).toHaveAttribute('type', htmlType)
|
|
29
|
+
expect(kit).toHaveAttribute('value', value)
|
|
30
|
+
expect(content).toHaveTextContent(text)
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
// Link Test Variables
|
|
34
|
+
const link = 'https://www.google.com'
|
|
35
|
+
|
|
36
|
+
test('adds link to button', () => {
|
|
37
|
+
render(
|
|
38
|
+
<Button
|
|
39
|
+
data={{ testid: 'link-test' }}
|
|
40
|
+
link={link}
|
|
41
|
+
/>
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
const kit = screen.getByTestId('link-test')
|
|
45
|
+
|
|
46
|
+
expect(kit).toHaveAttribute('href', link)
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
test('button with secondary variant', () => {
|
|
50
|
+
render(
|
|
51
|
+
<Button
|
|
52
|
+
data={{ testid: 'variant-test' }}
|
|
53
|
+
variant="secondary"
|
|
54
|
+
/>
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
const kit = screen.getByTestId('variant-test')
|
|
58
|
+
|
|
59
|
+
expect(kit).toHaveClass('pb_button_kit_secondary_inline_enabled')
|
|
60
|
+
expect(kit).toHaveAttribute('type', 'button')
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
test('disable prop', () => {
|
|
64
|
+
render(
|
|
65
|
+
<Button
|
|
66
|
+
data={{ testid: 'disable-test' }}
|
|
67
|
+
disabled
|
|
68
|
+
/>
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
const kit = screen.getByTestId('disable-test')
|
|
72
|
+
|
|
73
|
+
expect(kit).toBeDisabled()
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
test('click event', async () => {
|
|
77
|
+
render(
|
|
78
|
+
<Button
|
|
79
|
+
data={{ testid: 'click-test' }}
|
|
80
|
+
onClick={() => appendAlert('clicked button!')}
|
|
81
|
+
/>
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
const kit = screen.getByTestId('click-test')
|
|
85
|
+
|
|
86
|
+
fireEvent.click(kit)
|
|
87
|
+
|
|
88
|
+
await waitFor(() => screen.getByText('clicked button!'))
|
|
89
|
+
|
|
90
|
+
expect(screen.getByText('clicked button!')).toBeInTheDocument()
|
|
91
|
+
})
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { render, screen } from '../utilities/test-utils'
|
|
3
|
+
|
|
4
|
+
import { Button, ButtonToolbar } from '../'
|
|
5
|
+
|
|
6
|
+
test('default test', () => {
|
|
7
|
+
render(
|
|
8
|
+
<ButtonToolbar
|
|
9
|
+
data={{ testid: 'default-test' }}
|
|
10
|
+
>
|
|
11
|
+
<Button
|
|
12
|
+
data={{ testid: 'child-button' }}
|
|
13
|
+
text="Test"
|
|
14
|
+
/>
|
|
15
|
+
</ButtonToolbar>
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
const kit = screen.getByTestId('default-test')
|
|
19
|
+
const child = screen.getByTestId('child-button')
|
|
20
|
+
|
|
21
|
+
expect(kit).toHaveClass('pb_button_toolbar_kit_horizontal_primary')
|
|
22
|
+
expect(kit).toContainElement(child)
|
|
23
|
+
expect(child).toHaveClass('pb_button_kit_primary_inline_enabled')
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
test('variant and orientation props', () => {
|
|
27
|
+
render(
|
|
28
|
+
<ButtonToolbar
|
|
29
|
+
data={{ testid: 'second-test' }}
|
|
30
|
+
orientation="vertical"
|
|
31
|
+
variant="secondary"
|
|
32
|
+
>
|
|
33
|
+
<Button
|
|
34
|
+
data={{ testid: 'child-button' }}
|
|
35
|
+
text="Create"
|
|
36
|
+
variant="secondary"
|
|
37
|
+
/>
|
|
38
|
+
</ButtonToolbar>
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
const kit = screen.getByTestId('second-test')
|
|
42
|
+
const child = screen.getByTestId('child-button')
|
|
43
|
+
|
|
44
|
+
expect(kit).toHaveClass('pb_button_toolbar_kit_vertical_secondary')
|
|
45
|
+
expect(child).toHaveClass('pb_button_kit_secondary_inline_enabled')
|
|
46
|
+
})
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module Playbook
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
module PbCard
|
|
5
|
+
class CardHeader < Playbook::KitBase
|
|
6
|
+
prop :header_color, type: Playbook::Props::String,
|
|
7
|
+
default: "category_1"
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
end
|
|
9
|
+
def classname
|
|
10
|
+
generate_classname("pb_card_header_kit", header_color)
|
|
12
11
|
end
|
|
13
12
|
end
|
|
14
13
|
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { render, screen } from '../utilities/test-utils'
|
|
3
|
+
|
|
4
|
+
import CircleIconButton from './_circle_icon_button'
|
|
5
|
+
|
|
6
|
+
test('default test', () => {
|
|
7
|
+
render(
|
|
8
|
+
<CircleIconButton
|
|
9
|
+
data={{ testid: 'default-test' }}
|
|
10
|
+
icon="plus"
|
|
11
|
+
/>
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
const kit = screen.getByTestId('default-test')
|
|
15
|
+
|
|
16
|
+
expect(kit).toHaveClass('pb_circle_icon_button_kit')
|
|
17
|
+
})
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/* @flow */
|
|
2
|
+
|
|
3
|
+
import classnames from 'classnames'
|
|
4
|
+
import React, { useState } from 'react'
|
|
5
|
+
import { globalProps } from '../utilities/globalProps.js'
|
|
6
|
+
import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
|
|
7
|
+
import CollapsibleContent from './child_kits/CollapsibleContent'
|
|
8
|
+
import CollapsibleMain from './child_kits/CollapsibleMain'
|
|
9
|
+
|
|
10
|
+
export const CollapsibleContext = React.createContext({})
|
|
11
|
+
|
|
12
|
+
type CollapsibleProps = {
|
|
13
|
+
children: CollapsibleMain | CollapsibleContent | ReactNode,
|
|
14
|
+
aria?: object,
|
|
15
|
+
className?: string,
|
|
16
|
+
collapsed?: boolean,
|
|
17
|
+
data?: object,
|
|
18
|
+
id?: string,
|
|
19
|
+
padding?: string,
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const useCollapsible = (initial = false) => {
|
|
23
|
+
const [collapsed, setCollapsed] = useState(initial)
|
|
24
|
+
|
|
25
|
+
return [
|
|
26
|
+
collapsed,
|
|
27
|
+
() => setCollapsed((t) => !t),
|
|
28
|
+
]
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const Collapsible = ({
|
|
32
|
+
aria = {},
|
|
33
|
+
className,
|
|
34
|
+
children = [],
|
|
35
|
+
collapsed = true,
|
|
36
|
+
data = {},
|
|
37
|
+
id,
|
|
38
|
+
padding = 'md',
|
|
39
|
+
...props
|
|
40
|
+
}: CollapsibleProps) => {
|
|
41
|
+
const [isCollapsed, collapse] = useCollapsible(collapsed)
|
|
42
|
+
const CollapsibleParent = React.Children.toArray(children)
|
|
43
|
+
|
|
44
|
+
if (CollapsibleParent.length !== 2) {
|
|
45
|
+
throw new Error('Collapsible requires <CollapsibleMain> and <CollapsibleContent> to function properly.')
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const Main = CollapsibleParent[0]
|
|
49
|
+
const Content = CollapsibleParent[1]
|
|
50
|
+
|
|
51
|
+
const { children: mainChildren, ...mainProps } = Main.props
|
|
52
|
+
const { children: contentChildren, ...contentProps } = Content.props
|
|
53
|
+
const ariaProps = buildAriaProps(aria)
|
|
54
|
+
const dataProps = buildDataProps(data)
|
|
55
|
+
const classes = classnames(
|
|
56
|
+
buildCss('pb_collapsible'),
|
|
57
|
+
className,
|
|
58
|
+
globalProps(props, { padding })
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<CollapsibleContext.Provider value={{ collapsed: isCollapsed, collapse }}>
|
|
63
|
+
<div
|
|
64
|
+
{...ariaProps}
|
|
65
|
+
{...dataProps}
|
|
66
|
+
className={classes}
|
|
67
|
+
id={id}
|
|
68
|
+
>
|
|
69
|
+
<CollapsibleMain {...mainProps}>
|
|
70
|
+
{mainChildren}
|
|
71
|
+
</CollapsibleMain>
|
|
72
|
+
|
|
73
|
+
<CollapsibleContent {...contentProps}>
|
|
74
|
+
{contentChildren}
|
|
75
|
+
</CollapsibleContent>
|
|
76
|
+
</div>
|
|
77
|
+
</CollapsibleContext.Provider>
|
|
78
|
+
)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
Collapsible.Main = CollapsibleMain
|
|
82
|
+
Collapsible.Content = CollapsibleContent
|
|
83
|
+
|
|
84
|
+
export default Collapsible
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
[class^=pb_collapsible_kit] {
|
|
2
|
+
.toggle-content {
|
|
3
|
+
display: none;
|
|
4
|
+
height: 0;
|
|
5
|
+
padding-bottom: 0 !important;
|
|
6
|
+
padding-top: 0 !important;
|
|
7
|
+
overflow: hidden;
|
|
8
|
+
transition: height 300ms, padding 300ms ease-in-out;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.toggle-content.is-visible {
|
|
12
|
+
display: block;
|
|
13
|
+
height: auto;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/* @flow */
|
|
2
|
+
|
|
3
|
+
import classnames from 'classnames'
|
|
4
|
+
import React, { useContext } from 'react'
|
|
5
|
+
import AnimateHeight from 'react-animate-height'
|
|
6
|
+
import { buildCss } from '../../utilities/props'
|
|
7
|
+
import { globalProps } from '../../utilities/globalProps.js'
|
|
8
|
+
|
|
9
|
+
import { CollapsibleContext } from '../_collapsible.jsx'
|
|
10
|
+
|
|
11
|
+
type CollapsibleContentProps = {
|
|
12
|
+
children: array<React.ReactNode> | React.ReactNode | string,
|
|
13
|
+
className?: string,
|
|
14
|
+
padding?: string,
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const CollapsibleContent = ({
|
|
18
|
+
children,
|
|
19
|
+
className,
|
|
20
|
+
padding = 'md',
|
|
21
|
+
...props
|
|
22
|
+
}: CollapsibleContentProps) => {
|
|
23
|
+
const context = useContext(CollapsibleContext)
|
|
24
|
+
const contentCSS = buildCss('pb_collapsible_content_kit')
|
|
25
|
+
const contentSpacing = globalProps(props, { padding })
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<div className={classnames(contentCSS, className, contentSpacing)}>
|
|
29
|
+
<AnimateHeight
|
|
30
|
+
duration={300}
|
|
31
|
+
height={context.collapsed ? 0 : 'auto'}
|
|
32
|
+
id="bottom-section"
|
|
33
|
+
>
|
|
34
|
+
{children}
|
|
35
|
+
</AnimateHeight>
|
|
36
|
+
</div>
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export default CollapsibleContent
|