playbook_ui 14.1.0.pre.alpha.PA1477timestampkit3536 → 14.1.0.pre.alpha.PBNTR417addcolorsupdatedefaultcolor3608
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 +2 -0
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +3 -3
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.html.erb +1 -1
- data/app/pb_kits/playbook/pb_badge/_badge.scss +9 -0
- data/app/pb_kits/playbook/pb_badge/_badge.tsx +8 -3
- data/app/pb_kits/playbook/pb_badge/badge.rb +1 -1
- data/app/pb_kits/playbook/pb_badge/badge.test.js +17 -11
- data/app/pb_kits/playbook/pb_badge/docs/_badge_notification.html.erb +13 -0
- data/app/pb_kits/playbook/pb_badge/docs/_badge_notification.jsx +31 -12
- data/app/pb_kits/playbook/pb_button/_button.tsx +4 -1
- data/app/pb_kits/playbook/pb_button/button.html.erb +1 -1
- data/app/pb_kits/playbook/pb_button/button.rb +4 -0
- data/app/pb_kits/playbook/pb_date_time/dateTime.test.js +2 -2
- data/app/pb_kits/playbook/pb_dialog/_close_icon.tsx +5 -1
- data/app/pb_kits/playbook/pb_dialog/_dialog.tsx +3 -1
- data/app/pb_kits/playbook/pb_dialog/dialog.test.jsx +20 -1
- data/app/pb_kits/playbook/pb_dialog/dialog_header.html.erb +1 -1
- data/app/pb_kits/playbook/pb_dialog/dialog_header.rb +4 -0
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_default.jsx +1 -5
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_loading.jsx +46 -0
- data/app/pb_kits/playbook/pb_dialog/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_dialog/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_filter/filter.rb +1 -1
- data/app/pb_kits/playbook/pb_form/docs/_form_form_with_validate.html.erb +1 -0
- data/app/pb_kits/playbook/pb_form_pill/_form_pill.scss +287 -47
- data/app/pb_kits/playbook/pb_form_pill/_form_pill.test.jsx +5 -5
- data/app/pb_kits/playbook/pb_form_pill/_form_pill.tsx +8 -4
- data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_colors.html.erb +117 -0
- data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_colors.jsx +227 -0
- data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_colors.md +1 -0
- data/app/pb_kits/playbook/pb_form_pill/docs/example.yml +4 -2
- data/app/pb_kits/playbook/pb_form_pill/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_form_pill/form_pill.html.erb +4 -4
- data/app/pb_kits/playbook/pb_form_pill/form_pill.rb +6 -2
- data/app/pb_kits/playbook/pb_gantt_chart/_gantt_chart.scss +3 -0
- data/app/pb_kits/playbook/pb_gantt_chart/_gantt_chart.tsx +72 -0
- data/app/pb_kits/playbook/pb_gantt_chart/docs/_gantt_chart_default.jsx +53 -0
- data/app/pb_kits/playbook/pb_gantt_chart/docs/example.yml +7 -0
- data/app/pb_kits/playbook/pb_gantt_chart/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_gantt_chart/gantt_chart.test.jsx +19 -0
- data/app/pb_kits/playbook/pb_icon/_icon.tsx +1 -1
- data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.tsx +5 -3
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_color.html.erb +72 -0
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_color.jsx +91 -0
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_color_rails.md +1 -0
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_color_react.md +1 -0
- data/app/pb_kits/playbook/pb_multi_level_select/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_multi_level_select/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_multi_level_select/multi_level_select.rb +4 -0
- data/app/pb_kits/playbook/pb_pagination/_pagination.scss +49 -13
- data/app/pb_kits/playbook/pb_pagination/_pagination.tsx +164 -0
- data/app/pb_kits/playbook/pb_pagination/docs/_pagination_default.jsx +19 -0
- data/app/pb_kits/playbook/pb_pagination/docs/_pagination_default_react.md +1 -0
- data/app/pb_kits/playbook/pb_pagination/docs/_pagination_page_change.jsx +62 -0
- data/app/pb_kits/playbook/pb_pagination/docs/_pagination_page_change_react.md +1 -0
- data/app/pb_kits/playbook/pb_pagination/docs/data.js +23 -0
- data/app/pb_kits/playbook/pb_pagination/docs/example.yml +3 -1
- data/app/pb_kits/playbook/pb_pagination/docs/index.js +2 -0
- data/app/pb_kits/playbook/pb_phone_number_input/_phone_number_input.scss +0 -7
- data/app/pb_kits/playbook/pb_popover/_popover.tsx +10 -5
- data/app/pb_kits/playbook/pb_rich_text_editor/_previewer_mixin.scss +132 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/_tiptap_styles.scss +50 -76
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_preview.jsx +73 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/index.js +2 -1
- data/app/pb_kits/playbook/pb_star_rating/index.js +78 -41
- data/app/pb_kits/playbook/pb_star_rating/star_rating.html.erb +4 -2
- data/app/pb_kits/playbook/pb_star_rating/star_rating.rb +17 -0
- data/app/pb_kits/playbook/pb_star_rating/subcomponents/_star_rating_display.tsx +0 -2
- data/app/pb_kits/playbook/pb_star_rating/subcomponents/_star_rating_interactive.tsx +0 -1
- data/app/pb_kits/playbook/pb_time/_time.tsx +12 -8
- data/app/pb_kits/playbook/pb_time/time.html.erb +3 -3
- data/app/pb_kits/playbook/pb_time/time.rb +4 -0
- data/app/pb_kits/playbook/pb_timestamp/timestamp.rb +2 -37
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.test.jsx +18 -2
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.tsx +4 -0
- data/app/pb_kits/playbook/pb_typeahead/components/MultiValue.tsx +26 -18
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_color.html.erb +31 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_color.jsx +26 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_color_rails.md +1 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_color_react.md +1 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_typeahead/typeahead.rb +4 -0
- data/app/pb_kits/playbook/tokens/_colors.scss +2 -0
- data/app/pb_kits/playbook/tokens/_container.scss +21 -0
- data/app/pb_kits/playbook/utilities/_min_width.scss +45 -0
- data/app/pb_kits/playbook/utilities/globalPropNames.mjs +1 -0
- data/app/pb_kits/playbook/utilities/globalProps.ts +20 -3
- data/app/pb_kits/playbook/utilities/icons/allicons.tsx +59 -0
- data/app/pb_kits/playbook/utilities/icons/clock.svg +9 -0
- data/app/pb_kits/playbook/utilities/icons/spinner.svg +3 -0
- data/app/pb_kits/playbook/utilities/icons/times.svg +3 -0
- data/dist/chunks/_typeahead-BbHBDL7C.js +22 -0
- data/dist/chunks/_weekday_stacked-DEfI42pf.js +45 -0
- data/dist/chunks/lazysizes-B7xYodB-.js +1 -0
- data/dist/chunks/{lib-BE0Z3F7x.js → lib-u02fp5X7.js} +2 -2
- data/dist/chunks/{pb_form_validation-TzZQ0Flx.js → pb_form_validation-iGj5wwU2.js} +1 -1
- data/dist/chunks/vendor.js +1 -1
- data/dist/menu.yml +4 -0
- 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 +1 -0
- data/lib/playbook/spacing.rb +31 -2
- data/lib/playbook/version.rb +1 -1
- metadata +43 -10
- data/dist/chunks/_typeahead-D-4y9pbv.js +0 -22
- data/dist/chunks/_weekday_stacked-Cax4nrUa.js +0 -45
- data/dist/chunks/lazysizes-DHz07jlL.js +0 -1
- /data/app/pb_kits/playbook/pb_pagination/docs/{_pagination_default.md → _pagination_default_rails.md} +0 -0
@@ -6,6 +6,7 @@
|
|
6
6
|
@import "../tokens/typography";
|
7
7
|
@import "../tokens/shadows";
|
8
8
|
@import "../tokens/transition";
|
9
|
+
@import "previewer_mixin";
|
9
10
|
|
10
11
|
[class^="pb_rich_text_editor_kit"] {
|
11
12
|
.toolbar_button {
|
@@ -85,109 +86,44 @@
|
|
85
86
|
}
|
86
87
|
|
87
88
|
code {
|
88
|
-
|
89
|
-
background: $bg_light;
|
90
|
-
padding: 0.1rem 0.3rem;
|
91
|
-
margin: 0 5px;
|
92
|
-
box-shadow: 0 2px 10px $shadow;
|
93
|
-
border-radius: 0.25rem;
|
94
|
-
overflow: hidden;
|
95
|
-
font-size: ($text_small - 1px);
|
89
|
+
@include preview_code;
|
96
90
|
}
|
97
91
|
|
98
92
|
pre {
|
99
|
-
|
100
|
-
padding: $space_sm;
|
101
|
-
border-radius: $border_rad_heaviest;
|
102
|
-
margin: 1.5rem 0 2rem 0;
|
103
|
-
code {
|
104
|
-
background: transparent;
|
105
|
-
box-shadow: none;
|
106
|
-
border: 0;
|
107
|
-
color: #faf6e4;
|
108
|
-
}
|
93
|
+
@include preview_pre_codeblock;
|
109
94
|
}
|
110
95
|
a {
|
111
|
-
|
112
|
-
border-bottom: 1px solid $primary;
|
113
|
-
&:hover {
|
114
|
-
color: $text_lt_default;
|
115
|
-
border-bottom: 1px solid $text_lt_default;
|
116
|
-
}
|
96
|
+
@include preview_a;
|
117
97
|
}
|
118
98
|
blockquote {
|
119
|
-
|
120
|
-
padding: $space_sm $space_md;
|
121
|
-
font-style: italic;
|
122
|
-
p {
|
123
|
-
margin: 0;
|
124
|
-
}
|
99
|
+
@include preview_blockquote;
|
125
100
|
}
|
126
101
|
&:focus-visible {
|
127
102
|
outline: unset;
|
128
103
|
@include transition_default;
|
129
104
|
}
|
130
105
|
h1 {
|
131
|
-
|
132
|
-
line-height: $text_larger;
|
133
|
-
font-weight: $bolder;
|
134
|
-
letter-spacing: $lspace_tight;
|
135
|
-
margin: 2.1rem 0 0 0;
|
106
|
+
@include preview_h1;
|
136
107
|
}
|
137
108
|
h2 {
|
138
|
-
|
139
|
-
line-height: $text_larger;
|
140
|
-
font-weight: $bolder;
|
141
|
-
letter-spacing: $lspace_tight;
|
142
|
-
margin: 1.9rem 0 0 0;
|
109
|
+
@include preview_h2;
|
143
110
|
}
|
144
111
|
h3 {
|
145
|
-
|
146
|
-
line-height: $text_large;
|
147
|
-
font-weight: $bolder;
|
148
|
-
letter-spacing: $lspace_tight;
|
149
|
-
margin: 1.7rem 0 0 0;
|
112
|
+
@include preview_h3;
|
150
113
|
}
|
151
114
|
h4,
|
152
115
|
h5,
|
153
116
|
h6 {
|
154
|
-
|
155
|
-
line-height: $text_base;
|
156
|
-
letter-spacing: $lspace_tight;
|
157
|
-
font-weight: $bolder;
|
117
|
+
@include preview_smaller_headings;
|
158
118
|
}
|
159
119
|
hr {
|
160
|
-
|
161
|
-
box-sizing: content-box;
|
162
|
-
overflow: hidden;
|
163
|
-
background: transparent;
|
164
|
-
border-bottom: 1px solid $transparent;
|
165
|
-
height: 1px;
|
166
|
-
padding: 0;
|
167
|
-
background-color: $border_light;
|
168
|
-
border: 0;
|
120
|
+
@include preview_hr;
|
169
121
|
}
|
170
122
|
ol {
|
171
|
-
|
172
|
-
padding-left: $space_md;
|
173
|
-
list-style: decimal;
|
174
|
-
li {
|
175
|
-
margin: 2px 0;
|
176
|
-
p {
|
177
|
-
margin: 0;
|
178
|
-
}
|
179
|
-
}
|
123
|
+
@include preview_ol;
|
180
124
|
}
|
181
125
|
ul {
|
182
|
-
|
183
|
-
margin: 1rem 0 0 0;
|
184
|
-
padding-left: $space_md;
|
185
|
-
li {
|
186
|
-
margin: 2px 0;
|
187
|
-
p {
|
188
|
-
margin: 0;
|
189
|
-
}
|
190
|
-
}
|
126
|
+
@include preview_ul;
|
191
127
|
}
|
192
128
|
}
|
193
129
|
}
|
@@ -233,3 +169,41 @@
|
|
233
169
|
}
|
234
170
|
}
|
235
171
|
}
|
172
|
+
.tiptap-content {
|
173
|
+
@include preview_first_child;
|
174
|
+
a {
|
175
|
+
@include preview_a;
|
176
|
+
}
|
177
|
+
blockquote {
|
178
|
+
@include preview_blockquote;
|
179
|
+
}
|
180
|
+
h1 {
|
181
|
+
@include preview_h1;
|
182
|
+
}
|
183
|
+
h2 {
|
184
|
+
@include preview_h2;
|
185
|
+
}
|
186
|
+
h3 {
|
187
|
+
@include preview_h3;
|
188
|
+
}
|
189
|
+
h4,
|
190
|
+
h5,
|
191
|
+
h6 {
|
192
|
+
@include preview_smaller_headings;
|
193
|
+
}
|
194
|
+
hr {
|
195
|
+
@include preview_hr;
|
196
|
+
}
|
197
|
+
ol {
|
198
|
+
@include preview_ol;
|
199
|
+
}
|
200
|
+
p {
|
201
|
+
@include preview_p;
|
202
|
+
}
|
203
|
+
pre {
|
204
|
+
@include preview_pre_codeblock;
|
205
|
+
}
|
206
|
+
ul {
|
207
|
+
@include preview_ul;
|
208
|
+
}
|
209
|
+
}
|
@@ -0,0 +1,73 @@
|
|
1
|
+
import React, { useState } from 'react'
|
2
|
+
import { Button, Card, RichTextEditor } from 'playbook-ui'
|
3
|
+
import { useEditor, EditorContent } from "@tiptap/react"
|
4
|
+
import StarterKit from "@tiptap/starter-kit"
|
5
|
+
import Link from '@tiptap/extension-link'
|
6
|
+
|
7
|
+
|
8
|
+
const RichTextEditorAdvancedPreview = (props) => {
|
9
|
+
|
10
|
+
const editor = useEditor({
|
11
|
+
extensions: [
|
12
|
+
StarterKit,
|
13
|
+
Link
|
14
|
+
],
|
15
|
+
content: "Add text here, format it, and press \"Preview Output\" to see what your stylized output will look like on the page."
|
16
|
+
})
|
17
|
+
|
18
|
+
const [showPreview, setShowPreview] = useState(false)
|
19
|
+
const [previewText, setPreviewText] = useState(<div />)
|
20
|
+
|
21
|
+
const handleChange = () => {
|
22
|
+
if (editor) {
|
23
|
+
setPreviewText(editor.getHTML())
|
24
|
+
}
|
25
|
+
}
|
26
|
+
|
27
|
+
const handleClick = () => {
|
28
|
+
handleChange()
|
29
|
+
setShowPreview(true)
|
30
|
+
}
|
31
|
+
if (!editor) {
|
32
|
+
return null
|
33
|
+
}
|
34
|
+
|
35
|
+
|
36
|
+
return (
|
37
|
+
<div>
|
38
|
+
<RichTextEditor
|
39
|
+
advancedEditor={editor}
|
40
|
+
id="content-advanced-preview-editor"
|
41
|
+
onChange={handleChange}
|
42
|
+
{...props}
|
43
|
+
>
|
44
|
+
<EditorContent editor={editor}/>
|
45
|
+
</RichTextEditor>
|
46
|
+
{showPreview && (
|
47
|
+
<Card
|
48
|
+
marginTop="md"
|
49
|
+
maxWidth="md"
|
50
|
+
>
|
51
|
+
<div
|
52
|
+
className="tiptap-content"
|
53
|
+
// eslint-disable-next-line react/no-danger
|
54
|
+
dangerouslySetInnerHTML={{ __html: previewText }}
|
55
|
+
id="advanced-preview-content"
|
56
|
+
/>
|
57
|
+
</Card>
|
58
|
+
)}
|
59
|
+
{!showPreview && (
|
60
|
+
<div />
|
61
|
+
)}
|
62
|
+
<Button
|
63
|
+
id="preview-button"
|
64
|
+
marginTop="md"
|
65
|
+
onClick={handleClick}
|
66
|
+
text="Preview Output"
|
67
|
+
variant="secondary"
|
68
|
+
/>
|
69
|
+
</div>
|
70
|
+
)
|
71
|
+
}
|
72
|
+
|
73
|
+
export default RichTextEditorAdvancedPreview
|
@@ -9,4 +9,5 @@ export { default as RichTextEditorInline } from './_rich_text_editor_inline.jsx'
|
|
9
9
|
export { default as RichTextEditorPreview } from './_rich_text_editor_preview.jsx'
|
10
10
|
export { default as RichTextEditorAdvancedDefault } from './_rich_text_editor_advanced_default.jsx'
|
11
11
|
export { default as RichTextEditorMoreExtensions } from './_rich_text_editor_more_extensions.jsx'
|
12
|
-
export { default as RichTextEditorToolbarDisabled } from './_rich_text_editor_toolbar_disabled.jsx'
|
12
|
+
export { default as RichTextEditorToolbarDisabled } from './_rich_text_editor_toolbar_disabled.jsx'
|
13
|
+
export { default as RichTextEditorAdvancedPreview } from './_rich_text_editor_advanced_preview.jsx'
|
@@ -1,119 +1,156 @@
|
|
1
|
-
import PbEnhancedElement from "../pb_enhanced_element"
|
1
|
+
import PbEnhancedElement from "../pb_enhanced_element"
|
2
2
|
|
3
|
-
const
|
4
|
-
const
|
3
|
+
const STAR_RATING_WRAPPER_SELECTOR = "[data-pb-star-rating-wrapper]"
|
4
|
+
const STAR_RATING_SELECTOR = "[data-pb-star-rating]"
|
5
|
+
const STAR_RATING_INPUT_DATA_SELECTOR = "[data-pb-star-rating-input]"
|
5
6
|
|
6
7
|
export default class PbStarRating extends PbEnhancedElement {
|
7
8
|
static get selector() {
|
8
|
-
return
|
9
|
+
return STAR_RATING_WRAPPER_SELECTOR
|
9
10
|
}
|
10
11
|
|
11
12
|
connect() {
|
12
|
-
this.
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
this.addEventListeners()
|
14
|
+
this.handleFormReset()
|
15
|
+
}
|
16
|
+
|
17
|
+
addEventListeners() {
|
18
|
+
this.element.querySelectorAll(STAR_RATING_SELECTOR).forEach(star => {
|
19
|
+
star.addEventListener("click", (event) => {
|
20
|
+
const clickedStarId = event.currentTarget.id
|
21
|
+
this.updateStarColors(clickedStarId)
|
22
|
+
this.updateHiddenInputValue(clickedStarId)
|
23
|
+
this.clearFormValidation()
|
24
|
+
})
|
17
25
|
|
18
|
-
document.querySelectorAll(STAR_RATING_SELECTOR).forEach(star => {
|
19
26
|
star.addEventListener("mouseenter", (event) => {
|
20
27
|
const hoveredStarId = event.currentTarget.id
|
21
|
-
this.updateStarHoverColors(hoveredStarId)
|
28
|
+
this.updateStarHoverColors(hoveredStarId)
|
22
29
|
})
|
23
30
|
|
24
31
|
star.addEventListener("mouseleave", () => {
|
25
|
-
this.removeStarHoverColors()
|
32
|
+
this.removeStarHoverColors()
|
26
33
|
})
|
27
34
|
|
28
35
|
star.addEventListener("keydown", (event) => {
|
29
36
|
if (event.key === 'Enter' || event.key === ' ') {
|
30
|
-
event.preventDefault()
|
31
|
-
this.handleStarClick(star.id)
|
37
|
+
event.preventDefault()
|
38
|
+
this.handleStarClick(star.id)
|
32
39
|
}
|
33
40
|
})
|
34
41
|
})
|
35
42
|
}
|
36
43
|
|
37
44
|
handleStarClick(starId) {
|
38
|
-
this.updateStarColors(starId)
|
39
|
-
this.updateHiddenInputValue(starId)
|
45
|
+
this.updateStarColors(starId)
|
46
|
+
this.updateHiddenInputValue(starId)
|
40
47
|
}
|
41
48
|
|
42
49
|
updateStarColors(clickedStarId) {
|
43
|
-
const allStars =
|
50
|
+
const allStars = this.element.querySelectorAll(STAR_RATING_SELECTOR)
|
44
51
|
|
45
52
|
allStars.forEach(star => {
|
46
|
-
const starId = star.id
|
47
|
-
const icon = star.querySelector(".interactive-star-icon")
|
53
|
+
const starId = star.id
|
54
|
+
const icon = star.querySelector(".interactive-star-icon")
|
48
55
|
|
49
56
|
if (icon) {
|
50
57
|
if (starId <= clickedStarId) {
|
51
58
|
if (star.classList.contains("yellow_star")) {
|
52
|
-
icon.classList.add("yellow-star-selected")
|
59
|
+
icon.classList.add("yellow-star-selected")
|
53
60
|
} else if (star.classList.contains("primary_star_light")) {
|
54
|
-
icon.classList.add("primary-star-selected")
|
61
|
+
icon.classList.add("primary-star-selected")
|
55
62
|
} else if (star.classList.contains("primary_star_dark")) {
|
56
|
-
icon.classList.add("primary-star-selected")
|
63
|
+
icon.classList.add("primary-star-selected")
|
57
64
|
} else if (star.classList.contains("subtle_star_light")) {
|
58
|
-
icon.classList.add("subtle-star-selected")
|
65
|
+
icon.classList.add("subtle-star-selected")
|
59
66
|
} else if (star.classList.contains("subtle_star_dark")) {
|
60
|
-
icon.classList.add("subtle-star-selected")
|
67
|
+
icon.classList.add("subtle-star-selected")
|
61
68
|
} else {
|
62
|
-
icon.classList.add("yellow-star-selected")
|
69
|
+
icon.classList.add("yellow-star-selected")
|
63
70
|
}
|
64
71
|
} else {
|
65
|
-
icon.classList.remove("yellow-star-selected", "primary-star-selected", "subtle-star-selected")
|
72
|
+
icon.classList.remove("yellow-star-selected", "primary-star-selected", "subtle-star-selected")
|
66
73
|
}
|
67
|
-
icon.classList.remove("star-hovered")
|
74
|
+
icon.classList.remove("star-hovered")
|
68
75
|
}
|
69
|
-
})
|
76
|
+
})
|
70
77
|
}
|
71
78
|
|
72
79
|
updateHiddenInputValue(value) {
|
73
|
-
const hiddenInput =
|
80
|
+
const hiddenInput = this.element.querySelector(STAR_RATING_INPUT_DATA_SELECTOR)
|
74
81
|
if (hiddenInput) {
|
75
|
-
hiddenInput.value = value
|
82
|
+
hiddenInput.value = value
|
76
83
|
}
|
77
84
|
}
|
78
85
|
|
79
86
|
updateStarHoverColors(hoveredStarId) {
|
80
|
-
const allStars =
|
87
|
+
const allStars = this.element.querySelectorAll(STAR_RATING_SELECTOR)
|
81
88
|
|
82
89
|
allStars.forEach(star => {
|
83
|
-
const starId = star.id
|
84
|
-
const icon = star.querySelector(".interactive-star-icon")
|
90
|
+
const starId = star.id
|
91
|
+
const icon = star.querySelector(".interactive-star-icon")
|
85
92
|
|
86
93
|
if (icon) {
|
87
94
|
if (starId <= hoveredStarId) {
|
88
95
|
if (!icon.classList.contains("yellow-star-selected") &&
|
89
96
|
!icon.classList.contains("primary-star-selected") &&
|
90
97
|
!icon.classList.contains("subtle-star-selected")) {
|
91
|
-
icon.classList.add("star-hovered")
|
98
|
+
icon.classList.add("star-hovered")
|
92
99
|
}
|
93
100
|
} else {
|
94
|
-
icon.classList.remove("star-hovered")
|
101
|
+
icon.classList.remove("star-hovered")
|
95
102
|
}
|
96
103
|
}
|
97
|
-
})
|
104
|
+
})
|
98
105
|
}
|
99
106
|
|
100
107
|
|
101
108
|
removeStarHoverColors() {
|
102
|
-
const allStars =
|
109
|
+
const allStars = this.element.querySelectorAll(STAR_RATING_SELECTOR)
|
103
110
|
|
104
111
|
allStars.forEach(star => {
|
105
|
-
const icon = star.querySelector(".interactive-star-icon")
|
112
|
+
const icon = star.querySelector(".interactive-star-icon")
|
106
113
|
if (icon) {
|
107
114
|
if (!icon.classList.contains("yellow-star-selected") &&
|
108
115
|
!icon.classList.contains("primary-star-selected") &&
|
109
116
|
!icon.classList.contains("subtle-star-selected")) {
|
110
|
-
icon.classList.remove("star-hovered")
|
117
|
+
icon.classList.remove("star-hovered")
|
111
118
|
}
|
112
119
|
}
|
113
|
-
})
|
120
|
+
})
|
114
121
|
}
|
115
122
|
|
116
123
|
isStarSelected() {
|
117
|
-
return
|
124
|
+
return this.element.querySelectorAll(".yellow-star-selected, .primary-star-selected, .subtle-star-selected").length > 0
|
125
|
+
}
|
126
|
+
|
127
|
+
handleFormReset() {
|
128
|
+
const form = this.element.closest("form")
|
129
|
+
if (form) {
|
130
|
+
form.addEventListener("reset", () => {
|
131
|
+
this.updateHiddenInputValue("")
|
132
|
+
this.resetStarRatingValues()
|
133
|
+
})
|
134
|
+
}
|
135
|
+
}
|
136
|
+
|
137
|
+
resetStarRatingValues() {
|
138
|
+
const allStars = this.element.querySelectorAll(STAR_RATING_SELECTOR)
|
139
|
+
allStars.forEach(star => {
|
140
|
+
const icon = star.querySelector(".interactive-star-icon")
|
141
|
+
if (icon) {
|
142
|
+
icon.classList.remove("yellow-star-selected", "primary-star-selected", "subtle-star-selected")
|
143
|
+
}
|
144
|
+
})
|
145
|
+
}
|
146
|
+
|
147
|
+
clearFormValidation() {
|
148
|
+
const hiddenInput = this.element.querySelector(STAR_RATING_INPUT_DATA_SELECTOR)
|
149
|
+
if (hiddenInput.checkValidity()) {
|
150
|
+
const errorLabelElement = this.element.querySelector(".pb_body_kit_negative")
|
151
|
+
if (errorLabelElement) {
|
152
|
+
errorLabelElement.remove()
|
153
|
+
}
|
154
|
+
}
|
118
155
|
}
|
119
156
|
}
|
@@ -39,11 +39,13 @@
|
|
39
39
|
<% end %>
|
40
40
|
|
41
41
|
<% else %>
|
42
|
-
<%= pb_rails("flex", props: { orientation: "column" }) do %>
|
42
|
+
<%= pb_rails("flex", props: { data: {"pb-star-rating-wrapper": "true" }, orientation: "column" }) do %>
|
43
43
|
<% if object.label.present? %>
|
44
44
|
<%= pb_rails("caption", props: {text: object.label, margin_bottom:"xs"}) %>
|
45
45
|
<% end %>
|
46
|
-
|
46
|
+
|
47
|
+
<%= hidden_input_tag %>
|
48
|
+
|
47
49
|
<%= pb_rails("flex", props: { orientation: "row" }) do %>
|
48
50
|
<% object.denominator.times do |index| %>
|
49
51
|
<div data-pb-star-rating id="<%= index + 1 %>" class="<%= star_color %>">
|
@@ -30,6 +30,10 @@ module Playbook
|
|
30
30
|
default: "display"
|
31
31
|
prop :label, type: Playbook::Props::String
|
32
32
|
prop :name, type: Playbook::Props::String
|
33
|
+
prop :required, type: Playbook::Props::Boolean,
|
34
|
+
default: false
|
35
|
+
prop :input_options, type: Playbook::Props::HashProp,
|
36
|
+
default: {}
|
33
37
|
|
34
38
|
def one_decimal_rating
|
35
39
|
rating.to_f.round(1)
|
@@ -106,6 +110,19 @@ module Playbook
|
|
106
110
|
def classname
|
107
111
|
generate_classname("pb_star_rating_kit")
|
108
112
|
end
|
113
|
+
|
114
|
+
def hidden_input_tag
|
115
|
+
tag(:input, all_input_options)
|
116
|
+
end
|
117
|
+
|
118
|
+
def all_input_options
|
119
|
+
input_options.merge(
|
120
|
+
data: { "pb-star-rating-input": true },
|
121
|
+
name: name,
|
122
|
+
required: required,
|
123
|
+
style: "display: none"
|
124
|
+
)
|
125
|
+
end
|
109
126
|
end
|
110
127
|
end
|
111
128
|
end
|
@@ -36,7 +36,6 @@ const StarRatingDisplay = (props: StarRatingDisplayProps) => {
|
|
36
36
|
<Icon
|
37
37
|
className={starIcon[colorOption].className}
|
38
38
|
customIcon={starIcon[colorOption].icon as unknown as { [key: string]: SVGElement }}
|
39
|
-
icon=""
|
40
39
|
/>
|
41
40
|
</React.Fragment>
|
42
41
|
))}
|
@@ -45,7 +44,6 @@ const StarRatingDisplay = (props: StarRatingDisplayProps) => {
|
|
45
44
|
<Icon
|
46
45
|
className={starIcon[backgroundType].className}
|
47
46
|
customIcon={starIcon[backgroundType].icon as unknown as { [key: string]: SVGElement }}
|
48
|
-
icon=""
|
49
47
|
/>
|
50
48
|
</React.Fragment>
|
51
49
|
))}
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import React from "react";
|
2
2
|
import classnames from "classnames";
|
3
3
|
|
4
|
+
import { getAllIcons } from "../utilities/icons/allicons"
|
4
5
|
import { buildCss, buildHtmlProps } from "../utilities/props";
|
5
6
|
import { globalProps, GlobalProps } from "../utilities/globalProps";
|
6
7
|
import DateTime from '../pb_kit/dateTime';
|
@@ -42,7 +43,7 @@ const Time = (props: TimeProps): React.ReactElement => {
|
|
42
43
|
globalProps(props),
|
43
44
|
className
|
44
45
|
);
|
45
|
-
|
46
|
+
const clockIcon = getAllIcons()["clock"]
|
46
47
|
const htmlProps = buildHtmlProps(htmlOptions);
|
47
48
|
|
48
49
|
return (
|
@@ -54,9 +55,10 @@ const Time = (props: TimeProps): React.ReactElement => {
|
|
54
55
|
unstyled
|
55
56
|
? (
|
56
57
|
<span>
|
57
|
-
|
58
|
-
|
59
|
-
|
58
|
+
<Icon
|
59
|
+
className="svg-inline--fa clock"
|
60
|
+
customIcon={clockIcon.icon as unknown as { [key: string]: SVGElement }}
|
61
|
+
/>
|
60
62
|
{" "}
|
61
63
|
</span>
|
62
64
|
)
|
@@ -65,10 +67,12 @@ const Time = (props: TimeProps): React.ReactElement => {
|
|
65
67
|
<Body color="light"
|
66
68
|
tag="span"
|
67
69
|
>
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
70
|
+
<Icon
|
71
|
+
className="svg-inline--fa clock"
|
72
|
+
customIcon={clockIcon.icon as unknown as { [key: string]: SVGElement }}
|
73
|
+
fixedWidth
|
74
|
+
size={size === "md" ? "" : "sm"}
|
75
|
+
/>
|
72
76
|
{" "}
|
73
77
|
</Body>
|
74
78
|
</>
|
@@ -13,7 +13,7 @@
|
|
13
13
|
<% if object.unstyled %>
|
14
14
|
<% if object.show_icon %>
|
15
15
|
<span>
|
16
|
-
<%= pb_rails("icon", props: {
|
16
|
+
<%= pb_rails("icon", props: { custom_icon: Playbook::Engine.root.join(clock_icon), fixed_width: true }) %>
|
17
17
|
</span>
|
18
18
|
<% end %>
|
19
19
|
|
@@ -27,7 +27,7 @@
|
|
27
27
|
<% elsif size == "md" %>
|
28
28
|
<% if object.show_icon %>
|
29
29
|
<%= pb_rails("body", props: { color: "light", tag: "span"}) do %>
|
30
|
-
<%= pb_rails("icon", props: {
|
30
|
+
<%= pb_rails("icon", props: { custom_icon: Playbook::Engine.root.join(clock_icon), fixed_width: true }) %>
|
31
31
|
<% end %>
|
32
32
|
<% end %>
|
33
33
|
|
@@ -41,7 +41,7 @@
|
|
41
41
|
<% else %>
|
42
42
|
<% if object.show_icon %>
|
43
43
|
<%= pb_rails("body", props: { color: "light", tag: "span"}) do %>
|
44
|
-
<%= pb_rails("icon", props: {
|
44
|
+
<%= pb_rails("icon", props: { custom_icon: Playbook::Engine.root.join(clock_icon), fixed_width: true, size: "sm" }) %>
|
45
45
|
<% end %>
|
46
46
|
<% end %>
|
47
47
|
|
@@ -27,15 +27,6 @@ module Playbook
|
|
27
27
|
values: %w[default elapsed updated],
|
28
28
|
default: "default"
|
29
29
|
|
30
|
-
# Variables to use with pb_time_ago method
|
31
|
-
SECS_PER_MIN = 60
|
32
|
-
SECS_PER_HOUR = 60 * SECS_PER_MIN
|
33
|
-
SECS_PER_DAY = 24 * SECS_PER_HOUR
|
34
|
-
SECS_PER_WEEK = 7 * SECS_PER_DAY
|
35
|
-
SECS_PER_MONTH = 4 * SECS_PER_WEEK
|
36
|
-
SECS_PER_YEAR = 12 * SECS_PER_MONTH
|
37
|
-
SECS_PER_CENT = 100 * SECS_PER_YEAR
|
38
|
-
|
39
30
|
def classname
|
40
31
|
generate_classname("pb_timestamp_kit", variant_class, align)
|
41
32
|
end
|
@@ -82,36 +73,10 @@ module Playbook
|
|
82
73
|
|
83
74
|
def format_elapsed_string
|
84
75
|
user_string = show_user ? " by #{text}" : ""
|
85
|
-
datetime_string = " #{
|
86
|
-
datetime_string[1] = hide_updated ? datetime_string[1].upcase : datetime_string[1]
|
76
|
+
datetime_string = " #{time_ago_in_words(pb_date_time.convert_to_timestamp)} ago"
|
87
77
|
updated_string = hide_updated ? "" : "Last updated"
|
88
|
-
"#{updated_string}#{user_string}#{datetime_string}"
|
89
|
-
end
|
90
78
|
|
91
|
-
|
92
|
-
time_ago = DateTime.now.to_i - value.to_i
|
93
|
-
case time_ago
|
94
|
-
when (0...SECS_PER_MIN)
|
95
|
-
"a few seconds"
|
96
|
-
when (SECS_PER_MIN...SECS_PER_HOUR)
|
97
|
-
time = time_ago / SECS_PER_MIN
|
98
|
-
time == 1 ? "a minute" : "#{time_ago / SECS_PER_MIN} minutes"
|
99
|
-
when (SECS_PER_HOUR...SECS_PER_DAY)
|
100
|
-
time = time_ago / SECS_PER_HOUR
|
101
|
-
time == 1 ? "an hour" : "#{time_ago / SECS_PER_HOUR} hours"
|
102
|
-
when (SECS_PER_DAY...SECS_PER_WEEK)
|
103
|
-
time = time_ago / SECS_PER_DAY
|
104
|
-
time == 1 ? "a day" : "#{time_ago / SECS_PER_DAY} days"
|
105
|
-
when (SECS_PER_WEEK...SECS_PER_MONTH)
|
106
|
-
time = time_ago / SECS_PER_WEEK
|
107
|
-
time == 1 ? "a week" : "#{time_ago / SECS_PER_WEEK} weeks"
|
108
|
-
when (SECS_PER_MONTH...SECS_PER_YEAR)
|
109
|
-
time = time_ago / SECS_PER_MONTH
|
110
|
-
time == 1 ? "a month" : "#{time_ago / SECS_PER_MONTH} months"
|
111
|
-
when (SECS_PER_YEAR...SECS_PER_CENT)
|
112
|
-
time = time_ago / SECS_PER_YEAR
|
113
|
-
time == 1 ? "a year" : "#{time_ago / SECS_PER_YEAR} years"
|
114
|
-
end
|
79
|
+
"#{updated_string}#{user_string}#{datetime_string}"
|
115
80
|
end
|
116
81
|
|
117
82
|
def datetime_or_text
|