playbook_ui 10.26.0.pre.alpha3 → 10.26.0.pre.alpha5

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 (108) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/_playbook.scss +1 -0
  3. data/app/pb_kits/playbook/data/menu.yml +1 -0
  4. data/app/pb_kits/playbook/index.js +2 -1
  5. data/app/pb_kits/playbook/pb_background/{_background.jsx → _background.tsx} +20 -13
  6. data/app/pb_kits/playbook/pb_badge/{_badge.jsx → _badge.tsx} +14 -15
  7. data/app/pb_kits/playbook/pb_badge/docs/_badge_colors.jsx +1 -1
  8. data/app/pb_kits/playbook/pb_badge/docs/_badge_default.jsx +1 -1
  9. data/app/pb_kits/playbook/pb_badge/docs/_badge_rounded.jsx +1 -1
  10. data/app/pb_kits/playbook/pb_badge/docs/index.js +3 -3
  11. data/app/pb_kits/playbook/pb_body/_body.tsx +1 -1
  12. data/app/pb_kits/playbook/pb_button/{_button.jsx → _button.tsx} +65 -46
  13. data/app/pb_kits/playbook/pb_button/docs/_button_default.html.erb +1 -0
  14. data/app/pb_kits/playbook/pb_button/docs/_button_options.jsx +1 -1
  15. data/app/pb_kits/playbook/pb_caption/{_caption.jsx → _caption.tsx} +7 -8
  16. data/app/pb_kits/playbook/pb_card/{_card.jsx → _card.tsx} +23 -23
  17. data/app/pb_kits/playbook/pb_card/docs/_card_background.jsx +1 -1
  18. data/app/pb_kits/playbook/pb_card/docs/_card_border_none.jsx +1 -1
  19. data/app/pb_kits/playbook/pb_card/docs/_card_border_radius.jsx +1 -1
  20. data/app/pb_kits/playbook/pb_card/docs/_card_light.jsx +17 -2
  21. data/app/pb_kits/playbook/pb_card/docs/_card_selected.jsx +1 -1
  22. data/app/pb_kits/playbook/pb_collapsible/child_kits/CollapsibleMain.jsx +4 -2
  23. data/app/pb_kits/playbook/pb_collapsible/collapsible_main.html.erb +1 -1
  24. data/app/pb_kits/playbook/pb_dashboard/pbChartsDarkTheme.js +37 -0
  25. data/app/pb_kits/playbook/pb_dashboard/pbChartsLightTheme.js +37 -0
  26. data/app/pb_kits/playbook/pb_flex/{_flex.jsx → _flex.tsx} +5 -5
  27. data/app/pb_kits/playbook/pb_form_pill/_form_pill.jsx +2 -2
  28. data/app/pb_kits/playbook/pb_highlight/_highlight.tsx +1 -1
  29. data/app/pb_kits/playbook/pb_icon/{_icon.jsx → _icon.tsx} +40 -30
  30. data/app/pb_kits/playbook/pb_pill/{_pill.jsx → _pill.tsx} +6 -8
  31. data/app/pb_kits/playbook/pb_pill/docs/_pill_default.jsx +1 -1
  32. data/app/pb_kits/playbook/pb_pill/docs/_pill_variants.jsx +1 -1
  33. data/app/pb_kits/playbook/pb_table/docs/_table_sticky.md +7 -0
  34. data/app/pb_kits/playbook/pb_table/styles/_sticky_header.scss +6 -4
  35. data/app/pb_kits/playbook/pb_title/{_title.jsx → _title.tsx} +10 -12
  36. data/app/pb_kits/playbook/pb_title/title.test.js +2 -2
  37. data/app/pb_kits/playbook/pb_treemap_chart/_treemap_chart.jsx +79 -0
  38. data/app/pb_kits/playbook/pb_treemap_chart/docs/_description.md +5 -0
  39. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_colors.html.erb +37 -0
  40. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_colors.jsx +48 -0
  41. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_colors.md +2 -0
  42. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_default.html.erb +37 -0
  43. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_default.jsx +47 -0
  44. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_default.md +3 -0
  45. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_drillable.html.erb +79 -0
  46. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_drillable.jsx +90 -0
  47. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_drillable.md +1 -0
  48. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_grouped_data.html.erb +54 -0
  49. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_grouped_data.jsx +65 -0
  50. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_grouped_data.md +3 -0
  51. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_tooltip.html.erb +37 -0
  52. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_tooltip.jsx +48 -0
  53. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_tooltip.md +3 -0
  54. data/app/pb_kits/playbook/pb_treemap_chart/docs/example.yml +15 -0
  55. data/app/pb_kits/playbook/pb_treemap_chart/docs/index.js +5 -0
  56. data/app/pb_kits/playbook/pb_treemap_chart/treemap_chart.html.erb +1 -0
  57. data/app/pb_kits/playbook/pb_treemap_chart/treemap_chart.rb +43 -0
  58. data/app/pb_kits/playbook/pb_user/{_user.jsx → _user.tsx} +20 -24
  59. data/app/pb_kits/playbook/playbook-doc.js +2 -0
  60. data/app/pb_kits/playbook/playbook-rails-react-bindings.js +2 -0
  61. data/app/pb_kits/playbook/plugins/pb_chart.js +34 -0
  62. data/app/pb_kits/playbook/tokens/_colors.scss +2 -1
  63. data/app/pb_kits/playbook/tokens/_display.scss +3 -3
  64. data/app/pb_kits/playbook/tokens/_screen_sizes.scss +25 -5
  65. data/app/pb_kits/playbook/utilities/_align_content.scss +10 -29
  66. data/app/pb_kits/playbook/utilities/_align_items.scss +11 -35
  67. data/app/pb_kits/playbook/utilities/_align_self.scss +10 -29
  68. data/app/pb_kits/playbook/utilities/_display.scss +9 -42
  69. data/app/pb_kits/playbook/utilities/_flex.scss +19 -14
  70. data/app/pb_kits/playbook/utilities/_flex_direction.scss +7 -18
  71. data/app/pb_kits/playbook/utilities/_flex_grow.scss +5 -8
  72. data/app/pb_kits/playbook/utilities/_flex_shrink.scss +5 -8
  73. data/app/pb_kits/playbook/utilities/_flex_wrap.scss +6 -13
  74. data/app/pb_kits/playbook/utilities/_justify_content.scss +10 -23
  75. data/app/pb_kits/playbook/utilities/_justify_self.scss +9 -19
  76. data/app/pb_kits/playbook/utilities/_mixins.scss +26 -0
  77. data/app/pb_kits/playbook/utilities/_order.scss +17 -55
  78. data/app/pb_kits/playbook/utilities/globalProps.ts +127 -113
  79. data/app/pb_kits/playbook/utilities/test/globalProps/alignContent.test.js +37 -0
  80. data/app/pb_kits/playbook/utilities/test/globalProps/alignItems.test.js +36 -0
  81. data/app/pb_kits/playbook/utilities/test/globalProps/alignSelf.test.js +37 -0
  82. data/app/pb_kits/playbook/utilities/test/globalProps/display.test.js +38 -0
  83. data/app/pb_kits/playbook/utilities/test/globalProps/flex.test.js +64 -0
  84. data/app/pb_kits/playbook/utilities/test/globalProps/flexDirection.test.js +37 -0
  85. data/app/pb_kits/playbook/utilities/test/globalProps/flexGrow.test.js +35 -0
  86. data/app/pb_kits/playbook/utilities/test/globalProps/flexShrink.test.js +35 -0
  87. data/app/pb_kits/playbook/utilities/test/globalProps/flexWrap.test.js +37 -0
  88. data/app/pb_kits/playbook/utilities/test/globalProps/justifyContent.test.js +37 -0
  89. data/app/pb_kits/playbook/utilities/test/globalProps/justifySelf.test.js +37 -0
  90. data/app/pb_kits/playbook/utilities/test/globalProps/order.test.js +35 -0
  91. data/app/pb_kits/playbook/utilities/test-utils.js +2 -0
  92. data/app/pb_kits/playbook/utilities/text.ts +22 -0
  93. data/dist/reset.css +60 -1
  94. data/lib/playbook/align_content.rb +11 -3
  95. data/lib/playbook/align_items.rb +10 -2
  96. data/lib/playbook/align_self.rb +9 -1
  97. data/lib/playbook/display.rb +2 -4
  98. data/lib/playbook/flex.rb +9 -1
  99. data/lib/playbook/flex_direction.rb +10 -2
  100. data/lib/playbook/flex_grow.rb +9 -1
  101. data/lib/playbook/flex_shrink.rb +9 -1
  102. data/lib/playbook/flex_wrap.rb +10 -2
  103. data/lib/playbook/justify_content.rb +10 -2
  104. data/lib/playbook/justify_self.rb +9 -1
  105. data/lib/playbook/order.rb +10 -2
  106. data/lib/playbook/version.rb +2 -2
  107. metadata +47 -13
  108. data/app/pb_kits/playbook/utilities/text.js +0 -15
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eec4050a38ffdbc91288fa4d1ebe864edc0485bf814f1569b50a4df569e6c666
4
- data.tar.gz: 5967691eccad475c60406d60b9aca79ee520a2736bfde034b48e6db8c1de3316
3
+ metadata.gz: 045be6d1cc5d7923963af542060ef78d8a45fc31c65eebb95923a18ab641c26e
4
+ data.tar.gz: 435afe93b7139f04a498ed7ce11091061cdb8e1a3d471f31d9dc9bbad937d0d1
5
5
  SHA512:
