playbook_ui 2.8.7 → 2.8.8

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.
Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/packs/examples.js +3 -0
  3. data/app/pb_kits/playbook/packs/kits.js +1 -0
  4. data/app/pb_kits/playbook/pb_avatar/_avatar.jsx +25 -36
  5. data/app/pb_kits/playbook/pb_bar_graph/_bar_graph.jsx +54 -14
  6. data/app/pb_kits/playbook/pb_bar_graph/barGraphSettings.js +17 -17
  7. data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_default.html.erb +8 -1
  8. data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_default.jsx +30 -8
  9. data/app/pb_kits/playbook/pb_body/_body.jsx +46 -33
  10. data/app/pb_kits/playbook/pb_body/docs/_body_dark.jsx +3 -0
  11. data/app/pb_kits/playbook/pb_body/docs/_body_light.jsx +3 -0
  12. data/app/pb_kits/playbook/pb_button/_button.jsx +106 -37
  13. data/app/pb_kits/playbook/pb_button/docs/_button_accessibility.jsx +15 -0
  14. data/app/pb_kits/playbook/pb_button/docs/_button_block_content.jsx +14 -0
  15. data/app/pb_kits/playbook/pb_button/docs/_button_default.jsx +22 -0
  16. data/app/pb_kits/playbook/pb_button/docs/_button_default_dark.jsx +22 -0
  17. data/app/pb_kits/playbook/pb_button/docs/_button_full_width.jsx +13 -0
  18. data/app/pb_kits/playbook/pb_button/docs/_button_link.jsx +23 -0
  19. data/app/pb_kits/playbook/pb_button/docs/_button_loading.jsx +23 -0
  20. data/app/pb_kits/playbook/pb_button/docs/example.yml +8 -4
  21. data/app/pb_kits/playbook/pb_button/docs/index.js +7 -3
  22. data/app/pb_kits/playbook/pb_caption/_caption.jsx +31 -34
  23. data/app/pb_kits/playbook/pb_card/_card.jsx +35 -20
  24. data/app/pb_kits/playbook/pb_card/docs/_card_content.jsx +17 -0
  25. data/app/pb_kits/playbook/pb_card/docs/_card_padding.jsx +23 -0
  26. data/app/pb_kits/playbook/pb_card/docs/_card_selected.jsx +14 -0
  27. data/app/pb_kits/playbook/pb_card/docs/_card_shadow.jsx +23 -0
  28. data/app/pb_kits/playbook/pb_card/docs/example.yml +4 -0
  29. data/app/pb_kits/playbook/pb_card/docs/index.js +4 -0
  30. data/app/pb_kits/playbook/pb_currency/_currency.jsx +67 -18
  31. data/app/pb_kits/playbook/pb_currency/docs/_currency_default.jsx +14 -1
  32. data/app/pb_kits/playbook/pb_currency/docs/_currency_large.jsx +28 -0
  33. data/app/pb_kits/playbook/pb_currency/docs/example.yml +2 -3
  34. data/app/pb_kits/playbook/pb_currency/docs/index.js +1 -0
  35. data/app/pb_kits/playbook/pb_dashboard_value/docs/_dashboard_value_default.jsx +1 -3
  36. data/app/pb_kits/playbook/pb_dashboard_value/docs/example.yml +0 -2
  37. data/app/pb_kits/playbook/pb_date/docs/_date_default.jsx +1 -1
  38. data/app/pb_kits/playbook/pb_icon/docs/_icon_default.jsx +1 -1
  39. data/app/pb_kits/playbook/pb_icon_circle/_icon_circle.jsx +1 -3
  40. data/app/pb_kits/playbook/pb_icon_value/docs/_icon_value_default.jsx +1 -3
  41. data/app/pb_kits/playbook/pb_label_pill/docs/_label_pill_default.jsx +1 -3
  42. data/app/pb_kits/playbook/pb_label_value/docs/_label_value_default.jsx +1 -3
  43. data/app/pb_kits/playbook/pb_line_graph/_line_graph.jsx +57 -25
  44. data/app/pb_kits/playbook/pb_line_graph/docs/{_rails.html.erb → _line_graph_default.html.erb} +0 -0
  45. data/app/pb_kits/playbook/pb_line_graph/docs/_line_graph_default.jsx +34 -0
  46. data/app/pb_kits/playbook/pb_line_graph/docs/example.yml +5 -2
  47. data/app/pb_kits/playbook/pb_line_graph/docs/index.js +1 -0
  48. data/app/pb_kits/playbook/pb_line_graph/lineGraphSettings.js +9 -9
  49. data/app/pb_kits/playbook/pb_list/docs/_list_default.jsx +1 -5
  50. data/app/pb_kits/playbook/pb_message/docs/_message_default.jsx +1 -3
  51. data/app/pb_kits/playbook/pb_online_status/docs/_online_status_default.jsx +1 -3
  52. data/app/pb_kits/playbook/pb_owner/docs/_owner_default.jsx +1 -3
  53. data/app/pb_kits/playbook/pb_owner_phone/docs/_owner_phone_default.jsx +1 -3
  54. data/app/pb_kits/playbook/pb_phone/docs/_phone_default.jsx +1 -3
  55. data/app/pb_kits/playbook/pb_pill/_pill.jsx +22 -16
  56. data/app/pb_kits/playbook/pb_pill/docs/_pill_default.jsx +21 -1
  57. data/app/pb_kits/playbook/pb_progress_simple/docs/_progress_simple_default.jsx +1 -3
  58. data/app/pb_kits/playbook/pb_section_separator/docs/_section_separator_default.jsx +1 -3
  59. data/app/pb_kits/playbook/pb_source/docs/_source_default.jsx +1 -3
  60. data/app/pb_kits/playbook/pb_star_rating/docs/_star_rating_default.jsx +1 -3
  61. data/app/pb_kits/playbook/pb_stat_change/docs/_stat_change_default.jsx +1 -3
  62. data/app/pb_kits/playbook/pb_stat_value/docs/_stat_value_default.jsx +1 -3
  63. data/app/pb_kits/playbook/pb_table/docs/example.yml +10 -10
  64. data/app/pb_kits/playbook/pb_time/docs/_time_default.html.erb +4 -9
  65. data/app/pb_kits/playbook/pb_time/docs/_time_default.jsx +1 -3
  66. data/app/pb_kits/playbook/pb_time/docs/_time_timestamp.html.erb +16 -0
  67. data/app/pb_kits/playbook/pb_time/docs/example.yml +4 -5
  68. data/app/pb_kits/playbook/pb_time/time.rb +19 -7
  69. data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_default.jsx +1 -3
  70. data/app/pb_kits/playbook/pb_title/_title.jsx +41 -30
  71. data/app/pb_kits/playbook/pb_title/docs/_title_light.jsx +1 -0
  72. data/app/pb_kits/playbook/pb_title_count/_title_count.scss +2 -2
  73. data/app/pb_kits/playbook/pb_title_count/docs/_title_count_default.jsx +1 -3
  74. data/app/pb_kits/playbook/pb_title_count/title_count.rb +1 -1
  75. data/app/pb_kits/playbook/pb_title_detail/docs/_title_detail_default.jsx +1 -3
  76. data/app/pb_kits/playbook/pb_toggle/_toggle.html.erb +2 -2
  77. data/app/pb_kits/playbook/pb_toggle/_toggle.scss +1 -0
  78. data/app/pb_kits/playbook/pb_toggle/docs/_toggle_default.jsx +1 -4
  79. data/app/pb_kits/playbook/pb_toggle/docs/_toggle_name.html.erb +25 -0
  80. data/app/pb_kits/playbook/pb_toggle/docs/example.yml +1 -1
  81. data/app/pb_kits/playbook/pb_toggle/toggle.rb +28 -11
  82. data/app/pb_kits/playbook/pb_user/docs/_user_default.jsx +1 -3
  83. data/app/pb_kits/playbook/pb_user_badge/docs/_user_badge_default.jsx +1 -3
  84. data/app/pb_kits/playbook/pb_vertical_nav/docs/_default_nav.jsx +1 -5
  85. data/lib/generators/kit/templates/kit_jsx.erb.tt +7 -29
  86. data/lib/playbook/version.rb +1 -1
  87. metadata +19 -7
  88. data/app/pb_kits/playbook/pb_button/docs/_button_dark.jsx +0 -14
  89. data/app/pb_kits/playbook/pb_button/docs/_button_light.jsx +0 -14
  90. data/app/pb_kits/playbook/pb_button/docs/_button_sizes.jsx +0 -14
  91. data/app/pb_kits/playbook/pb_line_graph/docs/_react.html.erb +0 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0a42e419ff336721df276fdf3b5b42e13645c628f60a08b07637934cc2d98974
