playbook_ui 10.26.0.pre.alpha.sticky1 → 10.26.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) 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} +20 -18
  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_flex/{_flex.jsx → _flex.tsx} +5 -5
  29. data/app/pb_kits/playbook/pb_form_pill/_form_pill.jsx +2 -2
  30. data/app/pb_kits/playbook/pb_highlight/_highlight.tsx +1 -1
  31. data/app/pb_kits/playbook/pb_icon/{_icon.jsx → _icon.tsx} +40 -30
  32. data/app/pb_kits/playbook/pb_image/_image.tsx +1 -1
  33. data/app/pb_kits/playbook/pb_pill/{_pill.jsx → _pill.tsx} +6 -8
  34. data/app/pb_kits/playbook/pb_pill/docs/_pill_default.jsx +1 -1
  35. data/app/pb_kits/playbook/pb_pill/docs/_pill_variants.jsx +1 -1
  36. data/app/pb_kits/playbook/pb_title/{_title.jsx → _title.tsx} +10 -12
  37. data/app/pb_kits/playbook/pb_title/title.test.js +2 -2
  38. data/app/pb_kits/playbook/pb_treemap_chart/_treemap_chart.jsx +79 -0
  39. data/app/pb_kits/playbook/pb_treemap_chart/docs/_description.md +5 -0
  40. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_colors.html.erb +37 -0
  41. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_colors.jsx +48 -0
  42. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_colors.md +2 -0
  43. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_default.html.erb +37 -0
  44. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_default.jsx +47 -0
  45. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_default.md +3 -0
  46. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_drillable.html.erb +79 -0
  47. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_drillable.jsx +90 -0
  48. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_drillable.md +1 -0
  49. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_grouped_data.html.erb +54 -0
  50. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_grouped_data.jsx +65 -0
  51. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_grouped_data.md +3 -0
  52. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_tooltip.html.erb +37 -0
  53. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_tooltip.jsx +48 -0
  54. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_tooltip.md +3 -0
  55. data/app/pb_kits/playbook/pb_treemap_chart/docs/example.yml +15 -0
  56. data/app/pb_kits/playbook/pb_treemap_chart/docs/index.js +5 -0
  57. data/app/pb_kits/playbook/pb_treemap_chart/treemap_chart.html.erb +1 -0
  58. data/app/pb_kits/playbook/pb_treemap_chart/treemap_chart.rb +43 -0
  59. data/app/pb_kits/playbook/pb_user/{_user.jsx → _user.tsx} +20 -24
  60. data/app/pb_kits/playbook/playbook-doc.js +2 -0
  61. data/app/pb_kits/playbook/playbook-rails-react-bindings.js +2 -0
  62. data/app/pb_kits/playbook/plugins/pb_chart.js +34 -0
  63. data/app/pb_kits/playbook/tokens/_colors.scss +2 -1
  64. data/app/pb_kits/playbook/tokens/_display.scss +13 -0
  65. data/app/pb_kits/playbook/tokens/_screen_sizes.scss +36 -0
  66. data/app/pb_kits/playbook/utilities/_align_content.scss +10 -29
  67. data/app/pb_kits/playbook/utilities/_align_items.scss +11 -35
  68. data/app/pb_kits/playbook/utilities/_align_self.scss +10 -29
  69. data/app/pb_kits/playbook/utilities/_display.scss +26 -2
  70. data/app/pb_kits/playbook/utilities/_flex.scss +19 -14
  71. data/app/pb_kits/playbook/utilities/_flex_direction.scss +7 -18
  72. data/app/pb_kits/playbook/utilities/_flex_grow.scss +5 -8
  73. data/app/pb_kits/playbook/utilities/_flex_shrink.scss +5 -8
  74. data/app/pb_kits/playbook/utilities/_flex_wrap.scss +6 -13
  75. data/app/pb_kits/playbook/utilities/_justify_content.scss +10 -23
  76. data/app/pb_kits/playbook/utilities/_justify_self.scss +9 -19
  77. data/app/pb_kits/playbook/utilities/_mixins.scss +26 -0
  78. data/app/pb_kits/playbook/utilities/_order.scss +17 -55
  79. data/app/pb_kits/playbook/utilities/globalProps.ts +150 -121
  80. data/app/pb_kits/playbook/utilities/props.ts +2 -2
  81. data/app/pb_kits/playbook/utilities/test/globalProps/alignContent.test.js +37 -0
  82. data/app/pb_kits/playbook/utilities/test/globalProps/alignItems.test.js +36 -0
  83. data/app/pb_kits/playbook/utilities/test/globalProps/alignSelf.test.js +37 -0
  84. data/app/pb_kits/playbook/utilities/test/globalProps/display.test.js +38 -0
  85. data/app/pb_kits/playbook/utilities/test/globalProps/flex.test.js +64 -0
  86. data/app/pb_kits/playbook/utilities/test/globalProps/flexDirection.test.js +37 -0
  87. data/app/pb_kits/playbook/utilities/test/globalProps/flexGrow.test.js +35 -0
  88. data/app/pb_kits/playbook/utilities/test/globalProps/flexShrink.test.js +35 -0
  89. data/app/pb_kits/playbook/utilities/test/globalProps/flexWrap.test.js +37 -0
  90. data/app/pb_kits/playbook/utilities/test/globalProps/justifyContent.test.js +37 -0
  91. data/app/pb_kits/playbook/utilities/test/globalProps/justifySelf.test.js +37 -0
  92. data/app/pb_kits/playbook/utilities/test/globalProps/order.test.js +35 -0
  93. data/app/pb_kits/playbook/utilities/test-utils.js +2 -0
  94. data/app/pb_kits/playbook/utilities/text.ts +22 -0
  95. data/dist/reset.css +1 -60
  96. data/lib/playbook/align_content.rb +11 -3
  97. data/lib/playbook/align_items.rb +10 -2
  98. data/lib/playbook/align_self.rb +9 -1
  99. data/lib/playbook/display.rb +19 -7
  100. data/lib/playbook/flex.rb +9 -1
  101. data/lib/playbook/flex_direction.rb +10 -2
  102. data/lib/playbook/flex_grow.rb +9 -1
  103. data/lib/playbook/flex_shrink.rb +9 -1
  104. data/lib/playbook/flex_wrap.rb +10 -2
  105. data/lib/playbook/justify_content.rb +10 -2
  106. data/lib/playbook/justify_self.rb +9 -1
  107. data/lib/playbook/order.rb +10 -2
  108. data/lib/playbook/pb_kit_helper.rb +6 -1
  109. data/lib/playbook/version.rb +2 -2
  110. metadata +52 -17
  111. data/app/pb_kits/playbook/utilities/text.js +0 -15
