playbook_ui 14.12.0.pre.alpha.PBNTR720railscarddraggable5649 → 14.12.0.pre.alpha.PBNTR834advtablemaxHeightstickyheader5932

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/_playbook.scss +1 -0
  3. data/app/pb_kits/playbook/pb_advanced_table/Components/CustomCell.tsx +1 -1
  4. data/app/pb_kits/playbook/pb_advanced_table/Components/TableHeaderCell.tsx +11 -4
  5. data/app/pb_kits/playbook/pb_advanced_table/Utilities/ActionBarAnimationHelper.ts +26 -0
  6. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +60 -10
  7. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +37 -21
  8. data/app/pb_kits/playbook/pb_advanced_table/advanced_table.html.erb +3 -3
  9. data/app/pb_kits/playbook/pb_advanced_table/advanced_table.rb +3 -1
  10. data/app/pb_kits/playbook/pb_advanced_table/advanced_table.test.jsx +1 -1
  11. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_loading.html.erb +33 -0
  12. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_loading_rails.md +1 -0
  13. data/app/pb_kits/playbook/pb_advanced_table/docs/{_advanced_table_loading.md → _advanced_table_loading_react.md} +2 -2
  14. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_responsive.html.erb +38 -0
  15. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props.jsx +1 -0
  16. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props_react.md +3 -1
  17. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props_sticky_header.jsx +55 -0
  18. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props_sticky_header_react.md +3 -0
  19. data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +3 -0
  20. data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +2 -1
  21. data/app/pb_kits/playbook/pb_advanced_table/index.js +9 -6
  22. data/app/pb_kits/playbook/pb_advanced_table/table_body.rb +17 -3
  23. data/app/pb_kits/playbook/pb_advanced_table/table_header.html.erb +15 -11
  24. data/app/pb_kits/playbook/pb_advanced_table/table_header.rb +14 -3
  25. data/app/pb_kits/playbook/pb_advanced_table/table_row.html.erb +10 -7
  26. data/app/pb_kits/playbook/pb_advanced_table/table_row.rb +9 -1
  27. data/app/pb_kits/playbook/pb_advanced_table/table_subrow_header.html.erb +1 -1
  28. data/app/pb_kits/playbook/pb_advanced_table/table_subrow_header.rb +9 -0
  29. data/app/pb_kits/playbook/pb_avatar/_avatar.scss +14 -0
  30. data/app/pb_kits/playbook/pb_avatar/_avatar.tsx +11 -7
  31. data/app/pb_kits/playbook/pb_avatar/avatar.html.erb +6 -7
  32. data/app/pb_kits/playbook/pb_avatar/docs/_avatar_badge_component_overlay.jsx +9 -3
  33. data/app/pb_kits/playbook/pb_avatar/docs/_avatar_circle_icon_component_overlay.jsx +6 -2
  34. data/app/pb_kits/playbook/pb_button/button.rb +1 -1
  35. data/app/pb_kits/playbook/pb_copy_button/_copy_button.scss +4 -0
  36. data/app/pb_kits/playbook/pb_copy_button/_copy_button.tsx +92 -0
  37. data/app/pb_kits/playbook/pb_copy_button/copy_button.html.erb +15 -0
  38. data/app/pb_kits/playbook/pb_copy_button/copy_button.rb +28 -0
  39. data/app/pb_kits/playbook/pb_copy_button/copy_button.test.jsx +64 -0
  40. data/app/pb_kits/playbook/pb_copy_button/docs/_copy_button_default.html.erb +2 -0
  41. data/app/pb_kits/playbook/pb_copy_button/docs/_copy_button_default.jsx +21 -0
  42. data/app/pb_kits/playbook/pb_copy_button/docs/_copy_button_from.html.erb +5 -0
  43. data/app/pb_kits/playbook/pb_copy_button/docs/_copy_button_from.jsx +45 -0
  44. data/app/pb_kits/playbook/pb_copy_button/docs/_copy_button_from.md +1 -0
  45. data/app/pb_kits/playbook/pb_copy_button/docs/example.yml +8 -0
  46. data/app/pb_kits/playbook/pb_copy_button/docs/index.js +2 -0
  47. data/app/pb_kits/playbook/pb_copy_button/index.js +47 -0
  48. data/app/pb_kits/playbook/pb_date/_date.tsx +14 -4
  49. data/app/pb_kits/playbook/pb_date/docs/_date_default.jsx +2 -1
  50. data/app/pb_kits/playbook/pb_date/docs/_date_unstyled.jsx +13 -5
  51. data/app/pb_kits/playbook/pb_file_upload/file_upload.html.erb +1 -6
  52. data/app/pb_kits/playbook/pb_filter/filter.html.erb +1 -5
  53. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_fixed_confirmation_toast_auto_close.html.erb +58 -0
  54. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_fixed_confirmation_toast_auto_close_rails.md +3 -0
  55. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/example.yml +1 -0
  56. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/index.js +7 -5
  57. data/app/pb_kits/playbook/pb_form_group/form_group.html.erb +1 -6
  58. data/app/pb_kits/playbook/pb_form_pill/form_pill.html.erb +1 -1
  59. data/app/pb_kits/playbook/pb_link/_link.tsx +18 -0
  60. data/app/pb_kits/playbook/pb_link/docs/_link_target.html.erb +15 -0
  61. data/app/pb_kits/playbook/pb_link/docs/_link_target.jsx +29 -0
  62. data/app/pb_kits/playbook/pb_link/docs/example.yml +5 -3
  63. data/app/pb_kits/playbook/pb_link/docs/index.js +2 -1
  64. data/app/pb_kits/playbook/pb_link/link.html.erb +1 -1
  65. data/app/pb_kits/playbook/pb_link/link.rb +6 -0
  66. data/app/pb_kits/playbook/pb_link/link.test.jsx +30 -0
  67. data/app/pb_kits/playbook/pb_progress_step/docs/_progress_step_tooltip.html.erb +6 -6
  68. data/app/pb_kits/playbook/pb_table/docs/_table_with_background_kit.html.erb +6 -9
  69. data/app/pb_kits/playbook/pb_table/docs/_table_with_background_kit.jsx +6 -9
  70. data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible_with_custom_content.jsx +12 -8
  71. data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible_with_custom_content_rails.html.erb +52 -0
  72. data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible_with_custom_content_rails.md +0 -0
  73. data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible_with_nested_rows_rails.html.erb +52 -0
  74. data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible_with_nested_rows_rails.md +3 -0
  75. data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible_with_nested_table_rails.html.erb +80 -0
  76. data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible_with_nested_table_rails.md +1 -0
  77. data/app/pb_kits/playbook/pb_table/docs/example.yml +3 -0
  78. data/app/pb_kits/playbook/pb_table/styles/_desktop_collapse.scss +26 -0
  79. data/app/pb_kits/playbook/pb_table/styles/_mobile.scss +0 -1
  80. data/app/pb_kits/playbook/pb_table/styles/_mobile_collapse.scss +25 -0
  81. data/app/pb_kits/playbook/pb_table/styles/_tablet_collapse.scss +25 -0
  82. data/app/pb_kits/playbook/pb_table/table_row.rb +1 -1
  83. data/app/pb_kits/playbook/pb_tooltip/_tooltip.tsx +3 -1
  84. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_default.html.erb +1 -1
  85. data/app/pb_kits/playbook/pb_tooltip/index.js +45 -27
  86. data/app/pb_kits/playbook/pb_tooltip/tooltip.rb +5 -1
  87. data/app/pb_kits/playbook/pb_user/_user.tsx +3 -0
  88. data/app/pb_kits/playbook/pb_user/docs/_user_light_weight.html.erb +42 -0
  89. data/app/pb_kits/playbook/pb_user/docs/_user_light_weight.jsx +59 -0
  90. data/app/pb_kits/playbook/pb_user/docs/_user_light_weight.md +2 -0
  91. data/app/pb_kits/playbook/pb_user/docs/example.yml +2 -0
  92. data/app/pb_kits/playbook/pb_user/docs/index.js +1 -0
  93. data/app/pb_kits/playbook/pb_user/user.html.erb +1 -1
  94. data/app/pb_kits/playbook/pb_user/user.rb +1 -0
  95. data/app/pb_kits/playbook/pb_user/user.test.js +14 -0
  96. data/dist/chunks/_typeahead-CkemExmL.js +36 -0
  97. data/dist/chunks/_weekday_stacked-DiNLeUtf.js +45 -0
  98. data/dist/chunks/{lib-kMuhBuU7.js → lib-DjpLC8uO.js} +1 -1
  99. data/dist/chunks/{pb_form_validation-DBJ0wZuS.js → pb_form_validation-S56UaHZl.js} +1 -1
  100. data/dist/chunks/vendor.js +1 -1
  101. data/dist/menu.yml +6 -0
  102. data/dist/playbook-doc.js +1 -1
  103. data/dist/playbook-rails-react-bindings.js +1 -1
  104. data/dist/playbook-rails.js +1 -1
  105. data/dist/playbook.css +1 -1
  106. data/lib/playbook/pb_forms_global_props_helper.rb +136 -0
  107. data/lib/playbook/pb_forms_helper.rb +13 -4
  108. data/lib/playbook/version.rb +1 -1
  109. metadata +41 -8
  110. data/dist/chunks/_typeahead-BWwaAo_0.js +0 -36
  111. data/dist/chunks/_weekday_stacked-zyBCd1s8.js +0 -45
  112. /data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/{_fixed_confirmation_toast_auto_close.md → _fixed_confirmation_toast_auto_close_react.md} +0 -0
