playbook_ui 15.6.0.pre.alpha.play265012993 → 15.6.0.pre.alpha.play266013023

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 (36) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_bar_graph/_bar_graph.tsx +0 -6
  3. data/app/pb_kits/playbook/pb_dialog/_dialog.tsx +2 -1
  4. data/app/pb_kits/playbook/pb_dialog/dialog.html.erb +1 -1
  5. data/app/pb_kits/playbook/pb_dialog/dialog.rb +1 -0
  6. data/app/pb_kits/playbook/pb_dialog/dialog.test.jsx +14 -0
  7. data/app/pb_kits/playbook/pb_dialog/dialog_header.html.erb +5 -4
  8. data/app/pb_kits/playbook/pb_dialog/dialog_header.rb +2 -0
  9. data/app/pb_kits/playbook/pb_dialog/docs/_dialog_closeable.html.erb +24 -0
  10. data/app/pb_kits/playbook/pb_dialog/docs/_dialog_closeable.jsx +60 -0
  11. data/app/pb_kits/playbook/pb_dialog/docs/_dialog_closeable.md +3 -0
  12. data/app/pb_kits/playbook/pb_dialog/docs/example.yml +2 -0
  13. data/app/pb_kits/playbook/pb_dialog/docs/index.js +2 -1
  14. data/app/pb_kits/playbook/pb_legend/_legend.tsx +1 -6
  15. data/app/pb_kits/playbook/pb_legend/legend.html.erb +0 -1
  16. data/app/pb_kits/playbook/pb_timeline/_item.tsx +3 -0
  17. data/app/pb_kits/playbook/pb_timeline/docs/_timeline_show_current_year.html.erb +60 -0
  18. data/app/pb_kits/playbook/pb_timeline/docs/_timeline_show_current_year.jsx +118 -0
  19. data/app/pb_kits/playbook/pb_timeline/docs/_timeline_show_current_year.md +1 -0
  20. data/app/pb_kits/playbook/pb_timeline/docs/_timeline_with_date.md +1 -1
  21. data/app/pb_kits/playbook/pb_timeline/docs/example.yml +2 -0
  22. data/app/pb_kits/playbook/pb_timeline/docs/index.js +1 -0
  23. data/app/pb_kits/playbook/pb_timeline/item.html.erb +1 -1
  24. data/app/pb_kits/playbook/pb_timeline/item.rb +2 -0
  25. data/app/pb_kits/playbook/pb_timeline/label.html.erb +2 -1
  26. data/app/pb_kits/playbook/pb_timeline/label.rb +2 -0
  27. data/app/pb_kits/playbook/pb_timeline/subcomponents/Label.tsx +3 -0
  28. data/app/pb_kits/playbook/pb_timeline/timeline.test.js +51 -0
  29. data/dist/chunks/_typeahead-CYNrKU10.js +6 -0
  30. data/dist/chunks/vendor.js +2 -2
  31. data/dist/menu.yml +2 -3
  32. data/dist/playbook-rails-react-bindings.js +1 -1
  33. data/dist/playbook-rails.js +1 -1
  34. data/lib/playbook/version.rb +1 -1
  35. metadata +9 -3
  36. data/dist/chunks/_typeahead-DMyvWpig.js +0 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b01617dcbc1a314898f562b32892261daddf8ccf2629bd9aade3ddb46fbb3d64
4
- data.tar.gz: 15e4c66a6efa09791d1cd72f4bd229beb21fffbc533cf5cc91ea4dfdac5c2588
3
+ metadata.gz: a6db43d3a7fb9e0f943643cf6bcfdb94d3aec4ac7d76204cb9b3d37977d0b266
4
+ data.tar.gz: a4633939ff364118352b782652738e3d0d1ada1c9af1bdfac6fa3ab9fbea0eff
5
5
  SHA512:
6
- metadata.gz: f5f4be93a8dac412cc0d97881c302a7ee5e794d5bf57964625a5b7f596853c1e5974fca8451548da63a2fe2977d1354a907e30fe3f0975931483f609aae816d0
7
- data.tar.gz: df6e483f09dcf147fc3920665fda47e37de87318fa7db4709e8216297c570e99b9683b61f368ddcea903a6c2b314bc93b7e11241953479218ac11cd26b0ef014
6
+ metadata.gz: 94a35af5bd9592f899fc5b0d4d92bfdad87fe9056f104910a01bd827f6f53871aeaceffd5e78b05296fb3b8c1ba075548b312016cc8f89fb863aa35cba084d33
7
+ data.tar.gz: b5c1c948b583c32209cba3fc3514d3f0f08d9537c33c7174b6b3c02afa954452972c3f881f3d313defb1d05afc0172ade58726a42f778004381b2d157a4c4a8c
@@ -1,7 +1,6 @@
1
1
  import React, { useState, useEffect } from "react";
