playbook_ui 14.1.0.pre.alpha.PA1477timestampkit3536 → 14.1.0.pre.alpha.PBNTR462starratingdefaultvalue3579

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/_playbook.scss +2 -0
  3. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +3 -3
  4. data/app/pb_kits/playbook/pb_advanced_table/advanced_table.html.erb +1 -1
  5. data/app/pb_kits/playbook/pb_badge/_badge.scss +9 -0
  6. data/app/pb_kits/playbook/pb_badge/_badge.tsx +8 -3
  7. data/app/pb_kits/playbook/pb_badge/badge.rb +1 -1
  8. data/app/pb_kits/playbook/pb_badge/badge.test.js +17 -11
  9. data/app/pb_kits/playbook/pb_badge/docs/_badge_notification.html.erb +13 -0
  10. data/app/pb_kits/playbook/pb_badge/docs/_badge_notification.jsx +31 -12
  11. data/app/pb_kits/playbook/pb_button/_button.tsx +4 -1
  12. data/app/pb_kits/playbook/pb_button/button.html.erb +1 -1
  13. data/app/pb_kits/playbook/pb_button/button.rb +4 -0
  14. data/app/pb_kits/playbook/pb_date_time/dateTime.test.js +2 -2
  15. data/app/pb_kits/playbook/pb_dialog/_close_icon.tsx +5 -1
  16. data/app/pb_kits/playbook/pb_dialog/_dialog.tsx +3 -1
  17. data/app/pb_kits/playbook/pb_dialog/dialog.html.erb +4 -1
  18. data/app/pb_kits/playbook/pb_dialog/dialog.rb +3 -0
  19. data/app/pb_kits/playbook/pb_dialog/dialog.test.jsx +20 -1
  20. data/app/pb_kits/playbook/pb_dialog/dialogHelper.js +21 -0
  21. data/app/pb_kits/playbook/pb_dialog/dialog_footer.html.erb +4 -2
  22. data/app/pb_kits/playbook/pb_dialog/dialog_footer.rb +10 -1
  23. data/app/pb_kits/playbook/pb_dialog/dialog_header.html.erb +1 -1
  24. data/app/pb_kits/playbook/pb_dialog/dialog_header.rb +4 -0
  25. data/app/pb_kits/playbook/pb_dialog/docs/_dialog_default.jsx +1 -5
  26. data/app/pb_kits/playbook/pb_dialog/docs/_dialog_loading.html.erb +13 -0
  27. data/app/pb_kits/playbook/pb_dialog/docs/_dialog_loading.jsx +46 -0
  28. data/app/pb_kits/playbook/pb_dialog/docs/_dialog_loading.md +3 -0
  29. data/app/pb_kits/playbook/pb_dialog/docs/example.yml +2 -1
  30. data/app/pb_kits/playbook/pb_dialog/docs/index.js +1 -0
  31. data/app/pb_kits/playbook/pb_filter/filter.rb +1 -1
  32. data/app/pb_kits/playbook/pb_form/docs/_form_form_with_validate.html.erb +1 -0
  33. data/app/pb_kits/playbook/pb_form_pill/_form_pill.scss +43 -25
  34. data/app/pb_kits/playbook/pb_form_pill/_form_pill.tsx +6 -2
  35. data/app/pb_kits/playbook/pb_form_pill/docs/example.yml +2 -2
  36. data/app/pb_kits/playbook/pb_form_pill/form_pill.html.erb +4 -4
  37. data/app/pb_kits/playbook/pb_form_pill/form_pill.rb +4 -0
  38. data/app/pb_kits/playbook/pb_gantt_chart/_gantt_chart.scss +3 -0
  39. data/app/pb_kits/playbook/pb_gantt_chart/_gantt_chart.tsx +72 -0
  40. data/app/pb_kits/playbook/pb_gantt_chart/docs/_gantt_chart_default.jsx +53 -0
  41. data/app/pb_kits/playbook/pb_gantt_chart/docs/example.yml +7 -0
  42. data/app/pb_kits/playbook/pb_gantt_chart/docs/index.js +1 -0
  43. data/app/pb_kits/playbook/pb_gantt_chart/gantt_chart.test.jsx +19 -0
  44. data/app/pb_kits/playbook/pb_icon/_icon.tsx +1 -1
  45. data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.tsx +0 -2
  46. data/app/pb_kits/playbook/pb_pagination/_pagination.scss +49 -13
  47. data/app/pb_kits/playbook/pb_pagination/_pagination.tsx +164 -0
  48. data/app/pb_kits/playbook/pb_pagination/docs/_pagination_default.jsx +19 -0
  49. data/app/pb_kits/playbook/pb_pagination/docs/_pagination_default_react.md +1 -0
  50. data/app/pb_kits/playbook/pb_pagination/docs/_pagination_page_change.jsx +62 -0
  51. data/app/pb_kits/playbook/pb_pagination/docs/_pagination_page_change_react.md +1 -0
  52. data/app/pb_kits/playbook/pb_pagination/docs/data.js +23 -0
  53. data/app/pb_kits/playbook/pb_pagination/docs/example.yml +3 -1
  54. data/app/pb_kits/playbook/pb_pagination/docs/index.js +2 -0
  55. data/app/pb_kits/playbook/pb_phone_number_input/_phone_number_input.scss +0 -7
  56. data/app/pb_kits/playbook/pb_popover/_popover.tsx +10 -5
  57. data/app/pb_kits/playbook/pb_rich_text_editor/_previewer_mixin.scss +132 -0
  58. data/app/pb_kits/playbook/pb_rich_text_editor/_tiptap_styles.scss +50 -76
  59. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_preview.jsx +73 -0
  60. data/app/pb_kits/playbook/pb_rich_text_editor/docs/example.yml +1 -0
  61. data/app/pb_kits/playbook/pb_rich_text_editor/docs/index.js +2 -1
  62. data/app/pb_kits/playbook/pb_star_rating/index.js +88 -41
  63. data/app/pb_kits/playbook/pb_star_rating/star_rating.html.erb +4 -2
  64. data/app/pb_kits/playbook/pb_star_rating/star_rating.rb +19 -0
  65. data/app/pb_kits/playbook/pb_star_rating/subcomponents/_star_rating_display.tsx +0 -2
  66. data/app/pb_kits/playbook/pb_star_rating/subcomponents/_star_rating_interactive.tsx +0 -1
  67. data/app/pb_kits/playbook/pb_time/_time.tsx +12 -8
  68. data/app/pb_kits/playbook/pb_time/time.html.erb +3 -3
  69. data/app/pb_kits/playbook/pb_time/time.rb +4 -0
  70. data/app/pb_kits/playbook/pb_timestamp/timestamp.rb +2 -37
  71. data/app/pb_kits/playbook/tokens/_container.scss +21 -0
  72. data/app/pb_kits/playbook/utilities/_min_width.scss +45 -0
  73. data/app/pb_kits/playbook/utilities/globalPropNames.mjs +1 -0
  74. data/app/pb_kits/playbook/utilities/globalProps.ts +20 -3
  75. data/app/pb_kits/playbook/utilities/icons/allicons.tsx +59 -0
  76. data/app/pb_kits/playbook/utilities/icons/clock.svg +9 -0
  77. data/app/pb_kits/playbook/utilities/icons/spinner.svg +3 -0
  78. data/app/pb_kits/playbook/utilities/icons/times.svg +3 -0
  79. data/dist/chunks/_typeahead-nSyn1ajB.js +22 -0
  80. data/dist/chunks/_weekday_stacked-iq_X37be.js +45 -0
  81. data/dist/chunks/lazysizes-B7xYodB-.js +1 -0
  82. data/dist/chunks/{lib-BE0Z3F7x.js → lib-D9uVVKnh.js} +2 -2
  83. data/dist/chunks/{pb_form_validation-TzZQ0Flx.js → pb_form_validation-u2wnZ3oe.js} +1 -1
  84. data/dist/chunks/vendor.js +1 -1
  85. data/dist/menu.yml +4 -0
  86. data/dist/playbook-doc.js +1 -1
  87. data/dist/playbook-rails-react-bindings.js +1 -1
  88. data/dist/playbook-rails.js +1 -1
  89. data/dist/playbook.css +1 -1
  90. data/lib/playbook/classnames.rb +1 -0
  91. data/lib/playbook/spacing.rb +31 -2
  92. data/lib/playbook/version.rb +1 -1
  93. metadata +34 -10
  94. data/dist/chunks/_typeahead-D-4y9pbv.js +0 -22
  95. data/dist/chunks/_weekday_stacked-Cax4nrUa.js +0 -45
  96. data/dist/chunks/lazysizes-DHz07jlL.js +0 -1
  97. /data/app/pb_kits/playbook/pb_pagination/docs/{_pagination_default.md → _pagination_default_rails.md} +0 -0