@@ -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 %>
@@ -209,6 +209,43 @@ const highchartsDarkTheme = {
209
209
  threshold: null,
210
210
  },
211
211
  },
212
+
213
+ //TREEMAP CHART STYLES
214
+ treemap: {
215
+ layoutAlgorithm: "squarified",
216
+ allowTraversingTree: false,
217
+ animationLimit: 1000,
218
+ colors: [
219
+ colors.data_1,
220
+ colors.data_2,
221
+ colors.data_3,
222
+ colors.data_4,
223
+ colors.data_5,
224
+ colors.data_6,
225
+ colors.data_7,
226
+ colors.data_8,
227
+ ],
228
+ colorByPoint: true,
229
+ dataLabels: {
230
+ enabled: true,
231
+ style: {
232
+ fontFamily: typography.font_family_base,
233
+ fontWeight: typography.bold,
234
+ fontSize: typography.heading_4,
235
+ },
236
+ },
237
+ levels: [
238
+ {
239
+ level: 1,
240
+ dataLabels: {
241
+ enabled: false,
242
+ },
243
+ },
244
+ ],
245
+ traverseUpButton: {
246
+ position: { y: -40 },
247
+ }
248
+ },
212
249
  },
213
250
  }
214
251
 
@@ -209,6 +209,43 @@ const highchartsTheme = {
209
209
  threshold: null,
210
210
  },
211
211
  },
