playbook_ui 13.32.0.pre.alpha.PLAY14143288 → 13.32.0.pre.alpha.PLAY14143297
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_custom.md +4 -0
- data/app/pb_kits/playbook/pb_collapsible/__snapshots__/collapsible.test.js.snap +1 -1
- data/app/pb_kits/playbook/pb_dropdown/_dropdown.tsx +9 -6
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_blank_selection.html.erb +10 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_blank_selection.jsx +31 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/index.js +2 -1
- data/app/pb_kits/playbook/pb_dropdown/dropdown.html.erb +2 -2
- data/app/pb_kits/playbook/pb_dropdown/dropdown.rb +6 -0
- data/app/pb_kits/playbook/pb_dropdown/dropdown_trigger.rb +1 -1
- data/app/pb_kits/playbook/pb_dropdown/index.js +33 -7
- data/app/pb_kits/playbook/pb_form_pill/_form_pill.scss +108 -5
- data/app/pb_kits/playbook/pb_form_pill/_form_pill.test.jsx +53 -0
- data/app/pb_kits/playbook/pb_form_pill/_form_pill.tsx +11 -2
- data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_example.html.erb +5 -1
- data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_example.jsx +1 -0
- data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_size.html.erb +2 -0
- data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_size.jsx +2 -0
- data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_tag.html.erb +4 -1
- data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_tag.jsx +3 -2
- data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_user.html.erb +2 -0
- data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_user.jsx +2 -0
- data/app/pb_kits/playbook/pb_form_pill/form_pill.html.erb +1 -1
- data/app/pb_kits/playbook/pb_form_pill/form_pill.rb +5 -1
- data/app/pb_kits/playbook/pb_icon/_icon.scss +210 -1
- data/app/pb_kits/playbook/pb_icon/_icon.tsx +100 -41
- data/app/pb_kits/playbook/pb_icon/icon.rb +33 -19
- data/app/pb_kits/playbook/pb_nav/_nav_item.test.js +2 -2
- data/app/pb_kits/playbook/pb_nav/docs/_tab_nav.html.erb +48 -0
- data/app/pb_kits/playbook/pb_nav/docs/_tab_nav.md +3 -0
- data/app/pb_kits/playbook/pb_nav/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_nav/index.js +43 -0
- data/app/pb_kits/playbook/pb_nav/nav.rb +9 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/TipTap/MoreExtensionsDropdown.tsx +1 -1
- data/app/pb_kits/playbook/pb_rich_text_editor/TipTap/ToolbarDropdown.tsx +1 -1
- data/app/pb_kits/playbook/pb_star_rating/_star_rating.scss +11 -2
- data/app/pb_kits/playbook/pb_star_rating/docs/_star_rating_interactive.html.erb +1 -0
- data/app/pb_kits/playbook/pb_star_rating/docs/example.yml +1 -1
- data/app/pb_kits/playbook/pb_star_rating/index.js +50 -0
- data/app/pb_kits/playbook/pb_star_rating/star_rating.html.erb +25 -5
- data/app/pb_kits/playbook/pb_star_rating/star_rating.rb +6 -0
- data/app/pb_kits/playbook/pb_table/_table.tsx +1 -1
- data/app/pb_kits/playbook/pb_table/index.ts +4 -4
- data/app/pb_kits/playbook/pb_table/subcomponents/_table_body.tsx +1 -1
- data/app/pb_kits/playbook/pb_table/subcomponents/_table_cell.tsx +1 -1
- data/app/pb_kits/playbook/pb_table/subcomponents/_table_head.tsx +1 -1
- data/app/pb_kits/playbook/pb_table/subcomponents/_table_header.tsx +1 -1
- data/app/pb_kits/playbook/pb_table/subcomponents/_table_row.tsx +1 -1
- data/app/pb_kits/playbook/pb_table/table.test.js +2 -0
- data/app/pb_kits/playbook/pb_text_input/_text_input.tsx +1 -1
- data/app/pb_kits/playbook/pb_text_input/docs/_text_input_default.jsx +1 -1
- data/app/pb_kits/playbook/pb_textarea/_textarea.tsx +45 -27
- data/app/pb_kits/playbook/pb_textarea/index.ts +3 -3
- data/app/pb_kits/playbook/pb_time/_time.tsx +3 -3
- data/app/pb_kits/playbook/pb_time_range_inline/_time_range_inline.tsx +1 -1
- data/app/pb_kits/playbook/pb_timeline/_item.tsx +1 -1
- data/app/pb_kits/playbook/pb_timeline/_timeline.tsx +1 -1
- data/app/pb_kits/playbook/pb_title_detail/_title_detail.tsx +10 -10
- data/app/pb_kits/playbook/pb_toggle/_toggle.tsx +1 -1
- data/app/pb_kits/playbook/pb_tooltip/_tooltip.tsx +2 -2
- data/app/pb_kits/playbook/pb_treemap_chart/_treemap_chart.tsx +1 -2
- data/app/pb_kits/playbook/pb_treemap_chart/treemapChart.test.js +2 -0
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.tsx +3 -3
- data/app/pb_kits/playbook/pb_typeahead/components/ClearIndicator.tsx +4 -4
- data/app/pb_kits/playbook/pb_typeahead/components/Control.tsx +11 -7
- data/app/pb_kits/playbook/pb_typeahead/components/IndicatorsContainer.tsx +8 -3
- data/app/pb_kits/playbook/pb_typeahead/components/MenuList.tsx +6 -1
- data/app/pb_kits/playbook/pb_typeahead/components/MultiValue.tsx +18 -19
- data/app/pb_kits/playbook/pb_typeahead/components/Option.tsx +6 -6
- data/app/pb_kits/playbook/pb_typeahead/components/Placeholder.tsx +6 -6
- data/app/pb_kits/playbook/pb_typeahead/components/ValueContainer.tsx +3 -3
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_custom_menu_list.jsx +2 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_default.html.erb +22 -57
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async.jsx +2 -2
- data/app/pb_kits/playbook/pb_typeahead/index.ts +31 -31
- data/app/pb_kits/playbook/pb_user/_user.tsx +1 -1
- data/app/pb_kits/playbook/pb_user_badge/_user_badge.tsx +6 -6
- data/app/pb_kits/playbook/pb_user_badge/badges/million-dollar.tsx +236 -235
- data/app/pb_kits/playbook/pb_user_badge/badges/veteran.tsx +1 -1
- data/app/pb_kits/playbook/pb_walkthrough/_walkthrough.tsx +68 -63
- data/app/pb_kits/playbook/pb_weekday_stacked/_weekday_stacked.tsx +1 -1
- data/dist/chunks/_typeahead.js +11 -11
- data/dist/chunks/_weekday_stacked.js +7 -7
- data/dist/playbook-doc.js +26 -26
- data/dist/playbook-rails.js +1 -1
- data/dist/playbook.css +1 -1
- data/lib/playbook/forms/builder/star_rating_field.rb +14 -0
- data/lib/playbook/forms/builder.rb +1 -0
- data/lib/playbook/version.rb +1 -1
- metadata +11 -3
- data/app/pb_kits/playbook/pb_icon/icon_aliases.json +0 -39
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1bf37fab9295d3717df47ed17f25adf7ae6cadaea0c0db579ff0068323efbe02
|
4
|
+
data.tar.gz: fbae6cac44fcccb99e9e21a2bacd4d3d2030c7fb306b57dc9e0949dc77e4e6bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2edcbb9d4d517bee989e93b152b68f97eea76ae30b79d47cc9e9a8567b67087ac4b2ceaa79010e3705f6e9a6b5aeef82de844456264cde30ca25cae1b5ff59f
|
7
|
+
data.tar.gz: f9de0eaf712a48b91db97b86be8f3e2b54800c213f8de69a26159cc2db89cf3a28403b43990651b8283c05d7ac9264c653040d311ef5895f0dc9342e32bfdadb
|
@@ -1,2 +1,6 @@
|
|
1
1
|
The `customOptions` prop provides comprehensive access to additional [Highcharts options](https://api.highcharts.com/highcharts/) that are not explicitly defined as props.
|
2
2
|
It's important to note that certain options may require specific script imports to function properly.
|
3
|
+
|
4
|
+
Note: If you are having trouble getting any Highcharts options to work, please match the formatting of our [staticOptions](https://github.com/powerhome/playbook/blob/master/playbook/app/pb_kits/playbook/pb_bar_graph/_bar_graph.tsx#L85-L141). For example, `yAxis` will need to be wrapped with square brackets.
|
5
|
+
|
6
|
+
You may also need to override any of the [defaults](https://github.com/powerhome/playbook/blob/master/playbook/app/pb_kits/playbook/pb_bar_graph/_bar_graph.tsx#L45-L73) in order to get that options to work.
|
@@ -28,7 +28,7 @@ exports[`html structure is correct 1`] = `
|
|
28
28
|
style="vertical-align: middle; color: rgb(193, 205, 214);"
|
29
29
|
>
|
30
30
|
<i
|
31
|
-
class="pb_icon_kit far fa-fw fa-lg fa-chevron-down"
|
31
|
+
class="pb_icon_kit far fa-lg fa-fw fa-lg fa-chevron-down"
|
32
32
|
/>
|
33
33
|
<span
|
34
34
|
aria-label="chevron-down icon"
|
@@ -22,6 +22,7 @@ import {
|
|
22
22
|
type DropdownProps = {
|
23
23
|
aria?: { [key: string]: string };
|
24
24
|
autocomplete?: boolean;
|
25
|
+
blankSelection?: string;
|
25
26
|
children?: React.ReactChild[] | React.ReactChild | React.ReactElement[];
|
26
27
|
className?: string;
|
27
28
|
dark?: boolean;
|
@@ -41,6 +42,7 @@ const Dropdown = (props: DropdownProps) => {
|
|
41
42
|
const {
|
42
43
|
aria = {},
|
43
44
|
autocomplete = false,
|
45
|
+
blankSelection = '',
|
44
46
|
children,
|
45
47
|
className,
|
46
48
|
dark = false,
|
@@ -118,11 +120,12 @@ const Dropdown = (props: DropdownProps) => {
|
|
118
120
|
setIsDropDownClosed(isClosed)
|
119
121
|
}, [isClosed])
|
120
122
|
|
121
|
-
const
|
123
|
+
const blankSelectionOption: GenericObject = blankSelection ? [{ label: blankSelection, value: "" }] : [];
|
124
|
+
const optionsWithBlankSelection = blankSelectionOption.concat(options);
|
125
|
+
const filteredOptions = optionsWithBlankSelection?.filter((option: GenericObject) => {
|
122
126
|
const label = typeof option.label === 'string' ? option.label.toLowerCase() : option.label;
|
123
127
|
return String(label).toLowerCase().includes(filterItem.toLowerCase());
|
124
|
-
}
|
125
|
-
);
|
128
|
+
});
|
126
129
|
|
127
130
|
// For keyboard accessibility: Set focus within dropdown to selected item if it exists
|
128
131
|
useEffect(() => {
|
@@ -196,7 +199,7 @@ const Dropdown = (props: DropdownProps) => {
|
|
196
199
|
inputWrapperRef,
|
197
200
|
isDropDownClosed,
|
198
201
|
isInputFocused,
|
199
|
-
|
202
|
+
optionsWithBlankSelection,
|
200
203
|
selected,
|
201
204
|
setFocusedOptionIndex,
|
202
205
|
setIsDropDownClosed,
|
@@ -235,8 +238,8 @@ const Dropdown = (props: DropdownProps) => {
|
|
235
238
|
<>
|
236
239
|
<DropdownTrigger />
|
237
240
|
<DropdownContainer>
|
238
|
-
{
|
239
|
-
|
241
|
+
{optionsWithBlankSelection &&
|
242
|
+
optionsWithBlankSelection?.map((option: GenericObject) => (
|
240
243
|
<Dropdown.Option key={option.id}
|
241
244
|
option={option}
|
242
245
|
/>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<%
|
2
|
+
options = [
|
3
|
+
{ label: 'United States', value: 'United States', id: 'us' },
|
4
|
+
{ label: 'Canada', value: 'Canada', id: 'ca' },
|
5
|
+
{ label: 'Pakistan', value: 'Pakistan', id: 'pk' },
|
6
|
+
]
|
7
|
+
|
8
|
+
%>
|
9
|
+
|
10
|
+
<%= pb_rails("dropdown", props: { blank_selection: "Select One...", options: options }) %>
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import { Dropdown } from 'playbook-ui'
|
3
|
+
|
4
|
+
const DropdownBlankSelection = (props) => {
|
5
|
+
const options = [
|
6
|
+
{
|
7
|
+
label: "United States",
|
8
|
+
value: "United States",
|
9
|
+
},
|
10
|
+
{
|
11
|
+
label: "Canada",
|
12
|
+
value: "Canada",
|
13
|
+
},
|
14
|
+
{
|
15
|
+
label: "Pakistan",
|
16
|
+
value: "Pakistan",
|
17
|
+
}
|
18
|
+
];
|
19
|
+
|
20
|
+
return (
|
21
|
+
<>
|
22
|
+
<Dropdown
|
23
|
+
blankSelection="Select one..."
|
24
|
+
options={options}
|
25
|
+
{...props}
|
26
|
+
/>
|
27
|
+
</>
|
28
|
+
)
|
29
|
+
}
|
30
|
+
|
31
|
+
export default DropdownBlankSelection
|
@@ -9,6 +9,7 @@ examples:
|
|
9
9
|
- dropdown_with_custom_padding: Custom Option Padding
|
10
10
|
- dropdown_error: Dropdown with Error
|
11
11
|
- dropdown_default_value: Default Value
|
12
|
+
- dropdown_blank_selection: Blank Selection
|
12
13
|
|
13
14
|
react:
|
14
15
|
- dropdown_default: Default
|
@@ -20,6 +21,7 @@ examples:
|
|
20
21
|
- dropdown_with_custom_padding: Custom Option Padding
|
21
22
|
- dropdown_error: Dropdown with Error
|
22
23
|
- dropdown_default_value: Default Value
|
24
|
+
- dropdown_blank_selection: Blank Selection
|
23
25
|
# - dropdown_with_autocomplete: Autocomplete
|
24
26
|
# - dropdown_with_autocomplete_and_custom_display: Autocomplete with Custom Display
|
25
27
|
# - dropdown_with_external_control: useDropdown Hook
|
@@ -10,4 +10,5 @@ export { default as DropdownWithExternalControl } from './_dropdown_with_externa
|
|
10
10
|
export { default as DropdownWithHook } from './_dropdown_with_hook.jsx'
|
11
11
|
export { default as DropdownSubcomponentStructure } from './_dropdown_subcomponent_structure.jsx'
|
12
12
|
export { default as DropdownError } from './_dropdown_error.jsx'
|
13
|
-
export { default as DropdownDefaultValue } from './_dropdown_default_value.jsx'
|
13
|
+
export { default as DropdownDefaultValue } from './_dropdown_default_value.jsx'
|
14
|
+
export { default as DropdownBlankSelection } from './_dropdown_blank_selection.jsx'
|
@@ -17,8 +17,8 @@
|
|
17
17
|
<% else %>
|
18
18
|
<%= pb_rails("dropdown/dropdown_trigger") %>
|
19
19
|
<%= pb_rails("dropdown/dropdown_container") do %>
|
20
|
-
<% if
|
21
|
-
<%
|
20
|
+
<% if options_with_blank.present? %>
|
21
|
+
<% options_with_blank.each do |option| %>
|
22
22
|
<%= pb_rails("dropdown/dropdown_option", props: {option: option}) %>
|
23
23
|
<% end %>
|
24
24
|
<% end %>
|
@@ -11,6 +11,8 @@ module Playbook
|
|
11
11
|
prop :required, type: Playbook::Props::Boolean,
|
12
12
|
default: false
|
13
13
|
prop :default_value
|
14
|
+
prop :blank_selection, type: Playbook::Props::String,
|
15
|
+
default: ""
|
14
16
|
|
15
17
|
def data
|
16
18
|
Hash(prop(:data)).merge(pb_dropdown: true)
|
@@ -29,6 +31,10 @@ module Playbook
|
|
29
31
|
def input_default_value
|
30
32
|
default_value.present? ? default_value.transform_keys(&:to_s) : ""
|
31
33
|
end
|
34
|
+
|
35
|
+
def options_with_blank
|
36
|
+
blank_selection.present? ? [{ id: "", value: "", label: blank_selection }] + options : options
|
37
|
+
end
|
32
38
|
end
|
33
39
|
end
|
34
40
|
end
|
@@ -9,6 +9,8 @@ const UP_ARROW_SELECTOR = "#dropdown_close_icon";
|
|
9
9
|
const OPTION_SELECTOR = "[data-dropdown-option-label]";
|
10
10
|
const CUSTOM_DISPLAY_SELECTOR = "[data-dropdown-custom-trigger]";
|
11
11
|
const INPUT_FORM_VALIDATION = "#dropdown-form-validation";
|
12
|
+
const DROPDOWN_TRIGGER_DISPLAY = "#dropdown_trigger_display";
|
13
|
+
const DROPDOWN_PLACEHOLDER = "[data-dropdown-placeholder]";
|
12
14
|
|
13
15
|
export default class PbDropdown extends PbEnhancedElement {
|
14
16
|
static get selector() {
|
@@ -25,6 +27,7 @@ export default class PbDropdown extends PbEnhancedElement {
|
|
25
27
|
this.bindEventListeners();
|
26
28
|
this.updateArrowDisplay(false);
|
27
29
|
this.handleFormValidation();
|
30
|
+
this.handleFormReset();
|
28
31
|
}
|
29
32
|
|
30
33
|
bindEventListeners() {
|
@@ -84,9 +87,7 @@ export default class PbDropdown extends PbEnhancedElement {
|
|
84
87
|
}
|
85
88
|
|
86
89
|
onOptionSelected(value, selectedOption) {
|
87
|
-
const triggerElement = this.element.querySelector(
|
88
|
-
"#dropdown_trigger_display"
|
89
|
-
);
|
90
|
+
const triggerElement = this.element.querySelector(DROPDOWN_TRIGGER_DISPLAY);
|
90
91
|
const customDisplayElement = this.element.querySelector(
|
91
92
|
"#dropdown_trigger_custom_display"
|
92
93
|
);
|
@@ -195,13 +196,38 @@ export default class PbDropdown extends PbEnhancedElement {
|
|
195
196
|
}
|
196
197
|
});
|
197
198
|
|
198
|
-
|
199
|
-
if (triggerElement) {
|
200
|
-
triggerElement.textContent = defaultValue.label;
|
201
|
-
}
|
199
|
+
this.setTriggerElementText(defaultValue.label);
|
202
200
|
|
203
201
|
hiddenInput.value = defaultValue.id;
|
204
202
|
inputFormValidation.value = defaultValue.id;
|
205
203
|
}
|
206
204
|
}
|
205
|
+
|
206
|
+
handleFormReset() {
|
207
|
+
const form = this.element.closest("form");
|
208
|
+
|
209
|
+
if (form) {
|
210
|
+
form.addEventListener("reset", () => {
|
211
|
+
this.resetDropdownValue();
|
212
|
+
});
|
213
|
+
}
|
214
|
+
}
|
215
|
+
|
216
|
+
resetDropdownValue() {
|
217
|
+
const hiddenInput = this.element.querySelector("#dropdown-selected-option");
|
218
|
+
const inputFormValidation = this.element.querySelector(INPUT_FORM_VALIDATION);
|
219
|
+
|
220
|
+
hiddenInput.value = "";
|
221
|
+
inputFormValidation.value = "";
|
222
|
+
|
223
|
+
const defaultPlaceholder = this.element.querySelector(DROPDOWN_PLACEHOLDER);
|
224
|
+
this.setTriggerElementText(defaultPlaceholder.dataset.dropdownPlaceholder);
|
225
|
+
}
|
226
|
+
|
227
|
+
setTriggerElementText(text) {
|
228
|
+
const triggerElement = this.element.querySelector(DROPDOWN_TRIGGER_DISPLAY);
|
229
|
+
if (triggerElement) {
|
230
|
+
triggerElement.textContent = text;
|
231
|
+
}
|
232
|
+
}
|
207
233
|
}
|
@@ -8,6 +8,7 @@ $selector: ".pb_form_pill";
|
|
8
8
|
$pb_form_pill_height: 37px;
|
9
9
|
$form_pill_colors: (
|
10
10
|
primary: map-get($status_color_text, "primary"),
|
11
|
+
neutral: map-get($status_color_text, "neutral"),
|
11
12
|
);
|
12
13
|
|
13
14
|
|
@@ -23,34 +24,71 @@ $form_pill_colors: (
|
|
23
24
|
cursor: pointer;
|
24
25
|
@each $color_name, $color_value in $form_pill_colors {
|
25
26
|
&[class*=_#{$color_name}] {
|
26
|
-
background-color:
|
27
|
+
background-color: mix($color_value, $card_light, 10%);
|
28
|
+
@if ($color_name == "neutral") {
|
29
|
+
background-color: $white;
|
30
|
+
border: 1px solid $border_light;
|
31
|
+
}
|
27
32
|
transition: background-color 0.2s ease;
|
28
33
|
box-shadow: none;
|
29
34
|
@media (hover:hover) {
|
30
35
|
&:hover {
|
31
|
-
background-color:
|
36
|
+
background-color: mix($color_value, $card_light, 20%);
|
37
|
+
@if ($color_name == "neutral") {
|
38
|
+
background-color: mix($neutral, $card_light, 20%);
|
39
|
+
border: 1px solid $border_light;
|
40
|
+
}
|
41
|
+
}
|
42
|
+
&:active {
|
43
|
+
background-color: mix($color_value, $card_light, 30%);
|
44
|
+
@if ($color_name == "neutral") {
|
45
|
+
background-color: mix($neutral, $card_light, 30%);
|
46
|
+
}
|
32
47
|
}
|
33
48
|
}
|
34
49
|
#{$selector}_text {
|
35
50
|
color: $color_value;
|
51
|
+
@if ($color_name == "neutral") {
|
52
|
+
color: $text_lt_default;
|
53
|
+
}
|
36
54
|
padding-left: $space-sm;
|
37
|
-
padding-right: calc($space-sm/
|
55
|
+
padding-right: calc($space-sm/2);
|
38
56
|
}
|
39
57
|
#{$selector}_close {
|
40
58
|
color: $color_value;
|
41
|
-
padding-left: calc($space-sm/
|
59
|
+
padding-left: calc($space-sm/4);
|
42
60
|
padding-right: calc($space-sm/4);
|
43
61
|
display: flex;
|
44
62
|
align-items: center;
|
45
|
-
height
|
63
|
+
// I had to temporarily change height to 27px so new hover state darker background forms a circle not an oval
|
64
|
+
// before size change (ticket 2 of 4) - change back to 100% when $pb_form_pill_height changed to 27px from 37px
|
65
|
+
height: 27px;
|
66
|
+
border-radius: 70px;
|
46
67
|
cursor: pointer;
|
68
|
+
&:hover {
|
69
|
+
background-color: mix($color_value, $card_light, 40%);
|
70
|
+
@if ($color_name == "neutral") {
|
71
|
+
background-color: mix($neutral, $card_light, 60%);
|
72
|
+
}
|
73
|
+
}
|
47
74
|
}
|
48
75
|
#{$selector}_tag {
|
49
76
|
color: $color_value;
|
50
77
|
padding-left: $space-sm;
|
78
|
+
@if ($color_name == "neutral") {
|
79
|
+
color: $text_lt_default;
|
80
|
+
}
|
51
81
|
}
|
52
82
|
}
|
53
83
|
}
|
84
|
+
&:focus {
|
85
|
+
outline: $primary solid 2px;
|
86
|
+
outline-offset: -1px;
|
87
|
+
}
|
88
|
+
&:focus-visible {
|
89
|
+
outline: $primary solid 2px;
|
90
|
+
outline-offset: -1px;
|
91
|
+
}
|
54
92
|
&.small {
|
55
93
|
height: fit-content;
|
56
94
|
height: -moz-fit-content;
|
@@ -70,6 +108,71 @@ $form_pill_colors: (
|
|
70
108
|
&::before { line-height: 21px; }
|
71
109
|
}
|
72
110
|
}
|
111
|
+
&.dark {
|
112
|
+
@each $color_name, $color_value in $form_pill_colors {
|
113
|
+
// In dark mode, the base patterns below are needed for the next tickets for success, warning, error, info.
|
114
|
+
// Primary and Neutral are exceptions to the general rule in the handoff
|
115
|
+
&[class*=_#{$color_name}] {
|
116
|
+
// background-color: mix($color_value, $card_dark, 10%);
|
117
|
+
// .pb_form_pill_tag {
|
118
|
+
// color: $color_name;
|
119
|
+
// }
|
120
|
+
// .pb_form_pill_close {
|
121
|
+
// color: $color_name;
|
122
|
+
// &:hover {
|
123
|
+
// background-color: mix($color_value, $card_dark, 40%);
|
124
|
+
// }
|
125
|
+
// }
|
126
|
+
// &:hover {
|
127
|
+
// background-color: mix($color_value, $card_dark, 20%);
|
128
|
+
// }
|
129
|
+
// &:active {
|
130
|
+
// background-color: mix($color_value, $card_dark, 30%);
|
131
|
+
// }
|
132
|
+
@if ($color_name == "neutral") {
|
133
|
+
background-color: transparent;
|
134
|
+
border: 1px solid $border_dark;
|
135
|
+
.pb_form_pill_text, .pb_form_pill_tag {
|
136
|
+
color: $text_dk_default;
|
137
|
+
}
|
138
|
+
.pb_form_pill_close {
|
139
|
+
color: $text_dk_default;
|
140
|
+
&:hover {
|
141
|
+
background-color: mix($neutral, $card_dark, 40%);
|
142
|
+
}
|
143
|
+
}
|
144
|
+
&:hover {
|
145
|
+
background-color: mix($white, $card_dark, 10%);
|
146
|
+
}
|
147
|
+
&:active {
|
148
|
+
background-color: mix($white, $card_dark, 20%);
|
149
|
+
}
|
150
|
+
&:focus {
|
151
|
+
border: 1px solid $primary;
|
152
|
+
}
|
153
|
+
}
|
154
|
+
@if ($color_name == "primary") {
|
155
|
+
background-color: mix($active_dark, $card_dark, 10%);
|
156
|
+
.pb_form_pill_text, .pb_form_pill_tag {
|
157
|
+
color: $active_dark;
|
158
|
+
}
|
159
|
+
.pb_form_pill_close {
|
160
|
+
color: $active_dark;
|
161
|
+
&:hover {
|
162
|
+
background-color: mix($active_dark, $card_dark, 40%);
|
163
|
+
}
|
164
|
+
}
|
165
|
+
&:hover {
|
166
|
+
background-color: mix($active_dark, $card_dark, 20px);
|
167
|
+
}
|
168
|
+
&:active {
|
169
|
+
background-color: mix($active_dark, $card_dark, 30%);
|
170
|
+
}
|
171
|
+
}
|
172
|
+
}
|
173
|
+
}
|
174
|
+
}
|
175
|
+
|
73
176
|
&[class*=lowercase] {
|
74
177
|
text-transform: lowercase;
|
75
178
|
}
|
@@ -0,0 +1,53 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { render, screen } from '../utilities/test-utils';
|
3
|
+
import FormPill from './_form_pill';
|
4
|
+
|
5
|
+
const testId = 'formpill';
|
6
|
+
|
7
|
+
test('should render classname', () => {
|
8
|
+
render(
|
9
|
+
<FormPill
|
10
|
+
data={{ testid: testId }}
|
11
|
+
text="test"
|
12
|
+
/>
|
13
|
+
)
|
14
|
+
|
15
|
+
const kit = screen.getByTestId(testId)
|
16
|
+
expect(kit).toHaveClass('pb_form_pill_kit_primary none')
|
17
|
+
});
|
18
|
+
|
19
|
+
test('displays text content', () => {
|
20
|
+
render(
|
21
|
+
<FormPill
|
22
|
+
data={{ testid: testId }}
|
23
|
+
text="test"
|
24
|
+
/>
|
25
|
+
)
|
26
|
+
|
27
|
+
const text = screen.getByText("test")
|
28
|
+
expect(text).toBeInTheDocument()
|
29
|
+
});
|
30
|
+
|
31
|
+
test('displays color variant', () => {
|
32
|
+
render(
|
33
|
+
<FormPill
|
34
|
+
color={"neutral"}
|
35
|
+
data={{ testid: testId }}
|
36
|
+
text={"test"}
|
37
|
+
/>
|
38
|
+
)
|
39
|
+
const kit = screen.getByTestId(testId)
|
40
|
+
expect(kit).toHaveClass(`pb_form_pill_kit_neutral none`)
|
41
|
+
});
|
42
|
+
|
43
|
+
test('displays size variant', () => {
|
44
|
+
render(
|
45
|
+
<FormPill
|
46
|
+
data={{ testid: testId }}
|
47
|
+
size={"small"}
|
48
|
+
text={"test"}
|
49
|
+
/>
|
50
|
+
)
|
51
|
+
const kit = screen.getByTestId('formpill')
|
52
|
+
expect(kit).toHaveClass(`pb_form_pill_kit_primary small none`)
|
53
|
+
});
|
@@ -4,7 +4,7 @@ import Title from '../pb_title/_title'
|
|
4
4
|
import Icon from '../pb_icon/_icon'
|
5
5
|
import Avatar from '../pb_avatar/_avatar'
|
6
6
|
import { globalProps, GlobalProps } from '../utilities/globalProps'
|
7
|
-
import { buildHtmlProps } from '../utilities/props'
|
7
|
+
import { buildDataProps, buildHtmlProps } from '../utilities/props'
|
8
8
|
|
9
9
|
type FormPillProps = {
|
10
10
|
className?: string,
|
@@ -17,6 +17,9 @@ type FormPillProps = {
|
|
17
17
|
avatarUrl?: string,
|
18
18
|
size?: string,
|
19
19
|
textTransform?: 'none' | 'lowercase',
|
20
|
+
color?: "primary" | "neutral",
|
21
|
+
data?: {[key: string]: string},
|
22
|
+
tabIndex?: number,
|
20
23
|
closeProps?: {
|
21
24
|
onClick?: React.MouseEventHandler<HTMLSpanElement>,
|
22
25
|
onMouseDown?: React.MouseEventHandler<HTMLSpanElement>,
|
@@ -35,20 +38,26 @@ const FormPill = (props: FormPillProps): React.ReactElement => {
|
|
35
38
|
closeProps = {},
|
36
39
|
size = '',
|
37
40
|
textTransform = 'none',
|
41
|
+
color = "primary",
|
42
|
+
data = {},
|
43
|
+
tabIndex,
|
38
44
|
} = props
|
39
45
|
const css = classnames(
|
40
|
-
`pb_form_pill_kit_${
|
46
|
+
`pb_form_pill_kit_${color}`,
|
41
47
|
globalProps(props),
|
42
48
|
className,
|
43
49
|
size === 'small' ? 'small' : null,
|
44
50
|
textTransform,
|
45
51
|
)
|
46
52
|
|
53
|
+
const dataProps = buildDataProps(data)
|
47
54
|
const htmlProps = buildHtmlProps(htmlOptions)
|
48
55
|
|
49
56
|
return (
|
50
57
|
<div className={css}
|
51
58
|
id={id}
|
59
|
+
tabIndex={tabIndex}
|
60
|
+
{...dataProps}
|
52
61
|
{...htmlProps}
|
53
62
|
>
|
54
63
|
{name &&
|
@@ -2,6 +2,7 @@
|
|
2
2
|
name: "Anna Black",
|
3
3
|
avatar_url: "https://randomuser.me/api/portraits/women/44.jpg",
|
4
4
|
size: "small",
|
5
|
+
tabindex: 0,
|
5
6
|
}) %>
|
6
7
|
|
7
8
|
<br />
|
@@ -10,4 +11,5 @@
|
|
10
11
|
<%= pb_rails("form_pill", props: {
|
11
12
|
name: "Anna Black",
|
12
13
|
size: "small",
|
14
|
+
tabindex: 0,
|
13
15
|
}) %>
|
@@ -9,6 +9,7 @@ const FormPillSize = (props) => {
|
|
9
9
|
avatarUrl="https://randomuser.me/api/portraits/women/44.jpg"
|
10
10
|
name="Anna Black"
|
11
11
|
size="small"
|
12
|
+
tabIndex={0}
|
12
13
|
{...props}
|
13
14
|
/>
|
14
15
|
<br />
|
@@ -16,6 +17,7 @@ const FormPillSize = (props) => {
|
|
16
17
|
<FormPill
|
17
18
|
name="Anna Black"
|
18
19
|
size="small"
|
20
|
+
tabIndex={0}
|
19
21
|
{...props}
|
20
22
|
/>
|
21
23
|
</div>
|
@@ -1,6 +1,7 @@
|
|
1
1
|
<%= pb_rails("form_pill", props: {
|
2
2
|
name: "Anna Black",
|
3
3
|
avatar_url: "https://randomuser.me/api/portraits/women/44.jpg",
|
4
|
+
tabindex: 0,
|
4
5
|
}) %>
|
5
6
|
|
6
7
|
<br />
|
@@ -8,4 +9,5 @@
|
|
8
9
|
|
9
10
|
<%= pb_rails("form_pill", props: {
|
10
11
|
name: "Anna Black",
|
12
|
+
tabindex: 0,
|
11
13
|
}) %>
|
@@ -9,6 +9,7 @@ const FormPillDefault = (props) => {
|
|
9
9
|
avatarUrl="https://randomuser.me/api/portraits/women/44.jpg"
|
10
10
|
name="Anna Black"
|
11
11
|
onClick={() => alert('Click!')}
|
12
|
+
tabIndex={0}
|
12
13
|
{...props}
|
13
14
|
/>
|
14
15
|
<br />
|
@@ -16,6 +17,7 @@ const FormPillDefault = (props) => {
|
|
16
17
|
<FormPill
|
17
18
|
name="Anna Black"
|
18
19
|
onClick={() => alert('Click!')}
|
20
|
+
tabIndex={0}
|
19
21
|
{...props}
|
20
22
|
/>
|
21
23
|
</div>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<%= content_tag(:div, id: object.id, data: object.data, class: object.classname + object.size_class, **combined_html_options) do %>
|
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: "xs" }) %>
|
4
4
|
<%= pb_rails("title", props: { text: object.name, size: 4, classname: "pb_form_pill_text" }) %>
|
@@ -11,9 +11,13 @@ module Playbook
|
|
11
11
|
prop :text_transform, type: Playbook::Props::Enum,
|
12
12
|
values: %w[none lowercase],
|
13
13
|
default: "none"
|
14
|
+
prop :color, type: Playbook::Props::Enum,
|
15
|
+
values: %w[primary neutral],
|
16
|
+
default: "primary"
|
17
|
+
prop :tabindex
|
14
18
|
|
15
19
|
def classname
|
16
|
-
generate_classname("pb_form_pill_kit",
|
20
|
+
generate_classname("pb_form_pill_kit", color, name, text, text_transform)
|
17
21
|
end
|
18
22
|
|
19
23
|
def display_text
|