playbook_ui 10.26.0.pre.alpha.sticky1 → 10.27.0.pre.datepicker1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (123) 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_avatar/_avatar.tsx +3 -3
  6. data/app/pb_kits/playbook/pb_background/{_background.jsx → _background.tsx} +20 -13
  7. data/app/pb_kits/playbook/pb_badge/{_badge.jsx → _badge.tsx} +14 -15
  8. data/app/pb_kits/playbook/pb_badge/docs/_badge_colors.jsx +1 -1
  9. data/app/pb_kits/playbook/pb_badge/docs/_badge_default.jsx +1 -1
  10. data/app/pb_kits/playbook/pb_badge/docs/_badge_rounded.jsx +1 -1
  11. data/app/pb_kits/playbook/pb_badge/docs/index.js +3 -3
  12. data/app/pb_kits/playbook/pb_body/_body.tsx +9 -9
  13. data/app/pb_kits/playbook/pb_button/{_button.jsx → _button.tsx} +65 -46
  14. data/app/pb_kits/playbook/pb_button/docs/_button_default.html.erb +1 -0
  15. data/app/pb_kits/playbook/pb_button/docs/_button_options.jsx +1 -1
  16. data/app/pb_kits/playbook/pb_caption/{_caption.jsx → _caption.tsx} +7 -8
  17. data/app/pb_kits/playbook/pb_card/{_card.jsx → _card.tsx} +24 -22
  18. data/app/pb_kits/playbook/pb_card/_card_mixin.scss +1 -0
  19. data/app/pb_kits/playbook/pb_card/docs/_card_background.jsx +1 -1
  20. data/app/pb_kits/playbook/pb_card/docs/_card_border_none.jsx +1 -1
  21. data/app/pb_kits/playbook/pb_card/docs/_card_border_radius.jsx +1 -1
  22. data/app/pb_kits/playbook/pb_card/docs/_card_light.jsx +1 -1
  23. data/app/pb_kits/playbook/pb_card/docs/_card_selected.jsx +1 -1
  24. data/app/pb_kits/playbook/pb_collapsible/child_kits/CollapsibleMain.jsx +4 -2
  25. data/app/pb_kits/playbook/pb_collapsible/collapsible_main.html.erb +1 -1
  26. data/app/pb_kits/playbook/pb_dashboard/pbChartsDarkTheme.js +37 -0
  27. data/app/pb_kits/playbook/pb_dashboard/pbChartsLightTheme.js +37 -0
  28. data/app/pb_kits/playbook/pb_date_picker/_date_picker.jsx +2 -2
  29. data/app/pb_kits/playbook/pb_date_picker/_date_picker.scss +1 -0
  30. data/app/pb_kits/playbook/pb_date_picker/date_picker.rb +3 -2
  31. data/app/pb_kits/playbook/pb_date_picker/date_picker_helper.js +16 -7
  32. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_default.html.erb +1 -1
  33. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_month_and_year.html.erb +1 -1
  34. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_month_and_year.jsx +1 -1
  35. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_month_and_year.md +1 -1
  36. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_week.html.erb +5 -0
  37. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_week.jsx +18 -0
  38. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_week.md +1 -0
  39. data/app/pb_kits/playbook/pb_date_picker/docs/example.yml +2 -0
  40. data/app/pb_kits/playbook/pb_date_picker/docs/index.js +1 -0
  41. data/app/pb_kits/playbook/pb_date_picker/sass_partials/_week_styles.scss +127 -0
  42. data/app/pb_kits/playbook/pb_flex/{_flex.jsx → _flex.tsx} +5 -5
  43. data/app/pb_kits/playbook/pb_form_pill/_form_pill.jsx +2 -2
  44. data/app/pb_kits/playbook/pb_highlight/_highlight.tsx +1 -1
  45. data/app/pb_kits/playbook/pb_icon/{_icon.jsx → _icon.tsx} +40 -30
  46. data/app/pb_kits/playbook/pb_image/_image.tsx +1 -1
  47. data/app/pb_kits/playbook/pb_pill/{_pill.jsx → _pill.tsx} +6 -8
  48. data/app/pb_kits/playbook/pb_pill/docs/_pill_default.jsx +1 -1
  49. data/app/pb_kits/playbook/pb_pill/docs/_pill_variants.jsx +1 -1
  50. data/app/pb_kits/playbook/pb_title/{_title.jsx → _title.tsx} +10 -12
  51. data/app/pb_kits/playbook/pb_title/title.test.js +2 -2
  52. data/app/pb_kits/playbook/pb_treemap_chart/_treemap_chart.jsx +79 -0
  53. data/app/pb_kits/playbook/pb_treemap_chart/docs/_description.md +5 -0
  54. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_colors.html.erb +37 -0
  55. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_colors.jsx +48 -0
  56. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_colors.md +2 -0
  57. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_default.html.erb +37 -0
  58. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_default.jsx +47 -0
  59. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_default.md +3 -0
  60. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_drillable.html.erb +79 -0
  61. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_drillable.jsx +90 -0
  62. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_drillable.md +1 -0
  63. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_grouped_data.html.erb +54 -0
  64. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_grouped_data.jsx +65 -0
  65. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_grouped_data.md +3 -0
  66. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_tooltip.html.erb +37 -0
  67. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_tooltip.jsx +48 -0
  68. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_tooltip.md +3 -0
  69. data/app/pb_kits/playbook/pb_treemap_chart/docs/example.yml +15 -0
  70. data/app/pb_kits/playbook/pb_treemap_chart/docs/index.js +5 -0
  71. data/app/pb_kits/playbook/pb_treemap_chart/treemap_chart.html.erb +1 -0
  72. data/app/pb_kits/playbook/pb_treemap_chart/treemap_chart.rb +43 -0
  73. data/app/pb_kits/playbook/pb_user/{_user.jsx → _user.tsx} +20 -24
  74. data/app/pb_kits/playbook/playbook-doc.js +2 -0
  75. data/app/pb_kits/playbook/playbook-rails-react-bindings.js +2 -0
  76. data/app/pb_kits/playbook/plugins/pb_chart.js +34 -0
  77. data/app/pb_kits/playbook/tokens/_colors.scss +2 -1
  78. data/app/pb_kits/playbook/tokens/_display.scss +13 -0
  79. data/app/pb_kits/playbook/tokens/_screen_sizes.scss +36 -0
  80. data/app/pb_kits/playbook/utilities/_align_content.scss +10 -29
  81. data/app/pb_kits/playbook/utilities/_align_items.scss +11 -35
  82. data/app/pb_kits/playbook/utilities/_align_self.scss +10 -29
  83. data/app/pb_kits/playbook/utilities/_display.scss +26 -2
  84. data/app/pb_kits/playbook/utilities/_flex.scss +19 -14
  85. data/app/pb_kits/playbook/utilities/_flex_direction.scss +7 -18
  86. data/app/pb_kits/playbook/utilities/_flex_grow.scss +5 -8
  87. data/app/pb_kits/playbook/utilities/_flex_shrink.scss +5 -8
  88. data/app/pb_kits/playbook/utilities/_flex_wrap.scss +6 -13
  89. data/app/pb_kits/playbook/utilities/_justify_content.scss +10 -23
  90. data/app/pb_kits/playbook/utilities/_justify_self.scss +9 -19
  91. data/app/pb_kits/playbook/utilities/_mixins.scss +26 -0
  92. data/app/pb_kits/playbook/utilities/_order.scss +17 -55
  93. data/app/pb_kits/playbook/utilities/globalProps.ts +150 -121
  94. data/app/pb_kits/playbook/utilities/test/globalProps/alignContent.test.js +37 -0
  95. data/app/pb_kits/playbook/utilities/test/globalProps/alignItems.test.js +36 -0
  96. data/app/pb_kits/playbook/utilities/test/globalProps/alignSelf.test.js +37 -0
  97. data/app/pb_kits/playbook/utilities/test/globalProps/display.test.js +38 -0
  98. data/app/pb_kits/playbook/utilities/test/globalProps/flex.test.js +64 -0
  99. data/app/pb_kits/playbook/utilities/test/globalProps/flexDirection.test.js +37 -0
  100. data/app/pb_kits/playbook/utilities/test/globalProps/flexGrow.test.js +35 -0
  101. data/app/pb_kits/playbook/utilities/test/globalProps/flexShrink.test.js +35 -0
  102. data/app/pb_kits/playbook/utilities/test/globalProps/flexWrap.test.js +37 -0
  103. data/app/pb_kits/playbook/utilities/test/globalProps/justifyContent.test.js +37 -0
  104. data/app/pb_kits/playbook/utilities/test/globalProps/justifySelf.test.js +37 -0
  105. data/app/pb_kits/playbook/utilities/test/globalProps/order.test.js +35 -0
  106. data/app/pb_kits/playbook/utilities/test-utils.js +2 -0
  107. data/app/pb_kits/playbook/utilities/text.ts +22 -0
  108. data/dist/reset.css +1 -60
  109. data/lib/playbook/align_content.rb +11 -3
  110. data/lib/playbook/align_items.rb +10 -2
  111. data/lib/playbook/align_self.rb +9 -1
  112. data/lib/playbook/display.rb +19 -7
  113. data/lib/playbook/flex.rb +9 -1
  114. data/lib/playbook/flex_direction.rb +10 -2
  115. data/lib/playbook/flex_grow.rb +9 -1
  116. data/lib/playbook/flex_shrink.rb +9 -1
  117. data/lib/playbook/flex_wrap.rb +10 -2
  118. data/lib/playbook/justify_content.rb +10 -2
  119. data/lib/playbook/justify_self.rb +9 -1
  120. data/lib/playbook/order.rb +10 -2
  121. data/lib/playbook/version.rb +2 -2
  122. metadata +52 -13
  123. 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: cf78ed906a18245b33919539767b4548820b23c2e88196f790cc4cc3c928dde4
