playbook_ui 8.0.3 → 8.1.0.pre.alpha1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (147) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +9 -0
  3. data/app/pb_kits/playbook/_playbook.scss +10 -7
  4. data/app/pb_kits/playbook/data/menu.yml +3 -1
  5. data/app/pb_kits/playbook/index.js +3 -0
  6. data/app/pb_kits/playbook/pb_avatar/_avatar.jsx +14 -2
  7. data/app/pb_kits/playbook/pb_avatar/avatar.html.erb +1 -1
  8. data/app/pb_kits/playbook/pb_avatar/avatar.rb +5 -2
  9. data/app/pb_kits/playbook/pb_avatar/avatar.test.js +5 -2
  10. data/app/pb_kits/playbook/pb_avatar/docs/_avatar_default.html.erb +5 -0
  11. data/app/pb_kits/playbook/pb_avatar/docs/_avatar_default.jsx +5 -0
  12. data/app/pb_kits/playbook/pb_avatar/docs/_avatar_status.html.erb +4 -0
  13. data/app/pb_kits/playbook/pb_avatar/docs/_avatar_status.jsx +4 -0
  14. data/app/pb_kits/playbook/pb_avatar_action_button/_avatar_action_button.jsx +6 -0
  15. data/app/pb_kits/playbook/pb_avatar_action_button/avatar_action_button.html.erb +2 -1
  16. data/app/pb_kits/playbook/pb_avatar_action_button/avatar_action_button.rb +2 -0
  17. data/app/pb_kits/playbook/pb_avatar_action_button/docs/_avatar_action_button_actions.html.erb +4 -0
  18. data/app/pb_kits/playbook/pb_avatar_action_button/docs/_avatar_action_button_actions.jsx +4 -0
  19. data/app/pb_kits/playbook/pb_avatar_action_button/docs/_avatar_action_button_default.html.erb +2 -0
  20. data/app/pb_kits/playbook/pb_avatar_action_button/docs/_avatar_action_button_default.jsx +2 -0
  21. data/app/pb_kits/playbook/pb_avatar_action_button/docs/_avatar_action_button_on_click.jsx +2 -0
  22. data/app/pb_kits/playbook/pb_avatar_action_button/docs/_avatar_action_button_onclick.html.erb +2 -0
  23. data/app/pb_kits/playbook/pb_avatar_action_button/docs/_avatar_action_button_placement.html.erb +8 -0
  24. data/app/pb_kits/playbook/pb_avatar_action_button/docs/_avatar_action_button_placement.jsx +8 -0
  25. data/app/pb_kits/playbook/pb_avatar_action_button/docs/_avatar_action_button_tooltip.html.erb +2 -0
  26. data/app/pb_kits/playbook/pb_avatar_action_button/pb_avatar_action_button.test.js +31 -0
  27. data/app/pb_kits/playbook/pb_badge/_badge.jsx +26 -1
  28. data/app/pb_kits/playbook/pb_button/_button.jsx +6 -0
  29. data/app/pb_kits/playbook/pb_button/button.test.js +91 -0
  30. data/app/pb_kits/playbook/pb_button/docs/_button_default.jsx +0 -1
  31. data/app/pb_kits/playbook/pb_button_toolbar/button_toolbar.test.js +46 -0
  32. data/app/pb_kits/playbook/pb_caption/_caption.jsx +3 -2
  33. data/app/pb_kits/playbook/pb_caption/caption.rb +1 -1
  34. data/app/pb_kits/playbook/pb_card/_card.jsx +18 -3
  35. data/app/pb_kits/playbook/pb_card/card.html.erb +1 -1
  36. data/app/pb_kits/playbook/pb_card/card.rb +3 -0
  37. data/app/pb_kits/playbook/pb_card/card_header.rb +7 -7
  38. data/app/pb_kits/playbook/pb_card/docs/_card_tag.html.erb +25 -0
  39. data/app/pb_kits/playbook/pb_card/docs/_card_tag.jsx +59 -0
  40. data/app/pb_kits/playbook/pb_card/docs/example.yml +2 -0
  41. data/app/pb_kits/playbook/pb_card/docs/index.js +1 -0
  42. data/app/pb_kits/playbook/pb_circle_icon_button/circle_icon_button.test.js +17 -0
  43. data/app/pb_kits/playbook/pb_collapsible/_collapsible.jsx +84 -0
  44. data/app/pb_kits/playbook/pb_collapsible/_collapsible.scss +15 -0
  45. data/app/pb_kits/playbook/pb_collapsible/child_kits/CollapsibleContent.jsx +40 -0
  46. data/app/pb_kits/playbook/pb_collapsible/child_kits/CollapsibleMain.jsx +59 -0
  47. data/app/pb_kits/playbook/pb_collapsible/collapsible.html.erb +7 -0
  48. data/app/pb_kits/playbook/pb_collapsible/collapsible.rb +11 -0
  49. data/app/pb_kits/playbook/pb_collapsible/collapsible.test.js +50 -0
  50. data/app/pb_kits/playbook/pb_collapsible/collapsible_content.html.erb +7 -0
  51. data/app/pb_kits/playbook/pb_collapsible/collapsible_content.rb +17 -0
  52. data/app/pb_kits/playbook/pb_collapsible/collapsible_main.html.erb +16 -0
  53. data/app/pb_kits/playbook/pb_collapsible/collapsible_main.rb +15 -0
  54. data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_default.html.erb +10 -0
  55. data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_default.jsx +19 -0
  56. data/app/pb_kits/playbook/pb_collapsible/docs/example.yml +9 -0
  57. data/app/pb_kits/playbook/pb_collapsible/docs/index.js +1 -0
  58. data/app/pb_kits/playbook/pb_collapsible/index.js +79 -0
  59. data/app/pb_kits/playbook/pb_dashboard/commonSettings.js +2 -2
  60. data/app/pb_kits/playbook/pb_dashboard/pbChartsLightTheme.js +2 -2
  61. data/app/pb_kits/playbook/pb_date_time_stacked/_date_time_stacked.jsx +6 -2
  62. data/app/pb_kits/playbook/pb_date_time_stacked/date_time_stacked.html.erb +1 -1
  63. data/app/pb_kits/playbook/pb_dialog/_close_icon.jsx +23 -0
  64. data/app/pb_kits/playbook/pb_dialog/_dialog.html.erb +10 -0
  65. data/app/pb_kits/playbook/pb_dialog/_dialog.jsx +142 -0
  66. data/app/pb_kits/playbook/pb_dialog/_dialog.scss +133 -0
  67. data/app/pb_kits/playbook/pb_dialog/_dialog_context.jsx +3 -0
  68. data/app/pb_kits/playbook/pb_dialog/child_kits/_dialog_body.jsx +21 -0
  69. data/app/pb_kits/playbook/pb_dialog/child_kits/_dialog_footer.jsx +36 -0
  70. data/app/pb_kits/playbook/pb_dialog/child_kits/_dialog_header.jsx +68 -0
  71. data/app/pb_kits/playbook/pb_dialog/dialog.rb +47 -0
  72. data/app/pb_kits/playbook/pb_dialog/dialog.test.jsx +23 -0
  73. data/app/pb_kits/playbook/pb_dialog/dialog_header.rb +31 -0
  74. data/app/pb_kits/playbook/pb_dialog/docs/_dialog_compound_components.jsx +53 -0
  75. data/app/pb_kits/playbook/pb_dialog/docs/_dialog_compound_components.md +2 -0
  76. data/app/pb_kits/playbook/pb_dialog/docs/_dialog_default.jsx +27 -0
  77. data/app/pb_kits/playbook/pb_dialog/docs/_dialog_scrollable.jsx +27 -0
  78. data/app/pb_kits/playbook/pb_dialog/docs/_dialog_scrollable.md +2 -0
  79. data/app/pb_kits/playbook/pb_dialog/docs/_dialog_separators.jsx +119 -0
  80. data/app/pb_kits/playbook/pb_dialog/docs/_dialog_separators.md +2 -0
  81. data/app/pb_kits/playbook/pb_dialog/docs/_dialog_should_close_on_overlay.jsx +28 -0
  82. data/app/pb_kits/playbook/pb_dialog/docs/_dialog_should_close_on_overlay.md +2 -0
  83. data/app/pb_kits/playbook/pb_dialog/docs/_dialog_sizes.jsx +93 -0
  84. data/app/pb_kits/playbook/pb_dialog/docs/example.yml +10 -0
  85. data/app/pb_kits/playbook/pb_dialog/docs/index.js +6 -0
  86. data/app/pb_kits/playbook/pb_docs/kit_example.rb +1 -1
  87. data/app/pb_kits/playbook/pb_inline/_inline.jsx +83 -0
  88. data/app/pb_kits/playbook/pb_inline/_inline.scss +58 -0
  89. data/app/pb_kits/playbook/pb_inline/docs/_inline_default.jsx +36 -0
  90. data/app/pb_kits/playbook/pb_inline/docs/_inline_input_options.jsx +58 -0
  91. data/app/pb_kits/playbook/pb_inline/docs/_inline_text_options.jsx +99 -0
  92. data/app/pb_kits/playbook/pb_inline/docs/example.yml +5 -0
  93. data/app/pb_kits/playbook/pb_inline/docs/index.js +3 -0
  94. data/app/pb_kits/playbook/pb_inline/inline.test.jsx +21 -0
  95. data/app/pb_kits/playbook/pb_nav/_item.jsx +2 -0
  96. data/app/pb_kits/playbook/pb_nav/_nav.jsx +2 -2
  97. data/app/pb_kits/playbook/pb_nav/item.html.erb +2 -2
  98. data/app/pb_kits/playbook/pb_nav/nav.html.erb +1 -1
  99. data/app/pb_kits/playbook/pb_online_status/_online_status.jsx +2 -0
  100. data/app/pb_kits/playbook/pb_online_status/online_status.html.erb +1 -1
  101. data/app/pb_kits/playbook/pb_progress_simple/_progress_simple.jsx +1 -1
  102. data/app/pb_kits/playbook/pb_progress_simple/_progress_simple.scss +5 -0
  103. data/app/pb_kits/playbook/pb_progress_simple/docs/_progress_simple_variants.html.erb +5 -0
  104. data/app/pb_kits/playbook/pb_progress_simple/docs/_progress_simple_variants.jsx +7 -0
  105. data/app/pb_kits/playbook/pb_progress_simple/docs/_progress_simple_variants.md +1 -1
  106. data/app/pb_kits/playbook/pb_progress_simple/progress_simple.rb +1 -1
  107. data/app/pb_kits/playbook/pb_rich_text_editor/_rich_text_editor.jsx +4 -3
  108. data/app/pb_kits/playbook/pb_text_input/_text_input.jsx +3 -0
  109. data/app/pb_kits/playbook/pb_textarea/_textarea.jsx +3 -0
  110. data/app/pb_kits/playbook/pb_time_stacked/_time_stacked.jsx +43 -26
  111. data/app/pb_kits/playbook/pb_time_stacked/_time_stacked.scss +18 -0
  112. data/app/pb_kits/playbook/pb_time_stacked/docs/_time_stacked_default.html.erb +18 -5
  113. data/app/pb_kits/playbook/pb_time_stacked/docs/_time_stacked_default.jsx +10 -5
  114. data/app/pb_kits/playbook/pb_time_stacked/time_stacked.html.erb +7 -3
  115. data/app/pb_kits/playbook/pb_time_stacked/time_stacked.rb +8 -30
  116. data/app/pb_kits/playbook/pb_time_stacked/time_stacked.test.js +33 -0
  117. data/app/pb_kits/playbook/pb_tooltip/_tooltip.scss +4 -3
  118. data/app/pb_kits/playbook/pb_typeahead/_typeahead.jsx +6 -1
  119. data/app/pb_kits/playbook/pb_typeahead/components/MultiValue.jsx +25 -2
  120. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_default.jsx +1 -0
  121. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills.jsx +7 -3
  122. data/app/pb_kits/playbook/plugins/pb_chart.js +1 -1
  123. data/app/pb_kits/playbook/react_rails_kits.js +4 -0
  124. data/app/pb_kits/playbook/tokens/_border_radius.scss +0 -10
  125. data/app/pb_kits/playbook/tokens/_colors.scss +0 -25
  126. data/app/pb_kits/playbook/tokens/_line_height.scss +0 -9
  127. data/app/pb_kits/playbook/tokens/_opacity.scss +0 -9
  128. data/app/pb_kits/playbook/tokens/_positioning.scss +0 -9
  129. data/app/pb_kits/playbook/tokens/_screen_sizes.scss +0 -9
  130. data/app/pb_kits/playbook/tokens/_shadows.scss +0 -9
  131. data/app/pb_kits/playbook/tokens/_spacing.scss +0 -10
  132. data/app/pb_kits/playbook/tokens/_typography.scss +0 -25
  133. data/app/pb_kits/playbook/tokens/exports/_border_radius.scss +10 -0
  134. data/app/pb_kits/playbook/tokens/exports/_colors.scss +26 -0
  135. data/app/pb_kits/playbook/tokens/exports/_line_height.scss +10 -0
  136. data/app/pb_kits/playbook/tokens/exports/_opacity.scss +10 -0
  137. data/app/pb_kits/playbook/tokens/exports/_positioning.scss +10 -0
  138. data/app/pb_kits/playbook/tokens/exports/_screen_sizes.scss +10 -0
  139. data/app/pb_kits/playbook/tokens/exports/_shadows.scss +10 -0
  140. data/app/pb_kits/playbook/tokens/exports/_spacing.scss +10 -0
  141. data/app/pb_kits/playbook/tokens/exports/_typography.scss +24 -0
  142. data/app/pb_kits/playbook/utilities/test-utils.js +6 -0
  143. data/app/pb_kits/playbook/vendor.js +3 -0
  144. data/dist/reset.css +1 -0
  145. data/lib/playbook/props/base.rb +1 -1
  146. data/lib/playbook/version.rb +1 -1
  147. metadata +74 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ba4203db09f20dc8904716f5920b8d0664ecbb7520939dcabb853cd0879ac6b4