6
- metadata.gz: 8ea97fd90f89882ee7e54d80b46e468fa5beffa6ee2e9dc64475e14ebfe4cdcfef43dcf6b3dd0ab06db030da9fb04f4e35fae1e35dcba93a8009a80200d24fd5
7
- data.tar.gz: edbf22cf4988bf3ddc4f7872dce6fe51041dd8a8a657bd8b118196fe42c8a0c06428fbc5a1efcec55525d6ae4b769279a3438b12ad174d2e52497b7610e2260d
6
+ metadata.gz: 05c0785c96569ca1bbbe5c1b84b6a9b4d0f475d5e77f6aa79d50d0e9508844b123312cf199b06d6a024cdba74fd2375ad491badb9ef17c3f64c93cdbe56a735e
7
+ data.tar.gz: ade48dc78c3998cf6483daae945badafbde0f2214fa902bbc17096166d7b4ea54cd66ad67eac20254ec4f1caa44238da44f96cb5c4cf16d5c020ff0d323bc06d
@@ -92,6 +92,7 @@
92
92
  @import 'pb_time_stacked/time_stacked';
93
93
  @import 'pb_walkthrough/walkthrough';
94
94
  @import 'pb_weekday_stacked/weekday_stacked';
95
+ @import './utilities/mixins';
95
96
  @import './utilities/spacing';