4
- data.tar.gz: f4619a7704a66989d2dbc5221d904e0fe3bec27d6908ea8349247de683fc68b2
3
+ metadata.gz: c517f7625c3f51b1f4cd966d4cf0ec2eab5dab7aed441ac0c74fa169ea293ab9
4
+ data.tar.gz: 16896c8a9467b0ef2fca85c7261a329485554a5d668967fdde99d992d8908184
5
5
  SHA512:
6
- metadata.gz: 27b1b9f29f502c1fb95cb03b6bd623ecd0a0c90cb3aad20b95fb687c9048f37c3a3e7737f27d14f54719f1dd0afa3455cfc46f2fdd0470e70b1879db59cdb615
7
- data.tar.gz: 9d7a07450758941dc3c1427723d94508bfef0a9db8ebc227d5ad12af04556fc4fe2a5d0aaa12d7f273bcd3658b8c2733581b24ca4dba3ac4fed359fb2965ef56
6
+ metadata.gz: c8aac77540457b3598a3717f2a1d310f1ee16ffd907a3185a97bfd05bcd4ac123009c125feea7331fd161ef5475de268a747e4461cbc12dbdce1adcdc364da66
7
+ data.tar.gz: '0815ddd5e47e45d9fd9f312a7b80e1b3015a06e09834a9212758ed43222790a801564162b56bb07ef0d6be6f41f761eca44a8cc2ba8fd006885a5e3f073bdcec'
@@ -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
 