@@ -0,0 +1,73 @@
1
+ import React, { useState } from 'react'
2
+ import { Button, Card, RichTextEditor } from 'playbook-ui'
3
+ import { useEditor, EditorContent } from "@tiptap/react"
4
+ import StarterKit from "@tiptap/starter-kit"
5
+ import Link from '@tiptap/extension-link'
6
+
7
+
8
+ const RichTextEditorAdvancedPreview = (props) => {
9
+
10
+ const editor = useEditor({
11
+ extensions: [
12
+ StarterKit,
13
+ Link
14
+ ],
15
+ content: "Add text here, format it, and press \"Preview Output\" to see what your stylized output will look like on the page."
16
+ })
17
+
18
+ const [showPreview, setShowPreview] = useState(false)
19
+ const [previewText, setPreviewText] = useState(<div />)
20
+
21
+ const handleChange = () => {
22
+ if (editor) {
23
+ setPreviewText(editor.getHTML())
24
+ }
25
+ }
26
+
27
+ const handleClick = () => {
28
+ handleChange()
29
+ setShowPreview(true)
30
+ }
31
+ if (!editor) {
32
+ return null
33
+ }
34
+
35
+
36
+ return (
37
+ <div>
38
+ <RichTextEditor
39
+ advancedEditor={editor}
40
+ id="content-advanced-preview-editor"
41
+ onChange={handleChange}
42
+ {...props}
43
+ >
44
+ <EditorContent editor={editor}/>
45
+ </RichTextEditor>
46
+ {showPreview && (
47
+ <Card
48
+ marginTop="md"
49
+ maxWidth="md"
50
+ >
51
+ <div
52
+ className="tiptap-content"
53
+ // eslint-disable-next-line react/no-danger
54
+ dangerouslySetInnerHTML={{ __html: previewText }}
55
+ id="advanced-preview-content"
56
+ />
57
+ </Card>
58
+ )}
59
+ {!showPreview && (
60
+ <div />
61
+ )}
62
+ <Button
63
+ id="preview-button"
64
+ marginTop="md"
65
+ onClick={handleClick}
66
+ text="Preview Output"
67
+ variant="secondary"
68
+ />
69
+ </div>
70
+ )
71
+ }
72
+
73
+ export default RichTextEditorAdvancedPreview
@@ -24,3 +24,4 @@ examples:
24
24
  - rich_text_editor_toolbar_bottom: Toolbar Bottom