4
- data.tar.gz: 2b58fa57e6183c3a85ecd8a9b5b8f37b1eebbc948f12cf0bb96e6794f60fe44a
3
+ metadata.gz: 61c58765172511056b14d6c3ecf08d6770d79ec343011f55da235ef43d337737
4
+ data.tar.gz: f7789d51bc27282142e0ad087f0b06337988409370aeaf1ab3be7c89a8e4b665
5
5
  SHA512:
6
- metadata.gz: '04357696dbf7422c03cb9743c7f9c580bd7ceb1f9ed0ca766fdc51dac963d84c4d032d5cee74548077c3eeeb8ab4911257a59062e3a433851d8b416af9cec0fa'
7
- data.tar.gz: 37d577d1189723e118498e326177ddaa7fc1d7041fa8217535bda8b10b45f564ee65eb0d0edcf7a955463f205ef4077dc90dad5b855568654fd4232028643fa5
6
+ metadata.gz: '068062e848cb483ce0e9c174a37eb4f3ba203ed06e113a7d79338267aa69b51d6f02580e6a443c76a757ca03f0053dd5f250a095a0b0f94a7fe23b11e808aef4'
7
+ data.tar.gz: 522f98246b9a15eced512ab65ceb75b155c9796514fc9822882b28f823674a210725749c998bf56c271fe4d24ccaafa3c0a69b07be5a34be5038bc23cb336d84
@@ -45,6 +45,9 @@ WebpackerReact.setup (input);
45
45
  import * as BarGraph from "pb_bar_graph/docs";