212
+
213
+ //TREEMAP CHART STYLES
214
+ treemap: {
215
+ layoutAlgorithm: "squarified",
216
+ allowTraversingTree: false,
217
+ animationLimit: 1000,
218
+ colors: [
219
+ colors.data_1,
220
+ colors.data_2,
221
+ colors.data_3,
222
+ colors.data_4,
223
+ colors.data_5,
224
+ colors.data_6,
225
+ colors.data_7,
226
+ colors.data_8,
227
+ ],
228
+ colorByPoint: true,
229
+ dataLabels: {
230
+ enabled: true,
231
+ style: {
232
+ fontFamily: typography.font_family_base,
233
+ fontWeight: typography.bold,
234
+ fontSize: typography.heading_4,
235
+ },
236
+ },
237
+ levels: [
238
+ {
239
+ level: 1,
240
+ dataLabels: {
241
+ enabled: false,
242
+ },
243
+ },
244
+ ],
245
+ traverseUpButton: {
246
+ position: { y: -40 },
247
+ }
248
+ },
212
249
  },
213
250
  }
214
251
 
@@ -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 =
@@ -1,8 +1,8 @@
1
1
  /* @flow */
2
2
  import React from 'react'
3
3
  import classnames from 'classnames'
4
- import Title from '../pb_title/_title.jsx'
5
- import Icon from '../pb_icon/_icon.jsx'
4
+ import Title from '../pb_title/_title'
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
@@ -1,16 +1,14 @@
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'
7
5
 
8
6
  type IconProps = {
9
- aria?: object,
10
- border?: boolean,
7
+ aria?: {[key: string]: string},
8
+ border?: string,
11
9
  className?: string,
12
- customIcon?: SVGElement,
13
- data?: object,
10
+ customIcon?: {[key: string] :SVGElement},
11
+ data?: {[key: string]: string},
14
12
  fixedWidth?: boolean,
15
13
  flip?: "horizontal" | "vertical" | "both" | "none",
16
14
  icon: string,
@@ -34,12 +32,13 @@ type IconProps = {
34
32
  | "9x"
35
33
  | "10x",
36
34
  spin?: boolean,
37
- }
35
+ } & GlobalProps
38
36
 
39
37
  const flipMap = {
40
38
  horizontal: 'fa-flip-horizontal',
41
39
  vertical: 'fa-flip-vertical',
42
40
  both: 'fa-flip-horizontal fa-flip-vertical',
41
+ none: ""
43
42
  }
44
43
 
