playbook_ui 14.12.0.pre.alpha.play1828updateviteversion5680 → 14.12.0.pre.alpha.play1849cssbargraph5901

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) 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 +2 -2
  5. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +3 -4
  6. data/app/pb_kits/playbook/pb_advanced_table/advanced_table.html.erb +8 -13
  7. data/app/pb_kits/playbook/pb_advanced_table/advanced_table.rb +2 -0
  8. data/app/pb_kits/playbook/pb_advanced_table/advanced_table.test.jsx +1 -1
  9. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_loading.html.erb +33 -0
  10. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_loading_rails.md +1 -0
  11. data/app/pb_kits/playbook/pb_advanced_table/docs/{_advanced_table_loading.md → _advanced_table_loading_react.md} +2 -2
  12. data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +1 -0
  13. data/app/pb_kits/playbook/pb_advanced_table/index.js +9 -6
  14. data/app/pb_kits/playbook/pb_advanced_table/table_body.rb +3 -1
  15. data/app/pb_kits/playbook/pb_advanced_table/table_header.html.erb +9 -5
  16. data/app/pb_kits/playbook/pb_advanced_table/table_header.rb +2 -0
  17. data/app/pb_kits/playbook/pb_advanced_table/table_row.html.erb +9 -6
  18. data/app/pb_kits/playbook/pb_advanced_table/table_row.rb +2 -0
  19. data/app/pb_kits/playbook/pb_avatar/_avatar.scss +14 -0
  20. data/app/pb_kits/playbook/pb_avatar/_avatar.tsx +11 -7
  21. data/app/pb_kits/playbook/pb_avatar/avatar.html.erb +6 -7
  22. data/app/pb_kits/playbook/pb_avatar/docs/_avatar_badge_component_overlay.jsx +9 -3
  23. data/app/pb_kits/playbook/pb_avatar/docs/_avatar_circle_icon_component_overlay.jsx +6 -2
  24. data/app/pb_kits/playbook/pb_bar_graph/BarGraphStyles.scss +60 -0
  25. data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_pb_styles.jsx +64 -0
  26. data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_pb_styles.md +1 -0
  27. data/app/pb_kits/playbook/pb_bar_graph/docs/example.yml +1 -0
  28. data/app/pb_kits/playbook/pb_bar_graph/docs/index.js +1 -0
  29. data/app/pb_kits/playbook/pb_button/button.rb +1 -1
  30. data/app/pb_kits/playbook/pb_copy_button/_copy_button.scss +4 -0
  31. data/app/pb_kits/playbook/pb_copy_button/_copy_button.tsx +92 -0
  32. data/app/pb_kits/playbook/pb_copy_button/copy_button.html.erb +15 -0
  33. data/app/pb_kits/playbook/pb_copy_button/copy_button.rb +28 -0
  34. data/app/pb_kits/playbook/pb_copy_button/copy_button.test.jsx +64 -0
  35. data/app/pb_kits/playbook/pb_copy_button/docs/_copy_button_default.html.erb +2 -0
  36. data/app/pb_kits/playbook/pb_copy_button/docs/_copy_button_default.jsx +21 -0
  37. data/app/pb_kits/playbook/pb_copy_button/docs/_copy_button_from.html.erb +5 -0
  38. data/app/pb_kits/playbook/pb_copy_button/docs/_copy_button_from.jsx +45 -0
  39. data/app/pb_kits/playbook/pb_copy_button/docs/_copy_button_from.md +1 -0
  40. data/app/pb_kits/playbook/pb_copy_button/docs/example.yml +8 -0
  41. data/app/pb_kits/playbook/pb_copy_button/docs/index.js +2 -0
  42. data/app/pb_kits/playbook/pb_copy_button/index.js +47 -0
  43. data/app/pb_kits/playbook/pb_date/_date.tsx +14 -4
  44. data/app/pb_kits/playbook/pb_date/docs/_date_default.jsx +2 -1
  45. data/app/pb_kits/playbook/pb_date/docs/_date_unstyled.jsx +13 -5
  46. data/app/pb_kits/playbook/pb_file_upload/file_upload.html.erb +1 -6
  47. data/app/pb_kits/playbook/pb_filter/filter.html.erb +1 -5
  48. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_fixed_confirmation_toast_auto_close.html.erb +58 -0
  49. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_fixed_confirmation_toast_auto_close_rails.md +3 -0
  50. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/example.yml +1 -0
  51. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/index.js +7 -5
  52. data/app/pb_kits/playbook/pb_form_group/form_group.html.erb +1 -6
  53. data/app/pb_kits/playbook/pb_form_pill/form_pill.html.erb +1 -1
  54. data/app/pb_kits/playbook/pb_home_address_street/_home_address_street.tsx +11 -7
  55. data/app/pb_kits/playbook/pb_home_address_street/docs/_home_address_street_formatting.html.erb +11 -0
  56. data/app/pb_kits/playbook/pb_home_address_street/docs/_home_address_street_formatting.jsx +22 -0
  57. data/app/pb_kits/playbook/pb_home_address_street/docs/_home_address_street_formatting_rails.md +1 -0
  58. data/app/pb_kits/playbook/pb_home_address_street/docs/_home_address_street_formatting_react.md +1 -0
  59. data/app/pb_kits/playbook/pb_home_address_street/docs/example.yml +2 -0
  60. data/app/pb_kits/playbook/pb_home_address_street/docs/index.js +1 -0
  61. data/app/pb_kits/playbook/pb_home_address_street/home_address_street.rb +11 -2
  62. data/app/pb_kits/playbook/pb_link/_link.tsx +18 -0
  63. data/app/pb_kits/playbook/pb_link/docs/_link_target.html.erb +15 -0
  64. data/app/pb_kits/playbook/pb_link/docs/_link_target.jsx +29 -0
  65. data/app/pb_kits/playbook/pb_link/docs/example.yml +5 -3
  66. data/app/pb_kits/playbook/pb_link/docs/index.js +2 -1
  67. data/app/pb_kits/playbook/pb_link/link.html.erb +1 -1
  68. data/app/pb_kits/playbook/pb_link/link.rb +6 -0
  69. data/app/pb_kits/playbook/pb_link/link.test.jsx +30 -0
  70. data/app/pb_kits/playbook/pb_progress_step/docs/_progress_step_tooltip.html.erb +6 -6
  71. data/app/pb_kits/playbook/pb_table/docs/_table_with_background_kit.html.erb +6 -9
  72. data/app/pb_kits/playbook/pb_table/docs/_table_with_background_kit.jsx +6 -9
  73. data/app/pb_kits/playbook/pb_table/styles/_desktop_collapse.scss +26 -0
  74. data/app/pb_kits/playbook/pb_table/styles/_mobile.scss +0 -1
  75. data/app/pb_kits/playbook/pb_table/styles/_mobile_collapse.scss +25 -0
  76. data/app/pb_kits/playbook/pb_table/styles/_tablet_collapse.scss +25 -0
  77. data/app/pb_kits/playbook/pb_tooltip/_tooltip.tsx +3 -1
  78. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_default.html.erb +1 -1
  79. data/app/pb_kits/playbook/pb_tooltip/index.js +45 -27
  80. data/app/pb_kits/playbook/pb_tooltip/tooltip.rb +5 -1
  81. data/app/pb_kits/playbook/pb_user/_user.tsx +3 -0
  82. data/app/pb_kits/playbook/pb_user/docs/_user_light_weight.html.erb +42 -0
  83. data/app/pb_kits/playbook/pb_user/docs/_user_light_weight.jsx +59 -0
  84. data/app/pb_kits/playbook/pb_user/docs/_user_light_weight.md +2 -0
  85. data/app/pb_kits/playbook/pb_user/docs/example.yml +2 -0
  86. data/app/pb_kits/playbook/pb_user/docs/index.js +1 -0
  87. data/app/pb_kits/playbook/pb_user/user.html.erb +1 -1
  88. data/app/pb_kits/playbook/pb_user/user.rb +1 -0
  89. data/app/pb_kits/playbook/pb_user/user.test.js +14 -0
  90. data/dist/chunks/_typeahead-BM1R3tnS.js +36 -0
  91. data/dist/chunks/_weekday_stacked-CmWdEFxG.js +45 -0
  92. data/dist/chunks/{lib-kMuhBuU7.js → lib-DjpLC8uO.js} +1 -1
  93. data/dist/chunks/{pb_form_validation-DBJ0wZuS.js → pb_form_validation-S56UaHZl.js} +1 -1
  94. data/dist/chunks/vendor.js +1 -1
  95. data/dist/menu.yml +6 -0
  96. data/dist/playbook-doc.js +1 -1
  97. data/dist/playbook-rails-react-bindings.js +1 -1
  98. data/dist/playbook-rails.js +1 -1
  99. data/dist/playbook.css +1 -1
  100. data/lib/playbook/pb_forms_global_props_helper.rb +136 -0
  101. data/lib/playbook/pb_forms_helper.rb +13 -4
  102. data/lib/playbook/version.rb +1 -1
  103. metadata +38 -8
  104. data/dist/chunks/_typeahead-BWwaAo_0.js +0 -36
  105. data/dist/chunks/_weekday_stacked-zyBCd1s8.js +0 -45
  106. /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,64 @@