25
25
  - rich_text_editor_inline: Inline
26
26
  - rich_text_editor_preview: Preview
27
+ - rich_text_editor_advanced_preview: Advanced Preview
@@ -9,4 +9,5 @@ export { default as RichTextEditorInline } from './_rich_text_editor_inline.jsx'
9
9
  export { default as RichTextEditorPreview } from './_rich_text_editor_preview.jsx'
10
10
  export { default as RichTextEditorAdvancedDefault } from './_rich_text_editor_advanced_default.jsx'
11
11
  export { default as RichTextEditorMoreExtensions } from './_rich_text_editor_more_extensions.jsx'
12
- export { default as RichTextEditorToolbarDisabled } from './_rich_text_editor_toolbar_disabled.jsx'
12
+ export { default as RichTextEditorToolbarDisabled } from './_rich_text_editor_toolbar_disabled.jsx'
13
+ export { default as RichTextEditorAdvancedPreview } from './_rich_text_editor_advanced_preview.jsx'
@@ -1,119 +1,166 @@
1
- import PbEnhancedElement from "../pb_enhanced_element";
1
+ import PbEnhancedElement from "../pb_enhanced_element"
2
2
 
3
- const STAR_RATING_SELECTOR = "[data-pb-star-rating]";
4
- const STAR_RATING_INPUT_ID = "star-rating-input";
3
+ const STAR_RATING_WRAPPER_SELECTOR = "[data-pb-star-rating-wrapper]"
4
+ const STAR_RATING_SELECTOR = "[data-pb-star-rating]"
5
+ const STAR_RATING_INPUT_DATA_SELECTOR = "[data-pb-star-rating-input]"
5
6
 
