playbook_ui 15.4.0 → 15.5.0.pre.rc.0

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 (66) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_date_picker/date_picker.html.erb +25 -11
  3. data/app/pb_kits/playbook/pb_date_range_inline/_date_range_inline.tsx +20 -13
  4. data/app/pb_kits/playbook/pb_date_range_inline/date_range_inline.rb +6 -4
  5. data/app/pb_kits/playbook/pb_date_range_inline/date_range_inline.test.js +17 -0
  6. data/app/pb_kits/playbook/pb_date_range_inline/docs/_date_range_inline_show_current_year.html.erb +4 -0
  7. data/app/pb_kits/playbook/pb_date_range_inline/docs/_date_range_inline_show_current_year.jsx +43 -0
  8. data/app/pb_kits/playbook/pb_date_range_inline/docs/_date_range_inline_show_current_year.md +1 -0
  9. data/app/pb_kits/playbook/pb_date_range_inline/docs/_description.md +1 -1
  10. data/app/pb_kits/playbook/pb_date_range_inline/docs/example.yml +3 -2
  11. data/app/pb_kits/playbook/pb_date_range_inline/docs/index.js +1 -0
  12. data/app/pb_kits/playbook/pb_date_stacked/_date_stacked.tsx +6 -4
  13. data/app/pb_kits/playbook/pb_date_stacked/date_stacked.html.erb +2 -3
  14. data/app/pb_kits/playbook/pb_date_stacked/date_stacked.rb +11 -5
  15. data/app/pb_kits/playbook/pb_date_stacked/date_stacked.test.js +26 -9
  16. data/app/pb_kits/playbook/pb_date_stacked/docs/_date_stacked_current_year.html.erb +12 -0
  17. data/app/pb_kits/playbook/pb_date_stacked/docs/{_date_stacked_not_current_year.jsx → _date_stacked_current_year.jsx} +6 -5
  18. data/app/pb_kits/playbook/pb_date_stacked/docs/_date_stacked_current_year.md +1 -0
  19. data/app/pb_kits/playbook/pb_date_stacked/docs/_date_stacked_default.html.erb +1 -1
  20. data/app/pb_kits/playbook/pb_date_stacked/docs/_date_stacked_default.jsx +1 -1
  21. data/app/pb_kits/playbook/pb_date_stacked/docs/_description.md +1 -1
  22. data/app/pb_kits/playbook/pb_date_stacked/docs/example.yml +2 -2
  23. data/app/pb_kits/playbook/pb_date_stacked/docs/index.js +1 -1
  24. data/app/pb_kits/playbook/pb_dropdown/index.js +1 -1
  25. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.tsx +31 -9
  26. data/app/pb_kits/playbook/pb_flex/_flex_item.tsx +12 -5
  27. data/app/pb_kits/playbook/pb_flex/docs/_flex_item_example.jsx +1 -0
  28. data/app/pb_kits/playbook/pb_nav/_item.tsx +18 -4
  29. data/app/pb_kits/playbook/pb_nav/_nav.scss +30 -5
  30. data/app/pb_kits/playbook/pb_nav/_nav_item.test.js +192 -0
  31. data/app/pb_kits/playbook/pb_nav/_vertical_nav.scss +1 -1
  32. data/app/pb_kits/playbook/pb_nav/docs/_horizontal_nav_disabled.html.erb +21 -0
  33. data/app/pb_kits/playbook/pb_nav/docs/_horizontal_nav_disabled.jsx +113 -0
  34. data/app/pb_kits/playbook/pb_nav/docs/_horizontal_nav_disabled.md +1 -0
  35. data/app/pb_kits/playbook/pb_nav/docs/_vertical_nav_disabled.html.erb +30 -0
  36. data/app/pb_kits/playbook/pb_nav/docs/_vertical_nav_disabled.jsx +117 -0
  37. data/app/pb_kits/playbook/pb_nav/docs/_vertical_nav_disabled.md +1 -0
  38. data/app/pb_kits/playbook/pb_nav/docs/example.yml +4 -0
  39. data/app/pb_kits/playbook/pb_nav/docs/index.js +3 -1
  40. data/app/pb_kits/playbook/pb_nav/item.html.erb +6 -4
  41. data/app/pb_kits/playbook/pb_nav/item.rb +11 -2
  42. data/app/pb_kits/playbook/pb_rich_text_editor/TipTap/Toolbar.tsx +1 -1
  43. data/app/pb_kits/playbook/pb_rich_text_editor/_rich_text_editor.tsx +61 -8
  44. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_default_rails.md +7 -0
  45. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_focus.html.erb +10 -2
  46. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_inline_rails.md +1 -0
  47. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_preview.html.erb +19 -11
  48. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_simple.html.erb +5 -1
  49. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_sticky.html.erb +1 -1
  50. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_sticky_rails.md +1 -0
  51. data/app/pb_kits/playbook/pb_rich_text_editor/docs/example.yml +2 -2
  52. data/app/pb_kits/playbook/pb_rich_text_editor/rich_text_editor.rb +16 -7
  53. data/dist/chunks/{_line_graph-r__oOO2H.js → _line_graph-eQNOB_GQ.js} +1 -1
  54. data/dist/chunks/_typeahead-vbfetkuE.js +24 -0
  55. data/dist/chunks/{_weekday_stacked-DgiIj2w3.js → _weekday_stacked-CvJHyUq6.js} +3 -3
  56. data/dist/chunks/{lib-CRUXizZe.js → lib-BCrK6CFU.js} +2 -2
  57. data/dist/chunks/{pb_form_validation-CywJN0ej.js → pb_form_validation-Cj4vdjWI.js} +1 -1
  58. data/dist/chunks/vendor.js +1 -1
  59. data/dist/playbook-doc.js +1 -19
  60. data/dist/playbook-rails-react-bindings.js +1 -1
  61. data/dist/playbook-rails.js +1 -1
  62. data/dist/playbook.css +1 -1
  63. data/lib/playbook/version.rb +2 -2
  64. metadata +22 -9
  65. data/app/pb_kits/playbook/pb_date_stacked/docs/_date_stacked_not_current_year.html.erb +0 -5
  66. data/dist/chunks/_typeahead-B7c52zVj.js +0 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f000abc583cece5823eebcb15113e1e1627c41bf69af15537d63502aa27dd812