1
+ import React from 'react'
2
+ import Highcharts from "highcharts";
3
+ import HighchartsReact from "highcharts-react-official";
4
+
5
+ import "../BarGraphStyles.scss";
6
+ // Your path might look more like this
7
+ //import "playbook-ui/dist/pb_bar_graph/BarGraphStyles.scss";
8
+
9
+ const columnChartData = [
10
+ {
11
+ name: "Installation",
12
+ data: [1475, 200, 3000, 654, 656],
13
+ },
14
+ {
15
+ name: "Manufacturing",
16
+ data: [4434, 524, 2320, 440, 500],
17
+ },
18
+ {
19
+ name: "Sales & Distribution",
20
+ data: [3387, 743, 1344, 434, 440],
21
+ },
22
+ {
23
+ name: "Project Development",
24
+ data: [3227, 878, 999, 780, 1000],
25
+ },
26
+ {
27
+ name: "Other",
28
+ data: [1111, 677, 3245, 500, 200],
29
+ },
30
+ ];
31
+
32
+ const columnOptions = {
33
+ chart: {
34
+ type: "column",
35
+ },
36
+ series: columnChartData,
37
+ title: {
38
+ text: "Solar Employment Growth by Sector, 2010-2016",
39
+ },
40
+ subtitle: {
41
+ text: "Source: thesolarfoundation.com",
42
+ },
43
+ xAxis: {
44
+ categories: ["Jan", "Feb", "Mar", "Apr", "May"],
45
+ },
46
+ yAxis: {
47
+ min: 0,
48
+ title: {
49
+ text: "Number of Employees",
50
+ },
51
+ },
52
+ legend: { enabled: false },
53
+ credits: { enabled: false },
54
+ };
55
+
56
+ const BarGraphPbStyles = () => (
57
+ <div>
58
+ <HighchartsReact highcharts={Highcharts}
59
+ options={columnOptions}
60
+ />
61
+ </div>
62
+ )
63
+
64
+ export default BarGraphPbStyles
@@ -0,0 +1 @@
1
+ You don't need to use the bargraph kit to apply the styles to your Highcharts Bargraph. Just import the BarGraphStyles.scss to your component and the sytles will apply automaticlly.
@@ -17,6 +17,7 @@ examples:
17
17
 