@@ -2,7 +2,7 @@ import React, { useState } from 'react'
2
2
  import classnames from 'classnames'
3
3
 
4
4
  import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
5
- import { globalProps } from '../utilities/globalProps'
5
+ import { globalProps, GlobalProps } from '../utilities/globalProps'
6
6
 
7
7
  import Image from '../pb_image/_image'
8
8
  import OnlineStatus from '../pb_online_status/_online_status'
@@ -18,14 +18,14 @@ type AvatarProps = {
18
18
  name: string,
19
19
  size?: "md" | "lg" | "sm" | "xl" | "xs" | "xxs",
20
20
  status: "away" | "offline" | "online",
21
- }
21
+ } & GlobalProps
22
22
 
23
23
  const firstTwoInitials = (name: string) =>
24
24
  name.split(/\s/).map((name) => name[0])
25
25
  .join('')
26
26
  .substring(0, 2)
27
27
 
28
- const Avatar = (props: AvatarProps) => {
28
+ const Avatar = (props: AvatarProps): React.ReactElement => {
29
29
  const {
30
30
  aria = {},
31
31
  className,
@@ -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'
@@ -2,14 +2,14 @@ import React from 'react'
2
2
  import classnames from 'classnames'
3
3
 
4
4
  import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
5
- import { globalProps } from '../utilities/globalProps'
5
+ import { globalProps, GlobalProps } from '../utilities/globalProps'
6
6
 
7
7
  import Highlight from '../pb_highlight/_highlight'
8
8
 
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},
@@ -20,7 +20,7 @@ type BodyProps = {
20
20
  tag?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'p' | 'span' | 'div',
21
21
  text?: string,
22
22
  variant: null | 'link',
23
- }
23
+ } & GlobalProps
24
24
 
25
25
  const Body = (props: BodyProps): React.ReactElement => {
26
26
  const {
@@ -56,12 +56,12 @@ const Body = (props: BodyProps): React.ReactElement => {
56
56
  id={id}
57
57
  >
58
58
  { highlighting && (
59
- <Highlight
60
- highlightedText={highlightedText}
61
- text={text}
62
- >
63
- {children}
64
- </Highlight>
59
+ <Highlight
60
+ highlightedText={highlightedText}
61
+ text={text}
62
+ >
63
+ {children}
64
+ </Highlight>
65
65
  ) }
66
66
  { !highlighting && (
67
67
  text || children
@@ -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,42 +1,43 @@
1
- /* @flow */
1
+ /* eslint-disable react/no-multi-comp */
2
2
 
3
3
  import React from 'react'
4
4
  import { get } from 'lodash'
5
5
  import classnames from 'classnames'
6
6
 
7
7
  import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
8
- import { globalProps } from '../utilities/globalProps'
9
- import { ProductColors, CategoryColors, BackgroundColors } from '../types'
8
+ import { GlobalProps, globalProps } from '../utilities/globalProps'
9
+ import type { ProductColors, CategoryColors, BackgroundColors } from '../types'
10
10
 
11
11
  type CardPropTypes = {
12
- aria?: object,
12
+ aria?: {[key: string]: string},
13
13
  background?: BackgroundColors | ProductColors | "none",
14
14
  borderNone?: boolean,
15
15
  borderRadius?: "xs" | "sm" | "md" | "lg" | "xl" | "none" | "rounded",
16
- children: array<React.ReactNode> | React.ReactNode,
16
+ children: React.ReactChild[] | React.ReactChild | number,
17
17
  className?: string,
18
- data?: object,
18
+ data?: {[key: string]: string},
19
19
  highlight?: {
20
20
  position?: "side" | "top",
21
21
  color?: string,
22
22
  },
23
+ length?: number,
23
24
  padding?: string,
24
25
  selected?: boolean,
25
26
  tag?: "div" | "section" | "footer" | "header" | "article" | "aside" | "main" | "nav",
26
- }
27
+ } & GlobalProps
27
28
 
28
29
  type CardHeaderProps = {
29
30
  headerColor?: BackgroundColors | ProductColors | CategoryColors | "none",
30
- children: array<React.ReactNode> | React.ReactNode,
31
+ children: React.ReactChild[] | React.ReactChild,
31
32
  className?: string,
32
33
  padding?: string,
33
- }
34
+ } & GlobalProps
34
35
 
35
36
  type CardBodyProps = {
36
- children: array<React.ReactNode> | React.ReactNode | string,
37
+ children: React.ReactChild[] | React.ReactChild | string,
37
38
  className?: string,
38
39
  padding?: string,
39
- }
40
+ } & GlobalProps
40
41
 
41
42
  // Header component
42
43
  const Header = (props: CardHeaderProps) => {
@@ -82,26 +83,27 @@ const Card = (props: CardPropTypes) => {
82
83
  const borderCSS = borderNone == true ? 'border_none' : ''
83
84
  const selectedCSS = selected == true ? 'selected' : 'deselected'
84
85
  const backgroundCSS = background == 'none' ? '' : `background_${background}`
85
- const cardCss = buildCss('pb_card_kit', selectedCSS, borderCSS, `border_radius_${borderRadius}`, backgroundCSS, {
86
- [`highlight_${highlight.position}`]: highlight.position,
87
- [`highlight_${highlight.color}`]: highlight.color,
88
- })
89
- const ariaProps = buildAriaProps(aria)
90
- 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)
91
92
 
92
93
  // coerce to array
93
- const cardChildren =
94
- typeof children === 'object' && children.length ? children : [children]
94
+ const cardChildren = React.Children.toArray(children)
95
95
 
96
- const subComponentTags = (tagName) => {
97
- return cardChildren.filter((c) => (
96
+ const subComponentTags = (tagName: string) => {
97
+ return cardChildren.filter((c: string) => (
98
98
  get(c, 'type.displayName') === tagName
99
99
  )).map((child, i) => {
100
+ if(React.isValidElement(child)) {
100
101
  return React.cloneElement(child, { key: `${tagName.toLowerCase()}-${i}` })
102
+ }
101
103
  })
102
104
  }
103
105
 
104
- const nonHeaderChildren = cardChildren.filter((child) => (get(child, 'type.displayName') !== 'Header'))
106
+ const nonHeaderChildren = cardChildren.filter((child: Node) => (get(child, 'type.displayName') !== 'Header'))
105
107
 
106
108
  const tagOptions = ['div', 'section', 'footer', 'header', 'article', 'aside', 'main', 'nav']
107
109
  const Tag = tagOptions.includes(tag) ? tag : 'div'
@@ -4,6 +4,7 @@
4
4
  @import "../tokens/colors";
5
5
  @import "../tokens/transition";
6
6
  @import "../tokens/animation-curves";
7
+ @import "../tokens/display";
7
8
 
8
9
  $pb_card_border_width: 1px;
9
10
  $pb_card_border_radius: $border_rad_heavier;
@@ -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 (