4
- data.tar.gz: '059507ff8521a46d3ba78685e5ba1fd66e4ba68bd233783861a68056236ece53'
3
+ metadata.gz: 1908d580a733d2f740d4764449b6a29a4da28df8569d05c6986bde253714b026
4
+ data.tar.gz: aab898d2e6a575ed7cb75bb23596e0f6d10fdc41e1b1b849cf7fa18ba4fcc374
5
5
  SHA512:
6
- metadata.gz: fa5849767fc5e43a45c586ca19f3e3f6a1c18e70656ed02e66c2f70a66b100a59797ef11f466faa269cec041f1b76da04fe76987dd929b6d3b9d3dfc03b4dbe5
7
- data.tar.gz: 94b3d9ece5cd3a6f8244ea3379ad07addf95d2742adbd095c7a49055fb0be2bbaa77ffd7c4c3b741d13354cd033e4c341de2e2704f065d28a8e235f9d5a6875b
6
+ metadata.gz: 9fdcef54c8ee3e0c25c7b37ddbc3c36125a51ebdfd87e3bbe87e4390fb74faa5282775b823041d8583abe15e50bf77cd68cf6c80fa1258d53bdcad787ceb48d2
7
+ data.tar.gz: e8da8e5b2fb73da7e16056b90e752c522df3d5bd9afacf19a27fd41586c3620b0567be99214b0763a051d852a105a170277adf0a91b7c63f2b7dee4ac0aa2115
@@ -70,22 +70,36 @@
70
70
  <%= javascript_tag do %>