96
97
  @import './utilities/cursor';
97
98
  @import './utilities/max_width';
@@ -20,6 +20,7 @@ kits:
20
20
  - gauge
21
21
  - legend
22
22
  - line_graph
23
+ - treemap_chart
23
24
  - dialog
24
25
  - filter
25
26
  - fixed_confirmation_toast
@@ -4,7 +4,6 @@ import 'lazysizes/plugins/attrchange/ls.attrchange'
4
4
  import 'lazysizes'
5
5
 
6
6
  // vvv React Component JSX Imports from the React Kits vvv
7
- export { default as Walkthrough } from './pb_walkthrough/_walkthrough'
8
7
  export { default as Avatar } from './pb_avatar/_avatar'
9
8
  export { default as AvatarActionButton } from './pb_avatar_action_button/_avatar_action_button'
10
9
  export { default as Background } from './pb_background/_background'
@@ -98,9 +97,11 @@ export { default as Title } from './pb_title/_title'
98
97
  export { default as TitleCount } from './pb_title_count/_title_count'
99
98
  export { default as TitleDetail } from './pb_title_detail/_title_detail'
100
99
  export { default as Toggle } from './pb_toggle/_toggle'
100
+ export { default as TreemapChart } from './pb_treemap_chart/_treemap_chart'
101
101
  export { default as Typeahead } from './pb_typeahead/_typeahead'
102
102
  export { default as User } from './pb_user/_user'
103
103
  export { default as UserBadge } from './pb_user_badge/_user_badge'
104
+ export { default as Walkthrough } from './pb_walkthrough/_walkthrough'
104
105
  export { default as WeekdayStacked } from './pb_weekday_stacked/_weekday_stacked'
105
106
  // ^^^ React Component JSX Imports from the React Kits ^^^
106
107
 
@@ -1,26 +1,24 @@
1
- /* @flow */
2
-
3
1
  import React from 'react'
4
2
  import classnames from 'classnames'
5
3
  import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
6
- import { globalProps } from '../utilities/globalProps'
4
+ import { GlobalProps, globalProps } from '../utilities/globalProps'
7
5
 