2
2
  import { globalProps } from "../utilities/globalProps";
3
3
  import { buildAriaProps, buildDataProps, buildHtmlProps } from "../utilities/props";
4
- import { deprecatedKitWarning } from "../utilities/deprecated";
5
4
 
6
5
  import HighchartsReact from "highcharts-react-official";
7
6
  import Highcharts from "highcharts";
@@ -169,11 +168,6 @@ if (Array.isArray(axisTitle) && axisTitle.length > 1 && axisTitle[1].name) {
169
168
 
170
169
  const [options, setOptions] = useState({});
171
170
 
172
- useEffect(() => {
173
- // Warn about deprecated kit (only once per page load, dev mode only)
174
- deprecatedKitWarning('BarGraph', 'Please use "PbBarGraph" instead.');
175
- }, []);
176
-
177
171
  useEffect(() => {
178
172
  setOptions(merge(staticOptions, customOptions));
179
173
  }, [chartData]);
@@ -51,6 +51,7 @@ const Dialog = (props: DialogProps): React.ReactElement => {
51
51
  cancelButton,
52
52
  confirmButton,
53
53
  className,
54
+ closeable,
54
55
  data = {},
55
56
  htmlOptions = {},
56
57
  id,
@@ -187,7 +188,7 @@ const Dialog = (props: DialogProps): React.ReactElement => {
187
188
  style={{ content: dynamicInlineProps }}
188
189
  >
189
190
  <>
190
- {title && !status ? <Dialog.Header>{title}</Dialog.Header> : null}
191
+ {title && !status ? <Dialog.Header closeable={closeable}>{title}</Dialog.Header> : null}
191
192
  {!status && text ? <Dialog.Body>{text}</Dialog.Body> : null}
192
193
  {status && (
193
194
  <Dialog.Body
@@ -14,7 +14,7 @@
14
14
  >
15
15
  <%= pb_content_tag(:dialog, role: "dialog", "aria-modal": "true", "aria-label": "Dialog") do %>
16
16
  <% if object.status === "" && object.title %>
17
- <%= pb_rails("dialog/dialog_header", props: { title: object.title, id: object.id }) %>
17
+ <%= pb_rails("dialog/dialog_header", props: { title: object.title, id: object.id, closeable: object.closeable }) %>
18
18
  <% end %>
19
19
  <% if object.status === "" && object.text %>
20
20
  <%= pb_rails("dialog/dialog_body", props: { text: object.text }) %>
@@ -23,6 +23,7 @@ module Playbook
23
23
  default: ""
24
24
  prop :custom_event_type, type: Playbook::Props::String,
25
25
  default: ""
26
+ prop :closeable, type: Playbook::Props::Boolean, default: true
26
27
 
27
28
  def classname
28
29
  generate_classname("pb_dialog pb_dialog_rails pb_dialog_#{size}_#{placement}")
@@ -129,3 +129,17 @@ test('renders loading dialog with disabled buttons', async () => {
129
129
 
130
130
  cleanup()
131
131
  })
132
+
133
+ test('renders dialog without close button when closeable is false', async () => {
134
+
135
+ const { queryByText, container } = render(<DialogTest closeable={false} />);
136
+
137
+ fireEvent.click(queryByText('Open Dialog'));
138
+
139
+ await waitFor(() => expect(queryByText("Header Title is the Title Prop")));
140
+
141
+ const closeBtn = container.querySelector('.pb_dialog_close_icon');
142
+ expect(closeBtn).not.toBeInTheDocument();
143
+
144
+ cleanup()
145
+ })
@@ -1,10 +1,11 @@
1
1
  <%= pb_content_tag(:div, class: object.sticky_header) do %>
2
2
  <%= pb_rails("flex", props: {classname:object.classname, spacing:"between", padding:"sm", align:"center"}) do %>
3
3
  <%= content.presence || object.title %>
4
-
5
- <button class="dialog-button-class pb_dialog_close_icon" type="button" data-close-dialog= <%= object.id %> aria-label="Close Dialog" >
6
- <%= pb_rails("icon", props: { custom_icon: Playbook::Engine::root.join(times_icon), aria: { hidden: true } }) %>
7
- </button>
4
+ <% if object.closeable %>
5
+ <button class="dialog-button-class pb_dialog_close_icon" type="button" data-close-dialog= <%= object.id %> aria-label="Close Dialog" >
6
+ <%= pb_rails("icon", props: { custom_icon: Playbook::Engine::root.join(times_icon), aria: { hidden: true } }) %>
7
+ </button>
8
+ <% end %>
8
9
  <% end %>
9
10
  <%= pb_rails("section_separator") %>
10
11
  <% end %>
@@ -4,6 +4,8 @@ module Playbook
4
4
  module PbDialog
5
5
  class DialogHeader < Playbook::KitBase
6
6
  prop :title
7
+ prop :closeable, type: Playbook::Props::Boolean,
8
+ default: true
7
9
 
8
10
  def classname
9
11
  generate_classname("dialog_header")
@@ -0,0 +1,24 @@
1
+ <%= pb_rails("flex", props:{wrap:true}) do %>
2
+ <%= pb_rails("button", props: { text: "Open Simple Dialog", data: {"open-dialog": "dialog-simple"}, margin_right:"md" }) %>
3
+ <%= pb_rails("button", props: { text: "Open Complex Dialog", data: {"open-dialog": "dialog-complex2"} }) %>
4
+ <% end %>
5
+
6
+ <%= pb_rails("dialog", props: {
7
+ id:"dialog-simple",
8
+ size: "sm",
9
+ title: "Header Title is the Title Prop",
10
+ text: "Hello Body Text, Nice to meet ya.",
11
+ cancel_button: "Cancel Button",
12
+ closeable: false,
13
+ confirm_button: "Okay",
14
+ confirm_button_id: "confirm-button-simple"
15
+ }) %>
16
+
17
+ <%= pb_rails("dialog", props: {
18
+ id:"dialog-complex2",
19
+ size: "sm"
20
+ }) do %>
21
+ <%= pb_rails("dialog/dialog_header", props: { id: "dialog-complex2", title:"Header Title inside Dialog Header", closeable: false } ) %>
22
+ <%= pb_rails("dialog/dialog_body", props:{text: "Hello Body Text, Nice to meet ya."}) %>
23
+ <%= pb_rails("dialog/dialog_footer", props: {cancel_button: "Cancel Button", confirm_button: "Okay", confirm_button_id:"confirm-complex2", id: "dialog-complex2"}) %>
24
+ <% end %>
@@ -0,0 +1,60 @@
1
+ import React, { useState } from 'react'
2
+ import Button from '../../pb_button/_button'
3
+ import Dialog from '../../pb_dialog/_dialog'
4
+
5
+
6
+ const DialogCloseable = () => {
7
+ // Simple example
8
+ const [isOpenSimple, setIsOpenSimple] = useState(false)
9
+ const closeSimple = () => setIsOpenSimple(false)
10
+ const openSimple = () => setIsOpenSimple(true)
11
+
12
+ // Complex example
13
+ const [isOpenComplex, setIsOpenComplex] = useState(false)
14
+ const closeComplex = () => setIsOpenComplex(false)
15
+ const openComplex = () => setIsOpenComplex(true)
16
+
17
+ return (
18
+ <>
19
+ <Button
20
+ marginRight='md'
21
+ onClick={openSimple}
22
+ >
23
+ {'Open Simple Dialog'}
24
+ </Button>
25
+ <Button onClick={openComplex}>{'Open Complex Dialog'}</Button>
26
+
27
+ <Dialog
28
+ cancelButton="Cancel Button"
29
+ closeable={false}
30
+ confirmButton="Okay"
31
+ onCancel={closeSimple}
32
+ onClose={closeSimple}
33
+ onConfirm={closeSimple}
34
+ opened={isOpenSimple}
35
+ size="sm"
36
+ text="Hello Body Text, Nice to meet ya."
37
+ title="Header Title is the Title Prop"
38
+ />
39
+ <Dialog
40
+ onClose={closeComplex}
41
+ opened={isOpenComplex}
42
+ size="sm"
43
+ >
44
+ <Dialog.Header closeable={false}>{'Header Title inside Dialog.Header'}</Dialog.Header>
45
+ <Dialog.Body>{'Hello Body Text, Nice to meet ya.'}</Dialog.Body>
46
+ <Dialog.Footer>
47
+ <Button onClick={closeComplex}>{'Okay'}</Button>
48
+ <Button
49
+ onClick={closeComplex}
50
+ variant="link"
51
+ >
52
+ {'Cancel Button'}
53
+ </Button>
54
+ </Dialog.Footer>
55
+ </Dialog>
56
+ </>
57
+ )
58
+ }
59
+
60
+ export default DialogCloseable
@@ -0,0 +1,3 @@
1
+ The `closeable` prop can be set to false to optionally render the Dialog header without the close “X” button. `closeable` is set to true by default.
2
+
3
+ This prop can be used with the simple as well as the complex version of the Dialog as can be seen here.
@@ -12,6 +12,7 @@ examples:
12
12
  - dialog_full_height_placement: Full Height Placement
13
13
  - dialog_loading: Loading
14
14
  - dialog_turbo_frames: Within Turbo Frames
15
+ - dialog_closeable: Close Button in Header
15
16
 
16
17
 
17
18
  react:
@@ -25,6 +26,7 @@ examples:
25
26
  - dialog_full_height: Full Height
26
27
  - dialog_full_height_placement: Full Height Placement
27
28
  - dialog_loading: Loading
29
+ - dialog_closeable: Close Button in Header
28
30
 
29
31
  swift:
30
32
  - dialog_default_swift: Simple
@@ -8,4 +8,5 @@ export { default as DialogStatus } from './_dialog_status.jsx'
8
8
  export { default as DialogStackedAlert } from './_dialog_stacked_alert.jsx'
9
9
  export { default as DialogFullHeight } from './_dialog_full_height.jsx'
10
10
  export { default as DialogFullHeightPlacement } from './_dialog_full_height_placement.jsx'
11
- export { default as DialogLoading } from './_dialog_loading.jsx'
11
+ export { default as DialogLoading } from './_dialog_loading.jsx'
12
+ export { default as DialogCloseable } from './_dialog_closeable.jsx'
@@ -1,9 +1,8 @@
1
- import React, { useEffect } from 'react'
1
+ import React from 'react'
2
2
  import classnames from 'classnames'
3
3
 
4
4
  import { buildAriaProps, buildCss, buildDataProps, buildHtmlProps } from '../utilities/props'
5
5
  import { globalProps } from '../utilities/globalProps'
6
- import { deprecatedKitWarning } from '../utilities/deprecated'
7
6
 
8
7
  import Body from '../pb_body/_body'
9
8
  import Title from '../pb_title/_title'
@@ -33,10 +32,6 @@ const Legend = (props: LegendProps) => {
33
32
  text,
34
33
  } = props
35
34
 
36
- useEffect(() => {
37
- deprecatedKitWarning('Legend')
38
- }, [])
39
-
40
35
  const ariaProps = buildAriaProps(aria)
41
36
  const dataProps = buildDataProps(data)
42
37
  const htmlProps = buildHtmlProps(htmlOptions)
@@ -1,4 +1,3 @@
1
- <%== deprecated_kit_warning('Legend') %>
2
1
  <%= pb_content_tag do %>
3
2
  <%= pb_rails("body", props: {color: object.body_color}) do %>
4
3
  <span style="<%= object.custom_color %>" class=<%= object.custom_color_class %>></span>
@@ -18,6 +18,7 @@ type ItemProps = {
18
18
  icon?: string,
19
19
  iconColor?: 'default' | 'royal' | 'blue' | 'purple' | 'teal' | 'red' | 'yellow' | 'green',
20
20
  lineStyle?: 'solid' | 'dotted',
21
+ showCurrentYear?: boolean,
21
22
  } & GlobalProps
22
23
 
23
24
  function isElementOfType<P>(
@@ -35,6 +36,7 @@ const TimelineItem = ({
35
36
  icon = 'user',
36
37
  iconColor = 'default',
37
38
  lineStyle = 'solid',
39
+ showCurrentYear = false,
38
40
  ...props
39
41
  }: ItemProps): React.ReactElement => {
40
42
  const timelineItemCss = buildCss('pb_timeline_item_kit', lineStyle)
@@ -73,6 +75,7 @@ const TimelineItem = ({
73
75
  <DateStacked
74
76
  align="center"
75
77
  date={date}
78
+ showCurrentYear={showCurrentYear}
76
79
  size="sm"
77
80
  />
78
81
  )}
@@ -0,0 +1,60 @@
1
+ <%= pb_rails("timeline", props: {orientation: "horizontal", show_date: true}) do %>
2
+ <%= pb_rails("timeline/item", props: {icon: "user", icon_color: "royal", line_style: "solid", date: Date.today, show_current_year: true }) do %>
3
+ <%= pb_rails("title_detail", props: {
4
+ title: "Jackson Heights",
5
+ detail: "37-27 74th Street"
6
+ }) %>
7
+ <% end %>
8
+ <%= pb_rails("timeline/item", props: {icon: "check", icon_color: "teal", line_style: "dotted" }) do %>
9
+ <%= pb_rails("title_detail", props: {
10
+ title: "Greenpoint",
11
+ detail: "81 Gate St Brooklyn"
12
+ }) %>
13
+ <% end %>
14
+ <%= pb_rails("timeline/item", props: { line_style: "solid"}) do |item| %>
15
+ <% item.label do %>
16
+ <%= pb_rails("timeline/label", props: { date: Date.today, show_current_year: true }) %>
17
+ <% end %>
18
+ <% item.step do %>
19
+ <%= pb_rails("timeline/step", props: { icon: 'map-marker-alt', icon_color: 'purple' }) %>
20
+ <% end %>
21
+ <% item.detail do %>
22
+ <%= pb_rails("title_detail", props: {
23
+ title: "Society Hill",
24
+ detail: "72 E St Astoria"
25
+ }) %>
26
+ <% end %>
27
+ <% end %>
28
+ <% end %>
29
+
30
+ <br /><br /><br />
31
+
32
+ <%= pb_rails("timeline", props: {orientation: "vertical", show_date: true}) do %>
33
+ <%= pb_rails("timeline/item", props: {icon: "user", icon_color: "royal", line_style: "solid", date: Date.today, show_current_year: true }) do %>
34
+ <%= pb_rails("title_detail", props: {
35
+ title: "Jackson Heights",
36
+ detail: "37-27 74th Street"
37
+ }) %>
38
+ <% end %>
39
+ <%= pb_rails("timeline/item", props: {icon: "check", icon_color: "teal", line_style: "dotted" }) do %>
40
+ <%= pb_rails("title_detail", props: {
41
+ title: "Greenpoint",
42
+ detail: "81 Gate St Brooklyn"
43
+ }) %>
44
+ <% end %>
45
+ <%= pb_rails("timeline/item", props: { line_style: "solid"}) do |item| %>
46
+ <% item.label do %>
47
+ <%= pb_rails("timeline/label", props: { date: Date.today, show_current_year: true }) %>
48
+ <% end %>
49
+ <% item.step do %>
50
+ <%= pb_rails("timeline/step", props: { icon: 'map-marker-alt', icon_color: 'purple' }) %>
51
+ <% end %>
52
+ <% item.detail do %>
53
+ <%= pb_rails("title_detail", props: {
54
+ title: "Society Hill",
55
+ detail: "72 E St Astoria"
56
+ }) %>
57
+ <% end %>
58
+ <% end %>
59
+ <% end %>
60
+
@@ -0,0 +1,118 @@
1
+ import React from 'react'
2
+
3
+ import Timeline from '../_timeline'
4
+ import TitleDetail from '../../pb_title_detail/_title_detail'
5
+
6
+ const TimelineShowCurrentYear = (props) => (
7
+ <div>
8
+ <Timeline
9
+ orientation="horizontal"
10
+ showDate
11
+ {...props}
12
+ >
13
+ <Timeline.Item
14
+ date={new Date()}
15
+ icon="user"
16
+ iconColor="royal"
17
+ showCurrentYear
18
+ {...props}
19
+ >
20
+ <TitleDetail
21
+ detail="37-27 74th Street"
22
+ title="Jackson Heights"
23
+ {...props}
24
+ />
25
+ </Timeline.Item>
26
+ <Timeline.Item
27
+ icon="check"
28
+ iconColor="teal"
29
+ lineStyle="dotted"
30
+ {...props}
31
+ >
32
+ <TitleDetail
33
+ detail="81 Gate St Brooklyn"
34
+ title="Greenpoint"
35
+ {...props}
36
+ />
37
+ </Timeline.Item>
38
+ <Timeline.Item
39
+ lineStyle="solid"
40
+ {...props}
41
+ >
42
+ <Timeline.Label
43
+ date={new Date()}
44
+ showCurrentYear
45
+ />
46
+ <Timeline.Step
47
+ icon="map-marker-alt"
48
+ iconColor="purple"
49
+ />
50
+ <Timeline.Detail>
51
+ <TitleDetail
52
+ detail="72 E St Astoria"
53
+ title="Society Hill"
54
+ {...props}
55
+ />
56
+ </Timeline.Detail>
57
+ </Timeline.Item>
58
+ </Timeline>
59
+
60
+ <br />
61
+ <br />
62
+ <br />
63
+
64
+ <Timeline
65
+ orientation="vertical"
66
+ showDate
67
+ {...props}
68
+ >
69
+ <Timeline.Item
70
+ date={new Date()}
71
+ icon="user"
72
+ iconColor="royal"
73
+ showCurrentYear
74
+ {...props}
75
+ >
76
+ <TitleDetail
77
+ detail="37-27 74th Street"
78
+ title="Jackson Heights"
79
+ {...props}
80
+ />
81
+ </Timeline.Item>
82
+ <Timeline.Item
83
+ icon="check"
84
+ iconColor="teal"
85
+ lineStyle="dotted"
86
+ {...props}
87
+ >
88
+ <TitleDetail
89
+ detail="81 Gate St Brooklyn"
90
+ title="Greenpoint"
91
+ {...props}
92
+ />
93
+ </Timeline.Item>
94
+ <Timeline.Item
95
+ lineStyle="solid"
96
+ {...props}
97
+ >
98
+ <Timeline.Label
99
+ date={new Date()}
100
+ showCurrentYear
101
+ />
102
+ <Timeline.Step
103
+ icon="map-marker-alt"
104
+ iconColor="purple"
105
+ />
106
+ <Timeline.Detail>
107
+ <TitleDetail
108
+ detail="72 E St Astoria"
109
+ title="Society Hill"
110
+ {...props}
111
+ />
112
+ </Timeline.Detail>
113
+ </Timeline.Item>
114
+ </Timeline>
115
+ </div>
116
+ )
117
+
118
+ export default TimelineShowCurrentYear
@@ -0,0 +1 @@
1
+ By default, the Timeline kit does NOT display the year if it is the current year. If you want to display the current year you can do so by setting `showCurrentYear`/`show_current_year` to true. Pass it to `Timeline.Item`/`timeline/item` when using its `date` prop, or to `Timeline.Label`/`timeline/label` if following the "With Children" pattern.
@@ -1 +1 @@
1
- Use the optional `showDate` prop to render the timeline kit with a visible date. If the date is from the current year, the year will not be displayed, however if date is NOT from the current year, the kit will display the year as well.
1
+ Use the optional `showDate` prop to render the timeline kit with a visible date. By default, if the date is from the current year, the year will not be displayed; however, if the date is NOT from the current year, the kit will display the year as well.
@@ -5,6 +5,7 @@ examples:
5
5
  - timeline_vertical: Vertical
6
6
  - timeline_with_date: With Date
7
7
  - timeline_with_children: With Children
8
+ - timeline_show_current_year: Show Current Year
8
9
  - timeline_with_gap: With Gap
9
10
 
10
11
 
@@ -13,4 +14,5 @@ examples:
13
14
  - timeline_vertical: Vertical
14
15
  - timeline_with_date: With Date
15
16
  - timeline_with_children: With Children
17
+ - timeline_show_current_year: Show Current Year
16
18
  - timeline_with_gap: With Gap
@@ -3,4 +3,5 @@ export { default as TimelineVertical } from './_timeline_vertical.jsx'
3
3
  export { default as TimelineWithDate } from './_timeline_with_date.jsx'
4
4
  export { default as TimelineWithChildren } from './_timeline_with_children.jsx'
5
5
  export { default as TimelineWithGap } from './_timeline_with_gap.jsx'
6
+ export { default as TimelineShowCurrentYear } from './_timeline_show_current_year.jsx'
6
7
 
@@ -2,7 +2,7 @@
2
2
  <% if label %>
3
3
  <%= label %>
4
4
  <% else %>
5
- <%= pb_rails("timeline/label", props: { date: date }) %>
5
+ <%= pb_rails("timeline/label", props: { date: date, show_current_year: show_current_year }) %>
6
6
  <% end %>
7
7
 
8
8
  <% if step %>
@@ -12,6 +12,8 @@ module Playbook
12
12
  prop :line_style, type: Playbook::Props::Enum,
13
13
  values: %w[solid dotted],
14
14
  default: "solid"
15
+ prop :show_current_year, type: Playbook::Props::Boolean,
16
+ default: false
15
17
 
16
18
  renders_one :label
17
19
  renders_one :step
@@ -3,7 +3,8 @@
3
3
  <%= pb_rails("date_stacked", props: {
4
4
  date: object.date,
5
5
  size: "sm",
6
- align: "center"
6
+ align: "center",
7
+ show_current_year: object.show_current_year
7
8
  }) %>
8
9
  <% else %>
9
10
  <%= content.presence %>
@@ -4,6 +4,8 @@ module Playbook
4
4
  module PbTimeline
5
5
  class Label < Playbook::KitBase
6
6
  prop :date
7
+ prop :show_current_year, type: Playbook::Props::Boolean,
8
+ default: false
7
9
 
8
10
  def classname
9
11
  generate_classname("pb_timeline_item_left_block")
@@ -9,6 +9,7 @@ type TimelineLabelProps = {
9
9
  children?: React.ReactNode,
10
10
  className?: string,
11
11
  htmlOptions?: { [key: string]: any },
12
+ showCurrentYear?: boolean,
12
13
  } & GlobalProps
13
14
 
14
15
  const TimelineLabel: React.FC<TimelineLabelProps> = ({
@@ -16,6 +17,7 @@ const TimelineLabel: React.FC<TimelineLabelProps> = ({
16
17
  children,
17
18
  className,
18
19
  htmlOptions = {},
20
+ showCurrentYear = false,
19
21
  ...props
20
22
  }) => {
21
23
  const htmlProps = buildHtmlProps(htmlOptions)
@@ -28,6 +30,7 @@ const TimelineLabel: React.FC<TimelineLabelProps> = ({
28
30
  {date && (
29
31
  <DateStacked align="center"
30
32
  date={date}
33
+ showCurrentYear={showCurrentYear}
31
34
  size="sm"
32
35
  />
33
36
  )}
@@ -170,3 +170,54 @@ test('should pass showDate prop with Children', () => {
170
170
  const kit = screen.getByTestId(testId)
171
171
  expect(kit).toHaveClass('pb_timeline_kit_horizontal_with_date')
172
172
  })
173
+
174
+ test('should pass showCurrentYear prop to items with date', () => {
175
+ const currentYear = new Date().getFullYear().toString()
176
+ render(
177
+ <Timeline
178
+ data={{ testid: testId }}
179
+ showDate
180
+ >
181
+ <Timeline.Item
182
+ date={new Date()}
183
+ icon="user"
184
+ iconColor="royal"
185
+ showCurrentYear
186
+ >
187
+ <TitleDetail
188
+ detail="37-27 74th Street"
189
+ title="Jackson Heights"
190
+ />
191
+ </Timeline.Item>
192
+ </Timeline>
193
+ )
194
+ const kit = screen.getByTestId(testId)
195
+ expect(kit).toBeInTheDocument()
196
+ const yearCaption = kit.querySelector('.pb_caption_kit_xs')
197
+ expect(yearCaption).toBeInTheDocument()
198
+ expect(yearCaption.textContent).toEqual(currentYear)
199
+ })
200
+
201
+ test('should not show current year by default', () => {
202
+ const currentYear = new Date().getFullYear().toString()
203
+ render(
204
+ <Timeline
205
+ data={{ testid: testId }}
206
+ showDate
207
+ >
208
+ <Timeline.Item
209
+ date={new Date()}
210
+ icon="user"
211
+ iconColor="royal"
212
+ >
213
+ <TitleDetail
214
+ detail="37-27 74th Street"
215
+ title="Jackson Heights"
216
+ />
217
+ </Timeline.Item>
218
+ </Timeline>
219
+ )
220
+ const kit = screen.getByTestId(testId)
221
+ expect(kit).toBeInTheDocument()
222
+ expect(kit).not.toHaveTextContent(currentYear)
223
+ })