playbook_ui 14.3.0.pre.rc.8 → 14.3.0.pre.rc.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 87f159ff1ca1720cfe5d67393dee393d6ba2c8ba9cc5265c0c90803bf06298ab
4
- data.tar.gz: 19e3c47ccac8485a2a65965817a9ab4c0035bf22c0eaaffc0f5eaaa7d0a35905
3
+ metadata.gz: d27bc0773d0b2b97125ccaf0b86f53cc44090fc1e7e7c77c39027bd0be7dd093
4
+ data.tar.gz: 5e4253b6ed65adcbe071d8581e9aa3b92b512a28aba751fe379d50f1587255c5
5
5
  SHA512:
6
- metadata.gz: 6d517ea8d227655b4ce33b0ef06f9f85e53820cc58f4048e24ba9fc8ab8a38e82ee3b09553e9ec3a44782f97da429f441891cebe400313aeb975eb26cdf56926
7
- data.tar.gz: d99e3d9ae1b4317a1bfb97e91488d4ec3fb4c92c90376e6093e67097663974b6f81c446ec4e0c34d42a93db70ee2f6a4a07feb0b4716d96df56325bc00cee910
6
+ metadata.gz: 54b2d14f3b2d4aab0f1f8fa0fbf106ffe53fa504cc4e07c51cb840fafbfe5ed903bab2a6a30c77a9342dce1452998914b2fbb0261da01bf8a557e9e7b37bba46
7
+ data.tar.gz: 879f68fe40a025427d08849c019874d9e62905d69020f478edfd8871781f0f5e2095d37748b3c986d0bab02c5ae56e2aa1c8382d4c2159af584ba7bdbefd3709
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable react/jsx-no-target-blank */
2
- /* eslint-disable react/no-multi-comp, flowtype/space-before-type-colon */
2
+ /* eslint-disable react/no-multi-comp */
3
3
 
4
4
  import React from 'react'
5
5
  import classnames from 'classnames'
