playbook_ui 10.21.0.pre.alpha.rg1 → 10.21.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (130) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/_playbook.scss +0 -11
  3. data/app/pb_kits/playbook/pb_avatar/_avatar.scss +2 -2
  4. data/app/pb_kits/playbook/pb_avatar/{_avatar.jsx → _avatar.tsx} +13 -14
  5. data/app/pb_kits/playbook/pb_avatar/avatar.rb +1 -1
  6. data/app/pb_kits/playbook/pb_avatar/avatar.test.js +1 -1
  7. data/app/pb_kits/playbook/pb_avatar_action_button/_avatar_action_button.jsx +1 -1
  8. data/app/pb_kits/playbook/pb_background/_background.jsx +8 -3
  9. data/app/pb_kits/playbook/pb_background/_background.scss +24 -8
  10. data/app/pb_kits/playbook/pb_background/background.rb +6 -6
  11. data/app/pb_kits/playbook/pb_background/docs/_background_image.html.erb +50 -2
  12. data/app/pb_kits/playbook/pb_background/docs/_background_image.jsx +71 -28
  13. data/app/pb_kits/playbook/pb_background/docs/_background_image.md +1 -0
  14. data/app/pb_kits/playbook/pb_bar_graph/_bar_graph.jsx +5 -1
  15. data/app/pb_kits/playbook/pb_bar_graph/bar_graph.rb +1 -0
  16. data/app/pb_kits/playbook/pb_bread_crumbs/_bread_crumb_item.jsx +1 -1
  17. data/app/pb_kits/playbook/pb_bread_crumbs/_bread_crumbs.jsx +1 -1
  18. data/app/pb_kits/playbook/pb_button/_button.jsx +5 -4
  19. data/app/pb_kits/playbook/pb_button/_button.scss +18 -1
  20. data/app/pb_kits/playbook/pb_button/button.rb +11 -3
  21. data/app/pb_kits/playbook/pb_button/button.test.js +13 -0
  22. data/app/pb_kits/playbook/pb_button/docs/_button_size.html.erb +3 -0
  23. data/app/pb_kits/playbook/pb_button/docs/_button_size.jsx +26 -0
  24. data/app/pb_kits/playbook/pb_button/docs/_button_size.md +1 -0
  25. data/app/pb_kits/playbook/pb_button/docs/example.yml +2 -0
  26. data/app/pb_kits/playbook/pb_button/docs/index.js +1 -0
  27. data/app/pb_kits/playbook/pb_button_toolbar/_button_toolbar.jsx +1 -1
  28. data/app/pb_kits/playbook/pb_caption/_caption.jsx +1 -1
  29. data/app/pb_kits/playbook/pb_card/_card.jsx +1 -1
  30. data/app/pb_kits/playbook/pb_card/card.html.erb +1 -1
  31. data/app/pb_kits/playbook/pb_card/card.rb +0 -88
  32. data/app/pb_kits/playbook/pb_card/card_body.rb +1 -1
  33. data/app/pb_kits/playbook/pb_checkbox/_checkbox.jsx +1 -1
  34. data/app/pb_kits/playbook/pb_circle_chart/_circle_chart.jsx +3 -0
  35. data/app/pb_kits/playbook/pb_circle_chart/circle_chart.rb +1 -0
  36. data/app/pb_kits/playbook/pb_circle_icon_button/_circle_icon_button.jsx +1 -1
  37. data/app/pb_kits/playbook/pb_collapsible/_collapsible.jsx +1 -1
  38. data/app/pb_kits/playbook/pb_collapsible/child_kits/CollapsibleContent.jsx +1 -1
  39. data/app/pb_kits/playbook/pb_currency/_currency.jsx +24 -3
  40. data/app/pb_kits/playbook/pb_currency/currency.rb +12 -3
  41. data/app/pb_kits/playbook/pb_currency/currency.test.js +35 -0
  42. data/app/pb_kits/playbook/pb_currency/docs/_currency_abbreviated.html.erb +27 -0
  43. data/app/pb_kits/playbook/pb_currency/docs/_currency_abbreviated.jsx +44 -0
  44. data/app/pb_kits/playbook/pb_currency/docs/_currency_variants.html.erb +1 -1
  45. data/app/pb_kits/playbook/pb_currency/docs/example.yml +2 -0
  46. data/app/pb_kits/playbook/pb_currency/docs/index.js +1 -0
  47. data/app/pb_kits/playbook/pb_dashboard/pbChartsDarkTheme.js +215 -0
  48. data/app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx +1 -1
  49. data/app/pb_kits/playbook/pb_dialog/_dialog.jsx +1 -1
  50. data/app/pb_kits/playbook/pb_dialog/child_kits/_dialog_body.jsx +1 -1
  51. data/app/pb_kits/playbook/pb_dialog/child_kits/_dialog_footer.jsx +1 -1
  52. data/app/pb_kits/playbook/pb_dialog/child_kits/_dialog_header.jsx +1 -1
  53. data/app/pb_kits/playbook/pb_distribution_bar/_distribution_bar.jsx +1 -1
  54. data/app/pb_kits/playbook/pb_file_upload/_file_upload.jsx +17 -10
  55. data/app/pb_kits/playbook/pb_file_upload/fileupload.test.js +40 -0
  56. data/app/pb_kits/playbook/pb_filter/Filter/FilterBackground.jsx +1 -1
  57. data/app/pb_kits/playbook/pb_flex/_flex.jsx +1 -1
  58. data/app/pb_kits/playbook/pb_flex/_flex_item.jsx +1 -1
  59. data/app/pb_kits/playbook/pb_flex/docs/_flex_align.jsx +1 -1
  60. data/app/pb_kits/playbook/pb_flex/flex_item.rb +24 -2
  61. data/app/pb_kits/playbook/pb_form_group/_form_group.jsx +1 -1
  62. data/app/pb_kits/playbook/pb_form_pill/_form_pill.jsx +2 -2
  63. data/app/pb_kits/playbook/pb_gauge/_gauge.jsx +3 -0
  64. data/app/pb_kits/playbook/pb_gauge/gauge.rb +1 -0
  65. data/app/pb_kits/playbook/pb_highlight/_highlight.jsx +1 -1
  66. data/app/pb_kits/playbook/pb_icon/_icon.jsx +1 -1
  67. data/app/pb_kits/playbook/pb_icon_stat_value/_icon_stat_value.jsx +1 -1
  68. data/app/pb_kits/playbook/pb_image/_image.scss +3 -3
  69. data/app/pb_kits/playbook/pb_image/{_image.jsx → _image.tsx} +11 -15
  70. data/app/pb_kits/playbook/pb_image/image.rb +1 -1
  71. data/app/pb_kits/playbook/pb_image/image.test.js +1 -1
  72. data/app/pb_kits/playbook/pb_label_pill/_label_pill.jsx +1 -1
  73. data/app/pb_kits/playbook/pb_layout/_layout.jsx +1 -1
  74. data/app/pb_kits/playbook/pb_line_graph/_line_graph.jsx +5 -1
  75. data/app/pb_kits/playbook/pb_line_graph/line_graph.rb +1 -0
  76. data/app/pb_kits/playbook/pb_list/_list.jsx +1 -1
  77. data/app/pb_kits/playbook/pb_list/_list_item.jsx +1 -1
  78. data/app/pb_kits/playbook/pb_multiple_users/_multiple_users.jsx +1 -1
  79. data/app/pb_kits/playbook/pb_online_status/{_online_status.jsx → _online_status.tsx} +4 -6
  80. data/app/pb_kits/playbook/pb_passphrase/_passphrase.jsx +2 -1
  81. data/app/pb_kits/playbook/pb_pill/_pill.jsx +1 -1
  82. data/app/pb_kits/playbook/pb_popover/_popover.jsx +1 -1
  83. data/app/pb_kits/playbook/pb_progress_simple/_progress_simple.jsx +1 -1
  84. data/app/pb_kits/playbook/pb_progress_step/_progress_step.jsx +1 -1
  85. data/app/pb_kits/playbook/pb_radio/_radio.jsx +1 -1
  86. data/app/pb_kits/playbook/pb_rich_text_editor/_rich_text_editor.jsx +5 -0
  87. data/app/pb_kits/playbook/pb_table/_table.jsx +1 -1
  88. data/app/pb_kits/playbook/pb_table/_table_row.jsx +1 -1
  89. data/app/pb_kits/playbook/pb_text_input/_text_input.jsx +1 -1
  90. data/app/pb_kits/playbook/pb_text_input/_text_input.scss +1 -1
  91. data/app/pb_kits/playbook/pb_text_input/text_input.test.js +14 -0
  92. data/app/pb_kits/playbook/pb_textarea/_textarea.jsx +1 -0
  93. data/app/pb_kits/playbook/pb_time/_time.jsx +1 -1
  94. data/app/pb_kits/playbook/pb_title/_title.jsx +1 -1
  95. data/app/pb_kits/playbook/pb_toggle/_toggle.jsx +1 -1
  96. data/app/pb_kits/playbook/pb_typeahead/_typeahead.jsx +1 -1
  97. data/app/pb_kits/playbook/pb_user_badge/_user_badge.jsx +1 -1
  98. data/app/pb_kits/playbook/pb_walkthrough/_walkthrough.jsx +1 -1
  99. data/app/pb_kits/playbook/pb_weekday_stacked/_weekday_stacked.jsx +1 -1
  100. data/app/pb_kits/playbook/plugins/pb_chart.js +8 -4
  101. data/app/pb_kits/playbook/utilities/globalProps.ts +156 -0
  102. data/app/pb_kits/playbook/utilities/{props.js → props.ts} +9 -7
  103. data/lib/playbook/classnames.rb +0 -11
  104. data/lib/playbook/kit_base.rb +0 -22
  105. data/lib/playbook/version.rb +1 -1
  106. metadata +18 -32
  107. data/app/pb_kits/playbook/types.js +0 -4
  108. data/app/pb_kits/playbook/utilities/_align_content.scss +0 -29
  109. data/app/pb_kits/playbook/utilities/_align_items.scss +0 -24
  110. data/app/pb_kits/playbook/utilities/_align_self.scss +0 -29
  111. data/app/pb_kits/playbook/utilities/_flex.scss +0 -15
  112. data/app/pb_kits/playbook/utilities/_flex_direction.scss +0 -19
  113. data/app/pb_kits/playbook/utilities/_flex_grow.scss +0 -9
  114. data/app/pb_kits/playbook/utilities/_flex_shrink.scss +0 -9
  115. data/app/pb_kits/playbook/utilities/_flex_wrap.scss +0 -14
  116. data/app/pb_kits/playbook/utilities/_justify_content.scss +0 -23
  117. data/app/pb_kits/playbook/utilities/_justify_self.scss +0 -19
  118. data/app/pb_kits/playbook/utilities/_order.scss +0 -55
  119. data/app/pb_kits/playbook/utilities/globalProps.js +0 -175
  120. data/lib/playbook/align_content.rb +0 -29
  121. data/lib/playbook/align_items.rb +0 -29
  122. data/lib/playbook/align_self.rb +0 -29
  123. data/lib/playbook/flex.rb +0 -29
  124. data/lib/playbook/flex_direction.rb +0 -29
  125. data/lib/playbook/flex_grow.rb +0 -29
  126. data/lib/playbook/flex_shrink.rb +0 -29
  127. data/lib/playbook/flex_wrap.rb +0 -29
  128. data/lib/playbook/justify_content.rb +0 -29
  129. data/lib/playbook/justify_self.rb +0 -29
  130. data/lib/playbook/order.rb +0 -29
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0a6ea164e06111d003426c3549cb4173cdb07a1161f61552c1bdf8b08b217656
4
- data.tar.gz: a4c26076cbc2d2710d481dd8a29b574a8eb1abbe3e411bee6010ff2049a1d313
3
+ metadata.gz: a59d79cb7efc701b2cfcda8f853e5d47f6e7a8bb0c63a26ea1fb1a0d1352d7ef
4
+ data.tar.gz: 4ce8a5b16f4dd0d58a56793bc8aaf8f7e285104fae767a7e4867853ea6531a5f
5
5
  SHA512:
