playbook_ui 10.16.0 → 10.18.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/_playbook.scss +3 -0
  3. data/app/pb_kits/playbook/pb_background/background.test.js +22 -0
  4. data/app/pb_kits/playbook/pb_bar_graph/_bar_graph.jsx +3 -0
  5. data/app/pb_kits/playbook/pb_bar_graph/bar_graph.rb +3 -0
  6. data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_colors.html.erb +26 -0
  7. data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_colors.jsx +37 -0
  8. data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_colors.md +2 -0
  9. data/app/pb_kits/playbook/pb_bar_graph/docs/example.yml +2 -0
  10. data/app/pb_kits/playbook/pb_bar_graph/docs/index.js +1 -0
  11. data/app/pb_kits/playbook/pb_caption/_caption.jsx +17 -4
  12. data/app/pb_kits/playbook/pb_caption/_caption.scss +25 -8
  13. data/app/pb_kits/playbook/pb_caption/_caption_mixin.scss +17 -0
  14. data/app/pb_kits/playbook/pb_caption/caption.rb +5 -1
  15. data/app/pb_kits/playbook/pb_caption/docs/_caption_example.html.erb +3 -0
  16. data/app/pb_kits/playbook/pb_caption/docs/_caption_example.jsx +27 -0
  17. data/app/pb_kits/playbook/pb_caption/docs/_caption_example.md +1 -0
  18. data/app/pb_kits/playbook/pb_caption/docs/example.yml +7 -4
  19. data/app/pb_kits/playbook/pb_caption/docs/index.js +1 -0
  20. data/app/pb_kits/playbook/pb_card/_card.jsx +1 -3
  21. data/app/pb_kits/playbook/pb_card/_card.scss +0 -6
  22. data/app/pb_kits/playbook/pb_card/_card_mixin.scss +1 -8
  23. data/app/pb_kits/playbook/pb_card/card.html.erb +2 -0
  24. data/app/pb_kits/playbook/pb_card/card.rb +0 -8
  25. data/app/pb_kits/playbook/pb_card/docs/_card_background.html.erb +1 -1
  26. data/app/pb_kits/playbook/pb_card/docs/_card_content.html.erb +3 -1
  27. data/app/pb_kits/playbook/pb_card/docs/_card_content.jsx +9 -2
  28. data/app/pb_kits/playbook/pb_circle_chart/circle_chart.rb +4 -0
  29. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_colors.md +2 -0
  30. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_default_date.md +3 -1
  31. data/app/pb_kits/playbook/pb_date_time_stacked/date_time_stacked.test.js +13 -4
  32. data/app/pb_kits/playbook/pb_docs/kit_example.rb +4 -0
  33. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/fixed_confirmation_toast.rb +4 -0
  34. data/app/pb_kits/playbook/pb_flex/_flex.jsx +4 -0
  35. data/app/pb_kits/playbook/pb_flex/_flex.scss +17 -1
  36. data/app/pb_kits/playbook/pb_flex/_flex_item.jsx +6 -2
  37. data/app/pb_kits/playbook/pb_flex/_flex_item.scss +22 -0
  38. data/app/pb_kits/playbook/pb_flex/docs/_flex_item.html.erb +12 -1
  39. data/app/pb_kits/playbook/pb_flex/docs/_flex_item.md +2 -0
  40. data/app/pb_kits/playbook/pb_flex/docs/_flex_item_align_self.html.erb +89 -0
  41. data/app/pb_kits/playbook/pb_flex/docs/_flex_item_align_self.jsx +210 -0
  42. data/app/pb_kits/playbook/pb_flex/docs/_flex_item_align_self.md +5 -0
  43. data/app/pb_kits/playbook/pb_flex/docs/_flex_item_example.jsx +27 -0
  44. data/app/pb_kits/playbook/pb_flex/docs/_flex_item_example.md +2 -0
  45. data/app/pb_kits/playbook/pb_flex/docs/example.yml +2 -0
  46. data/app/pb_kits/playbook/pb_flex/docs/index.js +1 -0
  47. data/app/pb_kits/playbook/pb_flex/flex.rb +14 -1
  48. data/app/pb_kits/playbook/pb_flex/flex_item.rb +16 -1
  49. data/app/pb_kits/playbook/pb_gauge/_gauge.jsx +3 -0
  50. data/app/pb_kits/playbook/pb_gauge/docs/_gauge_colors.html.erb +12 -0
  51. data/app/pb_kits/playbook/pb_gauge/docs/_gauge_colors.jsx +19 -0
  52. data/app/pb_kits/playbook/pb_gauge/docs/_gauge_colors.md +2 -0
  53. data/app/pb_kits/playbook/pb_gauge/docs/example.yml +2 -0
  54. data/app/pb_kits/playbook/pb_gauge/docs/index.js +1 -0
  55. data/app/pb_kits/playbook/pb_gauge/gauge.rb +2 -0
  56. data/app/pb_kits/playbook/pb_icon/icon.rb +4 -0
  57. data/app/pb_kits/playbook/pb_icon_circle/_icon_circle.scss +2 -2
  58. data/app/pb_kits/playbook/pb_icon_circle/docs/_icon_circle_color.html.erb +1 -1
  59. data/app/pb_kits/playbook/pb_icon_circle/docs/_icon_circle_color.jsx +1 -1
  60. data/app/pb_kits/playbook/pb_icon_circle/docs/_icon_circle_color.md +1 -0
  61. data/app/pb_kits/playbook/pb_icon_circle/icon_circle.rb +1 -1
  62. data/app/pb_kits/playbook/pb_icon_stat_value/icon_stat_value.rb +2 -0
  63. data/app/pb_kits/playbook/pb_image/_image.jsx +4 -1
  64. data/app/pb_kits/playbook/pb_image/_image.scss +24 -8
  65. data/app/pb_kits/playbook/pb_image/docs/_transition_image.html.erb +54 -0
  66. data/app/pb_kits/playbook/pb_image/docs/_transition_image.jsx +77 -0
  67. data/app/pb_kits/playbook/pb_image/docs/_transition_image.md +1 -0
  68. data/app/pb_kits/playbook/pb_image/docs/example.yml +2 -0
  69. data/app/pb_kits/playbook/pb_image/docs/index.js +1 -0
  70. data/app/pb_kits/playbook/pb_image/image.html.erb +1 -1
  71. data/app/pb_kits/playbook/pb_image/image.rb +8 -1
  72. data/app/pb_kits/playbook/pb_image/image.test.js +9 -4
  73. data/app/pb_kits/playbook/pb_line_graph/_line_graph.jsx +4 -1
  74. data/app/pb_kits/playbook/pb_line_graph/docs/_line_graph_colors.html.erb +26 -0
  75. data/app/pb_kits/playbook/pb_line_graph/docs/_line_graph_colors.jsx +37 -0
  76. data/app/pb_kits/playbook/pb_line_graph/docs/_line_graph_colors.md +2 -0
  77. data/app/pb_kits/playbook/pb_line_graph/docs/example.yml +2 -0
  78. data/app/pb_kits/playbook/pb_line_graph/docs/index.js +1 -0
  79. data/app/pb_kits/playbook/pb_line_graph/line_graph.rb +3 -0
  80. data/app/pb_kits/playbook/pb_list/list.rb +2 -0
  81. data/app/pb_kits/playbook/pb_select/select.rb +3 -0
  82. data/app/pb_kits/playbook/pb_source/source.rb +3 -0
  83. data/app/pb_kits/playbook/pb_text_input/text_input.rb +2 -0
  84. data/app/pb_kits/playbook/pb_title/docs/_title_light.html.erb +4 -1
  85. data/app/pb_kits/playbook/pb_title/title.html.erb +4 -2
  86. data/app/pb_kits/playbook/plugins/pb_chart.js +16 -24
  87. data/app/pb_kits/playbook/tokens/_colors.scss +3 -1
  88. data/app/pb_kits/playbook/utilities/_cursor.scss +3 -0
  89. data/app/pb_kits/playbook/utilities/_display.scss +23 -0
  90. data/app/pb_kits/playbook/utilities/_shadow.scss +11 -0
  91. data/app/pb_kits/playbook/utilities/globalProps.js +19 -1
  92. data/lib/playbook/classnames.rb +3 -0
  93. data/lib/playbook/cursor.rb +29 -0
  94. data/lib/playbook/display.rb +29 -0
  95. data/lib/playbook/engine.rb +0 -1
  96. data/lib/playbook/kit_base.rb +6 -0
  97. data/lib/playbook/markdown/helper.rb +2 -2
  98. data/lib/playbook/pb_doc_helper.rb +4 -0
  99. data/lib/playbook/props/base.rb +2 -2
  100. data/lib/playbook/shadow.rb +29 -0
  101. data/lib/playbook/version.rb +2 -2
  102. data/lib/playbook.rb +3 -0
  103. metadata +42 -15