45
44
  const Icon = (props: IconProps) => {
@@ -50,7 +49,7 @@ const Icon = (props: IconProps) => {
50
49
  customIcon,
51
50
  data = {},
52
51
  fixedWidth = true,
53
- flip = false,
52
+ flip = "none",
54
53
  icon,
55
54
  id,
56
55
  inverse = false,
@@ -90,31 +89,42 @@ const Icon = (props: IconProps) => {
90
89
  )
91
90
 
92
91
  aria.label ? null : aria.label = `${icon} icon`
93
- const ariaProps = buildAriaProps(aria)
94
- const dataProps = buildDataProps(data)
92
+ const ariaProps: {[key: string]: any} = buildAriaProps(aria)
93
+ const dataProps: {[key: string]: any} = buildDataProps(data)
95
94
 
96
95
  // Add a conditional here to show only the SVG if custom
96
+ const displaySVG = (customIcon: any) => {
97
+ if (customIcon)
98
+ return (
99
+ <>
100
+ {
101
+ React.cloneElement(customIcon, {
102
+ ...dataProps,
103
+ className: classes,
104
+ id,
105
+ })
106
+ }
107
+ </>
108
+ )
109
+ else
110
+ return (
111
+ <>
112
+ <i
113
+ {...dataProps}
114
+ className={classes}
115
+ id={id}
116
+ />
117
+ <span
118
+ {...ariaProps}
119
+ hidden
120
+ />
121
+ </>
122
+ )
123
+ }
124
+
97
125
  return (
98
126
  <>
99
- <If condition={customIcon}>
100
- {
101
- React.cloneElement(customIcon, {
102
- ...dataProps,
103
- className: classes,
104
- id,
105
- })
106
- }
107
- <Else />
108
- <i
109
- {...dataProps}
110
- className={classes}
111
- id={id}
112
- />
113
- <span
114
- {...ariaProps}
115
- hidden
116
- />
117
- </If>
127
+ {displaySVG(customIcon)}
118
128
  </>
119
129
  )
120
130
  }
@@ -16,7 +16,7 @@ type ImageType = {
16
16
  url?: string,
17
17
  } & GlobalProps
18
18
 
19
- const Image = (props: ImageType) => {
19
+ const Image = (props: ImageType): React.ReactElement => {
20
20
  const {
21
21
  alt = '',
22
22
  aria = {},
@@ -1,21 +1,19 @@
1
- /* @flow */
2
-
3
1
  import React from 'react'
4
2
 
5
3
  import classnames from 'classnames'
6
- import Title from '../pb_title/_title.jsx'
4
+ import Title from '../pb_title/_title'
7
5
  import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
8
- import { globalProps } from '../utilities/globalProps'
6
+ import { GlobalProps, globalProps } from '../utilities/globalProps'
9
7
 
10
8
  type PillProps = {
11
- aria?: object,
9
+ aria?: {[key: string]: string},
12
10
  className?: string,
13
- data?: object,
11
+ data?: {[key: string]: string},
14
12
  id?: string,
15
13
  text: string,
16
14
  variant?: "success" | "warning" | "error" | "info" | "neutral",
17
15
  textTransform?: "none" | "lowercase"
18
- }
16
+ } & GlobalProps
19
17
 
20
18
  const Pill = (props: PillProps) => {
21
19
  const {
@@ -49,4 +47,4 @@ const Pill = (props: PillProps) => {
49
47
  )
50
48
  }
51
49
 
52
- export default Pill
50
+ export default Pill
@@ -1,5 +1,5 @@
1
1
  import React from 'react'
2
- import Pill from '../_pill.jsx'
2
+ import Pill from '../_pill'
3
3
 
4
4
  const PillDefault = (props) => {
5
5
  return (
@@ -1,5 +1,5 @@
1
1
  import React from 'react'
2
- import Pill from '../_pill.jsx'
2
+ import Pill from '../_pill'
3
3
 
4
4
  const PillVariants = (props) => {
5
5
  return (
@@ -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 TitleProps = {
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?: 1 | 2 | 3 | 4,
16
14
  tag?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "div" | "span",
17
15
  text?: string,
18
16
  variant?: null | "link",
19
- }
17
+ } & GlobalProps
20
18
 
21
- const Title = (props: TitleProps) => {
19
+ const Title = (props: TitleProps): React.ReactElement => {
22
20
  if (props.variant) deprecatedProps('Title', ['variant']) //variant prop is deprecated, use color instead
23
21
  const {
24
22
  aria = {},
@@ -33,14 +31,14 @@ const Title = (props: TitleProps) => {
33
31
  variant = null,
34
32
  } = props
35
33
 
36
- const ariaProps = buildAriaProps(aria)
37
- const dataProps = buildDataProps(data)
34
+ const ariaProps: {[key: string]: string | number} = buildAriaProps(aria)
35
+ const dataProps: {[key: string]: string | number} = buildDataProps(data)
38
36
  const classes = classnames(
39
- buildCss('pb_title_kit', size, variant, color),
37
+ buildCss('pb_title_kit', `size_${size}`, variant, color),
40
38
  globalProps(props),
41
39
  className,
42
40
  )
43
- const Tag = `${tag}`
41
+ const Tag: React.ReactElement | any = `${tag}`
44
42
 
45
43
  return (
46
44
  <Tag
@@ -12,7 +12,7 @@ test('returns namespaced class name', () => {
12
12
  )
13
13
 
14
14
  const kit = screen.getByTestId('primary-test')
15
- expect(kit).toHaveClass('pb_title_kit_3')
15
+ expect(kit).toHaveClass('pb_title_kit_size_3')
16
16
  })
17
17
 
18
18
  test('with colors', () => {
@@ -25,5 +25,5 @@ test('with colors', () => {
25
25
  )
26
26
 
27
27
  const kit = screen.getByTestId('primary-test')
28
- expect(kit).toHaveClass('pb_title_kit_3_success')
28
+ expect(kit).toHaveClass('pb_title_kit_size_3_success')
29
29
  })
@@ -0,0 +1,79 @@
1
+ /* @flow */
2
+
3
+ import React from 'react'
4
+ import classnames from 'classnames'
5
+
6
+ import { globalProps } from '../utilities/globalProps'
7
+ import pbChart from '../plugins/pb_chart'
8
+
9
+ type TreemapChartProps = {
10
+ chartData: array<{
11
+ name: string,
12
+ parent?: string | number,
13
+ value: number,
14
+ color?: string,
15
+ id?: string | number,
16
+ }>,
17
+ className?: string,
18
+ colors: array,
19
+ dark?: boolean,
20
+ drillable: boolean,
21
+ grouped: boolean,
22
+ height?: string,
23
+ id: number,
24
+ title: string,
25
+ tooltipHtml: string,
26
+ type?: string,
27
+ }
28
+
29
+ export default class TreemapChart extends React.Component<TreemapChartProps> {
30
+ static defaultProps = {
31
+ className: 'pb_treemap_chart',
32
+ dark: false,
33
+ drillable: false,
34
+ grouped: false,
35
+ type: 'treemap',
36
+ }
37
+
38
+ componentDidMount() {
39
+ const {
40
+ chartData,
41
+ className,
42
+ colors = [],
43
+ dark,
44
+ drillable,
45
+ grouped,
46
+ height,
47
+ id,
48
+ title = "",
49
+ tooltipHtml = '<span style="font-weight: bold; color:{point.color};">&#9679; </span>{point.name}: <b>{point.value}</b>',
50
+ type,
51
+ } = this.props
52
+
53
+ new pbChart(`.${className}`, {
54
+ chartData: chartData,
55
+ colors: colors,
56
+ dark,
57
+ drillable,
58
+ grouped,
59
+ height: height,
60
+ id: id,
61
+ title: title,
62
+ tooltipHtml,
63
+ type,
64
+ })
65
+ }
66
+
67
+ props: TreemapChartProps
68
+
69
+ render() {
70
+ const { className, id } = this.props
71
+
72
+ return (
73
+ <div
74
+ className={classnames(globalProps(this.props), className)}
75
+ id={id}
76
+ />
77
+ )
78
+ }
79
+ }
@@ -0,0 +1,5 @@
1
+ Treemap charts are used to compare the relative size of groups of data. They can also use a nested data structure, allowing a user to drill down into a group to see its constituent data points.
2
+
3
+ The default height of treemap is 400px and can be changed. The default height is in pixel units, but can also use percentage string (percentage would be that of the width. For example, `height:"50%"` would mean that the height is 50% of the width). This allows for preserving the aspect ratio across responsive sizes.
4
+
5
+ For more information, see: <a href="https://api.highcharts.com/highcharts/chart.height" target="_blank"> highcharts/chart.height</a>.
@@ -0,0 +1,37 @@
1
+ <% data = [
2
+ {
3
+ name: "Pepperoni",
4
+ parent: "Toppings",
5
+ value: 600,
6
+ }, {
7
+ name: "Cheese",
8
+ parent: "Toppings",
9
+ value: 510,
10
+ }, {
11
+ name: "Mushroom",
12
+ parent: "Toppings",
13
+ value: 330,
14
+ },{
15
+ name: "Onions",
16
+ parent: "Toppings",
17
+ value: 250,
18
+ }, {
19
+ name: "Olives",
20
+ parent: "Toppings",
21
+ value: 204,
22
+ }, {
23
+ name: "Pineapple",
24
+ parent: "Toppings",
25
+ value: 90,
26
+ }, {
27
+ name: "Pizza Toppings",
28
+ id: "Toppings",
29
+ },
30
+ ] %>
31
+
32
+ <%= pb_rails("treemap_chart", props: {
33
+ chart_data: data,
34
+ colors: ["data-4", "data-7", "#8E6E53", "#124732"],
35
+ id: "treemap-colors",
36
+ title: "Favored Pizza Toppings",
37
+ }) %>
@@ -0,0 +1,48 @@
1
+ import React from 'react'
2
+
3
+ import TreemapChart from '../_treemap_chart'
4
+
5
+ const chartData = [
6
+ {
7
+ name: "Pepperoni",
8
+ parent: "Toppings",
9
+ value: 600,
10
+ }, {
11
+ name: "Cheese",
12
+ parent: "Toppings",
13
+ value: 510,
14
+ }, {
15
+ name: "Mushroom",
16
+ parent: "Toppings",
17
+ value: 330,
18
+ },{
19
+ name: "Onions",
20
+ parent: "Toppings",
21
+ value: 250,
22
+ }, {
23
+ name: "Olives",
24
+ parent: "Toppings",
25
+ value: 204,
26
+ }, {
27
+ name: "Pineapple",
28
+ parent: "Toppings",
29
+ value: 90,
30
+ }, {
31
+ name: "Pizza Toppings",
32
+ id: "Toppings",
33
+ },
34
+ ]
35
+
36
+ const TreemapChartColors = (props) => (
37
+ <div>
38
+ <TreemapChart
39
+ chartData={chartData}
40
+ colors={["data-4", "data-7", "#8E6E53", "#124732"]}
41
+ id="treemap-colors"
42
+ title="Favored Pizza Toppings"
43
+ {...props}
44
+ />
45
+ </div>
46
+ )
47
+
48
+ export default TreemapChartColors
@@ -0,0 +1,2 @@
1
+ Custom data colors allow for color customization to match the needs of business requirements.
2
+ Pass the prop `colors` and use desired values `data-1 | data-2 | data-3 | data-4 | data-5 | data-6 | data-7 | data-8` in an array. Hex colors are also available `eg: #CA0095`
@@ -0,0 +1,37 @@
1
+ <% data = [
2
+ {
3
+ name: "Pepperoni",
4
+ parent: "Toppings",
5
+ value: 600,
6
+ }, {
7
+ name: "Cheese",
8
+ parent: "Toppings",
9
+ value: 510,
10
+ }, {
11
+ name: "Mushroom",
12
+ parent: "Toppings",
13
+ value: 330,
14
+ },{
15
+ name: "Onions",
16
+ parent: "Toppings",
17
+ value: 250,
18
+ }, {
19
+ name: "Olives",
20
+ parent: "Toppings",
21
+ value: 204,
22
+ }, {
23
+ name: "Pineapple",
24
+ parent: "Toppings",
25
+ value: 90,
26
+ }, {
27
+ name: "Pizza Toppings",
28
+ id: "Toppings",
29
+ },
30
+ ] %>
31
+
32
+
33
+ <%= pb_rails("treemap_chart", props: {
34
+ chart_data: data,
35
+ id: "treemap-default",
36
+ title: "Favored Pizza Toppings",
37
+ }) %>
@@ -0,0 +1,47 @@
1
+ import React from 'react'
2
+
3
+ import TreemapChart from '../_treemap_chart'
4
+
5
+ const chartData = [
6
+ {
7
+ name: "Pepperoni",
8
+ parent: "Toppings",
9
+ value: 600,
10
+ }, {
11
+ name: "Cheese",
12
+ parent: "Toppings",
13
+ value: 510,
14
+ }, {
15
+ name: "Mushroom",
16
+ parent: "Toppings",
17
+ value: 330,
18
+ },{
19
+ name: "Onions",
20
+ parent: "Toppings",
21
+ value: 250,
22
+ }, {
23
+ name: "Olives",
24
+ parent: "Toppings",
25
+ value: 204,
26
+ }, {
27
+ name: "Pineapple",
28
+ parent: "Toppings",
29
+ value: 90,
30
+ }, {
31
+ name: "Pizza Toppings",
32
+ id: "Toppings",
33
+ },
34
+ ]
35
+
36
+ const TreemapChartDefault = (props) => (
37
+ <div>
38
+ <TreemapChart
39
+ chartData={chartData}
40
+ id="treemap-default"
41
+ title="Favored Pizza Toppings"
42
+ {...props}
43
+ />
44
+ </div>
45
+ )
46
+
47
+ export default TreemapChartDefault
@@ -0,0 +1,3 @@
1
+ Points are automatically arranged by their `value` size.
2
+
3
+ By default, point colors are assigned sequentially from the global `data` colors. Note that data points without a value (such as parent nodes) will still take on the next available color.