4
- data.tar.gz: 0ee8e4ae7924af54ee7998407b6f30d9f55020e1d4df2a8d8987ab02e912080e
3
+ metadata.gz: 7a3094cf29b37623db8e98428c084b6ab9b83d7ada528d70de6cd7a876784d10
4
+ data.tar.gz: c214e4fe02f07672f3e8c2aa8887c683c5a1ddb987f5e4c33da5d60f5f8f32b9
5
5
  SHA512:
6
- metadata.gz: c8afdb091c129aaaf7e6df96c88c8b526067b88f38094a5371fe249dac3017f43c37e9bb5fbca7f484a423fc993ce81861c892411ae926fca2b839092a3bd592
7
- data.tar.gz: 9403b804db36c8ada5bae70b336bd37c8903c3c6b6493d0888318daf7a38f7e4b4b7d6b00a2f5c66c02ae45790f33017de2f2a5e58524cf3e7c518a3413446a1
6
+ metadata.gz: 91a1e1d81bf3a06745d3df8ae2b9a16ae71878444fc3c4ef839230d79017cd4d554ccfe79f1d2f93c2d213020465ee634e9bf52c8216448c0536ae7ee4be92bf
7
+ data.tar.gz: fe21bfb352f669bbaf6d640d97d8400b0882b19df3b369969a0c1cd4409c6adce3695229dc2721c42aa5388603fd3f1a57b292fe2f619d2b354ff4de7ba9893a
data/README.md CHANGED
@@ -42,6 +42,15 @@ See [docs/upgrade-guide](./docs/upgrade-guide)
42
42
 
