playbook_ui 14.6.2 → 14.7.0.pre.alpha.PBNTR667railstypeaheadformintegration4454

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.
Files changed (119) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/_playbook.scss +3 -2
  3. data/app/pb_kits/playbook/pb_advanced_table/Components/CustomCell.tsx +8 -1
  4. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +21 -28
  5. data/app/pb_kits/playbook/pb_advanced_table/advanced_table.test.jsx +37 -1
  6. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_custom_cell.jsx +13 -2
  7. data/app/pb_kits/playbook/pb_card/_card.tsx +11 -4
  8. data/app/pb_kits/playbook/pb_card/_card_mixin.scss +1 -2
  9. data/app/pb_kits/playbook/pb_currency/_currency.tsx +16 -6
  10. data/app/pb_kits/playbook/pb_currency/currency.rb +38 -11
  11. data/app/pb_kits/playbook/pb_currency/currency.test.js +35 -0
  12. data/app/pb_kits/playbook/pb_currency/docs/_currency_comma_separator.html.erb +7 -0
  13. data/app/pb_kits/playbook/pb_currency/docs/_currency_comma_separator.jsx +18 -0
  14. data/app/pb_kits/playbook/pb_currency/docs/_currency_comma_separator.md +3 -0
  15. data/app/pb_kits/playbook/pb_currency/docs/example.yml +3 -1
  16. data/app/pb_kits/playbook/pb_currency/docs/index.js +1 -0
  17. data/app/pb_kits/playbook/pb_dialog/_dialog.tsx +5 -1
  18. data/app/pb_kits/playbook/pb_dropdown/_dropdown.tsx +8 -7
  19. data/app/pb_kits/playbook/pb_flex/_flex.tsx +3 -1
  20. data/app/pb_kits/playbook/pb_flex/_flex_item.tsx +8 -2
  21. data/app/pb_kits/playbook/pb_flex/flex_item.html.erb +3 -6
  22. data/app/pb_kits/playbook/pb_flex/flex_item.rb +7 -2
  23. data/app/pb_kits/playbook/pb_form/docs/_form_form_with.html.erb +2 -2
  24. data/app/pb_kits/playbook/pb_form/docs/_form_form_with_loading.html.erb +1 -1
  25. data/app/pb_kits/playbook/pb_form/docs/_form_form_with_validate.html.erb +63 -12
  26. data/app/pb_kits/playbook/pb_form_pill/_form_pill.scss +6 -2
  27. data/app/pb_kits/playbook/pb_form_pill/_form_pill.tsx +30 -26
  28. data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_truncated_text.html.erb +24 -1
  29. data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_truncated_text.jsx +25 -2
  30. data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_truncated_text_rails.md +3 -0
  31. data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_truncated_text_react.md +1 -0
  32. data/app/pb_kits/playbook/pb_form_pill/form_pill.html.erb +46 -8
  33. data/app/pb_kits/playbook/pb_link/_link.scss +66 -0
  34. data/app/pb_kits/playbook/pb_link/_link.tsx +107 -0
  35. data/app/pb_kits/playbook/pb_link/docs/_link_color.html.erb +30 -0
  36. data/app/pb_kits/playbook/pb_link/docs/_link_color.jsx +40 -0
  37. data/app/pb_kits/playbook/pb_link/docs/_link_disabled.html.erb +5 -0
  38. data/app/pb_kits/playbook/pb_link/docs/_link_disabled.jsx +15 -0
  39. data/app/pb_kits/playbook/pb_link/docs/_link_icon.html.erb +15 -0
  40. data/app/pb_kits/playbook/pb_link/docs/_link_icon.jsx +25 -0
  41. data/app/pb_kits/playbook/pb_link/docs/_link_tag.html.erb +35 -0
  42. data/app/pb_kits/playbook/pb_link/docs/_link_tag.jsx +45 -0
  43. data/app/pb_kits/playbook/pb_link/docs/_link_underline.html.erb +5 -0
  44. data/app/pb_kits/playbook/pb_link/docs/_link_underline.jsx +15 -0
  45. data/app/pb_kits/playbook/pb_link/docs/example.yml +16 -0
  46. data/app/pb_kits/playbook/pb_link/docs/index.js +5 -0
  47. data/app/pb_kits/playbook/pb_link/link.html.erb +21 -0
  48. data/app/pb_kits/playbook/pb_link/link.rb +44 -0
  49. data/app/pb_kits/playbook/pb_link/link.test.jsx +92 -0
  50. data/app/pb_kits/playbook/pb_popover/_popover.tsx +1 -1
  51. data/app/pb_kits/playbook/pb_selectable_card/_selectable_card.scss +67 -1
  52. data/app/pb_kits/playbook/pb_selectable_card/_selectable_card.tsx +1 -0
  53. data/app/pb_kits/playbook/pb_selectable_card/selectable_card.html.erb +1 -1
  54. data/app/pb_kits/playbook/pb_selectable_card/selectable_card.rb +5 -1
  55. data/app/pb_kits/playbook/pb_skeleton_loading/_skeleton_loading.scss +37 -0
  56. data/app/pb_kits/playbook/pb_skeleton_loading/_skeleton_loading.tsx +67 -0
  57. data/app/pb_kits/playbook/pb_skeleton_loading/_skeleton_loading_mixins.scss +40 -0
  58. data/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_border_radius.jsx +51 -0
  59. data/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_border_radius.md +1 -0
  60. data/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_color.jsx +26 -0
  61. data/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_color.md +1 -0
  62. data/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_default.html.erb +1 -0
  63. data/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_default.jsx +11 -0
  64. data/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_height_width.jsx +59 -0
  65. data/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_height_width.md +3 -0
  66. data/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_layout.jsx +20 -0
  67. data/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_layout.md +3 -0
  68. data/app/pb_kits/playbook/pb_skeleton_loading/docs/example.yml +13 -0
  69. data/app/pb_kits/playbook/pb_skeleton_loading/docs/index.js +5 -0
  70. data/app/pb_kits/playbook/pb_skeleton_loading/skeleton_loading.html.erb +12 -0
  71. data/app/pb_kits/playbook/pb_skeleton_loading/skeleton_loading.rb +8 -0
  72. data/app/pb_kits/playbook/pb_skeleton_loading/skeleton_loading.test.jsx +81 -0
  73. data/app/pb_kits/playbook/pb_timeline/_item.tsx +59 -23
  74. data/app/pb_kits/playbook/pb_timeline/_timeline.tsx +8 -0
  75. data/app/pb_kits/playbook/pb_timeline/detail.html.erb +3 -0
  76. data/app/pb_kits/playbook/pb_timeline/detail.rb +11 -0
  77. data/app/pb_kits/playbook/pb_timeline/docs/_timeline_with_children.html.erb +43 -0
  78. data/app/pb_kits/playbook/pb_timeline/docs/_timeline_with_children.jsx +68 -0
  79. data/app/pb_kits/playbook/pb_timeline/docs/_timeline_with_children.md +2 -0
  80. data/app/pb_kits/playbook/pb_timeline/docs/example.yml +2 -1
  81. data/app/pb_kits/playbook/pb_timeline/docs/index.js +1 -0
  82. data/app/pb_kits/playbook/pb_timeline/item.html.erb +17 -21
  83. data/app/pb_kits/playbook/pb_timeline/item.rb +4 -0
  84. data/app/pb_kits/playbook/pb_timeline/label.html.erb +12 -0
  85. data/app/pb_kits/playbook/pb_timeline/label.rb +13 -0
  86. data/app/pb_kits/playbook/pb_timeline/step.html.erb +14 -0
  87. data/app/pb_kits/playbook/pb_timeline/step.rb +16 -0
  88. data/app/pb_kits/playbook/pb_timeline/subcomponents/Detail.tsx +29 -0
  89. data/app/pb_kits/playbook/pb_timeline/subcomponents/Label.tsx +38 -0
  90. data/app/pb_kits/playbook/pb_timeline/subcomponents/Step.tsx +42 -0
  91. data/app/pb_kits/playbook/pb_timeline/subcomponents/index.tsx +3 -0
  92. data/app/pb_kits/playbook/pb_timeline/timeline.test.js +84 -0
  93. data/app/pb_kits/playbook/pb_typeahead/index.ts +36 -2
  94. data/app/pb_kits/playbook/pb_typeahead/typeahead.html.erb +5 -2
  95. data/app/pb_kits/playbook/pb_typeahead/typeahead.rb +4 -0
  96. data/app/pb_kits/playbook/tokens/_typography.scss +35 -0
  97. data/app/pb_kits/playbook/utilities/_hover.scss +46 -43
  98. data/app/pb_kits/playbook/utilities/globalPropNames.mjs +4 -0
  99. data/app/pb_kits/playbook/utilities/globalProps.ts +44 -2
  100. data/dist/chunks/_typeahead-B-juiSkw.js +22 -0
  101. data/dist/chunks/_weekday_stacked-DPqQHJ1l.js +45 -0
  102. data/dist/chunks/lazysizes-B7xYodB-.js +1 -0
  103. data/dist/chunks/{lib-D-mTv-kp.js → lib-DpxYMiKe.js} +1 -1
  104. data/dist/chunks/{pb_form_validation-BkWGwJsl.js → pb_form_validation-LqRlnmi6.js} +1 -1
  105. data/dist/chunks/vendor.js +1 -1
  106. data/dist/menu.yml +7 -1
  107. data/dist/playbook-doc.js +1 -1
  108. data/dist/playbook-rails-react-bindings.js +1 -1
  109. data/dist/playbook-rails.js +1 -1
  110. data/dist/playbook.css +1 -1
  111. data/lib/playbook/forms/builder/typeahead_field.rb +13 -0
  112. data/lib/playbook/hover.rb +4 -1
  113. data/lib/playbook/kit_base.rb +43 -5
  114. data/lib/playbook/version.rb +2 -2
  115. metadata +63 -11
  116. data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_truncated_text.md +0 -1
  117. data/dist/chunks/_typeahead-BV_n6U5W.js +0 -22
  118. data/dist/chunks/_weekday_stacked-Cy__g00H.js +0 -45
  119. data/dist/chunks/lazysizes-DHz07jlL.js +0 -1
