playbook_ui 10.26.0.pre.alpha.display1 → 10.26.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/_playbook.scss +1 -0
  3. data/app/pb_kits/playbook/pb_background/{_background.jsx → _background.tsx} +20 -13
  4. data/app/pb_kits/playbook/pb_badge/{_badge.jsx → _badge.tsx} +14 -15
  5. data/app/pb_kits/playbook/pb_badge/docs/_badge_colors.jsx +1 -1
  6. data/app/pb_kits/playbook/pb_badge/docs/_badge_default.jsx +1 -1
  7. data/app/pb_kits/playbook/pb_badge/docs/_badge_rounded.jsx +1 -1
  8. data/app/pb_kits/playbook/pb_badge/docs/index.js +3 -3
  9. data/app/pb_kits/playbook/pb_body/_body.tsx +1 -1
  10. data/app/pb_kits/playbook/pb_button/{_button.jsx → _button.tsx} +65 -46
  11. data/app/pb_kits/playbook/pb_button/docs/_button_default.html.erb +1 -0
  12. data/app/pb_kits/playbook/pb_button/docs/_button_options.jsx +1 -1
  13. data/app/pb_kits/playbook/pb_card/{_card.jsx → _card.tsx} +24 -24
  14. data/app/pb_kits/playbook/pb_card/docs/_card_background.jsx +1 -1
  15. data/app/pb_kits/playbook/pb_card/docs/_card_border_none.jsx +1 -1
  16. data/app/pb_kits/playbook/pb_card/docs/_card_border_radius.jsx +1 -1
  17. data/app/pb_kits/playbook/pb_card/docs/_card_light.jsx +1 -1
  18. data/app/pb_kits/playbook/pb_card/docs/_card_selected.jsx +1 -1
  19. data/app/pb_kits/playbook/pb_collapsible/child_kits/CollapsibleMain.jsx +4 -2
  20. data/app/pb_kits/playbook/pb_collapsible/collapsible_main.html.erb +1 -1
  21. data/app/pb_kits/playbook/pb_flex/{_flex.jsx → _flex.tsx} +5 -5
  22. data/app/pb_kits/playbook/pb_form_pill/_form_pill.jsx +1 -1
  23. data/app/pb_kits/playbook/pb_highlight/_highlight.tsx +1 -1
  24. data/app/pb_kits/playbook/pb_icon/{_icon.jsx → _icon.tsx} +40 -30
  25. data/app/pb_kits/playbook/pb_kit/dateTime.js +2 -1
  26. data/app/pb_kits/playbook/pb_pill/{_pill.jsx → _pill.tsx} +5 -7
  27. data/app/pb_kits/playbook/pb_pill/docs/_pill_default.jsx +1 -1
  28. data/app/pb_kits/playbook/pb_pill/docs/_pill_variants.jsx +1 -1
  29. data/app/pb_kits/playbook/pb_table/_table.jsx +3 -0
  30. data/app/pb_kits/playbook/pb_table/docs/_table_sticky.html.erb +83 -0
  31. data/app/pb_kits/playbook/pb_table/docs/_table_sticky.jsx +94 -0
  32. data/app/pb_kits/playbook/pb_table/docs/_table_sticky.md +10 -0
  33. data/app/pb_kits/playbook/pb_table/docs/example.yml +2 -0
  34. data/app/pb_kits/playbook/pb_table/docs/index.js +1 -0
  35. data/app/pb_kits/playbook/pb_table/styles/_all.scss +1 -0
  36. data/app/pb_kits/playbook/pb_table/styles/_sticky_header.scss +23 -0
  37. data/app/pb_kits/playbook/pb_table/table.rb +7 -1
  38. data/app/pb_kits/playbook/pb_table/table.test.js +17 -0
  39. data/app/pb_kits/playbook/pb_user/{_user.jsx → _user.tsx} +20 -24
  40. data/app/pb_kits/playbook/tokens/_colors.scss +2 -1
  41. data/app/pb_kits/playbook/tokens/_display.scss +1 -1
  42. data/app/pb_kits/playbook/tokens/_screen_sizes.scss +25 -5
  43. data/app/pb_kits/playbook/utilities/_align_content.scss +10 -29
  44. data/app/pb_kits/playbook/utilities/_align_items.scss +11 -35
  45. data/app/pb_kits/playbook/utilities/_align_self.scss +10 -29
  46. data/app/pb_kits/playbook/utilities/_display.scss +2 -36
  47. data/app/pb_kits/playbook/utilities/_flex.scss +19 -14
  48. data/app/pb_kits/playbook/utilities/_flex_direction.scss +7 -18
  49. data/app/pb_kits/playbook/utilities/_flex_grow.scss +5 -8
  50. data/app/pb_kits/playbook/utilities/_flex_shrink.scss +5 -8
  51. data/app/pb_kits/playbook/utilities/_flex_wrap.scss +6 -13
  52. data/app/pb_kits/playbook/utilities/_justify_content.scss +10 -23
  53. data/app/pb_kits/playbook/utilities/_justify_self.scss +9 -19
  54. data/app/pb_kits/playbook/utilities/_mixins.scss +26 -0
  55. data/app/pb_kits/playbook/utilities/_order.scss +17 -55
  56. data/app/pb_kits/playbook/utilities/globalProps.ts +125 -111
  57. data/app/pb_kits/playbook/utilities/test/globalProps/alignContent.test.js +37 -0
  58. data/app/pb_kits/playbook/utilities/test/globalProps/alignItems.test.js +36 -0
  59. data/app/pb_kits/playbook/utilities/test/globalProps/alignSelf.test.js +37 -0
  60. data/app/pb_kits/playbook/utilities/test/globalProps/display.test.js +38 -0
  61. data/app/pb_kits/playbook/utilities/test/globalProps/flex.test.js +64 -0
  62. data/app/pb_kits/playbook/utilities/test/globalProps/flexDirection.test.js +37 -0
  63. data/app/pb_kits/playbook/utilities/test/globalProps/flexGrow.test.js +35 -0
  64. data/app/pb_kits/playbook/utilities/test/globalProps/flexShrink.test.js +35 -0
  65. data/app/pb_kits/playbook/utilities/test/globalProps/flexWrap.test.js +37 -0
  66. data/app/pb_kits/playbook/utilities/test/globalProps/justifyContent.test.js +37 -0
  67. data/app/pb_kits/playbook/utilities/test/globalProps/justifySelf.test.js +37 -0
  68. data/app/pb_kits/playbook/utilities/test/globalProps/order.test.js +35 -0
  69. data/app/pb_kits/playbook/utilities/test-utils.js +2 -0
  70. data/app/pb_kits/playbook/utilities/text.ts +22 -0
  71. data/dist/reset.css +1 -60
  72. data/lib/playbook/align_content.rb +11 -3
  73. data/lib/playbook/align_items.rb +10 -2
  74. data/lib/playbook/align_self.rb +9 -1
  75. data/lib/playbook/display.rb +1 -3
  76. data/lib/playbook/flex.rb +9 -1
  77. data/lib/playbook/flex_direction.rb +10 -2
  78. data/lib/playbook/flex_grow.rb +9 -1
  79. data/lib/playbook/flex_shrink.rb +9 -1
  80. data/lib/playbook/flex_wrap.rb +10 -2
  81. data/lib/playbook/justify_content.rb +10 -2
  82. data/lib/playbook/justify_self.rb +9 -1
  83. data/lib/playbook/order.rb +10 -2
  84. data/lib/playbook/version.rb +2 -2
  85. metadata +32 -14
  86. 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: d4f47a9244130b0b201a8a8bfff26b8cda3de6efd934e0cbe2094c4a4a26bf56