18
18
  react:
19
19
  - bar_graph_default: Default
20
+ - bar_graph_pb_styles: Playbook Styles
20
21
  - bar_graph_legend: Legend
21
22
  - bar_graph_legend_position: Legend Position
22
23
  - bar_graph_legend_non_clickable: Legend Non Clickable
@@ -10,3 +10,4 @@ export { default as BarGraphStacked } from './_bar_graph_stacked.jsx'
10
10
  export { default as BarGraphNegativeNumbers } from './_bar_graph_negative_numbers.jsx'
11
11
  export { default as BarGraphSecondaryYAxis } from './_bar_graph_secondary_y_axis.jsx'
12
12
  export { default as BarGraphHorizontal } from './_bar_graph_horizontal.jsx'
13
+ export { default as BarGraphPbStyles } from './_bar_graph_pb_styles.jsx'
@@ -65,7 +65,7 @@ module Playbook
65
65
  end
66
66
 
67
67
  def tag
68
- link ? "a" : "button"
68
+ link && !disabled ? "a" : "button"
69
69
  end
70
70
 
71
71
  def valid_emoji(icon)
@@ -0,0 +1,4 @@
1
+ .pb_copy_button_kit {
2
+ width: fit-content;
3
+ height: fit-content;
4
+ }
@@ -0,0 +1,92 @@
1
+
2
+ import React, { useState } from 'react'
3
+ import classnames from 'classnames'
4
+ import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
5
+ import { globalProps } from '../utilities/globalProps'
6
+
7
+ import Button from '../pb_button/_button'
8
+ import Tooltip from '../pb_tooltip/_tooltip'
9
+
10
+ type CopyButtonProps = {
11
+ aria?: { [key: string]: string },
12
+ className?: string,
13
+ data?: { [key: string]: string },
14
+ id?: string,
15
+ from?: string,
16
+ text?: string,
17
+ tooltipPlacement?: "top" | "right" | "bottom" | "left",
18
+ tooltipText?: string,
19
+ value?: string,
20
+ }
21
+
22
+ const CopyButton = (props: CopyButtonProps) => {
23
+ const {
24
+ aria = {},
25
+ className,
26
+ data = {},
27
+ from = '',
28
+ id,
29
+ text= 'Copy',
30
+ tooltipPlacement= 'bottom',
31
+ tooltipText = 'Copied!',
32
+ value = '',
33
+ } = props
34
+
35
+ const [copied, setCopied] = useState(false)
36
+
37
+ const ariaProps = buildAriaProps(aria)
38
+ const dataProps = buildDataProps(data)
39
+ const classes = classnames(buildCss('pb_copy_button_kit'), globalProps(props), className)
40
+
41
+ const copy = () => {
42
+ if (!from && !value) {
43
+ return
44
+ }
45
+
46
+ if (value) {
47
+ navigator.clipboard.writeText(value)
48
+ } else if (from) {
49
+ const copyElement = document.getElementById(from);
50
+ let copyText = copyElement?.innerText
51
+
52
+ if (copyElement instanceof HTMLTextAreaElement || copyElement instanceof HTMLInputElement) {
53
+ copyText = copyElement.value;
54
+ }
55
+
56
+ if (copyText) {
57
+ navigator.clipboard.writeText(copyText)
58
+ }
59
+ }
60
+
61
+ setCopied(true)
62
+
63
+ setTimeout(() => {
64
+ setCopied(false)
65
+ }, 1000);
66
+ }
67
+
68
+ return (
69
+ <div
70
+ {...ariaProps}
71
+ {...dataProps}
72
+ className={classes}
73
+ id={id}
74
+ >
75
+ <Tooltip
76
+ forceOpenTooltip={copied}
77
+ placement={tooltipPlacement}
78
+ showTooltip={false}
79
+ text={tooltipText}
80
+ >
81
+ <Button
82
+ icon='copy'
83
+ onClick={copy}
84
+ >
85
+ { text }
86
+ </Button>
87
+ </Tooltip>
88
+ </div>
89
+ )
90
+ }
91
+
92
+ export default CopyButton
@@ -0,0 +1,15 @@
1
+ <%= pb_content_tag do %>
2
+ <%= pb_rails("button", props: { icon: "copy" }) do %>
3
+ <%= object.text %>
4
+ <% end %>
5
+ <% if object.id %>
6
+ <%= pb_rails("tooltip", props: {
7
+ trigger_element_selector: "##{object.id}",
8
+ position: object.tooltip_position,
9
+ tooltip_id: "#{object.id}_tooltip",
10
+ trigger_method: "click"
11
+ }) do %>
12
+ <%= object.tooltip_text %>
13
+ <% end %>
14
+ <% end %>
15
+ <% end %>
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Playbook
4
+ module PbCopyButton
5
+ class CopyButton < ::Playbook::KitBase
6
+ prop :text
7
+ prop :tooltip_position,
8
+ type: Playbook::Props::Enum,
9
+ values: %w[top right bottom left],
10
+ default: "top"
11
+ prop :tooltip_text, type: Playbook::Props::String,
12
+ default: "Copied!"
13
+ prop :value
14
+ prop :from
15
+
16
+ def classname
17
+ generate_classname("pb_copy_button_kit")
18
+ end
19
+
20
+ def data
21
+ Hash(values[:data]).merge(
22
+ "copy-value": value,
23
+ "from": from
24
+ )
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,64 @@
1
+ import React from 'react';
2
+ import { CopyButton } from 'playbook-ui'
3
+ import { ensureAccessible, renderKit, render, fireEvent, screen } from '../utilities/test-utils'
4
+
5
+ const props = {
6
+ data: { testid: 'default', value: 'copy' }
7
+ }
8
+
9
+ test('returns namespaced class name', () => {
10
+ const kit = renderKit(CopyButton, props)
11
+ expect(kit).toBeInTheDocument()
12
+ expect(kit).toHaveClass('pb_copy_button_kit')
13
+ })
14
+
15
+ it('should be accessible', async () => {
16
+ ensureAccessible(CopyButton, props)
17
+ })
18
+
19
+ // It's difficult to actually use navigator.clipboard.readText, so we mock
20
+ it('copies the value to clipboard and pastes it into an input', async () => {
21
+ Object.defineProperty(global, 'navigator', {
22
+ value: {
23
+ clipboard: {
24
+ writeText: jest.fn().mockResolvedValueOnce(undefined),
25
+ },
26
+ },
27
+ writable: true,
28
+ })
29
+
30
+ render(<CopyButton {...props} />)
31
+
32
+ const copyButton = screen.getByTestId('default')
33
+ fireEvent.click(copyButton)
34
+
35
+ await navigator.clipboard.writeText('copy')
36
+
37
+ expect(navigator.clipboard.writeText).toHaveBeenCalledWith("copy");
38
+ })
39
+
40
+ test('passes text and tooltip props to button', () => {
41
+ render(
42
+ <CopyButton
43
+ data={{ testid: 'text-test' }}
44
+ text={"text"}
45
+ tooltipPlacement="right"
46
+ tooltipText="Text copied!"
47
+ value="copy"
48
+ />
49
+ )
50
+
51
+ const content = screen.getByText("text")
52
+ expect(content).toHaveTextContent("text")
53
+
54
+ const kit = screen.getByTestId('text-test')
55
+ const button = kit.querySelector('.pb_button_kit_primary_inline_enabled')
56
+ expect(button).toBeInTheDocument()
57
+
58
+ fireEvent.click(button)
59
+ const tooltipContent = screen.getByText("Text copied!")
60
+ expect(tooltipContent).toHaveTextContent("Text copied!")
61
+
62
+ const tooltip = kit.querySelector('.pb_tooltip_kit')
63
+ expect(tooltip).toBeInTheDocument()
64
+ })
@@ -0,0 +1,2 @@
1
+ <%= pb_rails("copy_button", props: { id: "default-copy-button", text: "Copy Text", value: "Playbook makes it easy to support bleeding edge, or legacy systems. Use Playbook’s 200+ components and end-to-end design language to create simple, intuitive and beautiful experiences with ease." } ) %>
2
+ <%= pb_rails("textarea", props: { margin_top: "xs", placeholder: "Copy and paste here" }) %>
@@ -0,0 +1,21 @@
1
+ import React from 'react'
2
+ import { CopyButton, Textarea } from 'playbook-ui'
3
+
4
+ const CopyButtonDefault = (props) => (
5
+ <div>
6
+ <CopyButton
7
+ {...props}
8
+ text="Copy Text"
9
+ tooltipPlacement="right"
10
+ tooltipText="Text copied!"
11
+ value="Playbook makes it easy to support bleeding edge, or legacy systems. Use Playbook’s 200+ components and end-to-end design language to create simple, intuitive and beautiful experiences with ease."
12
+ />
13
+
14
+ <Textarea
15
+ {...props}
16
+ placeholder="Copy and paste here"
17
+ />
18
+ </div>
19
+ )
20
+
21
+ export default CopyButtonDefault
@@ -0,0 +1,5 @@
1
+ <%= pb_rails("body", props: { id: "body", text: "Copy this body text!"}) %>
2
+ <%= pb_rails("copy_button", props: { text: "Copy Body text", from: "body", id: "copy-body-button" }) %>
3
+ <%= pb_rails("text_input", props: { margin_top: "xs", placeholder: "Copy and paste here" }) %>
4
+ <%= pb_rails("copy_button", props: { text: "Copy Text Input", from: "copy-input", id: "copy-input-button" }) %>
5
+ <%= pb_rails("text_input", props: { margin_top: "xs", id: "copy-input" , value: "Copy and paste here" }) %>
@@ -0,0 +1,45 @@
1
+ import React, { useState } from 'react'
2
+ import { CopyButton, Body, TextInput, Textarea } from 'playbook-ui'
3
+
4
+ const CopyButtonFrom = (props) => {
5
+ const [text, setText] = useState("Copy this text input text")
6
+
7
+ const handleChange = (event) => {
8
+ setText(event.target.value);
9
+ }
10
+
11
+ return (<div>
12
+ <Body id="body">Copy this body text!</Body>
13
+ <CopyButton
14
+ {...props}
15
+ from="body"
16
+ marginBottom="sm"
17
+ text="Copy Body text"
18
+ tooltipPlacement="right"
19
+ tooltipText="Body text copied!"
20
+ />
21
+
22
+ <TextInput
23
+ {...props}
24
+ id="textinput"
25
+ onChange={handleChange}
26
+ value={text}
27
+ />
28
+ <CopyButton
29
+ {...props}
30
+ from="textinput"
31
+ marginBottom="sm"
32
+ text="Copy Text Input"
33
+ tooltipPlacement="right"
34
+ tooltipText="Text input copied!"
35
+ />
36
+
37
+ <Textarea
38
+ {...props}
39
+ placeholder="Copy and paste here"
40
+ />
41
+ </div>
42
+ )
43
+ }
44
+
45
+ export default CopyButtonFrom
@@ -0,0 +1 @@
1
+ Provide an element's ID as the `from` parameter, and its text will be copied. If the element is an input, its `value` will be copied; otherwise, the `innerText` will be used. Additionally, if a `value` prop is provided, it will override the content from the `from` element and be copied instead.
@@ -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