71
71
  (function() {
72
72
  const loadDatePicker = () => {
73
- datePickerHelper(<%= object.date_picker_config %>, "<%= object.scroll_container %>")
73
+ const input = document.getElementById("<%= object.picker_id %>");
74
+ if (input && !input._flatpickr) {
75
+ datePickerHelper(<%= object.date_picker_config %>, "<%= object.scroll_container %>")
74
76
 
75
- if (<%= object.selection_type == "quickpick" %>) {
76
- document.getElementById("<%= object.picker_id %>").addEventListener("change", ({ target }) => {
77
- const startDate = document.getElementById("<%= object.start_date_id %>")
78
- const endDate = document.getElementById("<%= object.end_date_id %>")
79
- const splittedValue = target.value.split(" to ")
80
- startDate.value = splittedValue[0]
81
- endDate.value = splittedValue[1] ? splittedValue[1] : splittedValue[0]
82
- })
77
+ if (<%= object.selection_type == "quickpick" %>) {
78
+ document.getElementById("<%= object.picker_id %>").addEventListener("change", ({ target }) => {
79
+ const startDate = document.getElementById("<%= object.start_date_id %>")
80
+ const endDate = document.getElementById("<%= object.end_date_id %>")
81
+ const splittedValue = target.value.split(" to ")
82
+ startDate.value = splittedValue[0]
83
+ endDate.value = splittedValue[1] ? splittedValue[1] : splittedValue[0]
84
+ })
85
+ }
83
86
  }
84
87
  }
85
88
 
86
- window.addEventListener("DOMContentLoaded", () => {
89
+ // Try to initialize immediately if DOM is ready
90
+ if (document.readyState === "loading") {
91
+ window.addEventListener("DOMContentLoaded", loadDatePicker)
92
+ } else {
87
93
  loadDatePicker()
88
- })
94
+ }
95
+
96
+ // For dynamically added content (modals, etc.), check again after a brief delay
97
+ setTimeout(() => {
98
+ const input = document.getElementById("<%= object.picker_id %>");
99
+ if (input && !input._flatpickr) {
100
+ loadDatePicker();
101
+ }
102
+ }, 100);
89
103
 
90
104
  if (<%= !object.custom_event_type.empty? %>) {
91
105
  window.addEventListener("<%= object.custom_event_type %>", () => {
@@ -19,6 +19,7 @@ type DateRangeInlineProps = {
19
19
  icon?: boolean;
20
20
  id?: string;
21
21
  size?: "sm" | "xs";
22
+ showCurrentYear?: boolean;
22
23
  startDate?: Date;
23
24
  };
24
25
 
@@ -45,6 +46,7 @@ const DateRangeInline = (props: DateRangeInlineProps): React.ReactElement => {
45
46
  icon = false,
46
47
  size = "sm",
47
48
  startDate,
49
+ showCurrentYear = false,
48
50
  } = props;
49
51
 
50
52
  const dateInCurrentYear = () => {
@@ -60,13 +62,10 @@ const DateRangeInline = (props: DateRangeInlineProps): React.ReactElement => {
60
62
  const htmlProps = buildHtmlProps(htmlOptions);
61
63
 
62
64
  const renderTime = (date: Date) => {
65
+ const includeYear = showCurrentYear || !dateInCurrentYear();
63
66
  return (
64
67
  <time dateTime={dateTimeIso(date)}>
65
- {dateInCurrentYear() ? (
66
- ` ${dateTimestamp(date, false)} `
67
- ) : (
68
- ` ${dateTimestamp(date, true)} `
69
- )}
68
+ {` ${dateTimestamp(date, includeYear)} `}
70
69
  </time>
71
70
  );
72
71
  };
@@ -83,7 +82,8 @@ const DateRangeInline = (props: DateRangeInlineProps): React.ReactElement => {
83
82
  {icon && (
84
83
  <Caption
85
84
  dark={dark}
86
- tag="span">
85
+ tag="span"
86
+ >
87
87
  <Icon
88
88
  className="pb_date_range_inline_icon"
89
89
  dark={dark}
@@ -96,12 +96,14 @@ const DateRangeInline = (props: DateRangeInlineProps): React.ReactElement => {
96
96
  )}
97
97
  <Caption
98
98
  dark={dark}
99
- tag="span">
99
+ tag="span"
100
+ >
100
101
  {renderTime(startDate)}
101
102
  </Caption>
102
103
  <Caption
103
104
  dark={dark}
104
- tag="span">
105
+ tag="span"
106
+ >
105
107
  <Icon
106
108
  className="pb_date_range_inline_arrow"
107
109
  dark={dark}
@@ -112,7 +114,8 @@ const DateRangeInline = (props: DateRangeInlineProps): React.ReactElement => {
112
114
  </Caption>
113
115
  <Caption
114
116
  dark={dark}
115
- tag="span">
117
+ tag="span"
118
+ >
116
119
  {renderTime(endDate)}
117
120
  </Caption>
118
121
  </>
@@ -124,7 +127,8 @@ const DateRangeInline = (props: DateRangeInlineProps): React.ReactElement => {
124
127
  <Body
125
128
  color={"light"}
126
129
  dark={dark}
127
- tag="span">
130
+ tag="span"
131
+ >
128
132
  <Icon
129
133
  className="pb_date_range_inline_icon"
130
134
  dark={dark}
@@ -137,13 +141,15 @@ const DateRangeInline = (props: DateRangeInlineProps): React.ReactElement => {
137
141
  )}
138
142
  <Body
139
143
  dark={dark}
140
- tag="span">
144
+ tag="span"
145
+ >
141
146
  {renderTime(startDate)}
142
147
  </Body>
143
148
  <Body
144
149
  color={"light"}
145
150
  dark={dark}
146
- tag="span">
151
+ tag="span"
152
+ >
147
153
  <Icon
148
154
  className="pb_date_range_inline_arrow"
149
155
  dark={dark}
@@ -154,7 +160,8 @@ const DateRangeInline = (props: DateRangeInlineProps): React.ReactElement => {
154
160
  </Body>
155
161
  <Body
156
162
  dark={dark}
157
- tag="span">
163
+ tag="span"
164
+ >
158
165
  {renderTime(endDate)}
159
166
  </Body>
160
167
  </>
@@ -14,7 +14,8 @@ module Playbook
14
14
  prop :align, type: Playbook::Props::Enum,
15
15
  values: %w[left center right],
16
16
  default: "left"
17
-
17
+ prop :show_current_year, type: Playbook::Props::Boolean,
18
+ default: false
18
19
  def classname
19
20
  generate_classname("pb_date_range_inline_kit", dark_class, align)
20
21
  end
@@ -38,11 +39,12 @@ module Playbook
38
39
  end
39
40
 
40
41
  def time_display(time)
42
+ include_year = show_current_year || !dates_in_current_year?
41
43
  content_tag(:time, datetime: time.to_iso) do
42
- if dates_in_current_year?
43
- "#{time.to_month_downcase} #{time.to_day}"
44
- else
44
+ if include_year
45
45
  "#{time.to_month_downcase} #{time.to_day}, #{time.to_year}"
46
+ else
47
+ "#{time.to_month_downcase} #{time.to_day}"
46
48
  end
47
49
  end
48
50
  end
@@ -111,6 +111,23 @@ describe("DateRangeInline Kit", () => {
111
111
  const text = kit.querySelector('.pb_caption_kit_md:first-child')
112
112
  expect(text.textContent).toEqual(" Jan 15 ")
113
113
  })
114
+
115
+ test("renders DateRangeInline with year when showCurrentYear is true", () => {
116
+ const currentYear = new Date().getFullYear()
117
+ render(
118
+ <DateRangeInline
119
+ data={{ testid: testId }}
120
+ endDate={new Date((`15 Aug ${currentYear}`))}
121
+ showCurrentYear
122
+ size="xs"
123
+ startDate={new Date(`15 Jan ${currentYear}`)}
124
+ />
125
+ )
126
+
127
+ const kit = screen.getByTestId(testId)
128
+ const text = kit.querySelector('.pb_caption_kit_md:first-child')
129
+ expect(text.textContent).toEqual(` Jan 15, ${currentYear} `)
130
+ })
114
131
 
115
132
 
116
133
  })
@@ -0,0 +1,4 @@
1
+ <%= pb_rails("date_range_inline", props: { start_date: Date.new(Date.current.year, 10, 31), end_date: Date.new(Date.current.year, 12, 7), size: "xs", show_current_year: true }) %>
2
+ <%= pb_rails("date_range_inline", props: { start_date: Date.new(Date.current.year, 10, 31), end_date: Date.new(Date.current.year, 12, 7), show_current_year: true }) %>
3
+ <%= pb_rails("date_range_inline", props: { start_date: Date.new(Date.current.year, 10, 31), end_date: Date.new(Date.current.year, 12, 7), align: "center", icon: true, size: "xs", show_current_year: true }) %>
4
+ <%= pb_rails("date_range_inline", props: { start_date: Date.new(Date.current.year, 10, 31), end_date: Date.new(Date.current.year, 12, 7), align: "center", icon: true, show_current_year: true }) %>
@@ -0,0 +1,43 @@
1
+ import React from 'react'
2
+ import DateRangeInline from '../_date_range_inline'
3
+
4
+ const DateRangeInlineShowCurrentYear = (props) => {
5
+ return (
6
+ <div>
7
+ <DateRangeInline
8
+ endDate={new Date(`7 Dec ${new Date().getFullYear()}`)}
9
+ showCurrentYear
10
+ size="xs"
11
+ startDate={new Date(`31 Oct ${new Date().getFullYear()}`)}
12
+ {...props}
13
+ />
14
+ <DateRangeInline
15
+ endDate={new Date(`7 Dec ${new Date().getFullYear()}`)}
16
+ showCurrentYear
17
+ size="sm"
18
+ startDate={new Date(`31 Oct ${new Date().getFullYear()}`)}
19
+ {...props}
20
+ />
21
+ <DateRangeInline
22
+ align="center"
23
+ endDate={new Date(`7 Dec ${new Date().getFullYear()}`)}
24
+ icon
25
+ showCurrentYear
26
+ size="xs"
27
+ startDate={new Date(`31 Oct ${new Date().getFullYear()}`)}
28
+ {...props}
29
+ />
30
+ <DateRangeInline
31
+ align="center"
32
+ endDate={new Date(`7 Dec ${new Date().getFullYear()}`)}
33
+ icon
34
+ showCurrentYear
35
+ size="sm"
36
+ startDate={new Date(`31 Oct ${new Date().getFullYear()}`)}
37
+ {...props}
38
+ />
39
+ </div>
40
+ )
41
+ }
42
+
43
+ export default DateRangeInlineShowCurrentYear
@@ -0,0 +1 @@
1
+ By default, the Date Range Inline 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 as shown here.
@@ -1 +1 @@
1
- Use to display a date range. Year will not show if it is the current year.
1
+ Use to display a date range.
@@ -2,11 +2,12 @@ examples:
2
2
 
3
3
  rails:
4
4
  - date_range_inline_default: Default
5
-
5
+ - date_range_inline_show_current_year: Show Current Year
6
6
 
7
7
  react:
8
8
  - date_range_inline_default: Default
9
-
9
+ - date_range_inline_show_current_year: Show Current Year
10
+
10
11
  swift:
11
12
  - date_range_inline_default_swift: Default
12
13
  - date_range_inline_props_swift: ""
@@ -1 +1,2 @@
1
1
  export { default as DateRangeInlineDefault } from './_date_range_inline_default.jsx'
2
+ export { default as DateRangeInlineShowCurrentYear } from './_date_range_inline_show_current_year.jsx'
@@ -19,6 +19,7 @@ type DateStackedProps = {
19
19
  size?: "sm" | "md";
20
20
  id?: string;
21
21
  reverse?: boolean;
22
+ showCurrentYear?: boolean;
22
23
  };
23
24
 
24
25
  const sizes: {sm: 4, md: 3} = {
@@ -37,6 +38,7 @@ const DateStacked = (props: DateStackedProps): React.ReactElement => {
37
38
  data={},
38
39
  htmlOptions={},
39
40
  size = "sm",
41
+ showCurrentYear = false,
40
42
  } = props;
41
43
  const classes = classnames(
42
44
  buildCss("pb_date_stacked_kit", align, size, {
@@ -55,7 +57,7 @@ const DateStacked = (props: DateStackedProps): React.ReactElement => {
55
57
  return (
56
58
  <>
57
59
  {bold == false ? (
58
- <div
60
+ <div
59
61
  {...dataProps}
60
62
  {...htmlProps}
61
63
  className={classes}
@@ -68,10 +70,10 @@ const DateStacked = (props: DateStackedProps): React.ReactElement => {
68
70
  text={DateTime.toDay(date).toString()}
69
71
  />
70
72
  </div>
71
- {currentYear != inputYear && <Caption size="xs">{inputYear}</Caption>}
73
+ {(currentYear != inputYear || showCurrentYear) && <Caption size="xs">{inputYear}</Caption>}
72
74
  </div>
73
75
  ) : (
74
- <div
76
+ <div
75
77
  {...dataProps}
76
78
  {...htmlProps}
77
79
  className={classes}
@@ -89,7 +91,7 @@ const DateStacked = (props: DateStackedProps): React.ReactElement => {
89
91
  size="4"
90
92
  text={DateTime.toDay(date).toString()}
91
93
  />
92
- {currentYear != inputYear && <Title size="4">{inputYear}</Title>}
94
+ {(currentYear != inputYear || showCurrentYear) && <Title size="4">{inputYear}</Title>}
93
95
  </div>
94
96
  </div>
95
97
  )}
@@ -4,16 +4,15 @@
4
4
 
5
5
  <div class="pb_date_stacked_day_month">
6
6
  <%= pb_rails("caption", props: { text: object.month }) %>
7
- <%= pb_rails("title", props: { text: object.day , size: object.title_size }) do %><% end %>
7
+ <%= pb_rails("title", props: { text: object.day , size: object.title_size }) %>
8
8
  <%= pb_rails("caption", props: { text: object.year, size:"xs" }) %>
9
9
  </div>
10
10
 
11
11
  <% else %>
12
12
  <div class="pb_date_stacked_day_month">
13
13
  <%= pb_rails("title", props: { text: object.month, size: 4 }) %>
14
- <%= pb_rails("title", props: { text: object.day, size: 4 }) do %><% end %>
14
+ <%= pb_rails("title", props: { text: object.day, size: 4 }) %>
15
15
  <%= pb_rails("title", props: { text: object.year, size:4 }) %>
16
-
17
16
  </div>
18
17
 
19
18
  <% end %>
@@ -16,6 +16,8 @@ module Playbook
16
16
  default: false
17
17
  prop :bold, type: Playbook::Props::Boolean,
18
18
  default: false
19
+ prop :show_current_year, type: Playbook::Props::Boolean,
20
+ default: false
19
21
 
20
22
  def classname
21
23
  generate_classname("pb_date_stacked_kit", align, size, reverse_class, dark_class)
@@ -37,11 +39,15 @@ module Playbook
37
39
  end
38
40
 
39
41
  def year
40
- current_year = DateTime.now.year.to_i
41
- year = Playbook::PbKit::PbDateTime.new(date).to_year.to_i
42
- if current_year != year
43
- content_tag(:time, datetime: year) do
44
- year.to_s
42
+ if show_current_year
43
+ Playbook::PbKit::PbDateTime.new(date).to_year.to_s
44
+ else
45
+ current_year = DateTime.now.year.to_i
46
+ year = Playbook::PbKit::PbDateTime.new(date).to_year.to_i
47
+ if current_year != year
48
+ content_tag(:time, datetime: year) do
49
+ year.to_s
50
+ end
45
51
  end
46
52
  end
47
53
  end
@@ -22,7 +22,7 @@ describe("DateStacked Kit", () => {
22
22
  align="left"
23
23
  data={{ testid: testId }}
24
24
  date={new Date()}
25
- size="sm"
25
+ size="sm"
26
26
  />
27
27
  )
28
28
 
@@ -36,7 +36,7 @@ describe("DateStacked Kit", () => {
36
36
  align="left"
37
37
  data={{ testid: testId }}
38
38
  date={new Date()}
39
- size="sm"
39
+ size="sm"
40
40
  />
41
41
  )
42
42
 
@@ -51,7 +51,7 @@ describe("DateStacked Kit", () => {
51
51
  align="left"
52
52
  data={{ testid: testId }}
53
53
  date={new Date()}
54
- size="sm"
54
+ size="sm"
55
55
  />
56
56
  )
57
57
 
@@ -66,7 +66,7 @@ describe("DateStacked Kit", () => {
66
66
  align="left"
67
67
  data={{ testid: testId }}
68
68
  date={new Date()}
69
- size="md"
69
+ size="md"
70
70
  />
71
71
  )
72
72
 
@@ -80,7 +80,7 @@ describe("DateStacked Kit", () => {
80
80
  align="left"
81
81
  data={{ testid: testId }}
82
82
  date={futureDate}
83
- size="sm"
83
+ size="sm"
84
84
  />
85
85
  )
86
86
 
@@ -89,6 +89,23 @@ describe("DateStacked Kit", () => {
89
89
  expect(text.textContent).toEqual("2016")
90
90
  })
91
91
 
92
+ test("renders current year when showCurrentYear is true", () => {
93
+ render(
94
+ <DateStacked
95
+ align="left"
96
+ data={{ testid: testId }}
97
+ date={new Date()}
98
+ showCurrentYear
99
+ size="sm"
100
+ />
101
+ )
102
+
103
+ const kit = screen.getByTestId(testId)
104
+ const text = kit.querySelector(".pb_caption_kit_xs")
105
+ const currentYear = new Date().getFullYear()
106
+ expect(text.textContent).toEqual(`${currentYear}`)
107
+ })
108
+
92
109
  test("renders correct className when order reversed", () => {
93
110
  render(
94
111
  <DateStacked
@@ -96,7 +113,7 @@ describe("DateStacked Kit", () => {
96
113
  data={{ testid: testId }}
97
114
  date={futureDate}
98
115
  reverse
99
- size="sm"
116
+ size="sm"
100
117
  />
101
118
  )
102
119
  const kit = screen.getByTestId(testId)
@@ -110,7 +127,7 @@ describe("DateStacked Kit", () => {
110
127
  bold
111
128
  data={{ testid: testId }}
112
129
  date={futureDate}
113
- size="md"
130
+ size="md"
114
131
  />
115
132
  )
116
133
 
@@ -125,7 +142,7 @@ describe("DateStacked Kit", () => {
125
142
  align="center"
126
143
  data={{ testid: testId }}
127
144
  date={futureDate}
128
- size="md"
145
+ size="md"
129
146
  />
130
147
  )
131
148
 
@@ -139,7 +156,7 @@ describe("DateStacked Kit", () => {
139
156
  align="right"
140
157
  data={{ testid: testId }}
141
158
  date={futureDate}
142
- size="md"
159
+ size="md"
143
160
  />
144
161
  )
145
162
 
@@ -0,0 +1,12 @@
1
+ <%= pb_rails("date_stacked", props: {
2
+ date: DateTime.now,
3
+ show_current_year: true
4
+ }) %>
5
+
6
+ <br>
7
+
8
+ <%= pb_rails("date_stacked", props: {
9
+ date: DateTime.now,
10
+ show_current_year: true,
11
+ size: "md"
12
+ }) %>
@@ -1,12 +1,13 @@
1
1
  import React from 'react'
2
2
  import DateStacked from '../_date_stacked'
3
3
 
4
- const DateStackedNotCurrentYear = (props) => {
4
+ const DateStackedCurrentYear = (props) => {
5
5
  return (
6
6
  <div>
7
7
 
8
8
  <DateStacked
9
- date={new Date('20 Mar 2018')}
9
+ date={new Date()}
10
+ showCurrentYear
10
11
  size="sm"
11
12
  {...props}
12
13
  />
@@ -14,13 +15,13 @@ const DateStackedNotCurrentYear = (props) => {
14
15
  <br />
15
16
 
16
17
  <DateStacked
17
- date={new Date('20 Mar 2018')}
18
+ date={new Date()}
19
+ showCurrentYear
18
20
  size="md"
19
21
  {...props}
20
22
  />
21
-
22
23
  </div>
23
24
  )
24
25
  }
25
26
 
26
- export default DateStackedNotCurrentYear
27
+ export default DateStackedCurrentYear
@@ -0,0 +1 @@
1
+ By default, the Date Stacked 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 as shown here.
@@ -2,4 +2,4 @@
2
2
 
3
3
  <br>
4
4
 
5
- <%= pb_rails("date_stacked", props: { date: DateTime.now, size: "md"}) %>
5
+ <%= pb_rails("date_stacked", props: { date: Date.new(2018, 03, 20), size: "md"}) %>
@@ -15,7 +15,7 @@ const DateStackedDefault = (props) => {
15
15
  <br />
16
16
 
17
17
  <DateStacked
18
- date={new Date()}
18
+ date={new Date('20 Mar 2018')}
19
19
  size="md"
20
20
  {...props}
21
21
  />
@@ -1 +1 @@
1
- Use to display the date, stacking month and day. Year will not show if it is the current year.
1
+ Use to display the date, stacking month and day.
@@ -2,7 +2,7 @@ examples:
2
2
 
3
3
  rails:
4
4
  - date_stacked_default: Default
5
- - date_stacked_not_current_year: Not Current Year
5
+ - date_stacked_current_year: Show Current Year
6
6
  - date_stacked_reverse: Day & Month Reverse
7
7
  - date_stacked_sizes: Sizes
8
8
  - date_stacked_align: Alignment
@@ -11,7 +11,7 @@ examples:
11
11
 
12
12
  react:
13
13
  - date_stacked_default: Default
14
- - date_stacked_not_current_year: Not Current Year
14
+ - date_stacked_current_year: Show Current Year
15
15
  - date_stacked_reverse: Day & Month Reverse
16
16
  - date_stacked_sizes: Sizes
17
17
  - date_stacked_bold: Bold
@@ -1,6 +1,6 @@
1
1
  export { default as DateStackedBold } from './_date_stacked_bold.jsx'
2
2
  export { default as DateStackedDefault } from './_date_stacked_default.jsx'
3
- export { default as DateStackedNotCurrentYear } from './_date_stacked_not_current_year.jsx'
3
+ export { default as DateStackedCurrentYear } from './_date_stacked_current_year.jsx'
4
4
  export { default as DateStackedReverse } from './_date_stacked_reverse.jsx'
5
5
  export { default as DateStackedSizes } from './_date_stacked_sizes.jsx'
6
6
  export { default as DateStackedAlign } from './_date_stacked_align.jsx'
@@ -126,7 +126,7 @@ export default class PbDropdown extends PbEnhancedElement {
126
126
  .label.toString()
127
127
  .toLowerCase();
128
128
 
129
- // hide or show option
129
+ // hide or show option
130
130
  const match = label.includes(lcTerm);
131
131
  opt.style.display = match ? "" : "none";
132
132
  if (match) hasMatch = true