6
- metadata.gz: 38c5657dd72a901913c9e537d435481ee0c43c48eed6380430e75fd74b5a6486d178de64a47f5ac2e9bff572b553e22eea7657b0dbd71f5494ad0afaf779c261
7
- data.tar.gz: 5d348958c7c6fbc22cdd8e04a0e11c0d55725182e36d5e1e4a478abd50550a7e910e26c56524ab08c43e31dd6d412abfc0a4965fc7894cd90e9ff882724cda26
6
+ metadata.gz: 36e213335bf164b63b39d2958360e6629c0f16cc07ea01fa2a645f36878fc531c5d4a4e84d8f8aa388c68bb9a92961727399297f45048e9cc7ea5e4d54078b18
7
+ data.tar.gz: 341993d316fbe3a2cad5b26861ae255128657a13505100aa12b46afd2694aa993fa7210f67faa86b2a2f79b9a8ed999d4786cb7a31512c75080aef5198283d72
@@ -100,14 +100,3 @@
100
100
  @import './utilities/shadow';
101
101
  @import './utilities/line_height';
102
102
  @import './utilities/display';
103
- @import './utilities/flex_direction';
104
- @import './utilities/justify_content';
105
- @import './utilities/flex_wrap';
106
- @import './utilities/justify_self';
107
- @import './utilities/align_items';
108
- @import './utilities/align_content';
109
- @import './utilities/align_self';
110
- @import './utilities/flex';
111
- @import './utilities/flex_grow';
112
- @import './utilities/flex_shrink';
113
- @import './utilities/order';
@@ -16,8 +16,8 @@ $avatar-sizes: (
16
16
  position: relative;
17
17
 
18
18
  @each $name, $size in $avatar-sizes {
19
- &[class*=_#{$name}],
20
- &[class*=_#{$name}_thumb] {
19
+ &[class*=_size_#{$name}],
20
+ &[class*=_size_#{$name}_thumb] {
21
21
  width: $size;
22
22
  height: $size;
23
23
  object-fit: cover;
@@ -1,8 +1,5 @@
1
- /* @flow */
2
-
3
1
  import React, { useState } from 'react'
4
2
  import classnames from 'classnames'
5
- import { map } from 'lodash'
6
3
 
7
4
  import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
8
5
  import { globalProps } from '../utilities/globalProps'
@@ -11,9 +8,9 @@ import Image from '../pb_image/_image'
11
8
  import OnlineStatus from '../pb_online_status/_online_status'
12
9
 
13
10
  type AvatarProps = {
14
- aria?: object,
11
+ aria?: {[key: string]: string},
15
12
  className?: string,
16
- data?: object,
13
+ data?: {[key: string]: string},
17
14
  dark?: boolean,
18
15
  id?: string,
19
16
  imageAlt?: string,
@@ -23,8 +20,8 @@ type AvatarProps = {
23
20
  status: "away" | "offline" | "online",
24
21
  }
25
22
 
26
- const firstTwoInitials = (name) =>
27
- map(name.split(/\s/), (name) => name[0])
23
+ const firstTwoInitials = (name: string) =>
24
+ name.split(/\s/).map((name) => name[0])
28
25
  .join('')
29
26
  .substring(0, 2)
30
27
 
@@ -41,10 +38,10 @@ const Avatar = (props: AvatarProps) => {
41
38
  status = null,
42
39
  dark = false,
43
40
  } = props
44
- const dataProps = buildDataProps(data)
45
- const ariaProps = buildAriaProps(aria)
41
+ const dataProps: {[key: string]: any} = buildDataProps(data)
42
+ const ariaProps: {[key: string]: any} = buildAriaProps(aria)
46
43
  const classes = classnames(
47
- buildCss('pb_avatar_kit', size),
44
+ buildCss('pb_avatar_kit', `size_${size}`),
48
45
  globalProps(props),
49
46
  className
50
47
  )
@@ -55,6 +52,8 @@ const Avatar = (props: AvatarProps) => {
55
52
  const [error, setError] = useState(false)
56
53
  const handleError = () => setError(true)
57
54
 
55
+ const canShowImage = imageUrl && !error
56
+
58
57
  return (
59
58
  <div
60
59
  {...ariaProps}
@@ -66,21 +65,21 @@ const Avatar = (props: AvatarProps) => {
66
65
  className="avatar_wrapper"
67
66
  data-initials={initials}
68
67
  >
69
- <If condition={imageUrl && !error}>
68
+ { canShowImage && (
70
69
  <Image
71
70
  alt={imageAlt}
72
71
  onError={handleError}
73
72
  url={imageUrl}
74
73
  />
75
- </If>
74
+ )}
76
75
  </div>
77
- <If condition={status}>
76
+ {status && (
78
77
  <OnlineStatus
79
78
  className={`size_${size}`}
80
79
  dark={dark}
81
80
  status={status}
82
81
  />
83
- </If>
82
+ )}
84
83
  </div>
85
84
  )
86
85
  }
@@ -18,7 +18,7 @@ module Playbook
18
18
  end
19
19
 
20
20
  def classname
21
- generate_classname("pb_avatar_kit", size)
21
+ generate_classname("pb_avatar_kit", "size_#{size}")
22
22
  end
23
23
 
24
24
  def online_status_props
@@ -22,7 +22,7 @@ test('loads the given image url and name', () => {
22
22
  const image = screen.getByAltText(imageAlt)
23
23
  const initials = name.split(/\s/)[0].substr(0, 1) + name.split(/\s/)[1].substr(0, 1)
24
24
 
25
- expect(kit).toHaveClass('pb_avatar_kit_md')
25
+ expect(kit).toHaveClass('pb_avatar_kit_size_md')
26
26
  expect(kit).toHaveAttribute('data-initials', initials)
27
27
  expect(image).toHaveAttribute('data-src', imageUrl)
28
28
  expect(image).toHaveAttribute('src', imageUrl)
@@ -8,7 +8,7 @@ import {
8
8
  buildCss,
9
9
  buildDataProps,
10
10
  } from '../utilities/props'
11
- import { globalProps } from '../utilities/globalProps.js'
11
+ import { globalProps } from '../utilities/globalProps'
12
12
 
13
13
  import Avatar from '../pb_avatar/_avatar'
14
14
  import Icon from '../pb_icon/_icon'
@@ -3,9 +3,10 @@
3
3
  import React from 'react'
4
4
  import classnames from 'classnames'
5
5
  import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
6
- import { globalProps } from '../utilities/globalProps.js'
6
+ import { globalProps } from '../utilities/globalProps'
7
7
 
8
8
  type BackgroundProps = {
9
+ alt?: string,
9
10
  aria?: object,
10
11
  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',
11
12
  children?: array<React.ReactNode> | React.ReactNode,
@@ -15,10 +16,12 @@ type BackgroundProps = {
15
16
  imageUrl?: string,
16
17
  padding?: 'none' | 'xs' | 'sm' | 'md' | 'lg' | 'xl',
17
18
  tag?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'p' | 'span' | 'div',
19
+ transition?: 'fade' | 'blur' | 'scale',
18
20
  }
19
21
 
20
22
  const Background = (props: BackgroundProps) => {
21
23
  const {
24
+ alt = '',
22
25
  aria = {},
23
26
  backgroundColor = 'light',
24
27
  children,
@@ -27,22 +30,24 @@ const Background = (props: BackgroundProps) => {
27
30
  id,
28
31
  imageUrl = '',
29
32
  tag = 'div',
33
+ transition = '',
30
34
  } = props
31
35
 
32
36
  const ariaProps = buildAriaProps(aria)
33
37
  const dataProps = buildDataProps(data)
34
38
 
35
- const classes = classnames(buildCss('pb_background_kit'), globalProps(props), `pb_background_color_${backgroundColor}`, className)
36
- const Tag = `${tag}`
37
39
  const backgroundStyle = {
38
40
  backgroundImage: `url(${imageUrl})`,
39
41
  backgroundSize: 'cover',
40
42
  }
43
+ const classes = classnames(buildCss('pb_background_kit'), 'lazyload', backgroundStyle, transition, globalProps(props), `pb_background_color_${backgroundColor}`, className)
44
+ const Tag = `${tag}`
41
45
 
42
46
  return (
43
47
  <>
44
48
  <If condition={imageUrl}>
45
49
  <Tag
50
+ alt={alt}
46
51
  style={backgroundStyle}
47
52
  {...ariaProps}
48
53
  {...dataProps}
@@ -22,14 +22,30 @@ $background_colors: map-merge($additional_colors, $merge_kits2);
22
22
  }
23
23
  };
24
24
 
25
- .blur_up {
26
- -webkit-filter: blur(6px);
27
- filter: blur(6px);
28
- transition: filter 550ms, -webkit-filter 550ms;
25
+ &.fade {
26
+ opacity: 0;
27
+ &.lazyloaded {
28
+ opacity: 1;
29
+ transition: opacity 400ms ease-in;
30
+ }
29
31
  }
30
-
31
- .blur_up.lazyloaded {
32
- -webkit-filter: blur(0);
33
- filter: blur(0);
32
+
33
+ &.blur {
34
+ filter: blur(5px);
35
+ &.lazyloaded {
36
+ -webkit-filter: blur(0);
37
+ filter: blur(0);
38
+ transition: filter 400ms ease-in;
39
+ }
40
+ }
41
+
42
+ &.scale {
43
+ opacity: 0;
44
+ transform: scale(0.9);
45
+ &.lazyloaded {
46
+ opacity: 1;
47
+ transform: scale(1);
48
+ transition: 700ms ease-in;
49
+ }
34
50
  }
35
51
  }
@@ -12,18 +12,18 @@ module Playbook
12
12
  values: %w[h1 h2 h3 h4 h5 h6 p div span],
13
13
  default: "div"
14
14
 
15
+ prop :transition, type: Playbook::Props::Enum,
16
+ values: ["blur", "fade", "scale", nil],
17
+ default: nil
18
+
15
19
  def classname
16
- generate_classname("pb_background_kit", image_classname, background_color_classname, separator: " ")
20
+ generate_classname("pb_background_kit", image_classname, separator: " ")
17
21
  end
18
22
 
19
23
  private
20
24
 
21
25
  def image_classname
22
- image_url.present? ? "lazyload blur_up" : ""
23
- end
24
-
25
- def background_color_classname
26
- !image_url.present? ? "pb_background_color_#{background_color}" : ""
26
+ image_url.present? ? "lazyload #{transition}" : "pb_background_color_#{background_color}"
27
27
  end
28
28
  end
29
29
  end
@@ -1,5 +1,5 @@
1
- <%= pb_rails("background", props: { image_url: "https://images.unsplash.com/photo-1528459801416-a9e53bbf4e17?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1000&q=80", padding: "lg" }) do %>
2
- <%= pb_rails("flex", props: { horizontal: "center", orientation: "column" }) do %>
1
+ <%= pb_rails("background", props: { classname: "background-image", image_url: "https://images.unsplash.com/photo-1528459801416-a9e53bbf4e17?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1000&q=80", padding: "lg" }) do %>
2
+ <%= pb_rails("flex", props: { horizontal: "center", orientation: "column", margin_bottom: "xl" }) do %>
3
3
  <%= pb_rails("flex/flex_item") do %>
4
4
  <%= pb_rails("title", props: { dark: true, size: 1, text: "Background Kit Image" })%>
5
5
  <% end %>
@@ -11,3 +11,51 @@
11
11
  <% end %>
12
12
  <% end %>
13
13
  <% end %>
14
+
15
+
16
+ <%= pb_rails("flex", props: { margin_top: "lg" }) do %>
17
+ <%= pb_rails("flex/flex_item", props: {fixed_size: "250px"}) do %>
18
+ <%= pb_rails("select", props: {
19
+ id: "transition-dropdown",
20
+ label: "",
21
+ blank_selection: "Select a Transition...",
22
+ options: [
23
+ {
24
+ value: 'fade',
25
+ },
26
+ {
27
+ value: 'blur',
28
+ },
29
+ {
30
+ value: 'scale',
31
+ },
32
+ ]
33
+ }) %>
34
+ <% end %>
35
+ <% end %>
36
+
37
+ <script>
38
+ window.addEventListener('DOMContentLoaded', () => {
39
+ const transitionDropdown = document.querySelector("#transition-dropdown")
40
+ var option = ''
41
+
42
+ transitionDropdown.addEventListener('change', function() {
43
+ if (this.value === '') {
44
+ (transitionDropdown).className = (transitionDropdown).className + ' _disabled'
45
+ } else {
46
+ (transitionDropdown).removeAttribute("disabled");
47
+ (transitionDropdown).className = (transitionDropdown)
48
+ option = this.value
49
+ }
50
+ });
51
+
52
+ const updateTransition = (transition) => {
53
+ const imageTransition = document.querySelector('.background-image')
54
+ imageTransition.classList.remove("fade", "blur", "scale", "lazyloaded")
55
+ imageTransition.classList.add(transition, "lazyload")
56
+ }
57
+ (transitionDropdown).addEventListener('change', function() {
58
+ updateTransition(option)
59
+ })
60
+ });
61
+ </script>
@@ -1,36 +1,79 @@
1
- import React from 'react'
1
+ import React, { useState } from 'react'
2
2
  import { Background } from '../..'
3
- import { Card, Flex, FlexItem, Title } from '../..'
3
+ import { Card, Flex, FlexItem, Select, Title } from '../..'
4
4
 
5
- const BackgroundImage = (props) => (
6
- <Background imageUrl="https://images.unsplash.com/photo-1528459801416-a9e53bbf4e17?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1000&q=80">
7
- <Flex
8
- orientation="column"
9
- vertical="center"
10
- {...props}
11
- >
12
- <FlexItem>
13
- <Title
14
- dark
15
- padding="lg"
16
- size={1}
17
- text="Background Kit Image"
18
- {...props}
19
- />
20
- </FlexItem>
21
- <FlexItem
22
- padding="lg"
5
+ const BackgroundImage = (props) => {
6
+ const [transition, setTransition] = useState('')
7
+
8
+ const handleTransition = ({ target }) => {
9
+ setTransition(target.value)
10
+ }
11
+
12
+ const options = [
13
+ {
14
+ value: 'fade',
15
+ },
16
+ {
17
+ value: 'blur',
18
+ },
19
+ {
20
+ value: 'scale',
21
+ },
22
+ ]
23
+
24
+ return (
25
+ <>
26
+ <Background
27
+ alt="colorful background"
28
+ className="background lazyload"
29
+ imageUrl="https://images.unsplash.com/photo-1528459801416-a9e53bbf4e17?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1000&q=80"
30
+ transition={transition}
23
31
  {...props}
24
32
  >
25
- <Card
26
- shadow="deepest"
33
+ <Flex
34
+ orientation="column"
35
+ vertical="center"
27
36
  {...props}
28
37
  >
29
- {'We cannot seek achievement for ourselves and forget about progress and prosperity for our community... Our ambitions must be broad enough to include the aspirations and needs of others, for their sakes and for our own. - Cesar Chavez'}
30
- </Card>
31
- </FlexItem>
32
- </Flex>
33
- </Background>
34
- )
38
+ <FlexItem>
39
+ <Title
40
+ dark
41
+ padding="lg"
42
+ size={1}
43
+ text="Background Kit Image"
44
+ {...props}
45
+ />
46
+ </FlexItem>
47
+ <FlexItem
48
+ padding="lg"
49
+ {...props}
50
+ >
51
+ <Card
52
+ shadow="deepest"
53
+ {...props}
54
+ >
55
+ {
56
+ 'We cannot seek achievement for ourselves and forget about progress and prosperity for our community... Our ambitions must be broad enough to include the aspirations and needs of others, for their sakes and for our own. - Cesar Chavez'
57
+ }
58
+ </Card>
59
+ </FlexItem>
60
+ </Flex>
61
+ </Background>
62
+ <Flex marginTop="xl">
63
+ <FlexItem fixedSize="250px">
64
+ <Select
65
+ blankSelection="Select a Transition..."
66
+ label=""
67
+ name="dropdown"
68
+ onChange={handleTransition}
69
+ options={options}
70
+ transition={transition}
71
+ {...props}
72
+ />
73
+ </FlexItem>
74
+ </Flex>
75
+ </>
76
+ )
77
+ }
35
78
 
36
79
  export default BackgroundImage
@@ -0,0 +1 @@
1
+ To add a lazyload on the background image simply use the `transition` prop and one of the three string options `"fade"`, `"blur"`, or `"scale"`.
@@ -3,11 +3,12 @@
3
3
  import React from 'react'
4
4
  import classnames from 'classnames'
5
5
 
6
- import { globalProps } from '../utilities/globalProps.js'
6
+ import { globalProps } from '../utilities/globalProps'
7
7
  import pbChart from '../plugins/pb_chart'
8
8
 
9
9
  type BarGraphProps = {
10
10
  axisTitle: string,
11
+ dark?: Boolean,
11
12
  xAxisCategories: array,
12
13
  yAxisMin: number,
13
14
  yAxisMax: number,
@@ -30,6 +31,7 @@ type BarGraphProps = {
30
31
  export default class BarGraph extends React.Component<BarGraphProps> {
31
32
  static defaultProps = {
32
33
  className: 'pb_bar_graph',
34
+ dark: false,
33
35
  type: 'column',
34
36
  legend: false,
35
37
  toggleLegendClick: true,
@@ -38,6 +40,7 @@ export default class BarGraph extends React.Component<BarGraphProps> {
38
40
  componentDidMount() {
39
41
  const {
40
42
  axisTitle,
43
+ dark,
41
44
  xAxisCategories,
42
45
  yAxisMin,
43
46
  yAxisMax,
@@ -56,6 +59,7 @@ export default class BarGraph extends React.Component<BarGraphProps> {
56
59
 
57
60
  new pbChart(`.${className}`, {
58
61
  axisTitle: axisTitle,
62
+ dark,
59
63
  chartData: chartData,
60
64
  colors: colors,
61
65
  id: id,
@@ -33,6 +33,7 @@ module Playbook
33
33
  id: id,
34
34
  className: classname,
35
35
  chartData: chart_data,
36
+ dark: dark ? "dark" : "",
36
37
  type: chart_type,
37
38
  title: title,
38
39
  subtitle: subtitle,
@@ -2,7 +2,7 @@
2
2
 
3
3
  import React from 'react'
4
4
  import classnames from 'classnames'
5
- import { globalProps } from '../utilities/globalProps.js'
5
+ import { globalProps } from '../utilities/globalProps'
6
6
 
7
7
  import {
8
8
  buildAriaProps,
@@ -2,7 +2,7 @@
2
2
 
3
3
  import React from 'react'
4
4
  import classnames from 'classnames'
5
- import { globalProps } from '../utilities/globalProps.js'
5
+ import { globalProps } from '../utilities/globalProps'
6
6
 
7
7
  import {
8
8
  buildAriaProps,
@@ -3,7 +3,7 @@
3
3
  import React from 'react'
4
4
  import classnames from 'classnames'
5
5
  import { buildAriaProps, buildDataProps } from '../utilities/props'
6
- import { globalProps } from '../utilities/globalProps.js'
6
+ import { globalProps } from '../utilities/globalProps'
7
7
 
8
8
  import Icon from '../pb_icon/_icon.jsx'
9
9
 
@@ -22,7 +22,7 @@ type ButtonPropTypes = {
22
22
  loading?: boolean,
23
23
  newWindow?: boolean,
24
24
  onClick?: EventHandler,
25
- size: 'large' | 'medium' | 'small',
25
+ size?: 'sm' | 'md' | 'lg',
26
26
  text?: string,
27
27
  type: 'inline' | null,
28
28
  htmlType: string | 'button',
@@ -36,19 +36,19 @@ const buttonClassName = (props: ButtonPropTypes) => {
36
36
  disabled = false,
37
37
  fullWidth = false,
38
38
  loading = false,
39
- size = null,
40
39
  type = 'inline',
41
40
  variant = 'primary',
41
+ size = null,
42
42
  } = props
43
43
 
44
44
  let className = 'pb_button_kit'
45
45
 
46
46
  className += `${variant !== null ? `_${variant}` : ''}`
47
47
  className += `${type !== null ? `_${type}` : ''}`
48
- className += `${size !== null ? `_${size}` : ''}`
49
48
  className += `${fullWidth ? '_block' : ''}`
50
49
  className += disabled ? '_disabled' : '_enabled'
51
50
  className += loading ? '_loading' : ''
51
+ className += `${size !== null ? ` size_${size}` : ''}`
52
52
 
53
53
  return className
54
54
  }
@@ -106,6 +106,7 @@ const Button = (props: ButtonPropTypes) => {
106
106
  className={css}
107
107
  href={link}
108
108
  id={id}
109
+ rel="noreferrer"
109
110
  role="link"
110
111
  target={newWindow ? '_blank' : null}
111
112
  >
@@ -1,7 +1,24 @@
1
1
  @import "./button_mixins";
2
2
 
3
- [class^=pb_button_kit]{
3
+ $pb_button_sizes: (
4
+ "sm": 0.75rem,
5
+ "md": 0.875rem,
6
+ "lg": 1.125rem,
7
+ );
8
+
9
+ [class*=pb_button_kit]{
4
10
  @include pb_button;
11
+ // Size =================
12
+ @each $name, $size in $pb_button_sizes {
13
+ &[class*=size_#{$name}] {
14
+ font-size: $size;
15
+ padding: calc(#{$size} / 2) calc(#{$size} * 2.42) !important;
16
+ }
17
+ @if $name == "sm" {
18
+ min-height: 0;
19
+ }
20
+ }
21
+
5
22
  // Variants =================
6
23
  &[class*=_primary] {
7
24
  @include pb_button_primary;
@@ -18,6 +18,9 @@ module Playbook
18
18
  prop :text
19
19
  prop :type
20
20
  prop :value
21
+ prop :size, type: Playbook::Props::Enum,
22
+ values: ["sm", "md", "lg", nil],
23
+ default: nil
21
24
 
22
25
  def options
23
26
  {
@@ -44,12 +47,13 @@ module Playbook
44
47
  link ? "a" : "button"
45
48
  end
46
49
 
47
- private
48
-
49
50
  def classname
50
- generate_classname("pb_button_kit", variant, full_width_class, disabled_class, loading_class)
51
+ button_class = generate_classname("pb_button_kit", variant, full_width_class, disabled_class, loading_class)
52
+ button_class + size_class
51
53
  end
52
54
 
55
+ private
56
+
53
57
  def disabled_class
54
58
  disabled ? "disabled" : "enabled"
55
59
  end
@@ -61,6 +65,10 @@ module Playbook
61
65
  def loading_class
62
66
  loading ? "loading" : nil
63
67
  end
68
+
69
+ def size_class
70
+ size ? " size_#{size}" : ""
71
+ end
64
72
  end
65
73
  end
66
74
  end
@@ -89,3 +89,16 @@ test('click event', async () => {
89
89
 
90
90
  expect(screen.getByText('clicked button!')).toBeInTheDocument()
91
91
  })
92
+
93
+ test('size prop', () => {
94
+ render(
95
+ <Button
96
+ data={{ testid: 'size-test' }}
97
+ size="sm"
98
+ />
99
+ )
100
+
101
+ const kit = screen.getByTestId('size-test')
102
+
103
+ expect(kit).toHaveClass('pb_button_kit_primary_inline_enabled size_sm')
104
+ })
@@ -0,0 +1,3 @@
1
+ <%= pb_rails("button", props: { text: "Button sm size", size: "sm" }) %>
2
+ <%= pb_rails("button", props: { text: "Button md size", size: "md" }) %>
3
+ <%= pb_rails("button", props: { text: "Button lg size", size: "lg" }) %>
@@ -0,0 +1,26 @@
1
+ import React from 'react'
2
+ import { Button } from '../../'
3
+
4
+ const ButtonSize = (props) => (
5
+ <div>
6
+ <Button
7
+ size="sm"
8
+ text="Button sm size"
9
+ {...props}
10
+ />
11
+ {' '}
12
+ <Button
13
+ size="md"
14
+ text="Button md size"
15
+ {...props}
16
+ />
17
+ {' '}
18
+ <Button
19
+ size="lg"
20
+ text="Button lg size"
21
+ {...props}
22
+ />
23
+ </div>
24
+ )
25
+
26
+ export default ButtonSize