43
43
  * [Common Errors & Solutions](https://github.com/powerhome/playbook/wiki/Common-Errors-&-Solutions)
44
44
 
45
+ ### Reset.css
46
+
47
+ Playbook provides it's own `reset.css` boilerplate for optional use in your application. You can either:
48
+
49
+ 1. Import the `dist/reset.css` from the playbook_ui gem into your Rails view: `@import "reset.css"` (note: your path may vary depending on your application's asset paths)
50
+ 2. Import or include the file via the npm package: `import 'reset.css'` (note: your path may vary depending on your application's node-sass `includePaths`)
51
+
52
+ This asset aims to provide a commonly styles base for supported browsers.
53
+
45
54
  ### Building Playbook Kits
46
55
 
47
56
  * [Generating a Kit](https://github.com/powerhome/playbook/wiki/Generating-a-Kit)
@@ -1,11 +1,11 @@
1
- @import "tokens/fonts";
2
- @import "pb_background/background";
3
- @import "pb_body/body";
4
- @import "pb_button/button";
1
+ @import 'tokens/fonts';
2
+ @import 'pb_background/background';
3
+ @import 'pb_body/body';
4
+ @import 'pb_button/button';
5
5
  @import 'pb_button_toolbar/button_toolbar';
6
- @import "pb_caption/caption";
7
- @import "pb_card/card";
8
- @import "pb_title/title";
6
+ @import 'pb_caption/caption';
7
+ @import 'pb_card/card';
8
+ @import 'pb_title/title';
9
9
  @import 'pb_avatar/avatar';
10
10
  @import 'pb_avatar_action_button/avatar_action_button';
11
11
  @import 'pb_badge/badge';
@@ -13,6 +13,7 @@
13
13
  @import 'pb_checkbox/checkbox';
14
14
  @import 'pb_circle_chart/circle_chart';
15
15
  @import 'pb_circle_icon_button/circle_icon_button';
16
+ @import 'pb_collapsible/collapsible';
16
17
  @import 'pb_contact/contact';
17
18
  @import 'pb_currency/currency';
18
19
  @import 'pb_dashboard_value/dashboard_value';
@@ -24,6 +25,7 @@
24
25
  @import 'pb_date_stacked/date_stacked';
25
26
  @import 'pb_date_time_stacked/date_time_stacked';
26
27
  @import 'pb_date_year_stacked/date_year_stacked';
28
+ @import 'pb_dialog/dialog';
27
29
  @import 'pb_distribution_bar/distribution_bar';
28
30
  @import 'pb_file_upload/file_upload';
29
31
  @import 'pb_filter/filter';
@@ -41,6 +43,7 @@
41
43
  @import 'pb_icon_stat_value/icon_stat_value';
42
44
  @import 'pb_icon_value/icon_value';
43
45
  @import 'pb_image/image';
46
+ @import 'pb_inline/inline';
44
47
  @import 'pb_label_pill/label_pill';
45
48
  @import 'pb_label_value/label_value';
46
49
  @import 'pb_layout/layout';
@@ -8,6 +8,7 @@ kits:
8
8
  - circle_icon_button
9
9
  - card
10
10
  - checkbox
11
+ - collapsible
11
12
  - charts_and_graphs:
12
13
  - bar_graph
13
14
  - circle_chart
@@ -40,13 +41,13 @@ kits:
40
41
  - icon_stat_value
41
42
  - icon_value
42
43
  - image
44
+ - inline
43
45
  - layout
44
46
  - list
45
47
  - loading_inline
46
48
  - multiple_users
47
49
  - multiple_users_stacked
48
50
  - nav
49
- - online_status
50
51
  - tags:
51
52
  - badge
52
53
  - hashtag
@@ -95,3 +96,4 @@ kits:
95
96
  - weekday_stacked
96
97
  - user
97
98
  - user_badge
99
+ - dialog
@@ -17,6 +17,7 @@ export Card from './pb_card/_card.jsx'
17
17
  export Checkbox from './pb_checkbox/_checkbox.jsx'
18
18
  export CircleChart from './pb_circle_chart/_circle_chart.jsx'
19
19
  export CircleIconButton from './pb_circle_icon_button/_circle_icon_button.jsx'
20
+ export Collapsible from './pb_collapsible/_collapsible.jsx'
20
21
  export Contact from './pb_contact/_contact.jsx'
21
22
  export Currency from './pb_currency/_currency.jsx'
22
23
  export DashboardValue from './pb_dashboard_value/_dashboard_value.jsx'
@@ -28,6 +29,7 @@ export DateStacked from './pb_date_stacked/_date_stacked.jsx'
28
29
  export DateTime from './pb_date_time/_date_time.jsx'
29
30
  export DateTimeStacked from './pb_date_time_stacked/_date_time_stacked.jsx'
30
31
  export DateYearStacked from './pb_date_year_stacked/_date_year_stacked.jsx'
32
+ export Dialog from './pb_dialog/_dialog.jsx'
31
33
  export DistributionBar from './pb_distribution_bar/_distribution_bar.jsx'
32
34
  export FileUpload from './pb_file_upload/_file_upload.jsx'
33
35
  export Filter from './pb_filter/_filter.jsx'
@@ -45,6 +47,7 @@ export IconCircle from './pb_icon_circle/_icon_circle.jsx'
45
47
  export IconStatValue from './pb_icon_stat_value/_icon_stat_value.jsx'
46
48
  export IconValue from './pb_icon_value/_icon_value.jsx'
47
49
  export Image from './pb_image/_image.jsx'
50
+ export Inline from './pb_inline/_inline.jsx'
48
51
  export LabelPill from './pb_label_pill/_label_pill.jsx'
49
52
  export LabelValue from './pb_label_value/_label_value.jsx'
50
53
  export Layout from './pb_layout/_layout.jsx'
@@ -15,6 +15,7 @@ type AvatarProps = {
15
15
  data?: object,
16
16
  dark?: boolean,
17
17
  id?: string,
18
+ imageAlt?: string,
18
19
  imageUrl: string,
19
20
  name: string,
20
21
  size?: "md" | "lg" | "sm" | "xl" | "xs",
@@ -27,7 +28,18 @@ const firstTwoInitials = (name) =>
27
28
  .substring(0, 2)
28
29
 
29
30
  const Avatar = (props: AvatarProps) => {
30
- const { aria = {}, className, data = {}, name = null, id = '', imageUrl, size = 'md', status = null, dark = false } = props
31
+ const {
32
+ aria = {},
33
+ className,
34
+ data = {},
35
+ name = null,
36
+ id = '',
37
+ imageAlt = '',
38
+ imageUrl,
39
+ size = 'md',
40
+ status = null,
41
+ dark = false,
42
+ } = props
31
43
  const dataProps = buildDataProps(data)
32
44
  const ariaProps = buildAriaProps(aria)
33
45
  const classes = classnames(
@@ -55,7 +67,7 @@ const Avatar = (props: AvatarProps) => {
55
67
  >
56
68
  <If condition={imageUrl && !error}>
57
69
  <Image
58
- alt={name}
70
+ alt={imageAlt}
59
71
  onError={handleError}
60
72
  url={imageUrl}
61
73
  />
@@ -4,7 +4,7 @@
4
4
  class: object.classname,
5
5
  aria: object.aria) do %>
6
6
  <%= content_tag(:div, data: { initials: object.initials }, class: "avatar_wrapper") do %>
7
- <%= pb_rails("image", props: { url: object.image_url, on_error: object.handle_img_error }) if object.image_url.present? %>
7
+ <%= pb_rails("image", props: { alt: object.image_alt, url: object.image_url, on_error: object.handle_img_error }) if object.image_url.present? %>
8
8
  <% end %>
9
9
  <%= pb_rails("online_status", props: object.online_status_props) if object.status %>
10
10
  <% end %>
@@ -3,8 +3,11 @@
3
3
  module Playbook
4
4
  module PbAvatar
5
5
  class Avatar < Playbook::KitBase
6
- prop :image_url
7
- prop :name, default: ""
6
+ prop :image_url, type: Playbook::Props::String
7
+ prop :image_alt, type: Playbook::Props::String,
8
+ default: ""
9
+ prop :name, type: Playbook::Props::String,
10
+ default: ""
8
11
  prop :size, type: Playbook::Props::Enum,
9
12
  values: %w[xs sm md base lg xl],
10
13
  default: "md"
@@ -5,23 +5,26 @@ import Avatar from './_avatar'
5
5
 
6
6
  const imageUrl = 'https://randomuser.me/api/portraits/men/44.jpg',
7
7
  testId = 'tjohnson',
8
- name = 'Terry Johnson'
8
+ name = 'Terry Johnson',
9
+ imageAlt = 'Terry Johnson Standing'
9
10
 
10
11
  test('loads the given image url and name', () => {
11
12
  render(
12
13
  <Avatar
13
14
  data={{ testid: testId }}
15
+ imageAlt={imageAlt}
14
16
  imageUrl={imageUrl}
15
17
  name={name}
16
18
  />
17
19
  )
18
20
 
19
21
  const kit = screen.getByTestId(testId)
20
- const image = screen.getByAltText(name)
22
+ const image = screen.getByAltText(imageAlt)
21
23
  const initials = name.split(/\s/)[0].substr(0, 1) + name.split(/\s/)[1].substr(0, 1)
22
24
 
23
25
  expect(kit).toHaveClass('pb_avatar_kit_md')
24
26
  expect(kit).toHaveAttribute('data-initials', initials)
25
27
  expect(image).toHaveAttribute('data-src', imageUrl)
26
28
  expect(image).toHaveAttribute('src', imageUrl)
29
+ expect(image).toHaveAttribute('alt', imageAlt)
27
30
  })
@@ -1,6 +1,7 @@
1
1
  <%= pb_rails("avatar", props: {
2
2
  name: "Terry Johnson",
3
3
  size: "xs",
4
+ image_alt: "Terry Johnson Standing",
4
5
  image_url: "https://randomuser.me/api/portraits/men/44.jpg",
5
6
  status: "online"
6
7
  }) %>
@@ -10,6 +11,7 @@
10
11
  <%= pb_rails("avatar", props: {
11
12
  name: "Terry Johnson",
12
13
  size: "sm",
14
+ image_alt: "Terry Johnson Standing",
13
15
  image_url: "https://randomuser.me/api/portraits/men/44.jpg",
14
16
  status: "away"
15
17
  }) %>
@@ -19,6 +21,7 @@
19
21
  <%= pb_rails("avatar", props: {
20
22
  name: "Terry Johnson",
21
23
  size: "md",
24
+ image_alt: "Terry Johnson Standing",
22
25
  image_url: "https://randomuser.me/api/portraits/men/44.jpg",
23
26
  status: "offline"
24
27
  }) %>
@@ -28,6 +31,7 @@
28
31
  <%= pb_rails("avatar", props: {
29
32
  name: "Terry Johnson",
30
33
  size: "lg",
34
+ image_alt: "Terry Johnson Standing",
31
35
  image_url: "https://randomuser.me/api/portraits/men/44.jpg",
32
36
  status: "online"
33
37
  }) %>
@@ -37,6 +41,7 @@
37
41
  <%= pb_rails("avatar", props: {
38
42
  name: "Terry Johnson",
39
43
  size: "xl",
44
+ image_alt: "Terry Johnson Standing",
40
45
  image_url: "https://randomuser.me/api/portraits/men/44.jpg",
41
46
  status: "away"
42
47
  }) %>
@@ -5,6 +5,7 @@ const AvatarDefault = (props) => {
5
5
  return (
6
6
  <div>
7
7
  <Avatar
8
+ imageAlt="Terry Johnson Standing"
8
9
  imageUrl="https://randomuser.me/api/portraits/men/44.jpg"
9
10
  name="Terry Johnson"
10
11
  size="xs"
@@ -13,6 +14,7 @@ const AvatarDefault = (props) => {
13
14
  />
14
15
  <br />
15
16
  <Avatar
17
+ imageAlt="Terry Johnson Standing"
16
18
  imageUrl="https://randomuser.me/api/portraits/men/44.jpg"
17
19
  name="Terry Johnson"
18
20
  size="sm"
@@ -21,6 +23,7 @@ const AvatarDefault = (props) => {
21
23
  />
22
24
  <br />
23
25
  <Avatar
26
+ imageAlt="Terry Johnson Standing"
24
27
  imageUrl="https://randomuser.me/api/portraits/men/44.jpg"
25
28
  name="Terry Johnson"
26
29
  size="md"
@@ -29,6 +32,7 @@ const AvatarDefault = (props) => {
29
32
  />
30
33
  <br />
31
34
  <Avatar
35
+ imageAlt="Terry Johnson Standing"
32
36
  imageUrl="https://randomuser.me/api/portraits/men/44.jpg"
33
37
  name="Terry Johnson"
34
38
  size="lg"
@@ -37,6 +41,7 @@ const AvatarDefault = (props) => {
37
41
  />
38
42
  <br />
39
43
  <Avatar
44
+ imageAlt="Terry Johnson Standing"
40
45
  imageUrl="https://randomuser.me/api/portraits/men/44.jpg"
41
46
  name="Terry Johnson"
42
47
  size="xl"
@@ -1,6 +1,7 @@
1
1
  <%= pb_rails("avatar", props: {
2
2
  name: "Terry Johnson",
3
3
  size: "sm",
4
+ image_alt: "Terry Johnson Status",
4
5
  image_url: "https://randomuser.me/api/portraits/men/44.jpg"
5
6
  }) %>
6
7
 
@@ -9,6 +10,7 @@
9
10
  <%= pb_rails("avatar", props: {
10
11
  name: "Terry Johnson",
11
12
  size: "sm",
13
+ image_alt: "Terry Johnson Online",
12
14
  image_url: "https://randomuser.me/api/portraits/men/44.jpg",
13
15
  status: "online"
14
16
  }) %>
@@ -18,6 +20,7 @@
18
20
  <%= pb_rails("avatar", props: {
19
21
  name: "Terry Johnson",
20
22
  size: "sm",
23
+ image_alt: "Terry Johnson Away",
21
24
  image_url: "https://randomuser.me/api/portraits/men/44.jpg",
22
25
  status: "away"
23
26
  }) %>
@@ -27,6 +30,7 @@
27
30
  <%= pb_rails("avatar", props: {
28
31
  name: "Terry Johnson",
29
32
  size: "sm",
33
+ image_alt: "Terry Johnson Offline",
30
34
  image_url: "https://randomuser.me/api/portraits/men/44.jpg",
31
35
  status: "offline"
32
36
  }) %>
@@ -5,6 +5,7 @@ const AvatarStatus = (props) => {
5
5
  return (
6
6
  <>
7
7
  <Avatar
8
+ imageAlt="Terry Johnson Status"
8
9
  imageUrl="https://randomuser.me/api/portraits/men/44.jpg"
9
10
  name="Terry Johnson"
10
11
  size="sm"
@@ -14,6 +15,7 @@ const AvatarStatus = (props) => {
14
15
  <br />
15
16
 
16
17
  <Avatar
18
+ imageAlt="Terry Johnson Online"
17
19
  imageUrl="https://randomuser.me/api/portraits/men/44.jpg"
18
20
  name="Terry Johnson"
19
21
  size="sm"
@@ -24,6 +26,7 @@ const AvatarStatus = (props) => {
24
26
  <br />
25
27
 
26
28
  <Avatar
29
+ imageAlt="Terry Johnson Away"
27
30
  imageUrl="https://randomuser.me/api/portraits/men/44.jpg"
28
31
  name="Terry Johnson"
29
32
  size="sm"
@@ -34,6 +37,7 @@ const AvatarStatus = (props) => {
34
37
  <br />
35
38
 
36
39
  <Avatar
40
+ imageAlt="Terry Johnson Offline"
37
41
  imageUrl="https://randomuser.me/api/portraits/men/44.jpg"
38
42
  name="Terry Johnson"
39
43
  size="sm"
@@ -15,10 +15,12 @@ import { globalProps } from '../utilities/globalProps.js'
15
15
  type AvatarActionButtonProps = {
16
16
  action?: string,
17
17
  aria: Object,
18
+ linkAriaLabel?: string,
18
19
  className?: string,
19
20
  dark?: boolean,
20
21
  data?: Object,
21
22
  id?: string,
23
+ imageAlt?: string,
22
24
  imageUrl?: string,
23
25
  linkUrl?: string,
24
26
  name?: string,
@@ -31,10 +33,12 @@ const AvatarActionButton = (props: AvatarActionButtonProps) => {
31
33
  const {
32
34
  action = 'add',
33
35
  aria = {},
36
+ linkAriaLabel,
34
37
  className,
35
38
  dark = false,
36
39
  data = {},
37
40
  id,
41
+ imageAlt = '',
38
42
  imageUrl,
39
43
  linkUrl,
40
44
  name,
@@ -67,10 +71,12 @@ const AvatarActionButton = (props: AvatarActionButtonProps) => {
67
71
  id={id}
68
72
  >
69
73
  <a
74
+ aria-label={linkAriaLabel}
70
75
  href={linkUrl}
71
76
  onClick={onClick}
72
77
  >
73
78
  <Avatar
79
+ imageAlt={imageAlt}
74
80
  imageUrl={imageUrl}
75
81
  name={name}
76
82
  size={size}
@@ -14,11 +14,12 @@
14
14
  <% end %>
15
15
  <% end %>
16
16
 
17
- <%= link_to object.link_url, id: object.tooltip_id do %>
17
+ <%= link_to object.link_url, id: object.tooltip_id, 'aria-label': object.link_aria_label do %>
18
18
  <%= pb_rails("avatar", props: {
19
19
  dark: object.dark,
20
20
  name: object.name,
21
21
  size: object.size,
22
+ image_alt: object.image_alt,
22
23
  image_url: object.image_url,
23
24
  class: "avatar_action"
24
25
  }) %>
@@ -5,6 +5,8 @@ module Playbook
5
5
  class AvatarActionButton < Playbook::KitBase
6
6
  prop :action, type: Playbook::Props::String,
7
7
  default: "add"
8
+ prop :link_aria_label, type: Playbook::Props::String
9
+ prop :image_alt, type: Playbook::Props::String
8
10
  prop :image_url, type: Playbook::Props::String
9
11
  prop :link_url, type: Playbook::Props::String, default: "#"
10
12
  prop :tooltip_text, type: Playbook::Props::String
@@ -1,13 +1,17 @@
1
1
  <div class="pb--doc-demo-row">
2
2
 
3
3
  <%= pb_rails("avatar_action_button", props: {
4
+ link_aria_label: "Add Sophia Carden",
4
5
  name: "Sophia Carden",
6
+ image_alt: "Add Sophia Carden",
5
7
  image_url: "https://randomuser.me/api/portraits/women/8.jpg",
6
8
  action: "add",
7
9
  }) %>
8
10
 
9
11
  <%= pb_rails("avatar_action_button", props: {
12
+ link_aria_label: "Remove Sophia Carden",
10
13
  name: "Sophia Carden",
14
+ image_alt: "Remove Sophia Carden",
11
15
  image_url: "https://randomuser.me/api/portraits/women/8.jpg",
12
16
  action: "remove",
13
17
  }) %>
@@ -5,13 +5,17 @@ const AvatarActionButtonActions = (props) => (
5
5
  <div className="pb--doc-demo-row">
6
6
  <AvatarActionButton
7
7
  action="add"
8
+ imageAlt="Add Sophia Carden"
8
9
  imageUrl="https://randomuser.me/api/portraits/women/8.jpg"
10
+ linkAriaLabel="Add Sophia Carden"
9
11
  name="Sophia Carden"
10
12
  {...props}
11
13
  />
12
14
  <AvatarActionButton
13
15
  action="remove"
16
+ imageAlt="Remove Sophia Carden"
14
17
  imageUrl="https://randomuser.me/api/portraits/women/8.jpg"
18
+ linkAriaLabel="Remove Sophia Carden"
15
19
  name="Sophia Carden"
16
20
  {...props}
17
21
  />