8
6
  type BackgroundProps = {
9
7
  alt?: string,
10
- aria?: object,
8
+ aria?: {[key: string]: string},
11
9
  backgroundColor?: 'gradient' | 'dark' | 'light' | 'white' | 'success' | 'warning' | 'error' | 'info' | 'neutral' | 'primary' | 'category_1' | 'category_2' | 'category_3' | 'category_4' | 'category_5' | 'category_6' | 'category_7' | 'category_8' | 'category_9' | 'category_10' | 'category_11' | 'category_12' | 'category_13' | 'category_14' | 'category_15' | 'category_16' | 'category_17' | 'category_18' | 'category_19' | 'category_20' | 'category_21',
12
10
  backgroundRepeat?: 'repeat' | 'repeat-x' | 'repeat-y' | 'no-repeat' | 'space' | 'round' | 'initial' | 'inherit',
13
11
  backgroundSize?: 'auto' | 'cover' | 'contain',
14
- children?: array<React.ReactNode> | React.ReactNode,
12
+ children?: React.ReactChild[] | React.ReactNode,
15
13
  className?: string,
16
14
  customColor?: string,
17
- data?: object,
15
+ data?: {[key: string]: string},
18
16
  id?: string,
19
17
  imageUrl?: string,
20
18
  padding?: 'none' | 'xs' | 'sm' | 'md' | 'lg' | 'xl',
21
19
  tag?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'p' | 'span' | 'div',
22
20
  transition?: 'fade' | 'blur' | 'scale',
23
- }
21
+ } & GlobalProps
24
22
 