6
7
  export default class PbStarRating extends PbEnhancedElement {
7
8
  static get selector() {
8
- return STAR_RATING_SELECTOR;
9
+ return STAR_RATING_WRAPPER_SELECTOR
9
10
  }
10
11
 
11
12
  connect() {
12
- this.element.addEventListener("click", (event) => {
13
- const clickedStarId = event.currentTarget.id;
14
- this.updateStarColors(clickedStarId);
15
- this.updateHiddenInputValue(clickedStarId);
16
- });
13
+ this.addEventListeners()
14
+ this.handleFormReset()
15
+ this.setDefaultValue()
16
+ }
17
+
18
+ addEventListeners() {
19
+ this.element.querySelectorAll(STAR_RATING_SELECTOR).forEach(star => {
20
+ star.addEventListener("click", (event) => {
21
+ const clickedStarId = event.currentTarget.id
22
+ this.updateStarColors(clickedStarId)
23
+ this.updateHiddenInputValue(clickedStarId)
24
+ this.clearFormValidation()
25
+ })
17
26
 
18
- document.querySelectorAll(STAR_RATING_SELECTOR).forEach(star => {
19
27
  star.addEventListener("mouseenter", (event) => {
20
28
  const hoveredStarId = event.currentTarget.id
21
- this.updateStarHoverColors(hoveredStarId);
29
+ this.updateStarHoverColors(hoveredStarId)
22
30
  })
23
31
 
24
32
  star.addEventListener("mouseleave", () => {
25
- this.removeStarHoverColors();
33
+ this.removeStarHoverColors()
26
34
  })
27
35
 
28
36
  star.addEventListener("keydown", (event) => {
29
37
  if (event.key === 'Enter' || event.key === ' ') {
30
- event.preventDefault();
31
- this.handleStarClick(star.id);
38
+ event.preventDefault()
39
+ this.handleStarClick(star.id)
32
40
  }
33
41
  })
34
42
  })
35
43
  }
36
44
 
37
45
  handleStarClick(starId) {
38
- this.updateStarColors(starId);
39
- this.updateHiddenInputValue(starId);
46
+ this.updateStarColors(starId)
47
+ this.updateHiddenInputValue(starId)
40
48
  }
41
49
 
42
50
  updateStarColors(clickedStarId) {
43
- const allStars = document.querySelectorAll(STAR_RATING_SELECTOR);
51
+ const allStars = this.element.querySelectorAll(STAR_RATING_SELECTOR)
44
52
 
45
53
  allStars.forEach(star => {
46
- const starId = star.id;
47
- const icon = star.querySelector(".interactive-star-icon");
54
+ const starId = star.id
55
+ const icon = star.querySelector(".interactive-star-icon")
48
56
 
49
57
  if (icon) {
50
58
  if (starId <= clickedStarId) {
51
59
  if (star.classList.contains("yellow_star")) {
52
- icon.classList.add("yellow-star-selected");
60
+ icon.classList.add("yellow-star-selected")
53
61
  } else if (star.classList.contains("primary_star_light")) {
54
- icon.classList.add("primary-star-selected");
62
+ icon.classList.add("primary-star-selected")
55
63
  } else if (star.classList.contains("primary_star_dark")) {
56
- icon.classList.add("primary-star-selected");
64
+ icon.classList.add("primary-star-selected")
57
65
  } else if (star.classList.contains("subtle_star_light")) {
58
- icon.classList.add("subtle-star-selected");
66
+ icon.classList.add("subtle-star-selected")
59
67
  } else if (star.classList.contains("subtle_star_dark")) {
60
- icon.classList.add("subtle-star-selected");
68
+ icon.classList.add("subtle-star-selected")
61
69
  } else {
62
- icon.classList.add("yellow-star-selected");
70
+ icon.classList.add("yellow-star-selected")
63
71
  }
64
72
  } else {
65
- icon.classList.remove("yellow-star-selected", "primary-star-selected", "subtle-star-selected");
73
+ icon.classList.remove("yellow-star-selected", "primary-star-selected", "subtle-star-selected")
66
74
  }
67
- icon.classList.remove("star-hovered");
75
+ icon.classList.remove("star-hovered")
68
76
  }
69
- });
77
+ })
70
78
  }
71
79
 
72
80
  updateHiddenInputValue(value) {
73
- const hiddenInput = document.getElementById(STAR_RATING_INPUT_ID);
81
+ const hiddenInput = this.element.querySelector(STAR_RATING_INPUT_DATA_SELECTOR)
74
82
  if (hiddenInput) {
75
- hiddenInput.value = value;
83
+ hiddenInput.value = value
76
84
  }
77
85
  }
78
86
 
79
87
  updateStarHoverColors(hoveredStarId) {
80
- const allStars = document.querySelectorAll(STAR_RATING_SELECTOR);
88
+ const allStars = this.element.querySelectorAll(STAR_RATING_SELECTOR)
81
89
 
82
90
  allStars.forEach(star => {
83
- const starId = star.id;
84
- const icon = star.querySelector(".interactive-star-icon");
91
+ const starId = star.id
92
+ const icon = star.querySelector(".interactive-star-icon")
85
93
 
86
94
  if (icon) {
87
95
  if (starId <= hoveredStarId) {
88
96
  if (!icon.classList.contains("yellow-star-selected") &&
89
97
  !icon.classList.contains("primary-star-selected") &&
90
98
  !icon.classList.contains("subtle-star-selected")) {
91
- icon.classList.add("star-hovered");
99
+ icon.classList.add("star-hovered")
92
100
  }
93
101
  } else {
94
- icon.classList.remove("star-hovered");
102
+ icon.classList.remove("star-hovered")
95
103
  }
96
104
  }
97
- });
105
+ })
98
106
  }