46
46
  WebpackerReact.setup (BarGraph);
47
47
 
48
+ import * as LineGraph from "pb_line_graph/docs";
49
+ WebpackerReact.setup (LineGraph);
50
+
48
51
  import * as Icon from "pb_icon/docs";
49
52
  WebpackerReact.setup (Icon);
50
53
 
@@ -10,6 +10,7 @@ import "./pb_table.js";
10
10
  import "./pb_avatar.js";
11
11
  import "./pb_input.js";
12
12
  import "./pb_bar_graph.js";
13
+ import "./pb_line_graph.js";
13
14
  import "./pb_icon.js";
14
15
  import "./pb_dashboard_value.js";
15
16
  import "./pb_time.js";
@@ -35,46 +35,35 @@ const PbStatus = ({ size, status } : { size: String, status: String }) => (
35
35
  <div className={`pb_online_status_kit_${status} size_${size}`}/>
36
36
  )
37
37
 
38
- class Avatar extends React.Component<AvatarProps> {
39
- static defaultProps = {
40
- name: null,
41
- size: 'md'
42
- }
43
-
44
- props: AvatarProps
45
-
46
- render() {
47
- const {
48
- className,
49
- name,
50
- size,
51
- status,
52
- url
53
- } = this.props
38
+ const Avatar = ({
39
+ className,
40
+ name=null,
41
+ size='md',
42
+ status,
43
+ url
44
+ }: AvatarProps) => {
45
+ const css = classnames([
46
+ `pb_avatar_kit`,
47
+ `avatar_${size}`,
48
+ className,
49
+ ])
54
50
 
55
- const css = classnames([
56
- `pb_avatar_kit`,
57
- `avatar_${size}`,
58
- className,
59
- ])
60
-
61
- return (
62
- <div className={css}
51
+ return (
52
+ <div className={css}
53
+ data-initials={initials(name)}
54
+ >
55
+ <div
56
+ className="avatar_wrapper"
63
57
  data-initials={initials(name)}
64
58
  >
65
- <div
66
- className="avatar_wrapper"
67
- data-initials={initials(name)}
68
- >
69
- {image(url, name)}
70
- </div>
71
- <PbStatus
72
- size={size}
73
- status={status}
74
- />
59
+ {image(url, name)}
75
60
  </div>
76
- )
77
- }
61
+ <PbStatus
62
+ size={size}
63
+ status={status}
64
+ />
65
+ </div>
66
+ )
78
67
  }
79
68
 
80
69
  export default Avatar
@@ -1,21 +1,61 @@
1
- import React from 'react';
2
- import PropTypes from "prop-types";
1
+ /* @flow */
3
2
 
4
- const propTypes = {
5
- className: PropTypes.string,
6
- id: PropTypes.string
7
- };
3
+ import React from 'react'
4
+
5
+ import pbChart from "../plugins/pb_chart_plugin.js"
6
+
7
+ type BarGraphProps = {
8
+ axisTitle: String,
9
+ chartData: Array<{
10
+ name: String,
11
+ data: Array<Number>,
12
+ }>,
13
+ className?: String,
14
+ id: Number,
15
+ pointStart: Number,
16
+ subTitle?: String,
17
+ title: String,
18
+ }
19
+
20
+ export default class BarGraph extends React.Component<BarGraphProps> {
21
+ static defaultProps = {
22
+ className: 'pb_bar_graph',
23
+ type: 'column',
24
+ }
25
+
26
+ componentDidMount() {
27
+ const {
28
+ axisTitle,
29
+ className,
30
+ chartData,
31
+ id,
32
+ pointStart,
33
+ subTitle,
34
+ title,
35
+ type,
36
+ } = this.props
37
+
38
+ new pbChart(`.${className}`, {
39
+ axisTitle: axisTitle,
40
+ chartData: chartData,
41
+ id: id,
42
+ pointStart: pointStart,
43
+ subtitle: subTitle,
44
+ type,
45
+ title: title,
46
+ })
47
+ }
48
+
49
+ props: BarGraphProps
8
50
 
9
- class BarGraph extends React.Component {
10
51
  render() {
52
+ const { className, id } = this.props
53
+
11
54
  return (
12
- <div className="pb_bar_graph">
13
- <div id="highcharts-5nzaf00-0" />
14
- </div>
55
+ <div
56
+ className={className}
57
+ id={id}
58
+ />
15
59
  )
16
60
  }
17
61
  }
18
-
19
- BarGraph.propTypes = propTypes;
20
-
21
- export default BarGraph;
@@ -1,24 +1,24 @@
1
- import commonSettings from "../pb_dashboard/commonSettings.js";
1
+ import commonSettings from "../pb_dashboard/commonSettings.js"
2
2
 
3
3
  const sizeColumns = function(highchart) {
4
- let column = highchart.plotOptions.column;
5
- let series = highchart.plotOptions.series;
4
+ let column = highchart.plotOptions.column
5
+ let series = highchart.plotOptions.series
6
6
 
7
- column.borderRadius = 0;
8
- column.pointPadding = 0.3;
9
- column.groupPadding = 0.2;
7
+ column.borderRadius = 0
8
+ column.pointPadding = 0.3
9
+ column.groupPadding = 0.2
10
10
 
11
- series.borderWidth = 0;
12
- series.shadow = false;
13
- series.pointPadding = 0.3;
14
- series.groupPadding = 0.2;
15
- series.borderWidth = 0;
16
- series.shadow = false;
17
- };
11
+ series.borderWidth = 0
12
+ series.shadow = false
13
+ series.pointPadding = 0.3
14
+ series.groupPadding = 0.2
15
+ series.borderWidth = 0
16
+ series.shadow = false
17
+ }
18
18
 
19
19
  const pbBarGraph = function(highchart) {
20
- commonSettings(highchart);
21
- sizeColumns(highchart);
22
- };
20
+ commonSettings(highchart)
21
+ sizeColumns(highchart)
22
+ }
23
23
 