@@ -18,6 +18,7 @@ type HashtagProps = {
18
18
  id?: string,
19
19
  newWindow?: boolean,
20
20
  rel?: string,
21
+ target?: string,
21
22
  text?: string,
22
23
  type: "default" | "home" | "project" | "appointment",
23
24
  url?: string,
@@ -40,6 +41,7 @@ const Hashtag = (props: HashtagProps) => {
40
41
  id,
41
42
  newWindow,
42
43
  rel,
44
+ target,
43
45
  text,
44
46
  type = 'default',
45
47
  url,
@@ -50,6 +52,18 @@ const Hashtag = (props: HashtagProps) => {
50
52
  const htmlProps = buildHtmlProps(htmlOptions)
51
53
  const classes = classnames(buildCss('pb_hashtag_kit'), globalProps(props), className)
52
54
 
55
+ const getTargetAttribute = () => {
56
+ if (target && url) {
57
+ return target
58
+ } else if (newWindow) {
59
+ return '_blank'
60
+ } else {
61
+ return '_self'
62
+ }
63
+
64
+ return null
65
+ }
66
+
53
67
  return (
54
68
  <span
55
69
  {...ariaProps}
@@ -61,7 +75,7 @@ const Hashtag = (props: HashtagProps) => {
61
75
  <a
62
76
  href={url}
63
77
  rel={(newWindow ? "noreferrer" : rel)}
64
- target={(newWindow ? '_blank' : '_self')}
78
+ target={getTargetAttribute()}
65
79
  >
66
80
  <Badge
67
81
  dark={dark}
@@ -2,4 +2,4 @@
2
2
 
3
3
  <br/><br/>
4
4
 
5
- <%= pb_rails("hashtag", props: {text: "Open in a new Window", url: "https://google.com", type: "project", new_window: true}) %>
5
+ <%= pb_rails("hashtag", props: {text: "Open in a new Window", url: "https://google.com", type: "project", target: "_blank"}) %>
@@ -13,7 +13,7 @@ const HashtagLink = (props) => {
13
13
  <br />
14
14
  <br />
15
15
  <Hashtag
16
- newWindow
16
+ target="_blank"
17
17
  text="Open in a new window"
18
18
  type="project"
19
19
  url="https://google.com"
@@ -1 +1 @@
1
- Use the newWindow/new_window prop to control whether the link opens on the same page or a new tab (same page is the default behavior)
1
+ Use the `target` prop to control whether the link opens on the same or a new tab (same page is the default behavior). You can use any [web/standard](https://www.w3schools.com/tags/att_a_target.asp) values or a custom string to specify your link target.
@@ -1,5 +1,5 @@
1
1
  <%= pb_content_tag(:span) do %>
2
- <%= link_to object.url, target: object.link_option do %>
2
+ <%= link_to object.url, target: object.target_option do %>
3
3
  <%= pb_rails("badge", props: { dark: object.dark, variant: "primary", text: object.hashtag_text }) %>
4
4
  <% end %>
5
5
  <% end %>
@@ -10,6 +10,7 @@ module Playbook
10
10
  values: %w[default project home appointment],
11
11
  default: "default"
12
12
  prop :url
13
+ prop :target
13
14
 
14
15
  def classname
15
16
  generate_classname("pb_hastag_kit")
@@ -19,8 +20,14 @@ module Playbook
19
20
  type_text + text
20
21
  end
21
22
 
22
- def link_option
23
- new_window ? "_blank" : "_self"
23
+ def target_option
24
+ if target && url
25
+ target
26
+ elsif new_window
27
+ "_blank"
28
+ else
29
+ "_self"
30
+ end
24
31
  end
25
32
 
26
33
  private
@@ -23,6 +23,7 @@ type HomeAddressStreetProps = {
23
23
  homeId: string,
24
24
  houseStyle: string,
25
25
  homeUrl: string,
26
+ target: string,
26
27
  newWindow: boolean,
27
28
  state: string,
28
29
  zipcode: string,
@@ -42,6 +43,7 @@ const HomeAddressStreet = (props: HomeAddressStreetProps): React.ReactElement =>
42
43
  htmlOptions = {},
43
44
  homeId,
44
45
  homeUrl,
46
+ target,
45
47
  newWindow,
46
48
  houseStyle,
47
49
  state,
@@ -62,6 +64,19 @@ const HomeAddressStreet = (props: HomeAddressStreetProps): React.ReactElement =>
62
64
  const dataProps: GenericObject = buildDataProps(data)
63
65
  const ariaProps: GenericObject = buildAriaProps(aria)
64
66
  const htmlProps = buildHtmlProps(htmlOptions)
67
+
68
+ const getTargetAttribute = () => {
69
+ if (target && homeUrl) {
70
+ return target
71
+ } else if (newWindow) {
72
+ return '_blank'
73
+ } else {
74
+ return '_self'
75
+ }
76
+
77
+ return null
78
+ }
79
+
65
80
  return (
66
81
  <div
67
82
  className={classes(className, dark)}
@@ -120,6 +135,7 @@ const HomeAddressStreet = (props: HomeAddressStreetProps): React.ReactElement =>
120
135
  dark={dark}
121
136
  marginRight="xxs"
122
137
  newWindow={newWindow}
138
+ target={getTargetAttribute()}
123
139
  text={homeId}
124
140
  type="home"
125
141
  url={homeUrl || '#'}
@@ -33,6 +33,7 @@
33
33
  type: "home",
34
34
  dark: object.dark,
35
35
  classname: "home-hashtag",
36
+ target: object.target_option,
36
37
  new_window: object.new_window}) %>
37
38
  <% end %>
38
39
 
@@ -10,9 +10,20 @@ module Playbook
10
10
  prop :home_url
11
11
  prop :new_window, type: Playbook::Props::Boolean,
12
12
  default: false
13
+ prop :target
13
14
  prop :territory
14
15
  prop :zip
15
16
  prop :dark, type: Playbook::Props::Boolean, default: false
17
+
18
+ def target_option
19
+ if target && home_url
20
+ target
21
+ elsif new_window
22
+ "_blank"
23
+ else
24
+ "_self"
25
+ end
26
+ end
16
27
  end
17
28
  end
18
29
  end
@@ -5,7 +5,7 @@
5
5
  home_id: 8250263,
6
6
  home_url: "https://powerhrg.com/",
7
7
  house_style: "Colonial",
8
- new_window: true,
8
+ target: "_blank",
9
9
  state: "PA",
10
10
  zipcode: "19382",
11
11
  territory: "PHL",
@@ -11,8 +11,8 @@ const HomeAddressStreetLink= (props) => {
11
11
  homeId={8250263}
12
12
  homeUrl="https://powerhrg.com/"
13
13
  houseStyle="Colonial"
14
- newWindow
15
14
  state="PA"
15
+ target="_blank"
16
16
  territory="PHL"
17
17
  zipcode="19382"
18
18
  {...props}
@@ -1 +1 @@
1
- Use the `newWindow` / `new_window` prop to control whether the link opens on the same page or a new tab (same page is the default behavior)
1
+ Use the `target` prop to control whether the link opens on the same or a new tab (same page is the default behavior). You can use any [web/standard](https://www.w3schools.com/tags/att_a_target.asp) values or a custom string to specify your link target.
@@ -14,6 +14,7 @@ module Playbook
14
14
  prop :house_style
15
15
  prop :new_window, type: Playbook::Props::Boolean,
16
16
  default: false
17
+ prop :target
17
18
  prop :state
18
19
  prop :zipcode
19
20
  prop :territory
@@ -55,6 +56,7 @@ module Playbook
55
56
  dark: dark,
56
57
  home_id: home_id,
57
58
  home_url: home_url,
59
+ target: target_option,
58
60
  new_window: new_window,
59
61
  territory: territory,
60
62
  zip: zip,
@@ -69,11 +71,22 @@ module Playbook
69
71
  dark: dark,
70
72
  home_id: home_id,
71
73
  home_url: home_url,
74
+ target: target_option,
72
75
  new_window: new_window,
73
76
  territory: territory,
74
77
  }
75
78
  end
76
79
 
80
+ def target_option
81
+ if target && home_url
82
+ target
83
+ elsif new_window
84
+ "_blank"
85
+ else
86
+ "_self"
87
+ end
88
+ end
89
+
77
90
  private
78
91
 
79
92
  def dark_class
@@ -23,10 +23,10 @@ function HomeAdressStreetTest(props) {
23
23
  territory="PHL"
24
24
  zipcode="19382"
25
25
  {...props}
26
- />
26
+ />
27
27
  );
28
28
  }
29
-
29
+
30
30
  test("renders the component", () => {
31
31
  render(<HomeAdressStreetTest />);
32
32
  const kit = screen.getByTestId("primary-test");
@@ -23,7 +23,8 @@
23
23
  type: "home",
24
24
  dark: object.dark,
25
25
  classname: "home-hashtag",
26
- new_window: object.new_window}) %>
26
+ new_window: object.new_window,
27
+ target: object.target_option}) %>
27
28
  <% end %>
28
29
 
29
30
  <%= pb_rails "body", props: { color: "light", tag: "span", dark: object.dark } do %>
@@ -10,9 +10,20 @@ module Playbook
10
10
  prop :home_url
11
11
  prop :new_window, type: Playbook::Props::Boolean,
12
12
  default: false
13
+ prop :target
13
14
  prop :territory
14
15
  prop :dark, type: Playbook::Props::Boolean,
15
16
  default: false
17
+
18
+ def target_option
19
+ if target && home_url
20
+ target
21
+ elsif new_window
22
+ "_blank"
23
+ else
24
+ "_self"
25
+ end
26
+ end
16
27
  end
17
28
  end
18
29
  end