99
107
 
100
108
 
101
109
  removeStarHoverColors() {
102
- const allStars = document.querySelectorAll(STAR_RATING_SELECTOR);
110
+ const allStars = this.element.querySelectorAll(STAR_RATING_SELECTOR)
103
111
 
104
112
  allStars.forEach(star => {
105
- const icon = star.querySelector(".interactive-star-icon");
113
+ const icon = star.querySelector(".interactive-star-icon")
106
114
  if (icon) {
107
115
  if (!icon.classList.contains("yellow-star-selected") &&
108
116
  !icon.classList.contains("primary-star-selected") &&
109
117
  !icon.classList.contains("subtle-star-selected")) {
110
- icon.classList.remove("star-hovered");
118
+ icon.classList.remove("star-hovered")
111
119
  }
112
120
  }
113
- });
121
+ })
114
122
  }
115
123
 
116
124
  isStarSelected() {
117
- return document.querySelectorAll(".yellow-star-selected, .primary-star-selected, .subtle-star-selected").length > 0;
125
+ return this.element.querySelectorAll(".yellow-star-selected, .primary-star-selected, .subtle-star-selected").length > 0
126
+ }
127
+
128
+ handleFormReset() {
129
+ const form = this.element.closest("form")
130
+ if (form) {
131
+ form.addEventListener("reset", () => {
132
+ this.updateHiddenInputValue("")
133
+ this.resetStarRatingValues()
134
+ })
135
+ }
136
+ }
137
+
138
+ resetStarRatingValues() {
139
+ const allStars = this.element.querySelectorAll(STAR_RATING_SELECTOR)
140
+ allStars.forEach(star => {
141
+ const icon = star.querySelector(".interactive-star-icon")
142
+ if (icon) {
143
+ icon.classList.remove("yellow-star-selected", "primary-star-selected", "subtle-star-selected")
144
+ }
145
+ })
146
+ }
147
+
148
+ clearFormValidation() {
149
+ const hiddenInput = this.element.querySelector(STAR_RATING_INPUT_DATA_SELECTOR)
150
+ if (hiddenInput.checkValidity()) {
151
+ const errorLabelElement = this.element.querySelector(".pb_body_kit_negative")
152
+ if (errorLabelElement) {
153
+ errorLabelElement.remove()
154
+ }
155
+ }
156
+ }
157
+
158
+ setDefaultValue() {
159
+ const hiddenInput = this.element.querySelector(STAR_RATING_INPUT_DATA_SELECTOR)
160
+ const defaultValue = hiddenInput.value
161
+
162
+ if (defaultValue) {
163
+ this.updateStarColors(defaultValue)
164
+ }
118
165
  }
119
166
  }
@@ -39,11 +39,13 @@
39
39
  <% end %>
40
40
 
41
41
  <% else %>
42
- <%= pb_rails("flex", props: { orientation: "column" }) do %>
42
+ <%= pb_rails("flex", props: { data: {"pb-star-rating-wrapper": "true" }, orientation: "column" }) do %>
43
43
  <% if object.label.present? %>
44
44
  <%= pb_rails("caption", props: {text: object.label, margin_bottom:"xs"}) %>
45
45
  <% end %>
46
- <input type="hidden" id="star-rating-input" value="" name="<%= object.name %>"/>
46
+
47
+ <%= hidden_input_tag %>
48
+
47
49
  <%= pb_rails("flex", props: { orientation: "row" }) do %>
48
50
  <% object.denominator.times do |index| %>
49
51
  <div data-pb-star-rating id="<%= index + 1 %>" class="<%= star_color %>">
@@ -30,6 +30,11 @@ module Playbook
30
30
  default: "display"
31
31
  prop :label, type: Playbook::Props::String
32
32
  prop :name, type: Playbook::Props::String
33
+ prop :required, type: Playbook::Props::Boolean,
34
+ default: false
35
+ prop :input_options, type: Playbook::Props::HashProp,
36
+ default: {}
37
+ prop :default_value
33
38
 