24
- export default pbBarGraph;
24
+ export default pbBarGraph
@@ -15,6 +15,13 @@
15
15
  data: [18111]
16
16
  }] %>
17
17
 
18
- <%= pb_rails("bar_graph", props: { id: "bar-test", chart_data: data, point_start: "2012", title: 'Solar Employment Growth by Sector, 2010-2016', subtitle: 'Source: thesolarfoundation.com', axis_title: 'Number of Employees' } ) %>
18
+ <%= pb_rails("bar_graph", props: {
19
+ axis_title: 'Number of Employees',
20
+ chart_data: data,
21
+ id: "bar-test",
22
+ point_start: "2012",
23
+ subtitle: 'Source: thesolarfoundation.com',
24
+ title: 'Solar Employment Growth by Sector, 2010-2016'
25
+ }) %>
19
26
 
20
27
 
@@ -1,12 +1,34 @@
1
1
  import React from "react"
2
2
  import BarGraph from "../_bar_graph.jsx"
3
3
 
4
- function BarGraphDefault() {
5
- return (
6
- <div>
7
- <BarGraph />
8
- </div>
9
- )
10
- }
4
+ const chartData = [{
5
+ name: 'Installation',
6
+ data: [154175]
7
+ }, {
8
+ name: 'Manufacturing',
9
+ data: [40434]
10
+ }, {
11
+ name: 'Sales & Distribution',
12
+ data: [39387]
13
+ }, {
14
+ name: 'Project Development',
15
+ data: [34227]
16
+ }, {
17
+ name: 'Other',
18
+ data: [18111]
19
+ }]
11
20
 