@@ -52,9 +52,9 @@ $pb_icon_circle_sizes: (
52
52
  @each $color_name, $color_value in $colors {
53
53
  &[class*=_#{$color_name}] {
54
54
  color: $color_value;
55
- background: rgba(mix($bg_dark, $color_value, 10%), $opacity_2);
55
+ background: rgba(mix($bg_dark, $color_value, 10%), $opacity_1);
56
56
  &.dark {
57
- background: rgba(mix($bg_dark, $color_value, 10%), $opacity_5);
57
+ background: rgba(mix($bg_dark, $color_value, 10%), $opacity_2);
58
58
  }
59
59
  }
60
60
  }
@@ -5,7 +5,7 @@
5
5
  }) %>
6
6
  <%= pb_rails("icon_circle", props: {
7
7
  icon: "archive",
8
- variant: "blue",
8
+ variant: "orange",
9
9
  size: "sm"
10
10
  }) %>
11
11
  <%= pb_rails("icon_circle", props: {
@@ -15,7 +15,7 @@ const IconCircleColor = (props) => {
15
15
  <IconCircle
16
16
  icon="rocket"
17
17
  size="sm"
18
- variant="blue"
18
+ variant="orange"
19
19
  {...props}
20
20
  />
21
21
  <br />
@@ -0,0 +1 @@
1
+ Customize your icon circle by passing one of our seven base colors to the `variant` prop: `royal` `blue` `orange` `purple` `teal` `red` `yellow` `green`
@@ -8,7 +8,7 @@ module Playbook
8
8
  values: %w[xs sm md base lg xl],
9
9
  default: "md"
10
10
  prop :variant, type: Playbook::Props::Enum,
11
- values: %w[default royal blue purple teal red yellow green],
11
+ values: %w[default royal blue orange purple teal red yellow green],
12
12
  default: "default"
13
13
 
14
14
  def classname
@@ -33,6 +33,7 @@ module Playbook
33
33
  end
34
34
 
35
35
  def title_size
36
+ # rubocop:disable Style/CaseLikeIf
36
37
  if size == "lg"
37
38
  1
38
39
  elsif size == "md"
@@ -40,6 +41,7 @@ module Playbook
40
41
  else
41
42
  3
42
43
  end
44
+ # rubocop:enable Style/CaseLikeIf
43
45
  end
44
46
  end
45
47
  end
@@ -14,6 +14,7 @@ type ImageProps = {
14
14
  onError?: () => {},
15
15
  size: "xs" | "sm" | "md" | "lg" | "xl",
16
16
  rounded?: boolean,
17
+ transition: "blur" | "fade" | "scale",
17
18
  url: string,
18
19
  }
19
20
 
@@ -27,6 +28,7 @@ const Image = (props: ImageProps) => {
27
28
  onError = null,
28
29
  rounded = false,
29
30
  size = '',
31
+ transition = 'fade',
30
32
  url = '',
31
33
  } = props
32
34
 
@@ -34,7 +36,7 @@ const Image = (props: ImageProps) => {
34
36
  const classes = classnames(
35
37
  buildCss('pb_image_kit', size),
36
38
  'lazyload',
37
- 'blur_up',
39
+ transition,
38
40
  { rounded },
39
41
  globalProps(props),
40
42
  className
@@ -53,6 +55,7 @@ const Image = (props: ImageProps) => {
53
55
  onError={onError}
54
56
  rounded={+rounded}
55
57
  src={url}
58
+ transition={transition}
56
59
  />
57
60
  </div>
58
61
  )
@@ -28,15 +28,31 @@ $image-sizes: (
28
28
  border-radius: $border-rad-heaviest;
29
29
  }
30
30
 
31
- .blur_up {
32
- -webkit-filter: blur(6px);
33
- filter: blur(6px);
34
- transition: filter 550ms, -webkit-filter 550ms;
31
+ &.fade {
32
+ opacity: 0;
33
+ &.lazyloaded {
34
+ opacity: 1;
35
+ transition: opacity 300ms ease-in;
36
+ }
35
37
  }
36
-
37
- .blur_up.lazyloaded {
38
- -webkit-filter: blur(0);
39
- filter: blur(0);
38
+
39
+ &.blur {
40
+ filter: blur(5px);
41
+ &.lazyloaded {
42
+ -webkit-filter: blur(0);
43
+ filter: blur(0);
44
+ transition: filter 300ms ease-in;
45
+ }
46
+ }
47
+
48
+ &.scale {
49
+ opacity: 0;
50
+ transform: scale(0.9);
51
+ &.lazyloaded {
52
+ opacity: 1;
53
+ transform: scale(1);
54
+ transition: 700ms ease-in;
55
+ }
40
56
  }
41
57
  }
42
58
  }
@@ -0,0 +1,54 @@
1
+ <%= pb_rails("flex") do %>
2
+ <%= pb_rails("flex/flex_item", props: {fixed_size: "250px"}) do %>
3
+ <%= pb_rails("select", props: {
4
+ id: "transition-dropdown",
5
+ label: "",
6
+ blank_selection: "Select a Transition...",
7
+ options: [
8
+ {
9
+ value: 'fade',
10
+ },
11
+ {
12
+ value: 'blur',
13
+ },
14
+ {
15
+ value: 'scale',
16
+ },
17
+ ]
18
+ }) %>
19
+ <% end %>
20
+ <%= pb_rails("flex/flex_item") do %>
21
+ <%= pb_rails("button", props: {classname: "button", text: "Load Image", margin_left: "sm", margin_top: "xs", disabled: true }) %>
22
+ <% end %>
23
+ <% end %>
24
+ <%= pb_rails("image", props: { classname: "transition-image", alt: "picture of a misty forest", url: "", on_error: "this.style.display = 'none'" }) %>
25
+
26
+ <script>
27
+ window.addEventListener('DOMContentLoaded', () => {
28
+ const button = document.querySelector(".button")
29
+ const transitionDropdown = document.querySelector("#transition-dropdown")
30
+ var option = ''
31
+
32
+ transitionDropdown.addEventListener('change', function() {
33
+ if (this.value === '') {
34
+ button.className = button.className + ' _disabled'
35
+ } else {
36
+ button.removeAttribute("disabled");
37
+ button.className = button.className.replace(/\_disabled/gi, '')
38
+ option = this.value
39
+ }
40
+ });
41
+
42
+ const updateTransition = (transition) => {
43
+ const imageTransition = document.querySelector('.transition-image')
44
+ imageTransition.removeAttribute("style")
45
+ imageTransition.classList.remove("fade", "blur", "scale", "lazyloaded")
46
+ imageTransition.classList.add(transition, "lazyload")
47
+ imageTransition.src = "https://unsplash.it/500/400/?image=634"
48
+ }
49
+
50
+ button.addEventListener('click', function() {
51
+ updateTransition(option)
52
+ })
53
+ });
54
+ </script>
@@ -0,0 +1,77 @@
1
+ import React, { useState } from 'react'
2
+
3
+ import Image from '../_image'
4
+ import Select from '../../pb_select/_select'
5
+ import FlexItem from '../../pb_flex/_flex_item'
6
+ import Flex from '../../pb_flex/_flex'
7
+ import Button from '../../pb_button/_button'
8
+
9
+ const TransitionImage = (props) => {
10
+ const [transition, setTransition] = useState('')
11
+ const [apply, setApply] = useState({
12
+ url: '',
13
+ transition: '',
14
+ })
15
+
16
+ const loadImage = () => {
17
+ document.querySelector('.image').classList.remove(transition, 'lazyloaded')
18
+ setApply({
19
+ url: 'https://unsplash.it/500/400/?image=634',
20
+ transition: transition,
21
+ },
22
+ document.querySelector('.image').classList.add(transition, 'lazyload')
23
+ )
24
+ }
25
+
26
+ const handleTransition = ({ target }) => {
27
+ setTransition(target.value)
28
+ }
29
+
30
+ const options = [
31
+ {
32
+ value: 'fade',
33
+ },
34
+ {
35
+ value: 'blur',
36
+ },
37
+ {
38
+ value: 'scale',
39
+ },
40
+ ]
41
+
42
+ return (
43
+ <>
44
+ <Flex>
45
+ <FlexItem fixedSize="250px">
46
+ <Select
47
+ blankSelection="Select a Transition..."
48
+ label=""
49
+ onChange={handleTransition}
50
+ options={options}
51
+ {...props}
52
+ />
53
+ </FlexItem>
54
+ <FlexItem>
55
+ <Button
56
+ disabled={transition === '' ? true : false}
57
+ marginLeft="sm"
58
+ onClick={loadImage}
59
+ text="Load Image"
60
+ {...props}
61
+ />
62
+ </FlexItem>
63
+ </Flex>
64
+ <div style={{ display: apply.url === '' ? 'none' : 'block' }}>
65
+ <Image
66
+ alt="picture of a misty forest"
67
+ className="image"
68
+ transition={apply.transition}
69
+ url={apply.url}
70
+ {...props}
71
+ />
72
+ </div>
73
+ </>
74
+ )
75
+ }
76
+
77
+ export default TransitionImage
@@ -0,0 +1 @@
1
+ To add a transition, simply use the `transition` prop and one of the three string options `"fade"`, `"blur"`, or `"scale"`.
@@ -3,7 +3,9 @@ examples:
3
3
  - default_image: Default
4
4
  - rounded_image: Rounded
5
5
  - custom_error_image: Error Handling
6
+ - transition_image: Transition
6
7
  react:
7
8
  - default_image: Default
8
9
  - rounded_image: Rounded
9
10
  - custom_error_image: Error Handling
11
+ - transition_image: Transition
@@ -1,3 +1,4 @@
1
1
  export { default as DefaultImage } from './_default_image.jsx'
2
2
  export { default as RoundedImage } from './_rounded_image.jsx'
3
3
  export { default as CustomErrorImage } from './_custom_error_image.jsx'
4
+ export { default as TransitionImage } from './_transition_image.jsx'
@@ -7,4 +7,4 @@
7
7
  alt: object.alt,
8
8
  onerror: object.on_error,
9
9
  )
10
- %>
10
+ %>
@@ -11,10 +11,13 @@ module Playbook
11
11
  prop :size, type: Playbook::Props::Enum,
12
12
  values: %w[xs sm md lg xl none],
13
13
  default: "none"
14
+ prop :transition, type: Playbook::Props::Enum,
15
+ values: %w[blur fade scale none],
16
+ default: "fade"
14
17
  prop :url
15
18
 
16
19
  def classname
17
- generate_classname("pb_image_kit#{size_class} lazyload blur_up") + rounded_class
20
+ generate_classname("pb_image_kit#{size_class} #{transition_class} lazyload") + rounded_class
18
21
  end
19
22
 
20
23
  private
@@ -26,6 +29,10 @@ module Playbook
26
29
  def size_class
27
30
  size == "none" ? nil : "_#{size}"
28
31
  end
32
+
33
+ def transition_class
34
+ transition == "none" ? nil : transition
35
+ end
29
36
  end
30
37
  end
31
38
  end
@@ -7,6 +7,7 @@ const props = {
7
7
  data: { testid: 'avatar' },
8
8
  size: null,
9
9
  url: 'https://unsplash.it/500/400/?image=634',
10
+ transition: 'blur',
10
11
  }
11
12
 
12
13
  it('Should be accessible', async () => {
@@ -20,16 +21,20 @@ test('alt attribute', () => {
20
21
 
21
22
  test('default classname', () => {
22
23
  const kit = renderKit(Image, props)
23
- expect(kit).toHaveClass('pb_image_kit lazyload blur_up')
24
+ expect(kit).toHaveClass('pb_image_kit lazyload')
24
25
  })
25
26
 
26
27
  test('size = xs', () => {
27
28
  const kit = renderKit(Image, props, { size: 'xs' })
28
- expect(kit).toHaveClass('pb_image_kit_xs lazyload blur_up')
29
+ expect(kit).toHaveClass('pb_image_kit_xs lazyload')
30
+ })
31
+
32
+ test('transition = blur', () => {
33
+ const kit = renderKit(Image, props, { transition: 'blur' })
34
+ expect(kit).toHaveClass('pb_image_kit lazyload blur')
29
35
  })
30
36
 
31
37
  test('rounded = true', () => {
32
38
  const kit = renderKit(Image, props, { rounded: true })
33
- expect(kit).toHaveClass('pb_image_kit lazyload blur_up rounded')
39
+ expect(kit).toHaveClass('pb_image_kit lazyload rounded')
34
40
  })
35
-
@@ -25,7 +25,8 @@ type LineGraphProps = {
25
25
  legend?: boolean,
26
26
  toggleLegendClick?: boolean,
27
27
  height?: string,
28
- }
28
+ colors: array,
29
+ }
29
30
 
30
31
  export default class LineGraph extends React.Component<LineGraphProps> {
31
32
  static defaultProps = {
@@ -52,11 +53,13 @@ export default class LineGraph extends React.Component<LineGraphProps> {
52
53
  legend,
53
54
  toggleLegendClick,
54
55
  height,
56
+ colors = [],
55
57
  } = this.props
56
58
 
57
59
  new pbChart(`.${className}`, {
58
60
  axisTitle: axisTitle,
59
61
  chartData: chartData,
62
+ colors: colors,
60
63
  id: id,
61
64
  pointStart: pointStart,
62
65
  subtitle: subTitle,
@@ -0,0 +1,26 @@
1
+ <% data = [{
2
+ name: 'Installation',
3
+ data: [43934, 52503, 57177, 69658, 97031, 119931, 137133, 154175]
4
+ }, {
5
+ name: 'Manufacturing',
6
+ data: [24916, 28064, 29742, 40851, 50590, 65282, 70121, 85434]
7
+ }, {
8
+ name: 'Sales & Distribution',
9
+ data: [11744, 17722, 16005, 19771, 25185, 28377, 36147, 43387]
10
+ }, {
11
+ name: 'Project Development',
12
+ data: [5332, 6344, 7988, 12169, 15112, 14452, 22400, 30227]
13
+ }, {
14
+ name: 'Other',
15
+ data: [nil, nil, nil, 3112, 4989, 5816, 15274, 18111]
16
+ }] %>
17
+
18
+ <%= pb_rails("line_graph", props: {
19
+ id: "line-colors",
20
+ gradient: false,
21
+ chart_data: data,
22
+ x_axis_categories:['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],
23
+ title: 'Line Graph with Custom Data Colors',
24
+ axis_title: 'Number of Employees',
25
+ colors: ['data-4', 'data-5', 'data-6', 'data-7', 'data-8']
26
+ }) %>
@@ -0,0 +1,37 @@
1
+ import React from 'react'
2
+
3
+ import LineGraph from '../_line_graph'
4
+
5
+ const data = [{
6
+ name: 'Installation',
7
+ data: [43934, 52503, 57177, 69658, 97031, 119931, 137133, 154175],
8
+ }, {
9
+ name: 'Manufacturing',
10
+ data: [24916, 28064, 29742, 40851, 50590, 65282, 70121, 85434],
11
+ }, {
12
+ name: 'Sales & Distribution',
13
+ data: [11744, 17722, 16005, 19771, 25185, 28377, 36147, 43387],
14
+ }, {
15
+ name: 'Project Development',
16
+ data: [5332, 6344, 7988, 12169, 15112, 14452, 22400, 30227],
17
+ }, {
18
+ name: 'Other',
19
+ data: [null, null, null, 3112, 4989, 5816, 15274, 18111],
20
+ }]
21
+
22
+ const LineGraphColors = (props) => (
23
+ <div>
24
+ <LineGraph
25
+ axisTitle="Number of Employees"
26
+ chartData={data}
27
+ colors={['data-4', 'data-5', 'data-6', 'data-7', 'data-8']}
28
+ id="line-colors"
29
+ title="Line Graph with Custom Data Colors"
30
+ xAxisCategories={['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']}
31
+ yAxisMin={0}
32
+ {...props}
33
+ />
34
+ </div>
35
+ )
36
+
37
+ export default LineGraphColors
@@ -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`
@@ -5,6 +5,7 @@ examples:
5
5
  - line_graph_legend: Legend
6
6
  - line_graph_legend_nonclickable: Legend Nonclickable
7
7
  - line_graph_height: Height
8
+ - line_graph_colors: Color Overrides
8
9
 
9
10
 
10
11
  react:
@@ -12,3 +13,4 @@ examples:
12
13
  - line_graph_legend: Legend
13
14
  - line_graph_legend_nonclickable: Legend Nonclickable
14
15
  - line_graph_height: Height
16
+ - line_graph_colors: Color Overrides
@@ -2,3 +2,4 @@ export { default as LineGraphDefault } from './_line_graph_default.jsx'
2
2
  export { default as LineGraphLegend } from './_line_graph_legend.jsx'
3
3
  export { default as LineGraphLegendNonclickable } from './_line_graph_legend_nonclickable.jsx'
4
4
  export { default as LineGraphHeight } from './_line_graph_height.jsx'
5
+ export { default as LineGraphColors } from './_line_graph_colors.jsx'
@@ -20,6 +20,8 @@ module Playbook
20
20
  prop :toggle_legend_click, type: Playbook::Props::Boolean,
21
21
  default: true
22
22
  prop :height
23
+ prop :colors, type: Playbook::Props::Array,
24
+ default: []
23
25
 
24
26
  def chart_type
25
27
  gradient ? "area" : "line"
@@ -41,6 +43,7 @@ module Playbook
41
43
  legend: legend,
42
44
  toggleLegendClick: toggle_legend_click,
43
45
  height: height,
46
+ colors: colors,
44
47
  }
45
48
  end
46
49
 
@@ -43,6 +43,7 @@ module Playbook
43
43
  dark ? "dark" : nil
44
44
  end
45
45
 
46
+ # rubocop:disable Style/CaseLikeIf
46
47
  def layout_class
47
48
  if layout == "right"
48
49
  "layout_right"
@@ -52,6 +53,7 @@ module Playbook
52
53
  ""
53
54
  end
54
55
  end
56
+ # rubocop:enable Style/CaseLikeIf
55
57
 
56
58
  def size_class
57
59
  size ? "large" : nil
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # rubocop:disable Style/StringConcatenation
3
4
  require "action_view"
4
5
 
5
6
  module Playbook
@@ -72,3 +73,5 @@ module Playbook
72
73
  end
73
74
  end
74
75
  end
76
+
77
+ # rubocop:enable Style/StringConcatenation
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # rubocop:disable Style/SingleArgumentDig, Style/HashLikeCase
3
4
  module Playbook
4
5
  module PbSource
5
6
  class Source < Playbook::KitBase
@@ -59,3 +60,5 @@ module Playbook
59
60
  end
60
61
  end
61
62
  end
63
+
64
+ # rubocop:enable Style/SingleArgumentDig, Style/HashLikeCase
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # rubocop:disable Style/SingleArgumentDig
3
4
  module Playbook
4
5
  module PbTextInput
5
6
  class TextInput < Playbook::KitBase
@@ -86,3 +87,4 @@ module Playbook
86
87
  end
87
88
  end
88
89
  end
90
+ # rubocop:enable Style/SingleArgumentDig
@@ -1,4 +1,7 @@
1
- <%= pb_rails("title", props: { text: "Default Title" }) %>
1
+ <%= pb_rails("title", props: {
2
+ }) do %>
3
+ Default Title
4
+ <% end %>
2
5
 
3
6
  <br/>
4
7
 
@@ -1,5 +1,7 @@
1
- <%= content_tag(object.tag, object.text,
1
+ <%= content_tag(object.tag,
2
2
  aria: object.aria,
3
3
  id: object.id,
4
4
  data: object.data,
5
- class: object.classname) %>
5
+ class: object.classname) do %>
6
+ <%= content.presence || object.text %>
7
+ <% end %>
@@ -10,25 +10,14 @@ import solidGauge from 'highcharts/modules/solid-gauge'
10
10
  pie(Highcharts)
11
11
 
12
12
  // Map Data Color String Props to our SCSS Variables
13
+
13
14
  const mapColors = (array) => {
15
+ const regex = /(data)\-[1-8]/ //eslint-disable-line
16
+
14
17
  const newArray = array.map((item) => {
15
- return item == 'data-1'
16
- ? `${colors.data_1}`
17
- : item == 'data-2'
18
- ? `${colors.data_2}`
19
- : item == 'data-3'
20
- ? `${colors.data_3}`
21
- : item == 'data-4'
22
- ? `${colors.data_4}`
23
- : item == 'data-5'
24
- ? `${colors.data_5}`
25
- : item == 'data-6'
26
- ? `${colors.data_6}`
27
- : item == 'data-7'
28
- ? `${colors.data_7}`
29
- : item == 'data-8'
30
- ? `${colors.data_8}`
31
- : ''
18
+ return regex.test(item)
19
+ ? `${colors[`data_${item[item.length - 1]}`]}`
20
+ : item
32
21
  })
33
22
  return newArray
34
23
  }
@@ -72,13 +61,13 @@ class pbChart {
72
61
  if (this.options.type == 'variablepie' || this.options.type == 'pie'){
73
62
  this.setupPieChart(options)
74
63
  } else if (this.options.type == 'gauge') {
75
- this.setupGauge()
64
+ this.setupGauge(options)
76
65
  } else {
77
- this.setupChart()
66
+ this.setupChart(options)
78
67
  }
79
68
  }
80
69
 
81
- setupGauge() {
70
+ setupGauge(options) {
82
71
  highchartsMore(Highcharts)
83
72
  solidGauge(Highcharts)
84
73
  Highcharts.setOptions(highchartsTheme)
@@ -128,19 +117,21 @@ class pbChart {
128
117
  pointFormat: this.defaults.tooltipHtml,
129
118
  followPointer: true,
130
119
  },
120
+ colors: options.colors !== undefined && options.colors.length > 0 ? mapColors(options.colors) : highchartsTheme.colors,
131
121
  plotOptions: {
132
122
  series: {
133
123
  animation: !this.defaults.disableAnimation,
134
124
  },
135
125
  solidgauge: {
126
+ borderColor: options.colors !== undefined && options.colors.length === 1 ? mapColors(options.colors).join() : highchartsTheme.colors[0],
136
127
  dataLabels: {
137
128
  format: `<span class="prefix">${this.defaults.prefix}</span>` +
138
129
  '<span class="fix">{y:,f}</span>' +
139
130
  `<span class="suffix">${this.defaults.suffix}</span>`,
140
- },
141
- },
131
+ } },
142
132
  },
143
- })
133
+ },
134
+ )
144
135
  document.querySelectorAll('.gauge-pane').forEach((pane) => pane.setAttribute('stroke-linejoin', 'round'))
145
136
  if (document.querySelector('.prefix')) {
146
137
  document.querySelectorAll('.prefix').forEach((prefix) => prefix.setAttribute('y', '28'))
@@ -195,7 +186,7 @@ class pbChart {
195
186
  })
196
187
  }
197
188
 
198
- setupChart() {
189
+ setupChart(options) {
199
190
  Highcharts.setOptions(highchartsTheme)
200
191
 
201
192
  const configOptions = {
@@ -222,6 +213,7 @@ class pbChart {
222
213
  legend: {
223
214
  enabled: this.defaults.legend,
224
215
  },
216
+ colors: options.colors !== undefined && options.colors.length > 0 ? mapColors(options.colors) : highchartsTheme.colors,
225
217
  plotOptions: {
226
218
  series: {
227
219
  pointStart: this.defaults.pointStart,
@@ -12,6 +12,7 @@ $red: #FF2229;
12
12
  $yellow: #F9BB00;
13
13
  $green: #00CA74;
14
14
  $orange: #FD804C;
15
+ $default: #93a8b8;
15
16
  $colors: (
16
17
  royal: $royal,
17
18
  purple: $purple,
@@ -19,7 +20,8 @@ $colors: (
19
20
  red: $red,
20
21
  yellow: $yellow,
21
22
  green: $green,
22
- orange: $orange
23
+ orange: $orange,
24
+ default: $default,
23
25
  );
24
26
 
25
27
  /* Specialty Gradient -----------------*/