4
- data.tar.gz: 9c4edb754d6fae9fbef2c6d6511f5e75cfb7972c0981eaef7c6e1cdba514d87f
3
+ metadata.gz: 8ed156e9b15608fb8116a723d8dca86eb5b4295d88698532dc4bf8242bcd3ef6
4
+ data.tar.gz: d5a5f5e68f1aeeafdd80dc066ee4be2271e7c4f8c666ef1ccf6ff205a98645ef
5
5
  SHA512:
6
- metadata.gz: d8a99fee564a9f31533369b6ee239271b919aca58a965bf50c94fa6ad962e2e363454a3653404157848649269e3556da7cd79a73eaa4454ee38781f121af0beb
7
- data.tar.gz: e41bcf582fc5d536d489dd09a841c896bf69bdd4f0efbe8500ac9f63fa0a0fa39f7082450a9c25cfbe5cd70d323563af877ef02ad0f8c999f1b32646650c0586
6
+ metadata.gz: 2e8aef1428a28b4c32bde81b9d61f76a4cdf02c6f5a08bb226ec4af88b86a83060f1322ed8e5033ba9a212c11fcef9e364d633505c42139beb7a9a167d0084ac
7
+ data.tar.gz: f58619e5f506e3d5c8dfbcab0605e65566c0a8e22dfdf73ac561a5391da2b02893aa95d2ec252ebc018b9ff8bcfcc9097086d2374c5c33fb53b01cb0d6578de2
@@ -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';
@@ -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,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'
10
- import { ProductColors, CategoryColors, BackgroundColors } from '../types'
8
+ import { GlobalProps, globalProps } from '../utilities/globalProps'
9
+ import type { 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,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,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 %>
@@ -1,11 +1,10 @@
1
- /* @flow */
2
-
3
1
  import React from 'react'
4
2
  import classnames from 'classnames'
5
3
  import { buildCss, buildDataProps } from '../utilities/props'
6
- import { globalProps } from '../utilities/globalProps'
4
+ import { GlobalProps, globalProps } from '../utilities/globalProps'
5
+
7
6
  type FlexProps = {
8
- children: array<React.ReactNode> | React.ReactNode,
7
+ children: React.ReactChild[] | React.ReactNode,
9
8
  className?: string,
10
9
  data?: object,
11
10
  horizontal?: "left" | "center" | "right" | "stretch" | "none",
@@ -22,7 +21,7 @@ type FlexProps = {
22
21
  columnGap?: "xs" | "sm" | "md" | "lg" | "xl" | "none",
23
22
  wrap?: boolean,
24
23
  alignSelf?: "start" | "end" | "center" | "stretch" | "none"
25
- }
24
+ } & GlobalProps
26
25
 
27
26
  const Flex = (props: FlexProps) => {
28
27
  const {
@@ -43,6 +42,7 @@ const Flex = (props: FlexProps) => {
43
42
  wrap = false,
44
43
  alignSelf = 'none',
45
44
  } = props
45
+
46
46
  const orientationClass =
47
47
  orientation !== undefined ? `orientation_${orientation}` : ''
48
48
  const justifyClass =
@@ -2,7 +2,7 @@
2
2
  import React from 'react'
3
3
  import classnames from 'classnames'
4
4
  import Title from '../pb_title/_title'
5
- import Icon from '../pb_icon/_icon.jsx'
5
+ import Icon from '../pb_icon/_icon'
6
6
  import Avatar from '../pb_avatar/_avatar'
7
7
  import { globalProps } from '../utilities/globalProps'
8
8
 
@@ -8,7 +8,7 @@ type HighlightProps = {
8
8
  className?: string,
9
9
  data?: {[key: string]: string},
10
10
  id?: string,
11
- children?: React.ReactChild[] | string,
11
+ children?: React.ReactChild[] | React.ReactChild | string,
12
12
  text?: string,
13
13
  highlightedText?: string[],
14
14
  } & GlobalProps