25
23
  const Background = (props: BackgroundProps) => {
26
24
  const {
@@ -49,11 +47,13 @@ const Background = (props: BackgroundProps) => {
49
47
  }
50
48
  const getBackgroundColor = customColor ? 'pb_background_custom_color' : `pb_background_color_${backgroundColor}`
51
49
  const classes = classnames(buildCss('pb_background_kit'), 'lazyload', backgroundStyle, transition, globalProps(props), getBackgroundColor, className)
52
- const Tag = `${tag}`
53
50
 
54
- return (
55
- <>
56
- <If condition={imageUrl}>
51
+
52
+ const Tag: React.ReactElement | any = `${tag}`
53
+
54
+ const displayReturn = () => {
55
+ if (imageUrl)
56
+ return (
57
57
  <Tag
58
58
  alt={alt}
59
59
  style={backgroundStyle}
@@ -64,7 +64,9 @@ const Background = (props: BackgroundProps) => {
64
64
  >
65
65
  { children }
66
66
  </Tag>
67
- <Else />
67
+ )
68
+ else
69
+ return (
68
70
  <Tag
69
71
  {...ariaProps}
70
72
  {...dataProps}
@@ -74,7 +76,12 @@ const Background = (props: BackgroundProps) => {
74
76
  >
75
77
  { children }
76
78
  </Tag>
77
- </If>
79
+ )
80
+ }
81
+
82
+ return (
83
+ <>
84
+ { displayReturn() }
78
85
  </>
79
86
  )
80
87
  }
@@ -1,9 +1,7 @@
1
- /* @flow */
2
-
3
1
  import React from 'react'
4
2
  import classnames from 'classnames'
5
3
 
6
- import { globalProps } from '../utilities/globalProps'
4
+ import { GlobalProps, globalProps } from '../utilities/globalProps'
7
5
  import {
8
6
  buildAriaProps,
9
7
  buildCss,
@@ -13,21 +11,22 @@ import {
13
11
  import Icon from '../pb_icon/_icon'
14
12
 
15
13
  type BadgeProps = {
16
- aria?: object,
14
+ aria?: {[key: string]: string},
17
15
  className?: string,
18
16
  closeProps?: {
19
- onClick?: EventHandler,
20
- onMouseDown?: EventHandler,
21
- onTouchEnd?: EventHandler,
17
+ onClick?: React.MouseEventHandler<HTMLSpanElement>,
18
+ onMouseDown?: React.MouseEventHandler<HTMLSpanElement>,
19
+ onTouchEnd?: React.TouchEventHandler<HTMLSpanElement>,
22
20
  },
23
- data?: object,
21
+ data?: {[key: string]: string},
24
22
  id?: string,
25
- removeIcon?: Boolean,
26
- removeOnClick?: EventHandler,
23
+ removeIcon?: boolean,
24
+ removeOnClick?: React.MouseEventHandler<HTMLSpanElement>,
27
25
  rounded?: boolean,
28
26
  text?: string,
29
27
  variant?: "error" | "info" | "neutral" | "primary" | "success" | "warning",
30
- }
28
+ } & GlobalProps
29
+
31
30
  const Badge = (props: BadgeProps) => {
32
31
  const {
33
32
  aria = {},
@@ -36,7 +35,7 @@ const Badge = (props: BadgeProps) => {
36
35
  data = {},
37
36
  id,
38
37
  removeIcon = false,
39
- removeOnClick = () => {},
38
+ removeOnClick,
40
39
  rounded = false,
41
40
  text,
42
41
  variant = 'neutral',
@@ -44,7 +43,7 @@ const Badge = (props: BadgeProps) => {
44
43
  const ariaProps = buildAriaProps(aria)
45
44
  const dataProps = buildDataProps(data)
46
45
  const css = classnames(
47
- buildCss('pb_badge_kit', variant, { rounded }),
46
+ buildCss('pb_badge_kit', variant, rounded ? 'rounded' : null),
48
47
  globalProps(props),
49
48
  className
50
49
  )
@@ -58,7 +57,7 @@ const Badge = (props: BadgeProps) => {
58
57
  >
59
58
  <span>
60
59
  {text}
61
- <If condition={removeIcon}>
60
+ {removeIcon && (
62
61
  <span
63
62
  onClick={removeOnClick}
64
63
  style={{ cursor: 'pointer' }}
@@ -69,7 +68,7 @@ const Badge = (props: BadgeProps) => {
69
68
  icon="times"
70
69
  />
71
70
  </span>
72
- </If>
71
+ )}
73
72
  </span>
74
73
  </div>
75
74
  )
@@ -1,5 +1,5 @@
1
1
  import React from 'react'
2
- import Badge from '../_badge.jsx'
2
+ import Badge from '../_badge'
3
3
 
4
4
  const BadgeColors = (props) => {
5
5
  return (
@@ -1,5 +1,5 @@
1
1
  import React from 'react'
2
- import Badge from '../_badge.jsx'
2
+ import Badge from '../_badge'
3
3
 
4
4
  const BadgeDefault = (props) => {
5
5
  return (
@@ -1,5 +1,5 @@
1
1
  import React from 'react'
2
- import Badge from '../_badge.jsx'
2
+ import Badge from '../_badge'
3
3
 
4
4
  const BadgeRounded = (props) => {
5
5
  return (
@@ -1,3 +1,3 @@
1
- export { default as BadgeDefault } from './_badge_default.jsx'
2
- export { default as BadgeRounded } from './_badge_rounded.jsx'
3
- export { default as BadgeColors } from './_badge_colors.jsx'
1
+ export { default as BadgeDefault } from './_badge_default'
2
+ export { default as BadgeRounded } from './_badge_rounded'
3
+ export { default as BadgeColors } from './_badge_colors'
@@ -9,7 +9,7 @@ import Highlight from '../pb_highlight/_highlight'
9
9
  type BodyProps = {
10
10
  aria?: {[key: string]: string},
11
11
  className?: string,
12
- children?: React.ReactChild[],
12
+ children?: React.ReactChild[] | React.ReactChild,
13
13
  color?: 'default' | 'light' | 'lighter' | 'link',
14
14
  dark?: boolean,
15
15
  data?: {[key: string]: string},
@@ -1,18 +1,17 @@
1
- /* @flow */
2
-
3
1
  import React from 'react'
4
2
  import classnames from 'classnames'
5
3
  import { buildAriaProps, buildDataProps } from '../utilities/props'
6
- import { globalProps } from '../utilities/globalProps'
4
+ import { GlobalProps, globalProps } from '../utilities/globalProps'
5
+
6
+ import Icon from '../pb_icon/_icon'
7
7
 
8
- import Icon from '../pb_icon/_icon.jsx'
8
+ type EventHandler = (React.MouseEventHandler<HTMLElement>)
9
9
 
10
- type EventHandler = (SyntheticInputEvent<HTMLInputElement>) => void
11
10
  type ButtonPropTypes = {
12
- aria?: object,
13
- children?: array<React.ReactChild>,
14
- className?: string | array<string>,
15
- data?: object,
11
+ aria?: {[key: string]: string},
12
+ children?: React.ReactChild[] | React.ReactChild,
13
+ className?: string | string[],
14
+ data?: {[key: string]: string},
16
15
  disabled?: boolean,
17
16
  fixedWidth?: boolean,
18
17
  form?: string,
@@ -26,11 +25,11 @@ type ButtonPropTypes = {
26
25
  size?: 'sm' | 'md' | 'lg',
27
26
  text?: string,
28
27
  type: 'inline' | null,
29
- htmlType: string | 'button',
28
+ htmlType: 'submit' | 'reset' | 'button' | undefined,
30
29
  value?: string | null,
31
30
  variant: 'primary' | 'secondary' | 'link',
32
31
  wrapperClass: string,
33
- }
32
+ } & GlobalProps
34
33
 
35
34
  const buttonClassName = (props: ButtonPropTypes) => {
36
35
  const {
@@ -64,7 +63,7 @@ const Button = (props: ButtonPropTypes) => {
64
63
  icon = null,
65
64
  id,
66
65
  loading = false,
67
- onClick = () => {},
66
+ onClick,
68
67
  link = null,
69
68
  newWindow = false,
70
69
  text,
@@ -92,46 +91,66 @@ const Button = (props: ButtonPropTypes) => {
92
91
 
93
92
  const content = (
94
93
  <span className="pb_button_content">
95
- <If condition={icon !== null}>
94
+ {icon && (
96
95
  <i className={`pb_icon_kit far fa-${icon} fa-fw`} />
97
- {' '}
98
- </If>
96
+ )}
99
97
  <span>{text || children}</span>
100
98
  </span>
101
99
  )
102
100
 
101
+ const ifLoading = () => {
102
+ if (loading){
103
+ return(
104
+ <>
105
+ {loadingIcon}
106
+ </>
107
+ )
108
+ } else {
109
+ return (
110
+ content
111
+ )
112
+ }
113
+ }
114
+
115
+ const displayButton = () => {
116
+ if (link)
117
+ return (
118
+ <a
119
+ {...ariaProps}
120
+ {...dataProps}
121
+ className={css}
122
+ href={link}
123
+ id={id}
124
+ rel="noreferrer"
125
+ role="link"
126
+ target={newWindow ? '_blank' : null}
127
+ >
128
+ {ifLoading()}
129
+ </a>
130
+ )
131
+ else
132
+ return (
133
+ <button
134
+ {...ariaProps}
135
+ {...dataProps}
136
+ className={css}
137
+ disabled={disabled}
138
+ form={form}
139
+ id={id}
140
+ onClick={onClick}
141
+ role="button"
142
+ type={htmlType}
143
+ value={value}
144
+ >
145
+ {ifLoading()}
146
+ </button>
147
+ )
148
+ }
149
+
103
150
  return (
104
- <If condition={link !== null}>
105
- <a
106
- {...ariaProps}
107
- {...dataProps}
108
- className={css}
109
- href={link}
110
- id={id}
111
- rel="noreferrer"
112
- role="link"
113
- target={newWindow ? '_blank' : null}
114
- >
115
- <If condition={loading}>{loadingIcon}</If>
116
- {content}
117
- </a>
118
- <Else />
119
- <button
120
- {...ariaProps}
121
- {...dataProps}
122
- className={css}
123
- disabled={disabled}
124
- form={form}
125
- id={id}
126
- onClick={onClick}
127
- role="button"
128
- type={htmlType}
129
- value={value}
130
- >
131
- <If condition={loading}>{loadingIcon}</If>
132
- {content}
133
- </button>
134
- </If>
151
+ <>
152
+ {displayButton()}
153
+ </>
135
154
  )
136
155
  }
137
156
 
@@ -2,3 +2,4 @@
2
2
  <%= pb_rails("button", props: { text: "Button Secondary", variant: "secondary" }) %>
3
3
  <%= pb_rails("button", props: { text: "Button Link", variant: "link" }) %>
4
4
  <%= pb_rails("button", props: { text: "Button Disabled", disabled: true }) %>
5
+
@@ -1,5 +1,5 @@
1
1
  import React from 'react'
2
- import Button from '../_button.jsx'
2
+ import Button from '../_button'
3
3
 
4
4
  const ButtonOptions = (props) => (
5
5
  <div>
@@ -1,24 +1,22 @@
1
- /* @flow */
2
-
3
1
  import React from 'react'
4
2
  import classnames from 'classnames'
5
3
  import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
6
- import { deprecatedProps, globalProps } from '../utilities/globalProps'
4
+ import { deprecatedProps, globalProps, GlobalProps } from '../utilities/globalProps'
7
5
 
8
6
  type CaptionProps = {
9
- aria?: object,
10
- children: array<React.ReactNode> | React.ReactNode,
7
+ aria?: {[key: string]: string},
8
+ children: React.ReactChild[],
11
9
  className?: string,
12
10
  color?: "default" | "light" | "lighter" | "success" | "error" | "link",
13
- data?: object,
11
+ data?: {[key: string]: string},
14
12
  id?: string,
15
13
  size?: "xs" | "sm" | "md" | "lg" | "xl",
16
14
  tag?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "p" | "span" | "div" | "caption",
17
15
  text?: string,
18
16
  variant?: null | "link",
19
- };
17
+ } & GlobalProps;
20
18
 
21
- const Caption = (props: CaptionProps) => {
19
+ const Caption = (props: CaptionProps): React.ReactElement => {
22
20
  if (props.variant) deprecatedProps('Title', ['variant']) //variant prop is deprecated, use color instead
23
21
  const {
24
22
  aria = {},
@@ -32,6 +30,7 @@ const Caption = (props: CaptionProps) => {
32
30
  text,
33
31
  variant = null,
34
32
  } = props
33
+
35
34
  const tagOptions = [
36
35
  'h1',
37
36
  'h2',
@@ -1,43 +1,43 @@
1
1
  /* eslint-disable react/no-multi-comp */
2
- /* @flow */
3
2
 
4
3
  import React from 'react'
5
4
  import { get } from 'lodash'
6
5
  import classnames from 'classnames'
7
6
 
8
7
  import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
9
- import { globalProps } from '../utilities/globalProps'
8
+ import { GlobalProps, globalProps } from '../utilities/globalProps'
10
9
  import { ProductColors, CategoryColors, BackgroundColors } from '../types'
11
10
 
12
11
  type CardPropTypes = {
13
- aria?: object,
12
+ aria?: {[key: string]: string},
14
13
  background?: BackgroundColors | ProductColors | "none",
15
14
  borderNone?: boolean,
16
15
  borderRadius?: "xs" | "sm" | "md" | "lg" | "xl" | "none" | "rounded",
17
- children: array<React.ReactNode> | React.ReactNode,
16
+ children: React.ReactChild[] | React.ReactChild | number,
18
17
  className?: string,
19
- data?: object,
18
+ data?: {[key: string]: string},
20
19
  highlight?: {
21
20
  position?: "side" | "top",
22
21
  color?: string,
23
22
  },
23
+ length?: number,
24
24
  padding?: string,
25
25
  selected?: boolean,
26
26
  tag?: "div" | "section" | "footer" | "header" | "article" | "aside" | "main" | "nav",
27
- }
27
+ } & GlobalProps
28
28
 
29
29
  type CardHeaderProps = {
30
30
  headerColor?: BackgroundColors | ProductColors | CategoryColors | "none",
31
- children: array<React.ReactNode> | React.ReactNode,
31
+ children: React.ReactChild[] | React.ReactChild,
32
32
  className?: string,
33
- padding?: string
34
- }
33
+ padding?: string,
34
+ } & GlobalProps
35
35
 
36
36
  type CardBodyProps = {
37
- children: array<React.ReactNode> | React.ReactNode | string,
37
+ children: React.ReactChild[] | React.ReactChild | string,
38
38
  className?: string,
39
39
  padding?: string,
40
- }
40
+ } & GlobalProps
41
41
 
42
42
  // Header component
43
43
  const Header = (props: CardHeaderProps) => {
@@ -57,7 +57,6 @@ const Header = (props: CardHeaderProps) => {
57
57
  const Body = (props: CardBodyProps) => {
58
58
  const { children, padding = 'md', className } = props
59
59
  const bodyCSS = buildCss('pb_card_body_kit')
60
-
61
60
  const bodySpacing = globalProps(props, { padding })
62
61
 
63
62
  return (
@@ -84,26 +83,27 @@ const Card = (props: CardPropTypes) => {
84
83
  const borderCSS = borderNone == true ? 'border_none' : ''
85
84
  const selectedCSS = selected == true ? 'selected' : 'deselected'
86
85
  const backgroundCSS = background == 'none' ? '' : `background_${background}`
87
- const cardCss = buildCss('pb_card_kit', selectedCSS, borderCSS, `border_radius_${borderRadius}`, backgroundCSS, {
88
- [`highlight_${highlight.position}`]: highlight.position,
89
- [`highlight_${highlight.color}`]: highlight.color,
90
- })
91
- const ariaProps = buildAriaProps(aria)
92
- const dataProps = buildDataProps(data)
86
+ const cardCss = buildCss('pb_card_kit', selectedCSS, borderCSS, `border_radius_${borderRadius}`, backgroundCSS,
87
+ `highlight_${highlight.position}`,
88
+ `highlight_${highlight.color}`,
89
+ )
90
+ const ariaProps: {[key: string]: string} = buildAriaProps(aria)
91
+ const dataProps: {[key: string]: string} = buildDataProps(data)
93
92
 
94
93
  // coerce to array
95
- const cardChildren =
96
- typeof children === 'object' && children.length ? children : [children]
94
+ const cardChildren = React.Children.toArray(children)
97
95
 
98
- const subComponentTags = (tagName) => {
99
- return cardChildren.filter((c) => (
96
+ const subComponentTags = (tagName: string) => {
97
+ return cardChildren.filter((c: string) => (
100
98
  get(c, 'type.displayName') === tagName
101
99
  )).map((child, i) => {
100
+ if(React.isValidElement(child)) {
102
101
  return React.cloneElement(child, { key: `${tagName.toLowerCase()}-${i}` })
102
+ }
103
103
  })
104
104
  }
105
105
 
106
- const nonHeaderChildren = cardChildren.filter((child) => (get(child, 'type.displayName') !== 'Header'))
106
+ const nonHeaderChildren = cardChildren.filter((child: Node) => (get(child, 'type.displayName') !== 'Header'))
107
107
 
108
108
  const tagOptions = ['div', 'section', 'footer', 'header', 'article', 'aside', 'main', 'nav']
109
109
  const Tag = tagOptions.includes(tag) ? tag : 'div'
@@ -1,7 +1,7 @@
1
1
  import React from 'react'
2
2
  import Title from '../../pb_title/_title'
3
3
  import { Body } from '../../'
4
- import Card from '../_card.jsx'
4
+ import Card from '../_card'
5
5
 
6
6
  const CardBackground = (props) => {
7
7
  return (
@@ -1,5 +1,5 @@
1
1
  import React from 'react'
2
- import Card from '../_card.jsx'
2
+ import Card from '../_card'
3
3
 
4
4
  const CardBorderNone = (props) => {
5
5
  return (
@@ -1,5 +1,5 @@
1
1
  import React from 'react'
2
- import Card from '../_card.jsx'
2
+ import Card from '../_card'
3
3
 
4
4
  const CardLight = (props) => {
5
5
  return (
@@ -1,10 +1,25 @@
1
1
  import React from 'react'
2
- import Card from '../_card.jsx'
2
+ import Card from '../_card'
3
3
 
4
4
  const CardLight = (props) => {
5
5
  return (
6
6
  <div>
7
- <Card {...props}>{'Card content'}</Card>
7
+ <Card
8
+ flexDirection={{xs: "row", sm: "column", md: "rowReverse", lg: "columnReverse"}}
9
+ {...props}
10
+ >{'Card content'}</Card>
11
+ <Card
12
+ flexDirection="column"
13
+ {...props}
14
+ >{'Card content'}</Card>
15
+ <Card
16
+ flexDirection="rowReverse"
17
+ {...props}
18
+ >{'Card content'}</Card>
19
+ <Card
20
+ flexDirection="columnReverse"
21
+ {...props}
22
+ >{'Card content'}</Card>
8
23
  </div>
9
24
  )
10
25
  }
@@ -1,5 +1,5 @@
1
1
  import React from 'react'
2
- import Card from '../_card.jsx'
2
+ import Card from '../_card'
3
3
 
4
4
  const CardSelected = (props) => {
5
5
  return (
@@ -35,12 +35,14 @@ const Icon = ({ collapsed }: IconProps) => {
35
35
  const CollapsibleMain = ({
36
36
  children,
37
37
  className,
38
+ cursor = 'pointer',
38
39
  padding = 'md',
40
+
39
41
  ...props
40
42
  }: CollapsibleMainProps) => {
41
43
  const context = useContext(CollapsibleContext)
42
44
  const mainCSS = buildCss('pb_collapsible_main_kit')
43
- const mainSpacing = globalProps(props, { padding })
45
+ const mainSpacing = globalProps(props, { cursor, padding })
44
46
 
45
47
  return (
46
48
  <div className={classnames(mainCSS, className, mainSpacing)}>
@@ -50,7 +52,7 @@ const CollapsibleMain = ({
50
52
  vertical="center"
51
53
  >
52
54
  <FlexItem>{children}</FlexItem>
53
- <FlexItem><Icon collapsed={context.collapsed} /></FlexItem>
55
+ <FlexItem><Icon collapsed={context.collapsed}/></FlexItem>
54
56
  </Flex>
55
57
  </div>
56
58
  </div>
@@ -4,7 +4,7 @@
4
4
  class: object.classname,
5
5
  aria: object.aria) do %>
6
6
 
7
- <%= pb_rails("flex", props: {vertical: "center", spacing: "between"}) do %>
7
+ <%= pb_rails("flex", props: {vertical: "center", spacing: "between", cursor: "pointer"}) do %>
8
8
  <%= pb_rails("flex/flex_item") do %>
9
9
  <%= content.presence %>
10
10
  <% end %>