34
39
  def one_decimal_rating
35
40
  rating.to_f.round(1)
@@ -106,6 +111,20 @@ module Playbook
106
111
  def classname
107
112
  generate_classname("pb_star_rating_kit")
108
113
  end
114
+
115
+ def hidden_input_tag
116
+ tag(:input, all_input_options)
117
+ end
118
+
119
+ def all_input_options
120
+ input_options.merge(
121
+ data: { "pb-star-rating-input": true },
122
+ name: name,
123
+ required: required,
124
+ style: "display: none",
125
+ value: default_value || ""
126
+ )
127
+ end
109
128
  end
110
129
  end
111
130
  end
@@ -36,7 +36,6 @@ const StarRatingDisplay = (props: StarRatingDisplayProps) => {
36
36
  <Icon
37
37
  className={starIcon[colorOption].className}
38
38
  customIcon={starIcon[colorOption].icon as unknown as { [key: string]: SVGElement }}
39
- icon=""
40
39
  />
41
40
  </React.Fragment>
42
41
  ))}
@@ -45,7 +44,6 @@ const StarRatingDisplay = (props: StarRatingDisplayProps) => {
45
44
  <Icon
46
45
  className={starIcon[backgroundType].className}
47
46
  customIcon={starIcon[backgroundType].icon as unknown as { [key: string]: SVGElement }}
48
- icon=""
49
47
  />
50
48
  </React.Fragment>
51
49
  ))}
@@ -80,7 +80,6 @@ const StarRatingInteractive = (props: StarRatingInteractiveProps) => {
80
80
  onMouseEnter: () => handleMouseEnter(starIndex),
81
81
  onMouseLeave: () => handleMouseLeave(),
82
82
  }}
83
- icon=""
84
83
  tabIndex={0}
85
84
  />
86
85
  </div>
@@ -1,6 +1,7 @@
1
1
  import React from "react";
2
2
  import classnames from "classnames";
3
3
 
4
+ import { getAllIcons } from "../utilities/icons/allicons"
4
5
  import { buildCss, buildHtmlProps } from "../utilities/props";
5
6
  import { globalProps, GlobalProps } from "../utilities/globalProps";
6
7
  import DateTime from '../pb_kit/dateTime';
@@ -42,7 +43,7 @@ const Time = (props: TimeProps): React.ReactElement => {
42
43
  globalProps(props),
43
44
  className
44
45
  );
45
-
46
+ const clockIcon = getAllIcons()["clock"]
46
47
  const htmlProps = buildHtmlProps(htmlOptions);
47
48
 
