playbook_ui 14.12.0.pre.alpha.play1830updateclassnamesdependency5888 → 14.12.0.pre.alpha.play1849cssbargraph5901
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.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/pb_bar_graph/BarGraphStyles.scss +60 -0
- data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_pb_styles.jsx +64 -0
- data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_pb_styles.md +1 -0
- data/app/pb_kits/playbook/pb_bar_graph/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_bar_graph/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_copy_button/_copy_button.scss +2 -1
- data/app/pb_kits/playbook/pb_copy_button/copy_button.html.erb +15 -0
- data/app/pb_kits/playbook/pb_copy_button/copy_button.rb +28 -0
- data/app/pb_kits/playbook/pb_copy_button/docs/_copy_button_default.html.erb +2 -0
- data/app/pb_kits/playbook/pb_copy_button/docs/_copy_button_from.html.erb +5 -0
- data/app/pb_kits/playbook/pb_copy_button/docs/example.yml +3 -3
- data/app/pb_kits/playbook/pb_copy_button/index.js +47 -0
- data/app/pb_kits/playbook/pb_link/_link.tsx +18 -0
- data/app/pb_kits/playbook/pb_link/docs/_link_target.html.erb +15 -0
- data/app/pb_kits/playbook/pb_link/docs/_link_target.jsx +29 -0
- data/app/pb_kits/playbook/pb_link/docs/example.yml +5 -3
- data/app/pb_kits/playbook/pb_link/docs/index.js +2 -1
- data/app/pb_kits/playbook/pb_link/link.html.erb +1 -1
- data/app/pb_kits/playbook/pb_link/link.rb +6 -0
- data/app/pb_kits/playbook/pb_link/link.test.jsx +30 -0
- data/app/pb_kits/playbook/pb_progress_step/docs/_progress_step_tooltip.html.erb +6 -6
- data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_default.html.erb +1 -1
- data/app/pb_kits/playbook/pb_tooltip/index.js +45 -27
- data/app/pb_kits/playbook/pb_tooltip/tooltip.rb +5 -1
- data/dist/chunks/{_typeahead-B4ApU9B7.js → _typeahead-BM1R3tnS.js} +3 -3
- data/dist/chunks/{_weekday_stacked-Cionc19j.js → _weekday_stacked-CmWdEFxG.js} +2 -2
- data/dist/chunks/{lib-kMuhBuU7.js → lib-DjpLC8uO.js} +1 -1
- data/dist/chunks/{pb_form_validation-DBJ0wZuS.js → pb_form_validation-S56UaHZl.js} +1 -1
- data/dist/chunks/vendor.js +1 -1
- data/dist/menu.yml +2 -2
- data/dist/playbook-doc.js +1 -1
- data/dist/playbook-rails-react-bindings.js +1 -1
- data/dist/playbook-rails.js +1 -1
- data/dist/playbook.css +1 -1
- data/lib/playbook/version.rb +1 -1
- metadata +15 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3fa18fb0688024244c6382ffc1b706c671a1bcd95bc187944e3de19969a920f
|
4
|
+
data.tar.gz: 81c0ce2229e52de9d323d2e5c920a2279a8bffcc2b7953fe23c0ccb6045bbf3d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1df7e12000b4d865ac3a7b17e8a56aa7926f540a2dc762a779ff61f4134d970fd0f1b021c76c65886188e682239e18ce99e82f84b47d53d9745ab102cf86411b
|
7
|
+
data.tar.gz: 2602884b96a718ceee5534d12d2322656098d302cefd339677d43e953bc3097f5d999e922f5c6b3cedc7c5860d8c20af92fa5af3b30c847a76af9596a655f2e4
|
@@ -0,0 +1,60 @@
|
|
1
|
+
@import "../tokens/colors";
|
2
|
+
@import "../tokens/typography";
|
3
|
+
@import url("https://code.highcharts.com/css/highcharts.css");
|
4
|
+
// @import "highcharts/css/highcharts";
|
5
|
+
// @import "highcharts/highcharts.css";
|
6
|
+
|
7
|
+
:root {
|
8
|
+
--highcharts-color-0: #{$data_1};
|
9
|
+
--highcharts-color-1: #{$data_2};
|
10
|
+
--highcharts-color-2: #{$data_3};
|
11
|
+
--highcharts-color-3: #{$data_4};
|
12
|
+
--highcharts-color-4: #{$data_5};
|
13
|
+
--highcharts-color-5: #{$data_6};
|
14
|
+
--highcharts-color-6: #{$data_7};
|
15
|
+
--highcharts-color-7: #{$data_8};
|
16
|
+
}
|
17
|
+
|
18
|
+
.highcharts-title {
|
19
|
+
font-family: $font_family_base;
|
20
|
+
font-weight: $bold;
|
21
|
+
font-size: $heading_3;
|
22
|
+
color: $text_lt_default;
|
23
|
+
fill: $text_lt_default;
|
24
|
+
}
|
25
|
+
|
26
|
+
.highcharts-subtitle {
|
27
|
+
font-family: $font_family_base;
|
28
|
+
color: $text_lt_light;
|
29
|
+
fill: $text_lt_light;
|
30
|
+
font-weight: $regular;
|
31
|
+
font-size: $text_base;
|
32
|
+
}
|
33
|
+
|
34
|
+
.highcharts-yaxis > .highcharts-axis-title {
|
35
|
+
color: $text_lt_lighter;
|
36
|
+
fill: $text_lt_lighter;
|
37
|
+
font-family: $font_family_base;
|
38
|
+
font-weight: $bold;
|
39
|
+
font-size: $text_smaller;
|
40
|
+
}
|
41
|
+
|
42
|
+
.highcharts-axis-labels {
|
43
|
+
font-family: $font_family_base;
|
44
|
+
color: $text_lt_lighter;
|
45
|
+
fill: $text_lt_lighter;
|
46
|
+
font-weight: $bold;
|
47
|
+
font-size: $text_smaller;
|
48
|
+
}
|
49
|
+
|
50
|
+
.highcharts-grid-line {
|
51
|
+
stroke: $border_light;
|
52
|
+
}
|
53
|
+
|
54
|
+
.highcharts-point {
|
55
|
+
border-radius: 3px;
|
56
|
+
}
|
57
|
+
|
58
|
+
.highcharts-axis-line {
|
59
|
+
stroke: $border_light;
|
60
|
+
}
|
@@ -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.
|
@@ -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'
|
@@ -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,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,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,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
|
+
}
|
@@ -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'
|
@@ -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"
|
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 %>
|
@@ -1,5 +1,4 @@
|
|
1
1
|
import PbEnhancedElement from '../pb_enhanced_element'
|
2
|
-
|
3
2
|
import {
|
4
3
|
createPopperLite as createPopper,
|
5
4
|
flip,
|
@@ -17,27 +16,34 @@ export default class PbTooltip extends PbEnhancedElement {
|
|
17
16
|
|
18
17
|
connect() {
|
19
18
|
this.triggerElements.forEach((trigger) => {
|
20
|
-
|
21
|
-
this.mouseenterTimeout = setTimeout(() => {
|
22
|
-
this.showTooltip(trigger)
|
23
|
-
this.checkCloseTooltip(trigger)
|
24
|
-
}, TOOLTIP_TIMEOUT)
|
19
|
+
const method = this.triggerMethod
|
25
20
|
|
26
|
-
|
21
|
+
if (method === 'click') {
|
22
|
+
trigger.addEventListener('click', () => {
|
23
|
+
this.showTooltip(trigger)
|
24
|
+
})
|
25
|
+
} else {
|
26
|
+
trigger.addEventListener('mouseenter', () => {
|
27
|
+
this.mouseenterTimeout = setTimeout(() => {
|
28
|
+
this.showTooltip(trigger)
|
29
|
+
this.checkCloseTooltip(trigger)
|
30
|
+
}, TOOLTIP_TIMEOUT)
|
31
|
+
|
32
|
+
trigger.addEventListener('mouseleave', () => {
|
33
|
+
clearTimeout(this.mouseenterTimeout)
|
34
|
+
setTimeout(() => {
|
35
|
+
this.hideTooltip()
|
36
|
+
}, 0)
|
37
|
+
}, { once: true })
|
38
|
+
})
|
39
|
+
|
40
|
+
this.tooltip.addEventListener('mouseenter', () => {
|
27
41
|
clearTimeout(this.mouseenterTimeout)
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
})
|
34
|
-
})
|
35
|
-
|
36
|
-
this.tooltip.addEventListener('mouseenter', () => {
|
37
|
-
clearTimeout(this.mouseenterTimeout)
|
38
|
-
})
|
39
|
-
this.tooltip.addEventListener('mouseleave', () => {
|
40
|
-
this.hideTooltip()
|
42
|
+
})
|
43
|
+
this.tooltip.addEventListener('mouseleave', () => {
|
44
|
+
this.hideTooltip()
|
45
|
+
})
|
46
|
+
}
|
41
47
|
})
|
42
48
|
}
|
43
49
|
|
@@ -54,7 +60,7 @@ export default class PbTooltip extends PbEnhancedElement {
|
|
54
60
|
}
|
55
61
|
|
56
62
|
showTooltip(trigger) {
|
57
|
-
if (this.shouldShowTooltip ===
|
63
|
+
if (this.shouldShowTooltip === 'false') return
|
58
64
|
|
59
65
|
this.popper = createPopper(trigger, this.tooltip, {
|
60
66
|
placement: this.position,
|
@@ -78,6 +84,13 @@ export default class PbTooltip extends PbEnhancedElement {
|
|
78
84
|
],
|
79
85
|
})
|
80
86
|
this.tooltip.classList.add('show')
|
87
|
+
|
88
|
+
if (this.triggerMethod === 'click') {
|
89
|
+
clearTimeout(this.autoHideTimeout)
|
90
|
+
this.autoHideTimeout = setTimeout(() => {
|
91
|
+
this.hideTooltip()
|
92
|
+
}, 1000)
|
93
|
+
}
|
81
94
|
}
|
82
95
|
|
83
96
|
hideTooltip() {
|
@@ -94,25 +107,26 @@ export default class PbTooltip extends PbEnhancedElement {
|
|
94
107
|
let triggerEl
|
95
108
|
|
96
109
|
if (this.triggerElementId) {
|
97
|
-
triggerEl = document.querySelector(`#${this.triggerElementId}`)
|
110
|
+
triggerEl = document.querySelector(`#${this.triggerElementId}`)
|
98
111
|
} else {
|
99
112
|
const selectorIsId = this.triggerElementSelector.indexOf('#') > -1
|
100
|
-
triggerEl = selectorIsId
|
101
|
-
document.
|
113
|
+
triggerEl = selectorIsId
|
114
|
+
? document.querySelector(`${this.triggerElementSelector}`)
|
115
|
+
: document.querySelectorAll(`${this.triggerElementSelector}`)
|
102
116
|
}
|
103
117
|
|
104
118
|
if (!triggerEl) {
|
105
|
-
/* eslint no-console: ["error", { allow: ["warn", "error"] }] */
|
106
119
|
console.error('Tooltip Kit: an invalid or unavailable DOM reference was provided!')
|
107
120
|
return []
|
108
121
|
}
|
109
122
|
|
110
123
|
if (!triggerEl.length) triggerEl = [triggerEl]
|
111
|
-
return this._triggerElements =
|
124
|
+
return (this._triggerElements = this._triggerElements || triggerEl)
|
112
125
|
}
|
113
126
|
|
114
127
|
get tooltip() {
|
115
|
-
return this._tooltip =
|
128
|
+
return (this._tooltip =
|
129
|
+
this._tooltip || this.element.querySelector(`#${this.tooltipId}`))
|
116
130
|
}
|
117
131
|
|
118
132
|
get position() {
|
@@ -134,4 +148,8 @@ export default class PbTooltip extends PbEnhancedElement {
|
|
134
148
|
get shouldShowTooltip() {
|
135
149
|
return this.element.dataset.pbTooltipShowTooltip
|
136
150
|
}
|
151
|
+
|
152
|
+
get triggerMethod() {
|
153
|
+
return this.element.dataset.pbTooltipTriggerMethod || 'hover'
|
154
|
+
}
|
137
155
|
}
|