playbook_ui 14.6.2 → 14.7.0.pre.alpha.PBNTR667railstypeaheadformintegration4454

Sign up to get free protection for your applications and to get access to all the features.
Files changed (119) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/_playbook.scss +3 -2
  3. data/app/pb_kits/playbook/pb_advanced_table/Components/CustomCell.tsx +8 -1
  4. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +21 -28
  5. data/app/pb_kits/playbook/pb_advanced_table/advanced_table.test.jsx +37 -1
  6. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_custom_cell.jsx +13 -2
  7. data/app/pb_kits/playbook/pb_card/_card.tsx +11 -4
  8. data/app/pb_kits/playbook/pb_card/_card_mixin.scss +1 -2
  9. data/app/pb_kits/playbook/pb_currency/_currency.tsx +16 -6
  10. data/app/pb_kits/playbook/pb_currency/currency.rb +38 -11
  11. data/app/pb_kits/playbook/pb_currency/currency.test.js +35 -0
  12. data/app/pb_kits/playbook/pb_currency/docs/_currency_comma_separator.html.erb +7 -0
  13. data/app/pb_kits/playbook/pb_currency/docs/_currency_comma_separator.jsx +18 -0
  14. data/app/pb_kits/playbook/pb_currency/docs/_currency_comma_separator.md +3 -0
  15. data/app/pb_kits/playbook/pb_currency/docs/example.yml +3 -1
  16. data/app/pb_kits/playbook/pb_currency/docs/index.js +1 -0
  17. data/app/pb_kits/playbook/pb_dialog/_dialog.tsx +5 -1
  18. data/app/pb_kits/playbook/pb_dropdown/_dropdown.tsx +8 -7
  19. data/app/pb_kits/playbook/pb_flex/_flex.tsx +3 -1
  20. data/app/pb_kits/playbook/pb_flex/_flex_item.tsx +8 -2
  21. data/app/pb_kits/playbook/pb_flex/flex_item.html.erb +3 -6
  22. data/app/pb_kits/playbook/pb_flex/flex_item.rb +7 -2
  23. data/app/pb_kits/playbook/pb_form/docs/_form_form_with.html.erb +2 -2
  24. data/app/pb_kits/playbook/pb_form/docs/_form_form_with_loading.html.erb +1 -1
  25. data/app/pb_kits/playbook/pb_form/docs/_form_form_with_validate.html.erb +63 -12
  26. data/app/pb_kits/playbook/pb_form_pill/_form_pill.scss +6 -2
  27. data/app/pb_kits/playbook/pb_form_pill/_form_pill.tsx +30 -26
  28. data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_truncated_text.html.erb +24 -1
  29. data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_truncated_text.jsx +25 -2
  30. data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_truncated_text_rails.md +3 -0
  31. data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_truncated_text_react.md +1 -0
  32. data/app/pb_kits/playbook/pb_form_pill/form_pill.html.erb +46 -8
  33. data/app/pb_kits/playbook/pb_link/_link.scss +66 -0
  34. data/app/pb_kits/playbook/pb_link/_link.tsx +107 -0
  35. data/app/pb_kits/playbook/pb_link/docs/_link_color.html.erb +30 -0
  36. data/app/pb_kits/playbook/pb_link/docs/_link_color.jsx +40 -0
  37. data/app/pb_kits/playbook/pb_link/docs/_link_disabled.html.erb +5 -0
  38. data/app/pb_kits/playbook/pb_link/docs/_link_disabled.jsx +15 -0
  39. data/app/pb_kits/playbook/pb_link/docs/_link_icon.html.erb +15 -0
  40. data/app/pb_kits/playbook/pb_link/docs/_link_icon.jsx +25 -0
  41. data/app/pb_kits/playbook/pb_link/docs/_link_tag.html.erb +35 -0
  42. data/app/pb_kits/playbook/pb_link/docs/_link_tag.jsx +45 -0
  43. data/app/pb_kits/playbook/pb_link/docs/_link_underline.html.erb +5 -0
  44. data/app/pb_kits/playbook/pb_link/docs/_link_underline.jsx +15 -0
  45. data/app/pb_kits/playbook/pb_link/docs/example.yml +16 -0
  46. data/app/pb_kits/playbook/pb_link/docs/index.js +5 -0
  47. data/app/pb_kits/playbook/pb_link/link.html.erb +21 -0
  48. data/app/pb_kits/playbook/pb_link/link.rb +44 -0
  49. data/app/pb_kits/playbook/pb_link/link.test.jsx +92 -0
  50. data/app/pb_kits/playbook/pb_popover/_popover.tsx +1 -1
  51. data/app/pb_kits/playbook/pb_selectable_card/_selectable_card.scss +67 -1
  52. data/app/pb_kits/playbook/pb_selectable_card/_selectable_card.tsx +1 -0
  53. data/app/pb_kits/playbook/pb_selectable_card/selectable_card.html.erb +1 -1
  54. data/app/pb_kits/playbook/pb_selectable_card/selectable_card.rb +5 -1
  55. data/app/pb_kits/playbook/pb_skeleton_loading/_skeleton_loading.scss +37 -0
  56. data/app/pb_kits/playbook/pb_skeleton_loading/_skeleton_loading.tsx +67 -0
  57. data/app/pb_kits/playbook/pb_skeleton_loading/_skeleton_loading_mixins.scss +40 -0
  58. data/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_border_radius.jsx +51 -0
  59. data/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_border_radius.md +1 -0
  60. data/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_color.jsx +26 -0
  61. data/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_color.md +1 -0
  62. data/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_default.html.erb +1 -0
  63. data/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_default.jsx +11 -0
  64. data/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_height_width.jsx +59 -0
  65. data/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_height_width.md +3 -0
  66. data/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_layout.jsx +20 -0
  67. data/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_layout.md +3 -0
  68. data/app/pb_kits/playbook/pb_skeleton_loading/docs/example.yml +13 -0
  69. data/app/pb_kits/playbook/pb_skeleton_loading/docs/index.js +5 -0
  70. data/app/pb_kits/playbook/pb_skeleton_loading/skeleton_loading.html.erb +12 -0
  71. data/app/pb_kits/playbook/pb_skeleton_loading/skeleton_loading.rb +8 -0
  72. data/app/pb_kits/playbook/pb_skeleton_loading/skeleton_loading.test.jsx +81 -0
  73. data/app/pb_kits/playbook/pb_timeline/_item.tsx +59 -23
  74. data/app/pb_kits/playbook/pb_timeline/_timeline.tsx +8 -0
  75. data/app/pb_kits/playbook/pb_timeline/detail.html.erb +3 -0
  76. data/app/pb_kits/playbook/pb_timeline/detail.rb +11 -0
  77. data/app/pb_kits/playbook/pb_timeline/docs/_timeline_with_children.html.erb +43 -0
  78. data/app/pb_kits/playbook/pb_timeline/docs/_timeline_with_children.jsx +68 -0
  79. data/app/pb_kits/playbook/pb_timeline/docs/_timeline_with_children.md +2 -0
  80. data/app/pb_kits/playbook/pb_timeline/docs/example.yml +2 -1
  81. data/app/pb_kits/playbook/pb_timeline/docs/index.js +1 -0
  82. data/app/pb_kits/playbook/pb_timeline/item.html.erb +17 -21
  83. data/app/pb_kits/playbook/pb_timeline/item.rb +4 -0
  84. data/app/pb_kits/playbook/pb_timeline/label.html.erb +12 -0
  85. data/app/pb_kits/playbook/pb_timeline/label.rb +13 -0
  86. data/app/pb_kits/playbook/pb_timeline/step.html.erb +14 -0
  87. data/app/pb_kits/playbook/pb_timeline/step.rb +16 -0
  88. data/app/pb_kits/playbook/pb_timeline/subcomponents/Detail.tsx +29 -0
  89. data/app/pb_kits/playbook/pb_timeline/subcomponents/Label.tsx +38 -0
  90. data/app/pb_kits/playbook/pb_timeline/subcomponents/Step.tsx +42 -0
  91. data/app/pb_kits/playbook/pb_timeline/subcomponents/index.tsx +3 -0
  92. data/app/pb_kits/playbook/pb_timeline/timeline.test.js +84 -0
  93. data/app/pb_kits/playbook/pb_typeahead/index.ts +36 -2
  94. data/app/pb_kits/playbook/pb_typeahead/typeahead.html.erb +5 -2
  95. data/app/pb_kits/playbook/pb_typeahead/typeahead.rb +4 -0
  96. data/app/pb_kits/playbook/tokens/_typography.scss +35 -0
  97. data/app/pb_kits/playbook/utilities/_hover.scss +46 -43
  98. data/app/pb_kits/playbook/utilities/globalPropNames.mjs +4 -0
  99. data/app/pb_kits/playbook/utilities/globalProps.ts +44 -2
  100. data/dist/chunks/_typeahead-B-juiSkw.js +22 -0
  101. data/dist/chunks/_weekday_stacked-DPqQHJ1l.js +45 -0
  102. data/dist/chunks/lazysizes-B7xYodB-.js +1 -0
  103. data/dist/chunks/{lib-D-mTv-kp.js → lib-DpxYMiKe.js} +1 -1
  104. data/dist/chunks/{pb_form_validation-BkWGwJsl.js → pb_form_validation-LqRlnmi6.js} +1 -1
  105. data/dist/chunks/vendor.js +1 -1
  106. data/dist/menu.yml +7 -1
  107. data/dist/playbook-doc.js +1 -1
  108. data/dist/playbook-rails-react-bindings.js +1 -1
  109. data/dist/playbook-rails.js +1 -1
  110. data/dist/playbook.css +1 -1
  111. data/lib/playbook/forms/builder/typeahead_field.rb +13 -0
  112. data/lib/playbook/hover.rb +4 -1
  113. data/lib/playbook/kit_base.rb +43 -5
  114. data/lib/playbook/version.rb +2 -2
  115. metadata +63 -11
  116. data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_truncated_text.md +0 -1
  117. data/dist/chunks/_typeahead-BV_n6U5W.js +0 -22
  118. data/dist/chunks/_weekday_stacked-Cy__g00H.js +0 -45
  119. data/dist/chunks/lazysizes-DHz07jlL.js +0 -1