48
49
  return (
@@ -54,9 +55,10 @@ const Time = (props: TimeProps): React.ReactElement => {
54
55
  unstyled
55
56
  ? (
56
57
  <span>
57
- <Icon fixedWidth
58
- icon="clock"
59
- />
58
+ <Icon
59
+ className="svg-inline--fa clock"
60
+ customIcon={clockIcon.icon as unknown as { [key: string]: SVGElement }}
61
+ />
60
62
  {" "}
61
63
  </span>
62
64
  )
@@ -65,10 +67,12 @@ const Time = (props: TimeProps): React.ReactElement => {
65
67
  <Body color="light"
66
68
  tag="span"
67
69
  >
68
- <Icon fixedWidth
69
- icon="clock"
70
- size={size === "md" ? "" : "sm"}
71
- />
70
+ <Icon
71
+ className="svg-inline--fa clock"
72
+ customIcon={clockIcon.icon as unknown as { [key: string]: SVGElement }}
73
+ fixedWidth
74
+ size={size === "md" ? "" : "sm"}
75
+ />
72
76
  {" "}
73
77
  </Body>
74
78
  </>
@@ -13,7 +13,7 @@
13
13
  <% if object.unstyled %>
14
14
  <% if object.show_icon %>
15
15
  <span>
16
- <%= pb_rails("icon", props: { icon: "clock", fixed_width: true }) %>
16
+ <%= pb_rails("icon", props: { custom_icon: Playbook::Engine.root.join(clock_icon), fixed_width: true }) %>
17
17
  </span>
18
18
  <% end %>
19
19
 
@@ -27,7 +27,7 @@
27
27
  <% elsif size == "md" %>
28
28
  <% if object.show_icon %>
29
29
  <%= pb_rails("body", props: { color: "light", tag: "span"}) do %>
30
- <%= pb_rails("icon", props: { icon: "clock", fixed_width: true }) %>
30
+ <%= pb_rails("icon", props: { custom_icon: Playbook::Engine.root.join(clock_icon), fixed_width: true }) %>
31
31
  <% end %>
32
32
  <% end %>
33
33
 
@@ -41,7 +41,7 @@
41
41
  <% else %>
42
42
  <% if object.show_icon %>
43
43
  <%= pb_rails("body", props: { color: "light", tag: "span"}) do %>
44
- <%= pb_rails("icon", props: { icon: "clock", fixed_width: true, size: "sm" }) %>
44
+ <%= pb_rails("icon", props: { custom_icon: Playbook::Engine.root.join(clock_icon), fixed_width: true, size: "sm" }) %>
45
45
  <% end %>
46
46
  <% end %>
47
47
 
@@ -38,6 +38,10 @@ module Playbook
38
38
  def pb_date_time
39
39
  Playbook::PbKit::PbDateTime.new(time, timezone)
40
40
  end
41
+
42
+ def clock_icon
43
+ "app/pb_kits/playbook/utilities/icons/clock.svg"
44
+ end
41
45
  end
42
46
  end
43
47
  end
@@ -27,15 +27,6 @@ module Playbook
27
27
  values: %w[default elapsed updated],
28
28
  default: "default"
29
29
 
30
- # Variables to use with pb_time_ago method
31
- SECS_PER_MIN = 60
32
- SECS_PER_HOUR = 60 * SECS_PER_MIN
33
- SECS_PER_DAY = 24 * SECS_PER_HOUR
34
- SECS_PER_WEEK = 7 * SECS_PER_DAY
35
- SECS_PER_MONTH = 4 * SECS_PER_WEEK
36
- SECS_PER_YEAR = 12 * SECS_PER_MONTH
37
- SECS_PER_CENT = 100 * SECS_PER_YEAR
38
-
39
30
  def classname
40
31
  generate_classname("pb_timestamp_kit", variant_class, align)
41
32
  end
@@ -82,36 +73,10 @@ module Playbook
82
73
 
83
74
  def format_elapsed_string
84
75
  user_string = show_user ? " by #{text}" : ""
85
- datetime_string = " #{pb_time_ago(pb_date_time.convert_to_timestamp)} ago"
86
- datetime_string[1] = hide_updated ? datetime_string[1].upcase : datetime_string[1]
76
+ datetime_string = " #{time_ago_in_words(pb_date_time.convert_to_timestamp)} ago"
87
77
  updated_string = hide_updated ? "" : "Last updated"
88
- "#{updated_string}#{user_string}#{datetime_string}"
89
- end
90
78
 
91
- def pb_time_ago(value)
92
- time_ago = DateTime.now.to_i - value.to_i
93
- case time_ago
94
- when (0...SECS_PER_MIN)
95
- "a few seconds"
96
- when (SECS_PER_MIN...SECS_PER_HOUR)
97
- time = time_ago / SECS_PER_MIN
98
- time == 1 ? "a minute" : "#{time_ago / SECS_PER_MIN} minutes"
99
- when (SECS_PER_HOUR...SECS_PER_DAY)
100
- time = time_ago / SECS_PER_HOUR
101
- time == 1 ? "an hour" : "#{time_ago / SECS_PER_HOUR} hours"
102
- when (SECS_PER_DAY...SECS_PER_WEEK)
103
- time = time_ago / SECS_PER_DAY
104
- time == 1 ? "a day" : "#{time_ago / SECS_PER_DAY} days"
105
- when (SECS_PER_WEEK...SECS_PER_MONTH)
106
- time = time_ago / SECS_PER_WEEK
107
- time == 1 ? "a week" : "#{time_ago / SECS_PER_WEEK} weeks"
108
- when (SECS_PER_MONTH...SECS_PER_YEAR)
109
- time = time_ago / SECS_PER_MONTH
110
- time == 1 ? "a month" : "#{time_ago / SECS_PER_MONTH} months"
111
- when (SECS_PER_YEAR...SECS_PER_CENT)
112
- time = time_ago / SECS_PER_YEAR
113
- time == 1 ? "a year" : "#{time_ago / SECS_PER_YEAR} years"
114
- end
79
+ "#{updated_string}#{user_string}#{datetime_string}"
115
80
  end
116
81
 
117
82
  def datetime_or_text
@@ -0,0 +1,21 @@
1
+ $container_0: 0% !default;
2
+ $container_xxs: 320px !default;
3
+ $container_xs: 360px !default;
4
+ $container_sm: 540px !default;
5
+ $container_md: 720px !default;
6
+ $container_lg: 960px !default;
7
+ $container_xl: 1140px !default;
8
+ $container_xxl: 1320px !default;
9
+ $container_100: 100% !default;
10
+ $containers: (
11
+ container_0: $container_0,
12
+ container_xxs: $container_xxs,
13
+ container_xs: $container_xs,
14
+ container_sm: $container_sm,
15
+ container_md: $container_md,
16
+ container_lg: $container_lg,
17
+ container_xl: $container_xl,
18
+ container_xxl: $container_xxl,
19
+ container_100: $container_100,
20
+ none: 0,
21
+ );
@@ -0,0 +1,45 @@
1
+ @import "../tokens/container";
2
+
3
+ .min_width_0 {
4
+ min-width: map-get($containers, 'none');
5
+ }
6
+
7
+ .min_with_0_percent {
8
+ min-width: $container_0;
9
+ }
10
+
11
+ .min_width_xxs {
12
+ min-width: $container_xxs;
13
+ }
14
+
15
+ .min_width_xs {
16
+ min-width: $container_xs;
17
+ }
18
+
19
+ .min_width_sm {
20
+ min-width: $container_sm;
21
+ }
22
+
23
+ .min_width_md {
24
+ min-width: $container_md;
25
+ }
26
+
27
+ .min_width_lg {
28
+ min-width: $container_lg;
29
+ }
30
+
31
+ .min_width_xl {
32
+ min-width: $container_xl;
33
+ }
34
+
35
+ .min_width_xxl {
36
+ min-width: $container_xxl;
37
+ }
38
+
39
+ .min_width_100_percent {
40
+ min-width: $container_100;
41
+ }
42
+
43
+ .minwidth-resize {
44
+ resize: horizontal;
45
+ }
@@ -25,6 +25,7 @@ export default [
25
25
  "order",
26
26
  "numberSpacing",
27
27
  "maxWidth",
28
+ "minWidth",
28
29
  "marginRight",
29
30
  "marginLeft",
30
31
  "marginTop",
@@ -94,6 +94,10 @@ type MaxWidth = {
94
94
  maxWidth?: Sizes,
95
95
  }
96
96
 
97
+ type MinWidth = {
98
+ minWidth?: Sizes,
99
+ }
100
+
97
101
  type NumberSpacing = {
98
102
  numberSpacing?: "tabular",
99
103
  }
@@ -170,7 +174,7 @@ type ZIndex = {
170
174
  export type GlobalProps = AlignContent & AlignItems & AlignSelf &
171
175
  BorderRadius & Cursor & Dark & Display & DisplaySizes & Flex & FlexDirection &
172
176
  FlexGrow & FlexShrink & FlexWrap & JustifyContent & JustifySelf &
173
- LineHeight & Margin & MaxWidth & NumberSpacing & Order & Overflow & Padding &
177
+ LineHeight & Margin & MinWidth & MaxWidth & NumberSpacing & Order & Overflow & Padding &
174
178
  Position & Shadow & TextAlign & Truncate & VerticalAlign & ZIndex & { hover?: string } & Top & Right & Bottom & Left;
175
179
 
176
180
  const getResponsivePropClasses = (prop: {[key: string]: string}, classPrefix: string) => {
@@ -194,6 +198,14 @@ const getPositioningPropsClasses = (position: string, value: Sizes | {value: str
194
198
  return css;
195
199
  };
196
200
 
201
+ const filterClassName = (value: string): string => {
202
+ if (value.includes("%")) {
203
+ return value.replace("%", "_percent");
204
+ } else {
205
+ return value;
206
+ }
207
+ };
208
+
197
209
  // Prop categories
198
210
  const PROP_CATEGORIES: {[key:string]: (props: {[key: string]: any}) => string} = {
199
211
 
@@ -320,10 +332,15 @@ const PROP_CATEGORIES: {[key:string]: (props: {[key: string]: any}) => string} =
320
332
  css += numberSpacing ? `ns_${numberSpacing} ` : ''
321
333
  return css
322
334
  },
335
+ minWidthProps: ({ minWidth }: MinWidth) => {
336
+ let css = ''
337
+ css += minWidth ? `min_width_${filterClassName(minWidth)} ` : ''
338
+ return css.trimEnd()
339
+ },
323
340
  maxWidthProps: ({ maxWidth }: MaxWidth) => {
324
341
  let css = ''
325
- css += maxWidth ? `max_width_${maxWidth } ` : ''
326
- return css
342
+ css += maxWidth ? `max_width_${filterClassName(maxWidth)} ` : ''
343
+ return css.trimEnd()
327
344
  },
328
345
  zIndexProps: (zIndex: ZIndex) => {
329
346
  let css = ''