playbook_ui 14.7.0 → 14.8.0.pre.alpha.PLAY1598floatinguiupgrade4617
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/_playbook.scss +1 -0
- data/app/pb_kits/playbook/pb_card/docs/_card_light.md +1 -1
- data/app/pb_kits/playbook/pb_checkbox/checkbox.html.erb +2 -2
- data/app/pb_kits/playbook/pb_checkbox/checkbox.rb +0 -4
- data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_indeterminate.html.erb +84 -7
- data/app/pb_kits/playbook/pb_date/_date.scss +3 -0
- data/app/pb_kits/playbook/pb_date_picker/date_picker_helper.ts +1 -1
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_quick_pick_default_date.html.erb +42 -0
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_quick_pick_default_date.jsx +44 -0
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_quick_pick_default_date.md +1 -0
- data/app/pb_kits/playbook/pb_date_picker/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_date_picker/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_date_picker/plugins/quickPick.tsx +17 -1
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_default_rails.html.erb +26 -0
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_default_rails.md +7 -0
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_cards_rails.html.erb +38 -0
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_cards_rails.md +0 -0
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_list_rails.html.erb +19 -0
- data/app/pb_kits/playbook/pb_draggable/docs/example.yml +6 -0
- data/app/pb_kits/playbook/pb_draggable/draggable.html.erb +3 -0
- data/app/pb_kits/playbook/pb_draggable/draggable.rb +18 -0
- data/app/pb_kits/playbook/pb_draggable/draggable_container.html.erb +3 -0
- data/app/pb_kits/playbook/pb_draggable/draggable_container.rb +15 -0
- data/app/pb_kits/playbook/pb_draggable/draggable_item.html.erb +7 -0
- data/app/pb_kits/playbook/pb_draggable/draggable_item.rb +18 -0
- data/app/pb_kits/playbook/pb_draggable/index.js +125 -0
- data/app/pb_kits/playbook/pb_drawer/_drawer.scss +88 -175
- data/app/pb_kits/playbook/pb_drawer/_drawer.tsx +79 -47
- data/app/pb_kits/playbook/pb_drawer/drawer.test.jsx +20 -16
- data/app/pb_kits/playbook/pb_dropdown/_dropdown.scss +1 -0
- data/app/pb_kits/playbook/pb_dropdown/dropdown_container.html.erb +0 -1
- data/app/pb_kits/playbook/pb_dropdown/dropdown_container.rb +0 -4
- data/app/pb_kits/playbook/pb_form/docs/_form_form_with.html.erb +2 -2
- data/app/pb_kits/playbook/pb_form/docs/_form_form_with_loading.html.erb +1 -1
- data/app/pb_kits/playbook/pb_form/docs/_form_form_with_validate.html.erb +63 -12
- data/app/pb_kits/playbook/pb_selectable_card/docs/_selectable_card_default.html.erb +2 -1
- data/app/pb_kits/playbook/pb_timeline/_timeline.scss +43 -1
- data/app/pb_kits/playbook/pb_timeline/_timeline.tsx +6 -2
- data/app/pb_kits/playbook/pb_timeline/docs/_timeline_with_children.html.erb +47 -0
- data/app/pb_kits/playbook/pb_timeline/docs/_timeline_with_children.jsx +59 -0
- data/app/pb_kits/playbook/pb_timeline/docs/_timeline_with_gap.html.erb +94 -0
- data/app/pb_kits/playbook/pb_timeline/docs/_timeline_with_gap.jsx +180 -0
- data/app/pb_kits/playbook/pb_timeline/docs/_timeline_with_gap.md +1 -0
- data/app/pb_kits/playbook/pb_timeline/docs/example.yml +5 -3
- data/app/pb_kits/playbook/pb_timeline/docs/index.js +2 -0
- data/app/pb_kits/playbook/pb_timeline/timeline.rb +11 -1
- data/app/pb_kits/playbook/pb_timeline/timeline.test.js +4 -4
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.scss +3 -0
- data/app/pb_kits/playbook/pb_typeahead/index.ts +29 -3
- data/app/pb_kits/playbook/pb_typeahead/typeahead.html.erb +5 -2
- data/app/pb_kits/playbook/pb_typeahead/typeahead.rb +4 -0
- data/app/pb_kits/playbook/tokens/_height.scss +19 -0
- data/app/pb_kits/playbook/tokens/exports/_height.module.scss +37 -0
- data/app/pb_kits/playbook/utilities/_height.scss +33 -0
- data/app/pb_kits/playbook/utilities/_hover.scss +40 -27
- data/app/pb_kits/playbook/utilities/_max_width.scss +4 -0
- data/app/pb_kits/playbook/utilities/_min_width.scss +1 -1
- data/app/pb_kits/playbook/utilities/globalPropNames.mjs +0 -1
- data/app/pb_kits/playbook/utilities/globalProps.ts +29 -3
- data/app/pb_kits/playbook/utilities/test/globalProps/hover.test.js +79 -0
- data/dist/chunks/_typeahead-q6dSnFmE.js +22 -0
- data/dist/chunks/_weekday_stacked-BF7UZO3j.js +45 -0
- data/dist/chunks/lazysizes-B7xYodB-.js +1 -0
- data/dist/chunks/{lib-D-mTv-kp.js → lib-SyD3buPZ.js} +1 -1
- data/dist/chunks/{pb_form_validation-BkWGwJsl.js → pb_form_validation-Dt8UJgrJ.js} +1 -1
- data/dist/chunks/vendor.js +1 -1
- data/dist/menu.yml +322 -1
- data/dist/playbook-doc.js +1 -1
- data/dist/playbook-rails-react-bindings.js +1 -1
- data/dist/playbook-rails.js +1 -1
- data/dist/playbook.css +1 -1
- data/lib/playbook/classnames.rb +3 -0
- data/lib/playbook/forms/builder/typeahead_field.rb +13 -0
- data/lib/playbook/height.rb +29 -0
- data/lib/playbook/hover.rb +1 -1
- data/lib/playbook/kit_base.rb +16 -1
- data/lib/playbook/max_height.rb +29 -0
- data/lib/playbook/min_height.rb +29 -0
- data/lib/playbook/version.rb +2 -2
- metadata +35 -10
- data/dist/chunks/_typeahead-DhLic2Fe.js +0 -22
- data/dist/chunks/_weekday_stacked-CHPFjl8J.js +0 -45
- data/dist/chunks/lazysizes-DHz07jlL.js +0 -1
@@ -8,9 +8,15 @@ module Playbook
|
|
8
8
|
default: "horizontal"
|
9
9
|
prop :show_date, type: Playbook::Props::Boolean,
|
10
10
|
default: false
|
11
|
+
prop :gap, type: Playbook::Props::Enum,
|
12
|
+
values: %w[xs sm md lg none],
|
13
|
+
default: "none"
|
11
14
|
|
12
15
|
def classname
|
13
|
-
generate_classname("pb_timeline_kit",
|
16
|
+
generate_classname("pb_timeline_kit",
|
17
|
+
orientation,
|
18
|
+
date_class,
|
19
|
+
gap_class)
|
14
20
|
end
|
15
21
|
|
16
22
|
private
|
@@ -18,6 +24,10 @@ module Playbook
|
|
18
24
|
def date_class
|
19
25
|
show_date ? "with_date" : nil
|
20
26
|
end
|
27
|
+
|
28
|
+
def gap_class
|
29
|
+
gap == "none" ? nil : "gap_#{gap}"
|
30
|
+
end
|
21
31
|
end
|
22
32
|
end
|
23
33
|
end
|
@@ -147,26 +147,26 @@ test('should pass id prop', () => {
|
|
147
147
|
test('should have horizontal orientation by default', () => {
|
148
148
|
render(<TimelineDefault />)
|
149
149
|
const kit = screen.getByTestId(testId)
|
150
|
-
expect(kit).toHaveClass('
|
150
|
+
expect(kit).toHaveClass('pb_timeline_kit_horizontal')
|
151
151
|
})
|
152
152
|
|
153
153
|
test('should pass vertical orientation', () => {
|
154
154
|
const props = { orientation: 'vertical' }
|
155
155
|
render(<TimelineDefault {...props} />)
|
156
156
|
const kit = screen.getByTestId(testId)
|
157
|
-
expect(kit).toHaveClass('
|
157
|
+
expect(kit).toHaveClass('pb_timeline_kit_vertical')
|
158
158
|
})
|
159
159
|
|
160
160
|
test('should pass showDate prop', () => {
|
161
161
|
const props = { showDate: true }
|
162
162
|
render(<TimelineDefault {...props} />)
|
163
163
|
const kit = screen.getByTestId(testId)
|
164
|
-
expect(kit).toHaveClass('
|
164
|
+
expect(kit).toHaveClass('pb_timeline_kit_horizontal__with_date')
|
165
165
|
})
|
166
166
|
|
167
167
|
test('should pass showDate prop with Children', () => {
|
168
168
|
const props = { showDate: true }
|
169
169
|
render(<TimelineWithChildren {...props} />)
|
170
170
|
const kit = screen.getByTestId(testId)
|
171
|
-
expect(kit).toHaveClass('
|
171
|
+
expect(kit).toHaveClass('pb_timeline_kit_horizontal__with_date')
|
172
172
|
})
|
@@ -2,6 +2,7 @@
|
|
2
2
|
@import "../tokens/border_radius";
|
3
3
|
@import "../tokens/spacing";
|
4
4
|
@import "../tokens/shadows";
|
5
|
+
@import "../tokens/positioning";
|
5
6
|
|
6
7
|
[class^=pb_typeahead_kit] {
|
7
8
|
.typeahead-kit-select__option {
|
@@ -99,6 +100,7 @@
|
|
99
100
|
.typeahead-kit-select__menu {
|
100
101
|
background-color: $bg_dark;
|
101
102
|
color: $white;
|
103
|
+
z-index: $z_1;
|
102
104
|
}
|
103
105
|
.typeahead-kit-select__option:hover {
|
104
106
|
background-color: $active_dark;
|
@@ -182,6 +184,7 @@
|
|
182
184
|
}
|
183
185
|
|
184
186
|
.typeahead-kit-select__menu {
|
187
|
+
z-index: $z_1;
|
185
188
|
.typeahead-kit-select__menu-list {
|
186
189
|
padding: 0;
|
187
190
|
}
|
@@ -4,11 +4,12 @@ import { debounce } from 'lodash'
|
|
4
4
|
export default class PbTypeahead extends PbEnhancedElement {
|
5
5
|
_searchInput: HTMLInputElement
|
6
6
|
_resultsElement: HTMLElement
|
7
|
-
_debouncedSearch:
|
7
|
+
_debouncedSearch: () => void
|
8
8
|
_resultsLoadingIndicator: HTMLElement
|
9
9
|
_resultOptionTemplate: HTMLElement
|
10
10
|
_resultsOptionCache: Map<string, Array<DocumentFragment>>
|
11
11
|
_searchContext: string
|
12
|
+
_validSelection: boolean
|
12
13
|
|
13
14
|
static get selector() {
|
14
15
|
return '[data-pb-typeahead-kit]'
|
@@ -86,6 +87,9 @@ export default class PbTypeahead extends PbEnhancedElement {
|
|
86
87
|
const resultOption = (event.target as Element).closest('[data-result-option-item]')
|
87
88
|
if (!resultOption) return
|
88
89
|
|
90
|
+
this._validSelection = true
|
91
|
+
this.removeValidationError()
|
92
|
+
|
89
93
|
this.resultsCacheClear()
|
90
94
|
this.searchInputClear()
|
91
95
|
this.clearResults()
|
@@ -93,6 +97,28 @@ export default class PbTypeahead extends PbEnhancedElement {
|
|
93
97
|
this.element.dispatchEvent(new CustomEvent('pb-typeahead-kit-result-option-selected', { bubbles: true, detail: { selected: resultOption, typeahead: this } }))
|
94
98
|
}
|
95
99
|
|
100
|
+
removeValidationError() {
|
101
|
+
const inputWrapper = this.searchInput.closest('.text_input_wrapper')
|
102
|
+
if (inputWrapper) {
|
103
|
+
const errorMessage = inputWrapper.querySelector('.pb_body_kit_negative') as HTMLElement
|
104
|
+
if (errorMessage) {
|
105
|
+
errorMessage.style.display = 'none'
|
106
|
+
}
|
107
|
+
this.searchInput.classList.remove('error')
|
108
|
+
}
|
109
|
+
}
|
110
|
+
|
111
|
+
showValidationError() {
|
112
|
+
const inputWrapper = this.searchInput.closest('.text_input_wrapper')
|
113
|
+
if (inputWrapper) {
|
114
|
+
const errorMessage = inputWrapper.querySelector('.pb_body_kit_negative') as HTMLElement
|
115
|
+
if (errorMessage) {
|
116
|
+
errorMessage.style.display = 'block'
|
117
|
+
}
|
118
|
+
this.searchInput.classList.add('error')
|
119
|
+
}
|
120
|
+
}
|
121
|
+
|
96
122
|
clearResults() {
|
97
123
|
this.resultsElement.innerHTML = ''
|
98
124
|
}
|
@@ -201,8 +227,8 @@ export default class PbTypeahead extends PbEnhancedElement {
|
|
201
227
|
}
|
202
228
|
|
203
229
|
toggleResultsLoadingIndicator(visible: boolean) {
|
204
|
-
|
230
|
+
let visibilityProperty = '0'
|
205
231
|
if (visible) visibilityProperty = '1'
|
206
232
|
this.resultsLoadingIndicator.style.opacity = visibilityProperty
|
207
233
|
}
|
208
|
-
}
|
234
|
+
}
|
@@ -17,11 +17,14 @@
|
|
17
17
|
<%= pb_rails("text_input", props: {
|
18
18
|
type: "search",
|
19
19
|
input_options: object.input_options,
|
20
|
-
label: object.label,
|
21
20
|
name: object.name,
|
22
21
|
value: object.value,
|
23
22
|
placeholder: object.placeholder,
|
24
23
|
margin_bottom: "none",
|
24
|
+
required: object.required,
|
25
|
+
validation: object.validation,
|
26
|
+
label: object.label,
|
27
|
+
id: object.input_options[:id],
|
25
28
|
}) %>
|
26
29
|
<%= pb_rails("list", props: { ordered: false, borderless: false, xpadding: true, role: "status", aria: { live: "polite" }, data: { pb_typeahead_kit_results: true } }) do %>
|
27
30
|
<% end %>
|
@@ -33,4 +36,4 @@
|
|
33
36
|
<% end %>
|
34
37
|
</template>
|
35
38
|
<% end %>
|
36
|
-
<% end %>
|
39
|
+
<% end %>
|
@@ -40,6 +40,10 @@ module Playbook
|
|
40
40
|
prop :pill_color, type: Playbook::Props::Enum,
|
41
41
|
values: %w[primary neutral success warning error info data_1 data_2 data_3 data_4 data_5 data_6 data_7 data_8 windows siding roofing doors gutters solar insulation accessories],
|
42
42
|
default: "primary"
|
43
|
+
prop :required, type: Playbook::Props::Boolean,
|
44
|
+
default: false
|
45
|
+
prop :validation, type: Playbook::Props::HashProp,
|
46
|
+
default: {}
|
43
47
|
|
44
48
|
def classname
|
45
49
|
default_margin_bottom = margin_bottom.present? ? "" : " mb_sm"
|
@@ -0,0 +1,19 @@
|
|
1
|
+
|
2
|
+
$height_auto: auto !default;
|
3
|
+
$height_xs: 320px !default;
|
4
|
+
$height_sm: 480px !default;
|
5
|
+
$height_md: 768px !default;
|
6
|
+
$height_lg: 1024px !default;
|
7
|
+
$height_xl: 1280px !default;
|
8
|
+
$height_2xl: 1440px !default;
|
9
|
+
$height_3xl: 1920px !default;
|
10
|
+
$heights: (
|
11
|
+
height_auto: $height_auto,
|
12
|
+
height_xs: $height_xs,
|
13
|
+
height_sm: $height_sm,
|
14
|
+
height_md: $height_md,
|
15
|
+
height_lg: $height_lg,
|
16
|
+
height_xl: $height_xl,
|
17
|
+
height_xxl: $height_2xl,
|
18
|
+
height_xxxl: $height_3xl
|
19
|
+
);
|
@@ -0,0 +1,37 @@
|
|
1
|
+
@import "../height";
|
2
|
+
|
3
|
+
:export {
|
4
|
+
@mixin export_height($height_list) {
|
5
|
+
@each $name, $value in $height_list {
|
6
|
+
.#{$name} {
|
7
|
+
height: $value;
|
8
|
+
}
|
9
|
+
}
|
10
|
+
}
|
11
|
+
|
12
|
+
@include export_height($heights);
|
13
|
+
}
|
14
|
+
|
15
|
+
:export {
|
16
|
+
@mixin export_max_height($height_list) {
|
17
|
+
@each $name, $value in $height_list {
|
18
|
+
.max_#{$name} {
|
19
|
+
max-height: $value;
|
20
|
+
}
|
21
|
+
}
|
22
|
+
}
|
23
|
+
|
24
|
+
@include export_max_height($heights);
|
25
|
+
}
|
26
|
+
|
27
|
+
:export {
|
28
|
+
@mixin export_min_height($height_list) {
|
29
|
+
@each $name, $value in $height_list {
|
30
|
+
.min_#{$name} {
|
31
|
+
min-height: $value;
|
32
|
+
}
|
33
|
+
}
|
34
|
+
}
|
35
|
+
|
36
|
+
@include export_min_height($heights);
|
37
|
+
}
|
@@ -0,0 +1,33 @@
|
|
1
|
+
@import "../tokens/exports/height.module";
|
2
|
+
|
3
|
+
@mixin export_height($height_list) {
|
4
|
+
@each $name, $value in $height_list {
|
5
|
+
.#{$name} {
|
6
|
+
height: $value;
|
7
|
+
}
|
8
|
+
}
|
9
|
+
}
|
10
|
+
|
11
|
+
@mixin export_max_height($height_list) {
|
12
|
+
@each $name, $value in $height_list {
|
13
|
+
.max_#{$name} {
|
14
|
+
max-height: $value;
|
15
|
+
}
|
16
|
+
}
|
17
|
+
}
|
18
|
+
|
19
|
+
@mixin export_min_height($height_list) {
|
20
|
+
@each $name, $value in $height_list {
|
21
|
+
.min_#{$name} {
|
22
|
+
min-height: $value;
|
23
|
+
}
|
24
|
+
}
|
25
|
+
}
|
26
|
+
|
27
|
+
@include export_height($heights);
|
28
|
+
@include export_max_height($heights);
|
29
|
+
@include export_min_height($heights);
|
30
|
+
|
31
|
+
.height-resize {
|
32
|
+
resize: vertical;
|
33
|
+
}
|
@@ -21,34 +21,47 @@
|
|
21
21
|
}
|
22
22
|
|
23
23
|
@mixin hover-color-classes($colors-list) {
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
transition: color $transition-speed ease;
|
24
|
+
@each $name, $color in $colors-list {
|
25
|
+
.hover_background-#{"" + $name}:hover {
|
26
|
+
background-color: $color !important;
|
27
|
+
transition: background-color $transition-speed ease;
|
28
|
+
}
|
29
|
+
.hover_color-#{"" + $name}:hover {
|
30
|
+
color: $color !important;
|
31
|
+
transition: color $transition-speed ease;
|
32
|
+
}
|
34
33
|
}
|
35
34
|
}
|
35
|
+
|
36
|
+
@include hover-scale-classes($scales);
|
37
|
+
@include hover-shadow-classes($box_shadows);
|
38
|
+
@include hover-color-classes($product_colors);
|
39
|
+
@include hover-color-classes($status_colors);
|
40
|
+
@include hover-color-classes($data_colors);
|
41
|
+
@include hover-color-classes($shadow_colors);
|
42
|
+
@include hover-color-classes($colors);
|
43
|
+
@include hover-color-classes($interface_colors);
|
44
|
+
@include hover-color-classes($main_colors);
|
45
|
+
@include hover-color-classes($background_colors);
|
46
|
+
@include hover-color-classes($card_colors);
|
47
|
+
@include hover-color-classes($active_colors);
|
48
|
+
@include hover-color-classes($action_colors);
|
49
|
+
@include hover-color-classes($hover_colors);
|
50
|
+
@include hover-color-classes($border_colors);
|
51
|
+
@include hover-color-classes($text_colors);
|
52
|
+
@include hover-color-classes($category_colors);
|
53
|
+
|
54
|
+
.hover_visibility {
|
55
|
+
opacity: 0;
|
56
|
+
transition: opacity $transition-speed ease;
|
57
|
+
|
58
|
+
&:hover {
|
59
|
+
opacity: 1;
|
60
|
+
}
|
36
61
|
}
|
37
62
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
@include hover-color-classes($shadow_colors);
|
44
|
-
@include hover-color-classes($colors);
|
45
|
-
@include hover-color-classes($interface_colors);
|
46
|
-
@include hover-color-classes($main_colors);
|
47
|
-
@include hover-color-classes($background_colors);
|
48
|
-
@include hover-color-classes($card_colors);
|
49
|
-
@include hover-color-classes($active_colors);
|
50
|
-
@include hover-color-classes($action_colors);
|
51
|
-
@include hover-color-classes($hover_colors);
|
52
|
-
@include hover-color-classes($border_colors);
|
53
|
-
@include hover-color-classes($text_colors);
|
54
|
-
@include hover-color-classes($category_colors);
|
63
|
+
.group_hover:hover {
|
64
|
+
.group_hover.hover_visibility {
|
65
|
+
opacity: 1;
|
66
|
+
}
|
67
|
+
}
|
@@ -63,7 +63,8 @@ type FlexWrap = {
|
|
63
63
|
type Hover = Shadow & {
|
64
64
|
background?: string,
|
65
65
|
color?: string,
|
66
|
-
scale?: "sm" | "md" | "lg"
|
66
|
+
scale?: "sm" | "md" | "lg",
|
67
|
+
visibility?: boolean,
|
67
68
|
}
|
68
69
|
|
69
70
|
type GroupHover = {
|
@@ -230,9 +231,10 @@ const PROP_CATEGORIES: {[key:string]: (props: {[key: string]: any}) => string} =
|
|
230
231
|
let css = '';
|
231
232
|
if (!hover) return css;
|
232
233
|
css += hover.shadow ? `hover_shadow_${hover.shadow} ` : '';
|
233
|
-
css += hover.background ? `
|
234
|
+
css += hover.background ? `hover_background-${hover.background } ` : '';
|
234
235
|
css += hover.scale ? `hover_scale_${hover.scale} ` : '';
|
235
|
-
css += hover.color ? `
|
236
|
+
css += hover.color ? `hover_color-${hover.color } ` : '';
|
237
|
+
css += hover.visibility ? `hover_visibility` : '';
|
236
238
|
return css;
|
237
239
|
},
|
238
240
|
|
@@ -359,6 +361,30 @@ const PROP_CATEGORIES: {[key:string]: (props: {[key: string]: any}) => string} =
|
|
359
361
|
css += maxWidth ? `max_width_${filterClassName(maxWidth)} ` : ''
|
360
362
|
return css.trimEnd()
|
361
363
|
},
|
364
|
+
minHeightProps: ({ minHeight }: MinHeight) => {
|
365
|
+
const heightValues = ["auto", "xs", "sm", "md", "lg", "xl", "xxl", "xxxl"]
|
366
|
+
if (heightValues.includes(minHeight)) {
|
367
|
+
let css = ''
|
368
|
+
css += minHeight ? `min_height_${filterClassName(minHeight)} ` : ''
|
369
|
+
return css.trimEnd()
|
370
|
+
}
|
371
|
+
},
|
372
|
+
maxHeightProps: ({ maxHeight }: MaxHeight) => {
|
373
|
+
const heightValues = ["auto", "xs", "sm", "md", "lg", "xl", "xxl", "xxxl"]
|
374
|
+
if (heightValues.includes(maxHeight)) {
|
375
|
+
let css = ''
|
376
|
+
css += maxHeight ? `max_height_${filterClassName(maxHeight)} ` : ''
|
377
|
+
return css.trimEnd()
|
378
|
+
}
|
379
|
+
},
|
380
|
+
heightProps: ({ height }: Height) => {
|
381
|
+
const heightValues = ["auto", "xs", "sm", "md", "lg", "xl", "xxl", "xxxl"]
|
382
|
+
if (heightValues.includes(height)) {
|
383
|
+
let css = ''
|
384
|
+
css += height ? `height_${filterClassName(height)} ` : ''
|
385
|
+
return css.trimEnd()
|
386
|
+
}
|
387
|
+
},
|
362
388
|
zIndexProps: (zIndex: ZIndex) => {
|
363
389
|
let css = ''
|
364
390
|
Object.entries(zIndex).forEach((zIndexEntry) => {
|
@@ -0,0 +1,79 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { render, screen } from '../../test-utils';
|
3
|
+
import Body from '../../../pb_body/_body';
|
4
|
+
|
5
|
+
const testSubject = 'body';
|
6
|
+
|
7
|
+
test('Hover Props: returns proper class name', () => {
|
8
|
+
const testIdColor = `${testSubject}-hover-color-red`;
|
9
|
+
render(
|
10
|
+
<Body
|
11
|
+
data={{ testid: testIdColor }}
|
12
|
+
hover={{ color: 'red' }}
|
13
|
+
text="Hi"
|
14
|
+
/>
|
15
|
+
);
|
16
|
+
|
17
|
+
let kit = screen.getByTestId(testIdColor);
|
18
|
+
let expectedClassName = `hover_color-red`;
|
19
|
+
expect(kit).toHaveClass(expectedClassName);
|
20
|
+
|
21
|
+
const testIdBackground = `${testSubject}-hover-background-blue`;
|
22
|
+
render(
|
23
|
+
<Body
|
24
|
+
data={{ testid: testIdBackground }}
|
25
|
+
hover={{ background: 'blue' }}
|
26
|
+
text="Hi"
|
27
|
+
/>
|
28
|
+
);
|
29
|
+
|
30
|
+
kit = screen.getByTestId(testIdBackground);
|
31
|
+
expectedClassName = `hover_background-blue`;
|
32
|
+
expect(kit).toHaveClass(expectedClassName);
|
33
|
+
|
34
|
+
const testIdShadow = `${testSubject}-hover-shadow-deep`;
|
35
|
+
render(
|
36
|
+
<Body
|
37
|
+
data={{ testid: testIdShadow }}
|
38
|
+
hover={{ shadow: 'deep' }}
|
39
|
+
text="Hi"
|
40
|
+
/>
|
41
|
+
);
|
42
|
+
|
43
|
+
kit = screen.getByTestId(testIdShadow);
|
44
|
+
expectedClassName = `hover_shadow_deep`;
|
45
|
+
expect(kit).toHaveClass(expectedClassName);
|
46
|
+
|
47
|
+
const testIdScale = `${testSubject}-hover-scale`;
|
48
|
+
render(
|
49
|
+
<Body
|
50
|
+
data={{ testid: testIdScale }}
|
51
|
+
hover={{ scale: 'xl' }}
|
52
|
+
text="Test"
|
53
|
+
/>
|
54
|
+
);
|
55
|
+
|
56
|
+
kit = screen.getByTestId(testIdScale);
|
57
|
+
expectedClassName = `hover_scale_xl`;
|
58
|
+
expect(kit).toHaveClass(expectedClassName);
|
59
|
+
|
60
|
+
const testIdMultiple = `${testSubject}-hover-multiple`;
|
61
|
+
render(
|
62
|
+
<Body
|
63
|
+
data={{ testid: testIdMultiple }}
|
64
|
+
hover={{
|
65
|
+
color: 'green',
|
66
|
+
background: 'error',
|
67
|
+
shadow: 'deeper',
|
68
|
+
scale: 'xl',
|
69
|
+
}}
|
70
|
+
text="Hi"
|
71
|
+
/>
|
72
|
+
);
|
73
|
+
|
74
|
+
kit = screen.getByTestId(testIdMultiple);
|
75
|
+
expect(kit).toHaveClass('hover_color-green');
|
76
|
+
expect(kit).toHaveClass('hover_background-error');
|
77
|
+
expect(kit).toHaveClass('hover_shadow_deeper');
|
78
|
+
expect(kit).toHaveClass('hover_scale_xl');
|
79
|
+
});
|