@@ -0,0 +1,8 @@
1
+ examples:
2
+ rails:
3
+ - copy_button_default: Default
4
+ - copy_button_from: Copy From
5
+
6
+ react:
7
+ - copy_button_default: Default
8
+ - copy_button_from: Copy From
@@ -0,0 +1,2 @@
1
+ export { default as CopyButtonDefault } from './_copy_button_default.jsx'
2
+ export { default as CopyButtonFrom } from './_copy_button_from.jsx'
@@ -0,0 +1,47 @@
1
+ import PbEnhancedElement from "../pb_enhanced_element"
2
+
3
+ export default class PbCopyButton extends PbEnhancedElement {
4
+ static get selector() {
5
+ return '.pb_copy_button_kit'
6
+ }
7
+
8
+ connect() {
9
+ this.handleClick = this.handleClick.bind(this)
10
+ this.button = this.element.querySelector('button')
11
+ if (this.button) {
12
+ this.button.addEventListener('click', this.handleClick)
13
+ }
14
+ }
15
+
16
+ disconnect() {
17
+ if (this.button) {
18
+ this.button.removeEventListener('click', this.handleClick)
19
+ }
20
+ }
21
+
22
+ handleClick() {
23
+ const fromId = this.element.getAttribute('data-from')
24
+ if (fromId) {
25
+ const fromElement = document.querySelector(`#${fromId}`)
26
+ if (fromElement) {
27
+ let contentToCopy = ''
28
+ if (fromElement.tagName.toLowerCase() === 'input') {
29
+ contentToCopy = fromElement.value
30
+ } else {
31
+ contentToCopy = fromElement.innerText
32
+ }
33
+ navigator.clipboard.writeText(contentToCopy)
34
+ .catch(err => console.error('Failed to copy text', err))
35
+ return
36
+ }
37
+ }
38
+
39
+ const textToCopy = this.element.getAttribute('data-copy-value')
40
+ if (textToCopy) {
41
+ navigator.clipboard.writeText(textToCopy)
42
+ .catch(err => console.error('Failed to copy text', err))
43
+ } else {
44
+ console.warn('No data-copy-value attribute found or data-from element')
45
+ }
46
+ }
47
+ }
@@ -14,6 +14,7 @@ type PbDateProps = {
14
14
  alignment?: "left" | "center" | "right";
15
15
  aria?: { [key: string]: string };
16
16
  className?: string;
17
+ dark?: boolean;
17
18
  data?: { [key: string]: string };
18
19
  htmlOptions?: { [key: string]: string | number | boolean | (() => void) };
19
20
  id?: string;
@@ -29,6 +30,7 @@ const PbDate = (props: PbDateProps): React.ReactElement => {
29
30
  aria = {},
30
31
  alignment = "left",
31
32
  className,
33
+ dark = false,
32
34
  data = {},
33
35
  htmlOptions = {},
34
36
  id,
@@ -56,7 +58,7 @@ const PbDate = (props: PbDateProps): React.ReactElement => {
56
58
  );
57
59
 
58
60
  return (
59
- <div
61
+ <div
60
62
  {...ariaProps}
61
63
  {...dataProps}
62
64
  {...htmlProps}
@@ -93,7 +95,9 @@ const PbDate = (props: PbDateProps): React.ReactElement => {
93
95
  </>
94
96
  : size == "md" || size == "lg"
95
97
  ? (
96
- <Title size={4}
98
+ <Title
99
+ dark={dark}
100
+ size={4}
97
101
  tag="h4"
98
102
  >
99
103
  {showIcon && (
@@ -127,6 +131,7 @@ const PbDate = (props: PbDateProps): React.ReactElement => {
127
131
  <>
128
132
  {showIcon && (
129
133
  <Caption className="pb_icon_kit_container"
134
+ dark={dark}
130
135
  tag="span"
131
136
  >
132
137
  <Icon fixedWidth
@@ -138,15 +143,20 @@ const PbDate = (props: PbDateProps): React.ReactElement => {
138
143
 
139
144
  {showDayOfWeek && (
140
145
  <>
141
- <Caption tag="div">{weekday}</Caption>
146
+ <Caption dark={dark}
147
+ tag="div">
148
+ {weekday}
149
+ </Caption>
142
150
  <Caption color="light"
151
+ dark={dark}
143
152
  tag="div"
144
153
  text=" • "
145
154
  />
146
155
  </>
147
156
  )}
148
157
 
149
- <Caption tag="span">
158
+ <Caption dark={dark}
159
+ tag="span">
150
160
  {month} {day}
151
161
  {currentYear != year && <>{`, ${year}`}</>}
152
162
  </Caption>
@@ -18,7 +18,7 @@ const DateDefault = (props) => {
18
18
  value={"2012-08-03"}
19
19
  {...props}
20
20
  />
21
- <Caption>{"(Hyphenated Date)"}</Caption>
21
+ <Caption {...props}>{"(Hyphenated Date)"}</Caption>
22
22
  </div>
23
23
 
24
24
  <br />
@@ -56,6 +56,7 @@ const DateDefault = (props) => {
56
56
  <Title
57
57
  size={4}
58
58
  text={"(Hyphenated Date)"}
59
+ {...props}
59
60
  />
60
61
  </div>
61
62
 
@@ -4,7 +4,8 @@ import { Caption, Date as FormattedDate, Title } from 'playbook-ui'
4
4
  const DateUnstyled = (props) => {
5
5
  return (
6
6
  <>
7
- <Caption size="xs"
7
+ <Caption {...props}
8
+ size="xs"
8
9
  text="Basic unstyled example"
9
10
  />
10
11
  <FormattedDate
@@ -15,10 +16,14 @@ const DateUnstyled = (props) => {
15
16
 
16
17
  <br />
17
18
 
18
- <Caption size="xs"
19
+ <Caption {...props}
20
+
21
+ size="xs"
19
22
  text="Example with wrapping typography kit"
20
23
  />
21
- <Title size={1}>
24
+ <Title {...props}
25
+ size={1}
26
+ >
22
27
  <FormattedDate
23
28
  unstyled
24
29
  value={new Date('25 Dec 1995')}
@@ -28,10 +33,13 @@ const DateUnstyled = (props) => {
28
33
 
29
34
  <br />
30
35
 
31
- <Caption size="xs"
36
+ <Caption {...props}
37
+ size="xs"
32
38
  text="Example with icon + subcaption"
33
39
  />
34
- <Caption size="xs">
40
+ <Caption {...props}
41
+ size="xs"
42
+ >
35
43
  <FormattedDate
36
44
  showDayOfWeek
37
45
  showIcon
@@ -1,9 +1,4 @@
1
- <%= content_tag("div",
2
- aria: object.aria,
3
- class: object.classname,
4
- data: object.data,
5
- id: object.id,
6
- **combined_html_options) do %>
1
+ <%= pb_content_tag(:div) do %>
7
2
  <%= pb_rails("form_group", props: {cursor: "pointer", full_width: object.full_width}) do %>
8
3
  <label
9
4
  for="upload-<%= object.id %>"
@@ -1,8 +1,4 @@
1
- <%= content_tag(:div,
2
- id: object.id,
3
- data: object.data,
4
- class: object.classname,
5
- **combined_html_options) do %>
1
+ <%= pb_content_tag(:div) do %>
6
2
  <%= object.wrapper do %>
7
3
  <%= pb_rails("flex", props: { orientation: "row", padding_right: "lg", vertical: "center" }) do %>
8
4
  <% if (object.template != "sort_only") %>
@@ -0,0 +1,58 @@
1
+ <%= pb_rails("button", props: { text: "Show Auto Close Toast", variant: "secondary", data: { toast: "#toast-auto-close" } }) %>
2
+ <%= pb_rails("button", props: { text: "Show Closeable Auto Close Toast", variant: "secondary", data: { toast: "#toast-auto-close-closeable" } }) %>
3
+
4
+ <%= pb_rails("fixed_confirmation_toast", props: {
5
+ auto_close: 3000,
6
+ classname: "toast-to-hide",
7
+ id: "toast-auto-close",
8
+ text: "I will disappear in 3 seconds.",
9
+ status: "tip",
10
+ vertical: "top",
11
+ horizontal: "center"
12
+ }) %>
13
+
14
+ <%= pb_rails("fixed_confirmation_toast", props: {
15
+ auto_close: 10000,
16
+ closeable: true,
17
+ id: "toast-auto-close-closeable",
18
+ text: "I will disappear in 10 seconds.",
19
+ status: "tip",
20
+ vertical: "top",
21
+ horizontal: "center"
22
+ }) %>
23
+
24
+ <script>
25
+ document.addEventListener('DOMContentLoaded', () => {
26
+ // Initialize toast elements and buttons
27
+ const toasts = {
28
+ '#toast-auto-close': document.querySelector("#toast-auto-close"),
29
+ '#toast-auto-close-closeable': document.querySelector("#toast-auto-close-closeable")
30
+ }
31
+
32
+ const buttons = {
33
+ '#toast-auto-close': document.querySelector("button[data-toast='#toast-auto-close']"),
34
+ '#toast-auto-close-closeable': document.querySelector("button[data-toast='#toast-auto-close-closeable']")
35
+ }
36
+
37
+ // Store original toasts and remove them from DOM
38
+ const originalToasts = {}
39
+ Object.entries(toasts).forEach(([id, toast]) => {
40
+ if (toast) {
41
+ originalToasts[id] = toast.cloneNode(true)
42
+ toast.remove()
43
+ }
44
+ })
45
+
46
+ // Set up button click handlers
47
+ Object.keys(buttons).forEach((toastId) => {
48
+ const button = buttons[toastId]
49
+ if (button) {
50
+ button.onclick = () => {
51
+ const newToast = originalToasts[toastId].cloneNode(true)
52
+ newToast.style.display = "flex"
53
+ document.body.appendChild(newToast)
54
+ }
55
+ }
56
+ })
57
+ })
58
+ </script>
@@ -0,0 +1,3 @@
1
+ Auto close is used when you want the confirmation toast to close automatically after a certain time. `auto_close` property will be a delay number in ms.
2
+
3
+ The script tag in this code snippet is for demonstration purposes only. It clones the toasts in order to have it appear with a button click prompt and not upon initial page load. In a typical production environment the event triggering a fixed confirmation toast to appear would be handled by a controller or a separate javascript file.
@@ -5,6 +5,7 @@ examples:
5
5
  - fixed_confirmation_toast_multi_line: Multi Line
6
6
  - fixed_confirmation_toast_close: Click to Close
7
7
  - fixed_confirmation_toast_positions: Click to Show Positions
8
+ - fixed_confirmation_toast_auto_close: Click to Show Auto Close
8
9
  - fixed_confirmation_toast_children: Children
9
10
  - fixed_confirmation_toast_custom_icon: Custom Icon
10
11
 
@@ -2,16 +2,18 @@ import PbEnhancedElement from '../pb_enhanced_element'
2
2
 
3
3
  export default class PbFixedConfirmationToast extends PbEnhancedElement {
4
4
  static get selector() {
5
- return '.remove_toast'
5
+ return '[class*="pb_fixed_confirmation_toast_kit"]'
6
6
  }
7
7
 
8
8
  connect() {
9
9
  this.self = this.element
10
10
  this.autoCloseToast(this.self)
11
11
 
12
- this.self.addEventListener('click', () => {
13
- this.removeToast(this.self)
14
- })
12
+ if (this.self.classList.contains('remove_toast')) {
13
+ this.self.addEventListener('click', () => {
14
+ this.removeToast(this.self)
15
+ })
16
+ }
15
17
  }
16
18
 
17
19
  removeToast(elem) {
@@ -32,4 +34,4 @@ export default class PbFixedConfirmationToast extends PbEnhancedElement {
32
34
  }, autoCloseIntValue)
33
35
  }
34
36
  }
35
- }
37
+ }
@@ -1,8 +1,3 @@
1
- <%= content_tag(:div,
2
- aria: object.aria,
3
- class: object.classname,
4
- data: object.data,
5
- id: object.id,
6
- **combined_html_options) do %>
1
+ <%= pb_content_tag(:div) do %>
7
2
  <%= content.presence %>
8
3
  <% end %>
@@ -1,4 +1,4 @@
1
- <%= content_tag(:div, id: object.id, data: object.data, class: object.classname + object.size_class, tabindex: object.tabindex, **combined_html_options) do %>
1
+ <%= pb_content_tag(:div, class: object.classname + object.size_class, tabindex: object.tabindex) do %>
2
2
  <% if object.name.present? %>
3
3
  <%= pb_rails("avatar", props: { name: object.name, image_url: object.avatar_url, size: "xxs" }) %>
4
4
  <% if object.truncate %>
@@ -19,7 +19,9 @@ type LinkProps = {
19
19
  icon?: string,
20
20
  iconRight?: string,
21
21
  id?: string,
22
+ tabIndex?: number,
22
23
  tag?: 'a' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'p' | 'span' | 'div',
24
+ target?: string,
23
25
  text?: string,
24
26
  underline?: boolean,
25
27
  } & GlobalProps
@@ -37,7 +39,9 @@ const Link = (props: LinkProps): React.ReactElement => {
37
39
  icon = '',
38
40
  iconRight = '',
39
41
  id = '',
42
+ tabIndex,
40
43
  tag = 'a',
44
+ target = '',
41
45
  text = '',
42
46
  underline = false,
43
47
  } = props
@@ -52,6 +56,14 @@ const Link = (props: LinkProps): React.ReactElement => {
52
56
  )
53
57
  const Tag = tag as keyof JSX.IntrinsicElements
54
58
 
59
+ const getTargetAttribute = () => {
60
+ if (target && href) {
61
+ return target
62
+ }
63
+
64
+ return undefined
65
+ }
66
+
55
67
  const renderContent = () => (
56
68
  <>
57
69
  {icon && (
@@ -87,6 +99,9 @@ const Link = (props: LinkProps): React.ReactElement => {
87
99
  <a
88
100
  {...commonProps}
89
101
  href={href}
102
+ rel={target !== 'child' ? 'noreferrer' : undefined}
103
+ tabIndex={tabIndex}
104
+ target={getTargetAttribute()}
90
105
  >
91
106
  {renderContent()}
92
107
  </a>
@@ -96,6 +111,9 @@ const Link = (props: LinkProps): React.ReactElement => {
96
111
  <a
97
112
  {...commonProps}
98
113
  href={href}
114
+ rel={target !== 'child' ? 'noreferrer' : undefined}
115
+ tabIndex={tabIndex}
116
+ target={getTargetAttribute()}
99
117
  >
100
118
  <Tag>{renderContent()}</Tag>
101
119
  </a>
@@ -0,0 +1,15 @@
1
+ <div>
2
+ <%= pb_rails("link", props: {
3
+ href: "http://google.com",
4
+ target: "blank",
5
+ text: "Open In New Window"
6
+ }) %>
7
+ </div>
8
+
9
+ <div>
10
+ <%= pb_rails("link", props: {
11
+ href: "https://playbook.powerapp.cloud/",
12
+ target: "child",
13
+ text: "Open In Child Tab",
14
+ }) %>
15
+ </div>
@@ -0,0 +1,29 @@
1
+ import React from 'react'
2
+ import { Link } from 'playbook-ui'
3
+
4
+ const LinkTarget = (props) => (
5
+ <div>
6
+ <div>
7
+ <Link
8
+ aria={{ label: 'Link to Google in new window' }}
9
+ href="https://google.com"
10
+ tabIndex={0}
11
+ target='blank'
12
+ text="Open In New Window"
13
+ {...props}
14
+ />
15
+ </div>
16
+ <div>
17
+ <Link
18
+ aria={{ label: 'Link to Playbook in a child tab' }}
19
+ href="https://playbook.powerapp.cloud/"
20
+ tabIndex={0}
21
+ target='child'
22
+ text="Open In Child Tab"
23
+ {...props}
24
+ />
25
+ </div>
26
+ </div>
27
+ )
28
+
29
+ export default LinkTarget
@@ -1,16 +1,18 @@
1
1
  examples:
2
-
2
+
3
3
  rails:
4
4
  - link_color: Color
5
5
  - link_underline: Underline
6
6
  - link_icon: Icon
7
7
  - link_disabled: Disabled
8
8
  - link_tag: Tag
9
-
10
-
9
+ - link_target: Target
10
+
11
+
11
12
  react:
12
13
  - link_color: Color
13
14
  - link_underline: Underline
14
15
  - link_icon: Icon
15
16
  - link_disabled: Disabled
16
17
  - link_tag: Tag
18
+ - link_target: Target
@@ -2,4 +2,5 @@ export { default as LinkColor } from './_link_color.jsx'
2
2
  export { default as LinkUnderline } from './_link_underline.jsx'
3
3
  export { default as LinkIcon } from './_link_icon.jsx'
4
4
  export { default as LinkDisabled } from './_link_disabled.jsx'
5
- export { default as LinkTag } from './_link_tag.jsx'
5
+ export { default as LinkTag } from './_link_tag.jsx'
6
+ export { default as LinkTarget } from './_link_target.jsx'
@@ -9,7 +9,7 @@
9
9
  <% end %>
10
10
 
11
11
  <% if object.tag == "a" %>
12
- <%= pb_content_tag(object.tag, { href: object.href }) do %>
12
+ <%= pb_content_tag(object.tag, { href: object.href, target: object.target }) do %>
13
13
  <%= link_content.call %>
14
14
  <% end %>
15
15
  <% else %>
@@ -11,9 +11,11 @@ module Playbook
11
11
  prop :href
12
12
  prop :icon
13
13
  prop :icon_right
14
+ prop :tabindex
14
15
  prop :tag, type: Playbook::Props::Enum,
15
16
  values: %w[a h1 h2 h3 h4 h5 h6 p span div],
16
17
  default: "a"
18
+ prop :target
17
19
  prop :text
18
20
  prop :underline, type: Playbook::Props::Boolean,
19
21
  default: false
@@ -26,6 +28,10 @@ module Playbook
26
28
  text
27
29
  end
28
30
 
31
+ def target_attribute
32
+ target if target && href
33
+ end
34
+
29
35
  private
30
36
 
31
37
  def color_class
@@ -90,3 +90,33 @@ test('adds icon right', () => {
90
90
  const icon = kit.querySelector('.pb_icon_kit')
91
91
  expect(icon).toBeInTheDocument();
92
92
  })
93
+
94
+ test('should render target prop', () => {
95
+ render(
96
+ <Link
97
+ data={{ testid: 'target-test' }}
98
+ href="https://playbook.powerapp.cloud/"
99
+ target="blank"
100
+ />
101
+ )
102
+
103
+ const kit = screen.getByTestId('target-test')
104
+
105
+ expect(kit).toHaveAttribute('target', 'blank')
106
+ })
107
+
108
+
109
+ test('should render child target prop', () => {
110
+ render(
111
+ <Link
112
+ data={{ testid: 'target-test' }}
113
+ href="https://playbook.powerapp.cloud/"
114
+ tabIndex={0}
115
+ target="child"
116
+ />
117
+ )
118
+
119
+ const kit = screen.getByTestId('target-test')
120
+
121
+ expect(kit).toHaveAttribute('target', 'child')
122
+ })
@@ -2,7 +2,7 @@
2
2
  <%= pb_rails("progress_step/progress_step_item", props: {status: "complete", classname: "tooltip-trigger-1", tooltip: "Tooltip for step 1", tooltip_position: "right", step_direction: "horizontal" }) do %>
3
3
  step 1
4
4
  <% end %>
5
- <%= pb_rails("progress_step/progress_step_item", props: {status: "complete", classname: "tooltip-trigger-2", tooltip: "Tooltip for step 2", step_direction: "horizontal" }) do %>
5
+ <%= pb_rails("progress_step/progress_step_item", props: {status: "complete", classname: "tooltip-trigger-2", tooltip: "Tooltip for step 2", tooltip_position: "left", step_direction: "horizontal" }) do %>
6
6
  step 2
7
7
  <% end %>
8
8
  <%= pb_rails("progress_step/progress_step_item", props: {status: "active", classname: "tooltip-trigger-3", tooltip: "Tooltip for step 3", tooltip_position: "left", step_direction: "horizontal" }) do %>
@@ -11,7 +11,7 @@
11
11
  <%= pb_rails("progress_step/progress_step_item", props: {status: "inactive", classname: "tooltip-trigger-4", tooltip: "Tooltip for step 4", tooltip_position: "bottom" }) do %>
12
12
  step 4
13
13
  <% end %>
14
- <%= pb_rails("progress_step/progress_step_item", props: {status: "inactive", classname: "tooltip-trigger-5", tooltip: "Tooltip for step 5" }) do %>
14
+ <%= pb_rails("progress_step/progress_step_item", props: {status: "inactive", classname: "tooltip-trigger-5", tooltip: "Tooltip for step 5", tooltip_position: "left" }) do %>
15
15
  step 5
16
16
  <% end %>
17
17
  <% end %>
@@ -19,7 +19,7 @@
19
19
  <br /><br />
20
20
 
21
21
  <%= pb_rails("progress_step", props: {orientation: "vertical"}) do %>
22
- <%= pb_rails("progress_step/progress_step_item", props: {status: "complete", classname: "tooltip-trigger-6", tooltip: "Tooltip step 1", step_direction: "vertical" }) do %>
22
+ <%= pb_rails("progress_step/progress_step_item", props: {status: "complete", classname: "tooltip-trigger-6", tooltip: "Tooltip step 1", step_direction: "vertical", tooltip_position: "left" }) do %>
23
23
  <% end %>
24
24
  <%= pb_rails("progress_step/progress_step_item", props: {status: "active", classname: "tooltip-trigger-7", tooltip: "Tooltip step 2", tooltip_position: "left"}) do %>
25
25
  <% end %>
@@ -31,10 +31,10 @@
31
31
 
32
32
  <br /><br>
33
33
  <%= pb_rails("progress_step",props:{ variant:"tracker", icon:true}) do %>
34
- <%= pb_rails("progress_step/progress_step_item", props: {status: "complete", classname: "tooltip-trigger-10", tooltip: "The order has been received", step_direction: "horizontal" , tooltip_position: "right" }) do %>
34
+ <%= pb_rails("progress_step/progress_step_item", props: {status: "complete", classname: "tooltip-trigger-10", tooltip: "The order has been received", step_direction: "horizontal" , tooltip_position: "right" }) do %>
35
35
  <%= pb_rails("caption", props:{text: "Ordered"})%>
36
36
  <% end %>
37
- <%= pb_rails("progress_step/progress_step_item", props: {status: "active", classname: "tooltip-trigger-11", tooltip:"Item(s) have been shipped" }) do %>
37
+ <%= pb_rails("progress_step/progress_step_item", props: {status: "active", classname: "tooltip-trigger-11", tooltip:"Item(s) have been shipped", tooltip_position: "right" }) do %>
38
38
  <%= pb_rails("caption", props:{text: "Shipped"})%>
39
39
  <% end %>
40
40
  <%= pb_rails("progress_step/progress_step_item", props: {status: "inactive", classname: "tooltip-trigger-12", tooltip:"This step has not been reached", tooltip_position: "left" }) do %>
@@ -50,7 +50,7 @@
50
50
  <%= pb_rails("progress_step/progress_step_item", props: {status: "active", icon: "exclamation-triangle", classname: "tooltip-trigger-14", tooltip: "More details needed before shipment", tooltip_position: "bottom" }) do %>
51
51
  <%= pb_rails("caption", props:{text: "Shipped"})%>
52
52
  <% end %>
53
- <%= pb_rails("progress_step/progress_step_item", props: {status: "inactive", classname: "tooltip-trigger-15", tooltip: "This step is inactive"}) do %>
53
+ <%= pb_rails("progress_step/progress_step_item", props: {status: "inactive", classname: "tooltip-trigger-15", tooltip: "This step is inactive", tooltip_position: "bottom"}) do %>
54
54
  <%= pb_rails("caption", props:{text: "Out for Delivery"})%>
55
55
  <% end %>
56
56
  <%= pb_rails("progress_step/progress_step_item", props: {status: "inactive", classname: "tooltip-trigger-16", tooltip: "Estimated delivery: Jun 27", tooltip_position: "left"}) do %>
@@ -39,20 +39,17 @@
39
39
  </tr>
40
40
  </tbody>
41
41
  <% end %>
42
-
43
42
  <%= pb_rails("table", props: { size: "sm", margin_bottom: "lg" }) do %>
44
43
  <colgroup>
45
44
  <%= pb_rails("background", props: { background_color: "error_subtle", tag: "col" }) %>
46
- <%= pb_rails("background", props: { background_color: "card_light", tag: "col" }) %>
45
+ <%= pb_rails("background", props: { background_color: "info_subtle", tag: "col" }) %>
47
46
  <%= pb_rails("background", props: { background_color: "warning_subtle", tag: "col" }) %>
48
47
  </colgroup>
49
- <%= pb_rails("background", props: { background_color: "card_light", tag: "thead" }) do %>
50
- <tr>
51
- <th>Column 1</th>
52
- <th>Column 2</th>
53
- <th>Column 3</th>
54
- </tr>
55
- <% end %>
48
+ <thead>
49
+ <th>Column 1</th>
50
+ <th>Column 2</th>
51
+ <th>Column 3</th>
52
+ </thead>
56
53
  <tbody>
57
54
  <tr>
58
55
  <td>Value 1</td>
@@ -68,7 +68,7 @@ const TableWithBackgroundKit = (props) => {
68
68
  tag='col'
69
69
  />
70
70
  <Background
71
- backgroundColor="card_light"
71
+ backgroundColor="info_subtle"
72
72
  tag='col'
73
73
  />
74
74
  <Background
@@ -76,16 +76,13 @@ const TableWithBackgroundKit = (props) => {
76
76
  tag='col'
77
77
  />
78
78
  </colgroup>
79
- <Background
80
- backgroundColor="card_light"
81
- tag='thead'
82
- >
79
+ <thead>
83
80
  <tr>
84
- <th>{'Column 1'}</th>
85
- <th>{'Column 2'}</th>
86
- <th>{'Column 3'}</th>
81
+ <th>{'Column 1'}</th>
82
+ <th>{'Column 2'}</th>
83
+ <th>{'Column 3'}</th>
87
84
  </tr>
88
- </Background>
85
+ </thead>
89
86
  <tbody>
90
87
  <tr>
91
88
  <td>{'Value 1'}</td>