12
- export default BarGraphDefault;
21
+ const BarGraphDefault = () => (
22
+ <div>
23
+ <BarGraph
24
+ axisTitle="Number of Employees"
25
+ chartData={chartData}
26
+ id="bar-test"
27
+ pointStart={2012}
28
+ subTitle="Source: thesolarfoundation.com"
29
+ title="Solar Employment Growth by Sector, 2010-2016"
30
+ />
31
+ </div>
32
+ )
33
+
34
+ export default BarGraphDefault
@@ -1,36 +1,49 @@
1
- import React, { Component } from "react";
2
- import PropTypes from "prop-types";
3
-
4
- const propTypes = {
5
- text: PropTypes.string.isRequired,
6
- tag: PropTypes.string,
7
- color: PropTypes.string,
8
- dark: PropTypes.bool
9
- };
10
-
11
- const defaultProps = {
12
- text: "Hello Body Component",
13
- tag: "p",
14
- color: "",
15
- dark: false
16
- };
17
-
18
- class Body extends Component {
19
- render() {
20
- const { tag, text, color, dark } = this.props;
21
- // If color prop is not an empty string then render the given class
22
- const colorstyle = color !== "" ? `_${color}` : "";
23
-
24
- // If dark prop is true add the '-dark' class
25
- const themestyle = dark === true ? "_dark" : "";
26
-
27
- const Tag = `${tag}`;
28
-
29
- return <Tag className={"body" + colorstyle + themestyle}>{text}</Tag>;
30
- }
1
+ /* @flow */
2
+
3
+ import React from 'react'
4
+ import classnames from 'classnames'
5
+
6
+ type BodyProps = {
7
+ className?: String,
8
+ children?: Array<React.ReactChild>,
9
+ color: 'light' | 'lighter',
10
+ dark?: Boolean,
11
+ status?: 'negative' | 'positive',
12
+ tag: String,
13
+ text?: String,
31
14
  }
32
15
 
33
- Body.propTypes = propTypes;
34
- Body.defaultProps = defaultProps;
16
+ const bodyCSS = ({
17
+ color='light',
18
+ dark=false,
19
+ status='',
35
20
 
36
- export default Body;
21
+ }: BodyProps) => {
22
+
23
+ const colorStyle = color !== '' ? `_${color}` : ''
24
+
25
+ const themeStyle = dark === true ? '_dark' : ''
26
+
27
+ const statusStyle = status !== '' ? `_${status}` : ''
28
+
29
+ return 'pb_body_kit' + colorStyle + themeStyle + statusStyle
30
+ }
31
+
32
+ const Body = (props: BodyProps) => {
33
+ const {
34
+ className,
35
+ children,
36
+ text,
37
+ tag='p',
38
+ } = props
39
+
40
+ const Tag = `${tag}`
41
+
42
+ return (
43
+ <Tag className={classnames(bodyCSS(props), className)}>
44
+ { text || children }
45
+ </Tag>
46
+ )
47
+ }
48
+
49
+ export default Body
@@ -7,6 +7,9 @@ function BodyDark() {
7
7
  <Body dark text="I am a body kit (Default)" />
8
8
  <Body dark color="light" text="I am a body kit (Light)" />
9
9
  <Body dark color="lighter" text="I am a body kit (Lighter)" />
10
+
11
+ <Body dark status="negative" text="I am a body kit (Status: negative)" />
12
+ <Body dark status="positive" text="I am a body kit (Status: positive)" />
10
13
  </div>
11
14
  )
12
15
  }
@@ -7,6 +7,9 @@ function BodyLight() {
7
7
  <Body text="I am a body kit (Default)" />
8
8
  <Body color="light" text="I am a body kit (Light)" />
9
9
  <Body color="lighter" text="I am a body kit (Lighter)" />
10
+
11
+ <Body status="negative" text="I am a body kit (Status: negative)" />
12
+ <Body status="positive" text="I am a body kit (Status: positive)" />
10
13
  </div>
11
14
  )
12
15
  }