@@ -0,0 +1,51 @@
1
+ import React from 'react'
2
+ import { Flex, SkeletonLoading } from "playbook-ui"
3
+
4
+
5
+ const SkeletonLoadingBorderRadius = (props) => (
6
+ <Flex justify="evenly">
7
+ <SkeletonLoading
8
+ borderRadius="rounded"
9
+ height="50px"
10
+ width="100px"
11
+ {...props}
12
+ />
13
+ <SkeletonLoading
14
+ borderRadius="xl"
15
+ height="50px"
16
+ width="100px"
17
+ {...props}
18
+ />
19
+ <SkeletonLoading
20
+ borderRadius="lg"
21
+ height="50px"
22
+ width="100px"
23
+ {...props}
24
+ />
25
+ <SkeletonLoading
26
+ borderRadius="md"
27
+ height="50px"
28
+ width="100px"
29
+ {...props}
30
+ />
31
+ <SkeletonLoading
32
+ height="50px"
33
+ width="100px"
34
+ {...props}
35
+ />
36
+ <SkeletonLoading
37
+ borderRadius="xs"
38
+ height="50px"
39
+ width="100px"
40
+ {...props}
41
+ />
42
+ <SkeletonLoading
43
+ borderRadius="none"
44
+ height="50px"
45
+ width="100px"
46
+ {...props}
47
+ />
48
+ </Flex>
49
+ )
50
+
51
+ export default SkeletonLoadingBorderRadius
@@ -0,0 +1 @@
1
+ The `borderRadius` prop accepts all of our [BorderRadius](https://playbook.powerapp.cloud/visual_guidelines/border_radius) tokens, with `sm` as default.
@@ -0,0 +1,26 @@
1
+ import React from 'react'
2
+ import { Card, SkeletonLoading } from "playbook-ui"
3
+
4
+
5
+ const SkeletonLoadingColor = (props) => (
6
+ <div>
7
+ <Card
8
+ borderNone
9
+ {...props}
10
+ >
11
+ <SkeletonLoading {...props}/>
12
+ </Card>
13
+ <Card
14
+ background="light"
15
+ borderNone
16
+ {...props}
17
+ >
18
+ <SkeletonLoading
19
+ color="white"
20
+ {...props}
21
+ />
22
+ </Card>
23
+ </div>
24
+ )
25
+
26
+ export default SkeletonLoadingColor
@@ -0,0 +1 @@
1
+ The SkeletonLoading component has a default and a white `color` variant.
@@ -0,0 +1 @@
1
+ <%= pb_rails("skeleton_loading") %>
@@ -0,0 +1,11 @@
1
+ import React from 'react'
2
+ import { SkeletonLoading } from "playbook-ui"
3
+
4
+
5
+ const SkeletonLoadingDefault = (props) => (
6
+ <div>
7
+ <SkeletonLoading {...props} />
8
+ </div>
9
+ )
10
+
11
+ export default SkeletonLoadingDefault
@@ -0,0 +1,59 @@
1
+ import React from 'react'
2
+ import { Card, SkeletonLoading } from "playbook-ui"
3
+
4
+
5
+ const SkeletonLoadingHeightWidth = (props) => (
6
+ <div>
7
+ <SkeletonLoading
8
+ height="100px"
9
+ width="50%"
10
+ {...props}
11
+ />
12
+ <SkeletonLoading
13
+ gap="md"
14
+ height="20px"
15
+ marginY="md"
16
+ stack="3"
17
+ width="50px"
18
+ {...props}
19
+ />
20
+ <Card htmlOptions={{ style: { height: '200px', width: '100%' }}}
21
+ marginBottom="md"
22
+ padding="none"
23
+ >
24
+ <SkeletonLoading
25
+ borderRadius="md"
26
+ gap="xl"
27
+ height="50%"
28
+ width="300px"
29
+ {...props}
30
+ />
31
+ </Card>
32
+ <Card htmlOptions={{ style: { height: '200px', width: '100%' }}}
33
+ padding="none"
34
+ >
35
+ <SkeletonLoading
36
+ borderRadius="md"
37
+ gap="xl"
38
+ height="30%"
39
+ stack="2"
40
+ width="70%"
41
+ {...props}
42
+ />
43
+ </Card>
44
+ <SkeletonLoading
45
+ height="150px"
46
+ marginY="md"
47
+ width="150px"
48
+ {...props}
49
+ />
50
+ <SkeletonLoading
51
+ borderRadius="rounded"
52
+ height="150px"
53
+ width="150px"
54
+ {...props}
55
+ />
56
+ </div>
57
+ )
58
+
59
+ export default SkeletonLoadingHeightWidth
@@ -0,0 +1,3 @@
1
+ The `height` and `width` props accept pixel and percentage values. If using a percentage for `height`, the parent container must have a set height.
2
+
3
+ Set the `height` and `width` props to the same value to make a square. A `rounded` borderRadius will make a square a circle. If using percentages to make a square, your parent container must also be a square.
@@ -0,0 +1,20 @@
1
+ import React from 'react'
2
+ import { SkeletonLoading } from "playbook-ui"
3
+
4
+
5
+ const SkeletonLoadingLayout = (props) => (
6
+ <div>
7
+ <SkeletonLoading
8
+ stack="5"
9
+ {...props}
10
+ />
11
+ <SkeletonLoading
12
+ gap="md"
13
+ paddingTop="xl"
14
+ stack="3"
15
+ {...props}
16
+ />
17
+ </div>
18
+ )
19
+
20
+ export default SkeletonLoadingLayout
@@ -0,0 +1,3 @@
1
+ Use the `stack` and `gap` props in conjunction to layer multiple Skeleton loading bars on top of each other.
2
+
3
+ `stack` accepts a number that correlates to the number of rows (1 is default), and `gap` accepts a portion of our [spacing props](https://playbook.powerapp.cloud/visual_guidelines/spacing) (`xxs` as default, `xs`, `sm`, `md`, `lg`, `xl`, `xxl`) to set the pixel distance between each row. `gap` will not do anything if there is no corresponding `stack` prop set.
@@ -0,0 +1,13 @@
1
+ examples:
2
+
3
+ rails:
4
+ # - skeleton_loading_default: Default
5
+
6
+
7
+ react:
8
+ - skeleton_loading_default: Default
9
+ - skeleton_loading_color: Color
10
+ - skeleton_loading_layout: Layout
11
+ - skeleton_loading_border_radius: Border Radius
12
+ - skeleton_loading_height_width: Height & Width
13
+
@@ -0,0 +1,5 @@
1
+ export { default as SkeletonLoadingDefault } from './_skeleton_loading_default.jsx'
2
+ export { default as SkeletonLoadingColor } from './_skeleton_loading_color.jsx'
3
+ export { default as SkeletonLoadingLayout } from './_skeleton_loading_layout.jsx'
4
+ export { default as SkeletonLoadingBorderRadius } from './_skeleton_loading_border_radius.jsx'
5
+ export { default as SkeletonLoadingHeightWidth } from './_skeleton_loading_height_width.jsx'
@@ -0,0 +1,12 @@
1
+ <!-- Go to pb_content_tag definition in kit_base.rb for usage information. Commented out options are default (showing the default shape), and each can be deleted if not customizing that param. -->
2
+ <!-- If using nonstandard params please un-comment out and replace with your custom params. -->
3
+ <%= pb_content_tag(
4
+ # :div,
5
+ # aria: object.aria,
6
+ # class: object.classname,
7
+ # data: object.data,
8
+ # id: object.id,
9
+ # **combined_html_options
10
+ ) do %>
11
+ <span>SKELETON_LOADING CONTENT</span>
12
+ <% end %>
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Playbook
4
+ module PbSkeletonLoading
5
+ class SkeletonLoading < ::Playbook::KitBase
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,81 @@
1
+ import React from 'react'
2
+ import { render, screen } from '@testing-library/react'
3
+ import { ensureAccessible } from '../utilities/test-utils'
4
+ import { SkeletonLoading } from 'playbook-ui'
5
+
6
+ /* See these resources for more testing info:
7
+ - https://github.com/testing-library/jest-dom#usage for useage and examples
8
+ - https://jestjs.io/docs/en/using-matchers
9
+ */
10
+
11
+ describe('SkeletonLoading', () => {
12
+ const defaultProps = {
13
+ data: { testid: 'skeleton-loading' }
14
+ }
15
+
16
+ it('should be accessible', async () => {
17
+ ensureAccessible(SkeletonLoading, defaultProps)
18
+ })
19
+
20
+ it('renders with default props', () => {
21
+ const { container } = render(<SkeletonLoading {...defaultProps} />)
22
+ const skeleton = screen.getByTestId('skeleton-loading')
23
+
24
+ expect(skeleton).toBeInTheDocument()
25
+ expect(skeleton).toHaveClass('pb_skeleton_loading')
26
+ expect(container.querySelectorAll('div[class*="border_radius_"]')).toHaveLength(1)
27
+ })
28
+
29
+ it('renders multiple skeleton items based on stack prop', () => {
30
+ const props = {
31
+ ...defaultProps,
32
+ stack: 3
33
+ }
34
+ const { container } = render(<SkeletonLoading {...props} />)
35
+
36
+ expect(container.querySelectorAll('div[class*="border_radius_"]')).toHaveLength(3)
37
+ })
38
+
39
+ it('applies custom styles correctly', () => {
40
+ const props = {
41
+ ...defaultProps,
42
+ height: '24px',
43
+ width: '50%',
44
+ borderRadius: 'lg',
45
+ color: 'light',
46
+ dark: true
47
+ }
48
+ const { container } = render(<SkeletonLoading {...props} />)
49
+ const skeletonItem = container.querySelector('div[class*="border_radius_"]')
50
+
51
+ expect(skeletonItem).toHaveClass('border_radius_lg')
52
+ expect(skeletonItem).toHaveClass('dark')
53
+ })
54
+
55
+ it('applies gap class to items after first one', () => {
56
+ const props = {
57
+ ...defaultProps,
58
+ stack: 3,
59
+ gap: 'md'
60
+ }
61
+ const { container } = render(<SkeletonLoading {...props} />)
62
+ const skeletonItems = container.querySelectorAll('div[class*="border_radius_"]')
63
+
64
+ expect(skeletonItems[0]).not.toHaveClass('gap_md')
65
+ expect(skeletonItems[1]).toHaveClass('gap_md')
66
+ expect(skeletonItems[2]).toHaveClass('gap_md')
67
+ })
68
+
69
+ it('handles no gap properly', () => {
70
+ const props = {
71
+ ...defaultProps,
72
+ stack: 2,
73
+ gap: 'none'
74
+ }
75
+ const { container } = render(<SkeletonLoading {...props} />)
76
+ const skeletonItems = container.querySelectorAll('div[class*="border_radius_"]')
77
+
78
+ expect(skeletonItems[0]).not.toHaveClass('gap_none')
79
+ expect(skeletonItems[1]).not.toHaveClass('gap_none')
80
+ })
81
+ })
@@ -1,12 +1,15 @@
1
1
  import React from 'react'
2
2
  import classnames from 'classnames'
3
-
4
3
  import { buildCss, buildHtmlProps } from '../utilities/props'
5
- import { globalProps, GlobalProps } from "../utilities/globalProps";
4
+ import { globalProps, GlobalProps } from "../utilities/globalProps"
6
5
 
7
6
  import DateStacked from '../pb_date_stacked/_date_stacked'
8
7
  import IconCircle from '../pb_icon_circle/_icon_circle'
9
8
 
9
+ import TimelineLabel from './subcomponents/Label'
10
+ import TimelineStep from './subcomponents/Step'
11
+ import TimelineDetail from './subcomponents/Detail'
12
+
10
13
  type ItemProps = {
11
14
  className?: string,
12
15
  children?: React.ReactNode[] | React.ReactNode,
@@ -17,6 +20,13 @@ type ItemProps = {
17
20
  lineStyle?: 'solid' | 'dotted',
18
21
  } & GlobalProps
19
22
 
23
+ function isElementOfType<P>(
24
+ element: React.ReactNode,
25
+ component: React.ComponentType<P>
26
+ ): element is React.ReactElement<P> {
27
+ return React.isValidElement<P>(element) && element.type === component
28
+ }
29
+
20
30
  const TimelineItem = ({
21
31
  className,
22
32
  children,
@@ -31,31 +41,57 @@ const TimelineItem = ({
31
41
 
32
42
  const htmlProps = buildHtmlProps(htmlOptions)
33
43
 
44
+ const childrenArray = React.Children.toArray(children)
45
+
46
+ const labelChild = childrenArray.find(
47
+ (child): child is React.ReactElement => isElementOfType(child, TimelineLabel)
48
+ )
49
+
50
+ const stepChild = childrenArray.find(
51
+ (child): child is React.ReactElement => isElementOfType(child, TimelineStep)
52
+ )
53
+
54
+ const detailChild = childrenArray.find(
55
+ (child): child is React.ReactElement => isElementOfType(child, TimelineDetail)
56
+ )
57
+
58
+ const otherChildren = childrenArray.filter(
59
+ (child) =>
60
+ !isElementOfType(child, TimelineLabel) &&
61
+ !isElementOfType(child, TimelineStep) &&
62
+ !isElementOfType(child, TimelineDetail)
63
+ )
64
+
34
65
  return (
35
- <div
66
+ <div
36
67
  {...htmlProps}
37
68
  className={classnames(timelineItemCss, globalProps(props), className)}
38
69
  >
39
- <div className="pb_timeline_item_left_block">
40
- {date &&
41
- <DateStacked
42
- align="center"
43
- date={date}
44
- size="sm"
45
- />
46
- }
47
- </div>
48
- <div className="pb_timeline_item_step">
49
- <IconCircle
50
- icon={icon}
51
- size="xs"
52
- variant={iconColor}
53
- />
54
- <div className="pb_timeline_item_connector" />
55
- </div>
56
- <div className="pb_timeline_item_right_block">
57
- {children}
58
- </div>
70
+ {labelChild || (
71
+ <div className="pb_timeline_item_left_block">
72
+ {date && (
73
+ <DateStacked
74
+ align="center"
75
+ date={date}
76
+ size="sm"
77
+ />
78
+ )}
79
+ </div>
80
+ )}
81
+ {stepChild || (
82
+ <div className="pb_timeline_item_step">
83
+ <IconCircle icon={icon}
84
+ size="xs"
85
+ variant={iconColor}
86
+ />
87
+ <div className="pb_timeline_item_connector" />
88
+ </div>
89
+ )}
90
+ {detailChild || (
91
+ <div className="pb_timeline_item_right_block">
92
+ { otherChildren }
93
+ </div>
94
+ )}
59
95
  </div>
60
96
  )
61
97
  }
@@ -5,6 +5,11 @@ import { buildAriaProps, buildCss, buildDataProps, buildHtmlProps } from '../uti
5
5
  import { GlobalProps, globalProps } from '../utilities/globalProps'
6
6
 
7
7
  import TimelineItem from './_item'
8
+ import {
9
+ TimelineStep,
10
+ TimelineLabel,
11
+ TimelineDetail,
12
+ } from './subcomponents'
8
13
 
9
14
  type TimelineProps = {
10
15
  aria?: { [key: string]: string },
@@ -47,5 +52,8 @@ const Timeline = ({
47
52
  }
48
53
 
49
54
  Timeline.Item = TimelineItem
55
+ Timeline.Step = TimelineStep
56
+ Timeline.Label = TimelineLabel
57
+ Timeline.Detail = TimelineDetail
50
58
 
51
59
  export default Timeline
@@ -0,0 +1,3 @@
1
+ <%= pb_content_tag do %>
2
+ <%= content.presence %>
3
+ <% end %>
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Playbook
4
+ module PbTimeline
5
+ class Detail < Playbook::KitBase
6
+ def classname
7
+ generate_classname("pb_timeline_item_right_block")
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,43 @@
1
+ <%= pb_rails("timeline", props: {orientation: "horizontal", show_date: true}) do %>
2
+ <%= pb_rails("timeline/item", props: { line_style: "solid"}) do |item| %>
3
+
4
+ <% item.label do %>
5
+ <%= pb_rails("timeline/label") do %>
6
+ <%= pb_rails("title", props: { text: "Any Kit Here", size: 2 }) %>
7
+ <% end %>
8
+ <% end %>
9
+
10
+ <% item.step do %>
11
+ <%= pb_rails("timeline/step", props: { icon: 'check', icon_color: 'teal' }) %>
12
+ <% end %>
13
+
14
+ <% item.detail do %>
15
+ <%= pb_rails("title_detail", props: {
16
+ title: "Jackson Heights",
17
+ detail: "37-27 74th Street"
18
+ }) %>
19
+ <% end %>
20
+ <% end %>
21
+ <%= pb_rails("timeline/item", props: { line_style: "dotted"}) do |item| %>
22
+
23
+ <% item.step do %>
24
+ <%= pb_rails("timeline/step") do %>
25
+ <%= pb_rails("pill", props: { text: "Any Kit" , variant: "success" }) %>
26
+ <% end %>
27
+ <% end %>
28
+
29
+ <% item.detail do %>
30
+ <%= pb_rails("title_detail", props: {
31
+ title: "Greenpoint",
32
+ detail: "81 Gate St Brooklyn"
33
+ }) %>
34
+ <% end %>
35
+ <% end %>
36
+
37
+ <%= pb_rails("timeline/item", props: {icon: "map-marker-alt", icon_color: "purple", date: Date.today+1 }) do |item| %>
38
+ <%= pb_rails("title_detail", props: {
39
+ title: "Society Hill",
40
+ detail: "72 E St Astoria"
41
+ }) %>
42
+ <% end %>
43
+ <% end %>
@@ -0,0 +1,68 @@
1
+ import React from 'react'
2
+
3
+ import Timeline from '../_timeline'
4
+ import Title from '../../pb_title/_title'
5
+ import Pill from '../../pb_pill/_pill'
6
+
7
+ import TitleDetail from '../../pb_title_detail/_title_detail'
8
+
9
+ const TimelineWithChildren = (props) => (
10
+ <div>
11
+ <Timeline orientation="horizontal"
12
+ showDate
13
+ {...props}
14
+ >
15
+ <Timeline.Item lineStyle="solid"
16
+ {...props}
17
+ >
18
+ <Timeline.Label>
19
+ <Title size={2}
20
+ text='Any Kit Here'
21
+ />
22
+ </Timeline.Label>
23
+ <Timeline.Step icon="user"
24
+ iconColor="royal"
25
+ />
26
+ <Timeline.Detail>
27
+ <TitleDetail detail="37-27 74th Street"
28
+ title="Jackson Heights"
29
+ {...props}
30
+ />
31
+ </Timeline.Detail>
32
+ </Timeline.Item>
33
+
34
+ <Timeline.Item lineStyle="dotted"
35
+ {...props}
36
+ >
37
+ <Timeline.Step>
38
+ <Pill text="Any Kit"
39
+ variant="success"
40
+ />
41
+ </Timeline.Step>
42
+ <Timeline.Detail>
43
+ <TitleDetail detail="81 Gate St Brooklyn"
44
+ title="Greenpoint"
45
+ {...props}
46
+ />
47
+ </Timeline.Detail>
48
+ </Timeline.Item>
49
+
50
+ <Timeline.Item lineStyle="solid"
51
+ {...props}
52
+ >
53
+ <Timeline.Label date={new Date(new Date().setDate(new Date().getDate() + 1))} />
54
+ <Timeline.Step icon="map-marker-alt"
55
+ iconColor="purple"
56
+ />
57
+ <Timeline.Detail>
58
+ <TitleDetail detail="72 E St Astoria"
59
+ title="Society Hill"
60
+ {...props}
61
+ />
62
+ </Timeline.Detail>
63
+ </Timeline.Item>
64
+ </Timeline>
65
+ </div>
66
+ )
67
+
68
+ export default TimelineWithChildren
@@ -0,0 +1,2 @@
1
+ Any kit can be used inside of our compound components of label, step, or detail. Expand the code snippet below to see how to use these children elements.
2
+
@@ -4,10 +4,11 @@ examples:
4
4
  - timeline_default: Default
5
5
  - timeline_vertical: Vertical
6
6
  - timeline_with_date: With Date
7
+ - timeline_with_children: With Children
7
8
 
8
9
 
9
10
  react:
10
11
  - timeline_default: Default
11
12
  - timeline_vertical: Vertical
12
13
  - timeline_with_date: With Date
13
-
14
+ - timeline_with_children: With Children
@@ -1,3 +1,4 @@
1
1
  export { default as TimelineDefault } from './_timeline_default.jsx'
2
2
  export { default as TimelineVertical } from './_timeline_vertical.jsx'
3
3
  export { default as TimelineWithDate } from './_timeline_with_date.jsx'
4
+ export { default as TimelineWithChildren } from './_timeline_with_children.jsx'
@@ -1,25 +1,21 @@
1
1
  <%= pb_content_tag do %>
2
+ <% if label %>
3
+ <%= label %>
4
+ <% else %>
5
+ <%= pb_rails("timeline/label", props: { date: date }) %>
6
+ <% end %>
2
7
 
3
- <div class="pb_timeline_item_left_block">
4
- <% if object.date.present? %>
5
- <%= pb_rails("date_stacked", props: {
6
- date: object.date,
7
- size: "sm",
8
- align: "center"
9
- }) %>
10
- <% end %>
11
- </div>
12
-
13
- <div class="pb_timeline_item_step">
14
- <%= pb_rails("icon_circle", props: {
15
- icon: object.icon,
16
- variant: object.icon_color,
17
- size: "xs"
18
- }) %>
19
- <div class="pb_timeline_item_connector"></div>
20
- </div>
8
+ <% if step %>
9
+ <%= step %>
10
+ <% else %>
11
+ <%= pb_rails("timeline/step", props: { icon: icon, icon_color: icon_color }) %>
12
+ <% end %>
21
13
 
22
- <div class="pb_timeline_item_right_block">
23
- <%= content.presence %>
24
- </div>
14
+ <% if detail%>
15
+ <%= detail%>
16
+ <% else %>
17
+ <%= pb_rails("timeline/detail") do %>
18
+ <%= content %>
19
+ <% end %>
20
+ <% end %>
25
21
  <% end %>
@@ -13,6 +13,10 @@ module Playbook
13
13
  values: %w[solid dotted],
14
14
  default: "solid"
15
15
 
16
+ renders_one :label
17
+ renders_one :step
18
+ renders_one :detail
19
+
16
20
  def classname
17
21
  generate_classname("pb_timeline_item_kit", line_style)
18
22
  end
@@ -0,0 +1,12 @@
1
+ <%= pb_content_tag do %>
2
+ <% if object.date.present? %>
3
+ <%= pb_rails("date_stacked", props: {
4
+ date: object.date,
5
+ size: "sm",
6
+ align: "center"
7
+ }) %>
8
+ <% else %>
9
+ <%= content.presence %>
10
+ <% end %>
11
+ <% end %>
12
+