@@ -1,7 +1,7 @@
1
1
  import React from 'react'
2
2
  import classnames from 'classnames'
3
3
  import { buildCss, buildHtmlProps } from '../utilities/props'
4
- import { globalProps, GlobalProps } from '../utilities/globalProps'
4
+ import { globalProps, GlobalProps, globalInlineProps} from '../utilities/globalProps'
5
5
  type FlexItemPropTypes = {
6
6
  children: React.ReactNode[] | React.ReactNode,
7
7
  fixedSize?: string,
@@ -35,14 +35,20 @@ const FlexItem = (props: FlexItemPropTypes): React.ReactElement => {
35
35
  const fixedStyle =
36
36
  fixedSize !== undefined ? { flexBasis: `${fixedSize}` } : null
37
37
  const orderClass = order !== 'none' ? `order_${order}` : null
38
+ const dynamicInlineProps = globalInlineProps(props)
39
+ const combinedStyles = {
40
+ ...fixedStyle,
41
+ ...dynamicInlineProps
42
+ }
38
43
 
39
44
  const htmlProps = buildHtmlProps(htmlOptions)
40
45
 
46
+
41
47
  return (
42
48
  <div
43
49
  {...htmlProps}
44
50
  className={classnames(buildCss('pb_flex_item_kit', growClass, shrinkClass, flexClass, displayFlexClass), orderClass, alignSelfClass, globalProps(props), className)}
45
- style={fixedStyle}
51
+ style={combinedStyles}
46
52
  >
47
53
  {children}
48
54
  </div>
@@ -1,8 +1,5 @@
1
- <%= content_tag(:div,
2
- id: object.id,
3
- data: object.data,
4
- class: object.classname,
5
- style: object.style_value,
6
- **combined_html_options) do %>
1
+ <%= pb_content_tag(:div,
2
+ style: object.inline_styles
3
+ ) do %>
7
4
  <%= content.presence %>
8
5
  <% end %>
@@ -20,8 +20,13 @@ module Playbook
20
20
  generate_classname("pb_flex_item_kit", fixed_size_class, grow_class, shrink_class, display_flex_class) + align_self_class
21
21
  end
22
22
 
23
- def style_value
24
- "flex-basis: #{fixed_size};" if fixed_size.present?
23
+ def inline_styles
24
+ styles = []
25
+ styles << "flex-basis: #{fixed_size};" if fixed_size.present?
26
+ styles << "height: #{height};" if height.present?
27
+ styles << "min-height: #{min_height};" if min_height.present?
28
+ styles << "max-height: #{max_height};" if max_height.present?
29
+ styles.join(" ")
25
30
  end
26
31
 
27
32
  private
@@ -23,7 +23,7 @@
23
23
  %>
24
24
 
25
25
  <%= pb_form_with(scope: :example, url: "", method: :get) do |form| %>
26
- <%= form.typeahead :example_user, props: { data: { typeahead_example1: true, user: {} }, placeholder: "Search for a user" } %>
26
+ <%= form.typeahead :example_typeahead, props: { data: { typeahead_example1: true, user: {} }, label: true, placeholder: "Search for a user" } %>
27
27
  <%= form.text_field :example_text_field, props: { label: true } %>
28
28
  <%= form.phone_number_field :example_phone_number_field, props: { label: "Example phone field" } %>
29
29
  <%= form.email_field :example_email_field, props: { label: true } %>
@@ -92,7 +92,7 @@
92
92
  const selectedUserData = JSON.parse(selectedUserJSON)
93
93
 
94
94
  // set the input field's value
95
- event.target.querySelector('input[name=example_user]').value = selectedUserData.login
95
+ event.target.querySelector('input[name=example_typeahead]').value = selectedUserData.login
96
96
 
97
97
  // log the selected option's dataset
98
98
  console.log('The selected user data:')
@@ -1,5 +1,5 @@
1
1
  <%= pb_form_with(scope: :example, url: "", method: :get, loading: true) do |form| %>
2
- <%= form.text_field :example_text_field, props: { label: true } %>
2
+ <%= form.text_field :example_text_field_loading, props: { label: true } %>
3
3
 
4
4
  <%= form.actions do |action| %>
5
5
  <%= action.submit %>
@@ -22,23 +22,74 @@
22
22
  %>
23
23
 
24
24
  <%= pb_form_with(scope: :example, method: :get, url: "", validate: true) do |form| %>
25
- <%= form.text_field :example_text_field, props: { label: true, required: true } %>
26
- <%= form.phone_number_field :example_phone_number_field, props: { label: "Example phone field" } %>
27
- <%= form.email_field :example_email_field, props: { label: true, required: true } %>
28
- <%= form.number_field :example_number_field, props: { label: true, required: true } %>
29
- <%= form.search_field :example_project_number, props: { label: true, required: true, validation: { pattern: "[0-9]{2}-[0-9]{5}", message: "Please enter a valid project number (example: 33-12345)." } } %>
30
- <%= form.password_field :example_password_field, props: { label: true, required: true } %>
31
- <%= form.url_field :example_url_field, props: { label: true, required: true } %>
32
- <%= form.text_area :example_text_area, props: { label: true, required: true } %>
33
- <%= form.dropdown_field :example_dropdown, props: { label: true, options: example_dropdown_options, required: true } %>
34
- <%= form.select :example_select, [ ["Yes", 1], ["No", 2] ], props: { label: true, blank_selection: "Select One...", required: true } %>
35
- <%= form.collection_select :example_collection_select, example_collection, :value, :name, props: { label: true, blank_selection: "Select One...", required: true } %>
25
+ <%= form.typeahead :example_typeahead_validation, props: { data: { typeahead_example2: true, user: {} }, label: true, placeholder: "Search for a user", required: true, validation: { message: "Please select a user." } } %>
26
+ <%= form.text_field :example_text_field_validation, props: { label: true, required: true } %>
27
+ <%= form.phone_number_field :example_phone_number_field_validation, props: { label: "Example phone field" } %>
28
+ <%= form.email_field :example_email_field_validation, props: { label: true, required: true } %>
29
+ <%= form.number_field :example_number_field_validation, props: { label: true, required: true } %>
30
+ <%= form.search_field :example_project_number_validation, props: { label: true, required: true, validation: { pattern: "[0-9]{2}-[0-9]{5}", message: "Please enter a valid project number (example: 33-12345)." } } %>
31
+ <%= form.password_field :example_password_field_validation, props: { label: true, required: true } %>
32
+ <%= form.url_field :example_url_field_validation, props: { label: true, required: true } %>
33
+ <%= form.text_area :example_text_area_validation, props: { label: true, required: true } %>
34
+ <%= form.dropdown_field :example_dropdown_validation, props: { label: true, options: example_dropdown_options, required: true } %>
35
+ <%= form.select :example_select_validation, [ ["Yes", 1], ["No", 2] ], props: { label: true, blank_selection: "Select One...", required: true } %>
36
+ <%= form.collection_select :example_collection_select_validation, example_collection, :value, :name, props: { label: true, blank_selection: "Select One...", required: true } %>
36
37
  <%= form.check_box :example_checkbox, props: { text: "Example Checkbox", label: true, required: true } %>
37
38
  <%= form.date_picker :example_date_picker_2, props: { label: true, required: true } %>
38
- <%= form.star_rating_field :example_star_rating, props: { variant: "interactive", label: true, required: true } %>
39
+ <%= form.star_rating_field :example_star_rating_validation, props: { variant: "interactive", label: true, required: true } %>
39
40
 
40
41
  <%= form.actions do |action| %>
41
42
  <%= action.submit %>
42
43
  <%= action.button props: { type: "reset", text: "Cancel", variant: "secondary" } %>
43
44
  <% end %>
44
45
  <% end %>
46
+
47
+ <!-- form.typeahead user results example template -->
48
+ <template data-typeahead-example-result-option>
49
+ <%= pb_rails("user", props: {
50
+ name: tag(:slot, name: "name"),
51
+ orientation: "horizontal",
52
+ align: "left",
53
+ avatar_url: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR4nGP6zwAAAgcBApocMXEAAAAASUVORK5CYII=",
54
+ avatar: true
55
+ }) %>
56
+ </template>
57
+
58
+ <!-- form.typeahead JS example implementation -->
59
+ <%= javascript_tag defer: "defer" do %>
60
+ document.addEventListener("pb-typeahead-kit-search", function(event) {
61
+ if (!event.target.dataset || !event.target.dataset.typeaheadExample2) return
62
+
63
+ fetch(`https://api.github.com/search/users?q=${encodeURIComponent(event.detail.searchingFor)}`)
64
+ .then(response => response.json())
65
+ .then((result) => {
66
+ const resultOptionTemplate = document.querySelector("[data-typeahead-example-result-option]")
67
+
68
+ event.detail.setResults((result.items || []).map((user) => {
69
+ const wrapper = resultOptionTemplate.content.cloneNode(true)
70
+ wrapper.children[0].dataset.user = JSON.stringify(user)
71
+ wrapper.querySelector('slot[name="name"]').replaceWith(user.login)
72
+ wrapper.querySelector('img').dataset.src = user.avatar_url
73
+ return wrapper
74
+ }))
75
+ })
76
+ })
77
+
78
+
79
+ document.addEventListener("pb-typeahead-kit-result-option-selected", function(event) {
80
+ if (!event.target.dataset.typeaheadExample2) return
81
+
82
+ const selectedUserJSON = event.detail.selected.firstElementChild.dataset.user
83
+ const selectedUserData = JSON.parse(selectedUserJSON)
84
+
85
+ // set the input field's value
86
+ event.target.querySelector('input[name=example_typeahead_validation]').value = selectedUserData.login
87
+
88
+ // log the selected option's dataset
89
+ console.log('The selected user data:')
90
+ console.dir(selectedUserData)
91
+
92
+ // do even more with the data later - TBD
93
+ event.target.dataset.user = selectedUserJSON
94
+ })
95
+ <% end %>
@@ -142,7 +142,9 @@ $form_pill_colors: map-merge($status_color_text, map-merge($data_colors, $produc
142
142
  height: 12px !important;
143
143
  width: 12px !important;
144
144
  padding-right: $space_xs;
145
- + .pb_form_pill_text, + .pb_form_pill_tag {
145
+ + .pb_form_pill_text, + .pb_form_pill_tag,
146
+ + .pb_tooltip_kit .pb_form_pill_text, + .pb_tooltip_kit .pb_form_pill_tag,
147
+ + div .pb_form_pill_text, + div .pb_form_pill_tag {
146
148
  padding-left: 0;
147
149
  }
148
150
  }
@@ -169,7 +171,9 @@ $form_pill_colors: map-merge($status_color_text, map-merge($data_colors, $produc
169
171
  }
170
172
  .pb_form_pill_icon {
171
173
  padding-right: $space_xxs;
172
- + .pb_form_pill_text, + .pb_form_pill_tag {
174
+ + .pb_form_pill_text, + .pb_form_pill_tag,
175
+ + .pb_tooltip_kit .pb_form_pill_text, + .pb_tooltip_kit .pb_form_pill_tag,
176
+ + div .pb_form_pill_text, + div .pb_form_pill_tag {
173
177
  padding-left: 0;
174
178
  }
175
179
  }
@@ -3,6 +3,7 @@ import classnames from 'classnames'
3
3
  import Title from '../pb_title/_title'
4
4
  import Icon from '../pb_icon/_icon'
5
5
  import Avatar from '../pb_avatar/_avatar'
6
+ import Tooltip from '../pb_tooltip/_tooltip'
6
7
  import { globalProps, GlobalProps } from '../utilities/globalProps'
7
8
  import { buildDataProps, buildHtmlProps } from '../utilities/props'
8
9
 
@@ -62,6 +63,30 @@ const FormPill = (props: FormPillProps): React.ReactElement => {
62
63
  const dataProps = buildDataProps(data)
63
64
  const htmlProps = buildHtmlProps(htmlOptions)
64
65
 
66
+ const renderTitle = (content: string, className: string) => {
67
+ const titleComponent = (
68
+ <Title
69
+ className={className}
70
+ size={4}
71
+ text={content}
72
+ truncate={props.truncate}
73
+ />
74
+ )
75
+ if (props.truncate) {
76
+ return (
77
+ <Tooltip
78
+ interaction
79
+ placement="top"
80
+ position="fixed"
81
+ text={content}
82
+ >
83
+ {titleComponent}
84
+ </Tooltip>
85
+ )
86
+ }
87
+ return titleComponent
88
+ }
89
+
65
90
  return (
66
91
  <div className={css}
67
92
  id={id}
@@ -77,12 +102,7 @@ const FormPill = (props: FormPillProps): React.ReactElement => {
77
102
  size="xxs"
78
103
  status={null}
79
104
  />
80
- <Title
81
- className="pb_form_pill_text"
82
- size={4}
83
- text={name}
84
- truncate={props.truncate}
85
- />
105
+ {renderTitle(name, "pb_form_pill_text")}
86
106
  </>
87
107
  )}
88
108
  {((name && icon && !text) || (name && icon && text)) && (
@@ -93,12 +113,7 @@ const FormPill = (props: FormPillProps): React.ReactElement => {
93
113
  size="xxs"
94
114
  status={null}
95
115
  />
96
- <Title
97
- className="pb_form_pill_text"
98
- size={4}
99
- text={name}
100
- truncate={props.truncate}
101
- />
116
+ {renderTitle(name, "pb_form_pill_text")}
102
117
  <Icon
103
118
  className="pb_form_pill_icon"
104
119
  color={color}
@@ -113,22 +128,10 @@ const FormPill = (props: FormPillProps): React.ReactElement => {
113
128
  color={color}
114
129
  icon={icon}
115
130
  />
116
- <Title
117
- className="pb_form_pill_tag"
118
- size={4}
119
- text={text}
120
- truncate={props.truncate}
121
- />
131
+ {renderTitle(text, "pb_form_pill_tag")}
122
132
  </>
123
133
  )}
124
- {(!name && !icon && text) && (
125
- <Title
126
- className="pb_form_pill_tag"
127
- size={4}
128
- text={text}
129
- truncate={props.truncate}
130
- />
131
- )}
134
+ {(!name && !icon && text) && renderTitle(text, "pb_form_pill_tag")}
132
135
  <div
133
136
  className="pb_form_pill_close"
134
137
  onClick={onClick}
@@ -143,4 +146,5 @@ const FormPill = (props: FormPillProps): React.ReactElement => {
143
146
  </div>
144
147
  )
145
148
  }
149
+
146
150
  export default FormPill
@@ -13,7 +13,30 @@
13
13
  id: "typeahead-form-pill",
14
14
  is_multi: true,
15
15
  options: names,
16
- label: "Names",
16
+ label: "Truncation Within Typeahead",
17
17
  pills: true,
18
18
  truncate: 1,
19
19
  }) %>
20
+
21
+ <%= pb_rails("caption", props: { text: "Form Pill Truncation" }) %>
22
+ <%= pb_rails("card", props: { max_width: "xs" }) do %>
23
+ <%= pb_rails("form_pill", props: {
24
+ name: "Princess Amelia Mignonette Grimaldi Thermopolis Renaldo",
25
+ avatar_url: "https://randomuser.me/api/portraits/women/44.jpg",
26
+ tabindex: 0,
27
+ truncate: 1,
28
+ id: "truncation-1"
29
+ }) %>
30
+ <%= pb_rails("form_pill", props: {
31
+ icon: "badge-check",
32
+ text: "icon and a very long tag to show truncation",
33
+ tabindex: 0,
34
+ truncate: 1,
35
+ id: "truncation-2"
36
+ }) %>
37
+ <%= pb_rails("form_pill", props: {
38
+ text: "form pill long tag no tooltip show truncation",
39
+ tabindex: 0,
40
+ truncate: 1,
41
+ }) %>
42
+ <% end %>
@@ -1,5 +1,5 @@
1
1
  import React from 'react'
2
- import Typeahead from '../../pb_typeahead/_typeahead'
2
+ import { Card, Caption, FormPill, Typeahead } from 'playbook-ui'
3
3
 
4
4
  const names = [
5
5
  { label: 'Alexander Nathaniel Montgomery', value: 'Alexander Nathaniel Montgomery' },
@@ -15,11 +15,34 @@ const FormPillTruncatedText = (props) => {
15
15
  <Typeahead
16
16
  htmlOptions={{ style: { maxWidth: "240px" }}}
17
17
  isMulti
18
- label="Names"
18
+ label="Truncation Within Typeahead"
19
19
  options={names}
20
20
  truncate={1}
21
21
  {...props}
22
22
  />
23
+ <Caption text="Form Pill Truncation"/>
24
+ <Card maxWidth="xs">
25
+ <FormPill
26
+ avatarUrl="https://randomuser.me/api/portraits/women/44.jpg"
27
+ name="Princess Amelia Mignonette Grimaldi Thermopolis Renaldo"
28
+ onClick={() => alert('Click!')}
29
+ tabIndex={0}
30
+ truncate={1}
31
+ />
32
+ <FormPill
33
+ icon="badge-check"
34
+ onClick={() => {alert('Click!')}}
35
+ tabIndex={0}
36
+ text="icon and a very long tag to show truncation"
37
+ truncate={1}
38
+ />
39
+ <FormPill
40
+ onClick={() => {alert('Click!')}}
41
+ tabIndex={0}
42
+ text="form pill with a very long tag to show truncation"
43
+ truncate={1}
44
+ />
45
+ </Card>
23
46
  </>
24
47
  )
25
48
  }
@@ -0,0 +1,3 @@
1
+ For Form Pills with longer text, the truncate global prop can be used to truncate the label within each Form Pill. See [here](https://playbook.powerapp.cloud/visual_guidelines/truncate) for more information on the truncate global prop.
2
+
3
+ __NOTE__: For Rails Form Pills (not ones embedded within a React-rendered Typeahead or MultiLevelSelect), a unique `id` is required to enable the Tooltip functionality displaying the text or tag section of the Form Pill.
@@ -0,0 +1 @@
1
+ For Form Pills with longer text, the `truncate` global prop can be used to truncate the label within each Form Pill. Hover over the truncated Form Pill and a Tooltip containing the text or tag section of the Form Pill will appear. See [here](https://playbook.powerapp.cloud/visual_guidelines/truncate) for more information on the truncate global prop.
@@ -1,19 +1,57 @@
1
1
  <%= content_tag(:div, id: object.id, data: object.data, class: object.classname + object.size_class, tabindex: object.tabindex, **combined_html_options) do %>
2
2
  <% if object.name.present? %>
3
3
  <%= pb_rails("avatar", props: { name: object.name, image_url: object.avatar_url, size: "xxs" }) %>
4
- <%= pb_rails("title", props: { text: object.name, size: 4, classname: "pb_form_pill_text" }) %>
4
+ <% if object.truncate %>
5
+ <div>
6
+ <%= pb_rails("title", props: {
7
+ classname: "pb_form_pill_text truncate_#{object.truncate}",
8
+ id: object.id,
9
+ size: 4,
10
+ text: object.name,
11
+ }) %>
12
+ <% if object.id.present? %>
13
+ <%= pb_rails("tooltip", props: {
14
+ position: "top",
15
+ tooltip_id: "tooltip-#{object.id}",
16
+ trigger_element_selector: "##{object.id}"
17
+ }) do %>
18
+ <%= object.name %>
19
+ <% end %>
20
+ <% end %>
21
+ </div>
22
+ <% else %>
23
+ <%= pb_rails("title", props: { classname: "pb_form_pill_text", id: object.id, size: 4, text: object.name }) %>
24
+ <% end %>
5
25
  <% if object.icon.present? %>
6
26
  <%= pb_rails("icon", props: { classname: "pb_form_pill_icon", color: object.color, icon: object.icon }) %>
7
27
  <% end %>
8
28
  <% elsif object.text.present? %>
9
- <% if object.icon.present? %>
10
- <%= pb_rails("icon", props: { classname: "pb_form_pill_icon", color: object.color, icon: object.icon }) %>
11
- <% end %>
12
- <% if object.text.present? %>
13
- <%= pb_rails("title", props: { text: object.text, size: 4, classname: "pb_form_pill_tag" }) %>
14
- <% end %>
29
+ <% if object.icon.present? %>
30
+ <%= pb_rails("icon", props: { classname: "pb_form_pill_icon", color: object.color, icon: object.icon }) %>
31
+ <% end %>
32
+ <% if object.truncate %>
33
+ <div>
34
+ <%= pb_rails("title", props: {
35
+ classname: "pb_form_pill_tag truncate_#{object.truncate}",
36
+ id: object.id,
37
+ size: 4,
38
+ text: object.text,
39
+ }) %>
40
+ <% if object.id.present? %>
41
+ <%= pb_rails("tooltip", props: {
42
+ position: "top",
43
+ tooltip_id: "tooltip-#{object.id}",
44
+ trigger_element_selector: "##{object.id}"
45
+ }) do %>
46
+ <%= object.text %>
47
+ <% end %>
48
+ <% end %>
49
+ </div>
50
+ <% else %>
51
+ <%= pb_rails("title", props: { classname: "pb_form_pill_tag", id: object.id, size: 4, text: object.text, }) %>
52
+ <% end %>
15
53
  <% end %>
16
54
  <%= pb_rails("body", props: { classname: "pb_form_pill_close" }) do %>
17
55
  <%= pb_rails("icon", props: { icon: 'times', fixed_width: true, size: object.close_icon_size }) %>
18
56
  <% end %>
19
- <% end %>
57
+ <% end %>
@@ -0,0 +1,66 @@
1
+ @import "../tokens/colors";
2
+ @import "../tokens/line_height";
3
+ @import "../tokens/typography";
4
+ @import "../tokens/border_radius";
5
+
6
+ [class^=pb_link_kit]{
7
+ @include pb_link($primary);
8
+ &:hover {
9
+ color: $text_lt_default;
10
+ }
11
+ &:focus {
12
+ outline: none;
13
+ }
14
+ &:focus-visible {
15
+ border-radius: $border_rad_light;
16
+ outline: 1px solid $primary;
17
+ outline-offset: 2px;
18
+ }
19
+ &:visited {
20
+ color: $data_3;
21
+ }
22
+ &.dark {
23
+ @include pb_link($active_dark);
24
+ &:hover {
25
+ color: $text_dk_default;
26
+ }
27
+ }
28
+ @each $color_name, $color_value in $pb_link_colors {
29
+ &[class*=_#{"" + $color_name}] {
30
+ @include pb_link($color_value);
31
+
32
+ &:hover {
33
+ color: map-get($pb_link_hover_colors, $color_name);
34
+ }
35
+
36
+ &:visited {
37
+ color: $data_3;
38
+ }
39
+ }
40
+ }
41
+
42
+ @each $dark_color_name, $dark_color_value in $pb_dark_link_colors{
43
+ &[class*=_#{$dark_color_name}][class*=dark]{
44
+ @include pb_link($dark_color_value);
45
+
46
+ &:hover {
47
+ color: map-get($pb_dark_link_hover_colors, $dark_color_name);
48
+ }
49
+
50
+ &:visited {
51
+ color: $data_3;
52
+ }
53
+ }
54
+ }
55
+
56
+ &[class*=_underline] {
57
+ text-decoration: underline;
58
+ }
59
+
60
+ &[class*=_disabled] {
61
+ pointer-events: none;
62
+ cursor: default;
63
+ color: $text_lt_lighter;
64
+ }
65
+
66
+ }
@@ -0,0 +1,107 @@
1
+ import React from 'react'
2
+ import classnames from 'classnames'
3
+
4
+ import { buildAriaProps, buildCss, buildDataProps, buildHtmlProps } from '../utilities/props'
5
+ import { globalProps, GlobalProps } from '../utilities/globalProps'
6
+
7
+ import Icon from '../pb_icon/_icon'
8
+
9
+ type LinkProps = {
10
+ aria?: {[key: string]: string},
11
+ className?: string,
12
+ children?: React.ReactChild[] | React.ReactChild,
13
+ color?: 'default' | 'body' | 'muted' | 'destructive',
14
+ dark?: boolean,
15
+ data?: {[key: string]: string},
16
+ disabled?: boolean,
17
+ href?: string,
18
+ htmlOptions?: {[key: string]: string | number | boolean | (() => void) | ((arg?: Event) => void)},
19
+ icon?: string,
20
+ iconRight?: string,
21
+ id?: string,
22
+ tag?: 'a' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'p' | 'span' | 'div',
23
+ text?: string,
24
+ underline?: boolean,
25
+ } & GlobalProps
26
+
27
+ const Link = (props: LinkProps): React.ReactElement => {
28
+ const {
29
+ aria = {},
30
+ children,
31
+ className,
32
+ color = '',
33
+ data = {},
34
+ disabled = false,
35
+ href= '',
36
+ htmlOptions = {},
37
+ icon = '',
38
+ iconRight = '',
39
+ id = '',
40
+ tag = 'a',
41
+ text = '',
42
+ underline = false,
43
+ } = props
44
+
45
+ const ariaProps: {[key: string]: string} = buildAriaProps(aria)
46
+ const dataProps: {[key: string]: string} = buildDataProps(data)
47
+ const htmlProps = buildHtmlProps(htmlOptions);
48
+ const classes = classnames(
49
+ buildCss('pb_link_kit', color, underline ? 'underline' : '', disabled ? 'disabled' : ''),
50
+ globalProps(props),
51
+ className
52
+ )
53
+ const Tag = tag as keyof JSX.IntrinsicElements
54
+
55
+ const renderContent = () => (
56
+ <>
57
+ {icon && (
58
+ <Icon
59
+ fixedWidth
60
+ icon={icon}
61
+ marginRight="xxs"
62
+ size="xs"
63
+ />
64
+ )}
65
+ {text || children}
66
+ {iconRight && (
67
+ <Icon
68
+ fixedWidth
69
+ icon={iconRight}
70
+ marginLeft="xxs"
71
+ size="xs"
72
+ />
73
+ )}
74
+ </>
75
+ )
76
+
77
+ const commonProps = {
78
+ ...ariaProps,
79
+ ...dataProps,
80
+ ...htmlProps,
81
+ className: classes,
82
+ id,
83
+ }
84
+
85
+ if (tag === 'a') {
86
+ return (
87
+ <a
88
+ {...commonProps}
89
+ href={href}
90
+ >
91
+ {renderContent()}
92
+ </a>
93
+ )
94
+ } else {
95
+ return (
96
+ <a
97
+ {...commonProps}
98
+ href={href}
99
+ >
100
+ <Tag>{renderContent()}</Tag>
101
+ </a>
102
+ )
103
+ }
104
+
105
+ }
106
+
107
+ export default Link
@@ -0,0 +1,30 @@
1
+ <div>
2
+ <%= pb_rails("link", props: {
3
+ text: "link example",
4
+ href: "https://www.google.com/search?q=playbook+design+system",
5
+ }) %>
6
+ </div>
7
+
8
+ <div>
9
+ <%= pb_rails("link", props: {
10
+ text: "link example",
11
+ href: "https://www.youtube.com/@PowerHRG",
12
+ color: "body",
13
+ }) %>
14
+ </div>
15
+
16
+ <div>
17
+ <%= pb_rails("link", props: {
18
+ text: "link example",
19
+ href: "https://github.com/powerhome/.github/blob/main/profile/README.md",
20
+ color: "muted",
21
+ }) %>
22
+ </div>
23
+
24
+ <div>
25
+ <%= pb_rails("link", props: {
26
+ text: "link example",
27
+ href: "https://rubygems.org/gems/playbook_ui/",
28
+ color: "destructive",
29
+ }) %>
30
+ </div>