@@ -1,40 +1,109 @@
1
- import React, { Component } from "react";
2
- import PropTypes from "prop-types";
3
-
4
- const propTypes = {
5
- text: PropTypes.string.isRequired,
6
- type: PropTypes.oneOf(["primary", "danger", "dashed"]),
7
- size: PropTypes.oneOf(["large", "medium", "small"]),
8
- dark: PropTypes.bool,
9
- wrapperclass: PropTypes.string,
10
- componentclass: PropTypes.string
11
- };
12
-
13
- const defaultProps = {
14
- text: "Button",
15
- type: null,
16
- size: null,
17
- dark: false,
18
- wrapperclass: 'kit_btn_wrapper',
19
- componentclass: ''
20
-
21
- };
22
-
23
- class Button extends Component {
24
- render() {
25
- const { text, type, size, dark, wrapperclass, componentclass} = this.props;
26
-
27
- return (
28
- <div className={wrapperclass}>
29
- <button className={'pb_button' + (type !== null ? `_${type}` : "" ) + (size !== null ? `_${size}` : "" ) + (dark === true ? "_dark" : "") + (componentclass !== "" ? `${componentclass}` : "" )}>
30
- <span>{text}</span>
31
- </button>
32
- </div>
33
- );
34
- }
1
+ /* @flow */
2
+
3
+ import React, { Component } from 'react'
4
+ import PropTypes from 'prop-types'
5
+
6
+ type ButtonPropTypes = {
7
+ aria?: {
8
+ label: String,
9
+ },
10
+ children?: Array<React.ReactChild>,
11
+ dark: Boolean,
12
+ disabled?: Boolean,
13
+ fixedWidth?: Boolean,
14
+ fullWidth?: Boolean,
15
+ icon?: String,
16
+ loading?: Boolean,
17
+ newWindow?: Boolean,
18
+ size: 'large' | 'medium' | 'small',
19
+ text?: String,
20
+ type: 'inline' | null,
21
+ variant: 'primary' | 'secondary' | 'link',
22
+ wrapperClass: String,
23
+ }
24
+
25
+ const buttonClassName = (props: ButtonPropTypes) => {
26
+ const {
27
+ dark=false,
28
+ disabled=false,
29
+ fullWidth=false,
30
+ loading=false,
31
+ size=null,
32
+ type='inline',
33
+ variant='primary',
34
+ } = props
35
+
36
+ let className = 'pb_button_kit'
37
+
38
+ className += `${variant !== null ? `_${variant}` : ''}`
39
+ className += `${type !== null ? `_${type}` : ''}`
40
+ className += `${size !== null ? `_${size}` : ''}`
41
+ className += `${dark === true ? '_dark' : ''}`
42
+ className += `${fullWidth ? '_block' : ''}`
43
+ className += disabled ? '_disabled' : '_enabled'
44
+ className += loading ? '_loading' : ''
45
+
46
+ return className
47
+ }
48
+
49
+ const buttonAriaProps = (props: ButtonPropTypes) => {
50
+ const { aria } = props
51
+ if(typeof aria !== "object") return {}
52
+ const { label } = aria
53
+
54
+ let ariaProps = {}
55
+
56
+ if(label !== null) ariaProps['aria-label'] = label
57
+
58
+ return ariaProps
35
59
  }
36
60
 
37
- Button.propTypes = propTypes;
38
- Button.defaultProps = defaultProps;
61
+ const Button = (props : ButtonPropTypes) => {
62
+ const {
63
+ aria={},
64
+ children,
65
+ icon=null,
66
+ loading=false,
67
+ link=null,
68
+ newWindow=false,
69
+ text,
70
+ } = props
71
+
72
+ const buttonAria = buttonAriaProps(props)
73
+ const css = buttonClassName(props)
74
+ const loadingIcon = <i className="pb_icon_kit far fa-spinner fa-fw fa-pulse loading-icon"/>
75
+
76
+ const content = (
77
+ <span className="pb_button_content">
78
+ <If condition={icon !== null}>
79
+ <i className={`pb_icon_kit far fa-${icon} fa-fw`}/>
80
+ </If>
81
+ <span>{text || children}</span>
82
+ </span>
83
+ )
84
+
85
+ return (
86
+ <If condition={link !== null}>
87
+ <a
88
+ {...buttonAria}
89
+ className={css}
90
+ href={link}
91
+ target={newWindow ? '_blank' : null}
92
+ >
93
+ <If condition={loading}>
94
+ {loadingIcon}
95
+ </If>
96
+ {content}
97
+ </a>
98
+ <Else/>
99
+ <button {...buttonAria} className={css}>
100
+ <If condition={loading}>
101
+ {loadingIcon}
102
+ </If>
103
+ {content}
104
+ </button>
105
+ </If>
106
+ )
107
+ }
39
108
 
40
- export default Button;
109
+ export default Button