playbook_ui 14.0.0 → 14.1.0.pre.alpha.PBNTR455ganttchartPOC3569

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/_playbook.scss +1 -0
  3. data/app/pb_kits/playbook/pb_advanced_table/Components/TableHeaderCell.tsx +5 -2
  4. data/app/pb_kits/playbook/pb_advanced_table/SubKits/TableBody.tsx +24 -20
  5. data/app/pb_kits/playbook/pb_advanced_table/SubKits/TableHeader.tsx +17 -12
  6. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +86 -1
  7. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +5 -1
  8. data/app/pb_kits/playbook/pb_advanced_table/advanced_table.test.jsx +30 -0
  9. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_responsive.jsx +67 -0
  10. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_responsive.md +1 -0
  11. data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +1 -0
  12. data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +2 -1
  13. data/app/pb_kits/playbook/pb_avatar/_avatar.scss +0 -30
  14. data/app/pb_kits/playbook/pb_avatar/_avatar.tsx +19 -1
  15. data/app/pb_kits/playbook/pb_avatar/avatar.rb +44 -1
  16. data/app/pb_kits/playbook/pb_avatar/avatar.test.js +17 -0
  17. data/app/pb_kits/playbook/pb_date_picker/docs/_description.md +3 -1
  18. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.scss +1 -1
  19. data/app/pb_kits/playbook/pb_form/docs/_form_form_with.html.erb +1 -0
  20. data/app/pb_kits/playbook/pb_gantt_chart/_gantt_chart.scss +3 -0
  21. data/app/pb_kits/playbook/pb_gantt_chart/_gantt_chart.tsx +72 -0
  22. data/app/pb_kits/playbook/pb_gantt_chart/docs/_gantt_chart_default.jsx +53 -0
  23. data/app/pb_kits/playbook/pb_gantt_chart/docs/example.yml +7 -0
  24. data/app/pb_kits/playbook/pb_gantt_chart/docs/index.js +1 -0
  25. data/app/pb_kits/playbook/pb_gantt_chart/gantt_chart.test.jsx +19 -0
  26. data/app/pb_kits/playbook/pb_icon/_icon.tsx +3 -0
  27. data/app/pb_kits/playbook/pb_icon/icon.rb +2 -0
  28. data/app/pb_kits/playbook/pb_icon_circle/_icon_circle.tsx +2 -1
  29. data/app/pb_kits/playbook/pb_icon_circle/icon_circle.rb +2 -2
  30. data/app/pb_kits/playbook/pb_icon_stat_value/_icon_stat_value.scss +0 -11
  31. data/app/pb_kits/playbook/pb_icon_stat_value/_icon_stat_value.tsx +3 -2
  32. data/app/pb_kits/playbook/pb_icon_stat_value/docs/_icon_stat_value_color.html.erb +1 -0
  33. data/app/pb_kits/playbook/pb_icon_stat_value/icon_stat_value.rb +2 -2
  34. data/app/pb_kits/playbook/pb_icon_stat_value/icon_stat_value.test.js +5 -4
  35. data/app/pb_kits/playbook/pb_nav/_horizontal_nav.scss +1 -1
  36. data/app/pb_kits/playbook/pb_online_status/_online_status.scss +52 -5
  37. data/app/pb_kits/playbook/pb_online_status/_online_status.tsx +6 -1
  38. data/app/pb_kits/playbook/pb_online_status/docs/_online_status_no_border.html.erb +1 -0
  39. data/app/pb_kits/playbook/pb_online_status/docs/_online_status_no_border.jsx +14 -0
  40. data/app/pb_kits/playbook/pb_online_status/docs/_online_status_size.html.erb +3 -0
  41. data/app/pb_kits/playbook/pb_online_status/docs/_online_status_size.jsx +25 -0
  42. data/app/pb_kits/playbook/pb_online_status/docs/example.yml +6 -2
  43. data/app/pb_kits/playbook/pb_online_status/docs/index.js +2 -0
  44. data/app/pb_kits/playbook/pb_online_status/online_status.rb +11 -1
  45. data/app/pb_kits/playbook/pb_online_status/online_status.test.js +31 -0
  46. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_toggle.html.erb +61 -0
  47. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_toggle.jsx +70 -0
  48. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_toggle.md +1 -0
  49. data/app/pb_kits/playbook/pb_overlay/docs/example.yml +4 -2
  50. data/app/pb_kits/playbook/pb_overlay/docs/index.js +1 -0
  51. data/app/pb_kits/playbook/pb_rich_text_editor/_previewer_mixin.scss +132 -0
  52. data/app/pb_kits/playbook/pb_rich_text_editor/_tiptap_styles.scss +50 -76
  53. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_preview.jsx +73 -0
  54. data/app/pb_kits/playbook/pb_rich_text_editor/docs/example.yml +1 -0
  55. data/app/pb_kits/playbook/pb_rich_text_editor/docs/index.js +2 -1
  56. data/app/pb_kits/playbook/pb_star_rating/_star_rating.scss +83 -6
  57. data/app/pb_kits/playbook/pb_star_rating/docs/example.yml +3 -1
  58. data/app/pb_kits/playbook/pb_star_rating/index.js +73 -4
  59. data/app/pb_kits/playbook/pb_star_rating/star_rating.html.erb +1 -1
  60. data/app/pb_kits/playbook/pb_star_rating/star_rating.rb +2 -2
  61. data/app/pb_kits/playbook/pb_star_rating/stars/utils.tsx +5 -1
  62. data/app/pb_kits/playbook/pb_star_rating/subcomponents/_star_rating_interactive.tsx +50 -21
  63. data/app/pb_kits/playbook/pb_table/_table.tsx +1 -1
  64. data/app/pb_kits/playbook/pb_table/index.ts +4 -4
  65. data/app/pb_kits/playbook/pb_table/subcomponents/_table_body.tsx +1 -1
  66. data/app/pb_kits/playbook/pb_table/subcomponents/_table_cell.tsx +1 -1
  67. data/app/pb_kits/playbook/pb_table/subcomponents/_table_head.tsx +1 -1
  68. data/app/pb_kits/playbook/pb_table/subcomponents/_table_header.tsx +1 -1
  69. data/app/pb_kits/playbook/pb_table/subcomponents/_table_row.tsx +1 -1
  70. data/app/pb_kits/playbook/pb_table/table.test.js +2 -0
  71. data/app/pb_kits/playbook/pb_text_input/_text_input.tsx +1 -1
  72. data/app/pb_kits/playbook/pb_text_input/docs/_text_input_default.jsx +1 -1
  73. data/app/pb_kits/playbook/pb_textarea/_textarea.tsx +45 -27
  74. data/app/pb_kits/playbook/pb_textarea/index.ts +3 -3
  75. data/app/pb_kits/playbook/pb_time/_time.tsx +3 -3
  76. data/app/pb_kits/playbook/pb_time_range_inline/_time_range_inline.tsx +1 -1
  77. data/app/pb_kits/playbook/pb_timeline/_item.tsx +1 -1
  78. data/app/pb_kits/playbook/pb_timeline/_timeline.tsx +1 -1
  79. data/app/pb_kits/playbook/pb_title_detail/_title_detail.tsx +10 -10
  80. data/app/pb_kits/playbook/pb_toggle/_toggle.tsx +1 -1
  81. data/app/pb_kits/playbook/pb_tooltip/_tooltip.tsx +2 -2
  82. data/app/pb_kits/playbook/pb_treemap_chart/_treemap_chart.tsx +1 -2
  83. data/app/pb_kits/playbook/pb_treemap_chart/treemapChart.test.js +2 -0
  84. data/app/pb_kits/playbook/pb_typeahead/_typeahead.tsx +2 -2
  85. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_multi_kit.html.erb +1 -1
  86. data/app/pb_kits/playbook/pb_typeahead/typeahead.rb +1 -0
  87. data/app/pb_kits/playbook/pb_user/_user.tsx +1 -1
  88. data/app/pb_kits/playbook/pb_user_badge/_user_badge.tsx +6 -6
  89. data/app/pb_kits/playbook/pb_user_badge/badges/million-dollar.tsx +236 -235
  90. data/app/pb_kits/playbook/pb_user_badge/badges/veteran.tsx +1 -1
  91. data/app/pb_kits/playbook/pb_walkthrough/_walkthrough.tsx +68 -63
  92. data/app/pb_kits/playbook/pb_weekday_stacked/_weekday_stacked.tsx +1 -1
  93. data/app/pb_kits/playbook/utilities/_positioning.scss +26 -15
  94. data/dist/chunks/_typeahead-B6CmTH6o.js +22 -0
  95. data/dist/chunks/_weekday_stacked-CNZpeoOR.js +45 -0
  96. data/dist/chunks/{lib-Bf_E03gc.js → lib-XlOB2yGW.js} +2 -2
  97. data/dist/chunks/{pb_form_validation-D0dhqeN2.js → pb_form_validation-mwEv7D-z.js} +1 -1
  98. data/dist/chunks/vendor.js +1 -1
  99. data/dist/menu.yml +4 -0
  100. data/dist/playbook-doc.js +1 -1
  101. data/dist/playbook-rails-react-bindings.js +1 -1
  102. data/dist/playbook-rails.js +1 -1
  103. data/dist/playbook.css +1 -1
  104. data/lib/playbook/version.rb +2 -2
  105. metadata +27 -10
  106. data/app/pb_kits/playbook/pb_online_status/_online_status_mixins.scss +0 -32
  107. data/dist/chunks/_typeahead-COUJ88EA.js +0 -22
  108. data/dist/chunks/_weekday_stacked-BAkwel5p.js +0 -45
@@ -0,0 +1 @@
1
+ To toggle an overlay, add a button with an event handler. Remove the overlay container to reveal the underlying content. Re-wrap the overlay container to add the overlay back.
@@ -2,7 +2,9 @@ examples:
2
2
  react:
3
3
  - overlay_default: Default
4
4
  - overlay_multi_directional: Multi-directional
5
+ - overlay_toggle: Toggle
5
6
 
6
7
  rails:
7
- - overlay_default: Default
8
- - overlay_multi_directional: Multi-directional
8
+ - overlay_default: Default
9
+ - overlay_multi_directional: Multi-directional
10
+ - overlay_toggle: Toggle
@@ -1,2 +1,3 @@
1
1
  export { default as OverlayDefault } from './_overlay_default.jsx'
2
2
  export { default as OverlayMultiDirectional } from './_overlay_multi_directional.jsx'
3
+ export { default as OverlayToggle } from './_overlay_toggle.jsx'
@@ -0,0 +1,132 @@
1
+ @import "../tokens/border_radius";
2
+ @import "../tokens/colors";
3
+ @import "../tokens/spacing";
4
+ @import "../tokens/typography";
5
+
6
+ @mixin preview_first_child {
7
+ :first-child {
8
+ margin-top: 0;
9
+ }
10
+ }
11
+
12
+ @mixin preview_p {
13
+ margin: 1rem 0 0 0;
14
+ min-height: 1rem;
15
+ }
16
+
17
+ @mixin preview_code {
18
+ font-family: monospace;
19
+ background: $bg_light;
20
+ padding: 0.1rem 0.3rem;
21
+ box-shadow: 0 2px 10px $shadow;
22
+ border-radius: 0.25rem;
23
+ overflow: hidden;
24
+ }
25
+
26
+ @mixin preview_pre_codeblock {
27
+ display: inline-block;
28
+ width: 100%;
29
+ vertical-align: top;
30
+ font-family: monospace;
31
+ font-size: 0.9em;
32
+ padding: 0.5em;
33
+ overflow-x: auto;
34
+ background: $bg_dark;
35
+ padding: $space_sm;
36
+ border-radius: $border_rad_heaviest;
37
+ margin: 1.5rem 0 2rem 0;
38
+
39
+ code {
40
+ background: transparent !important;
41
+ box-shadow: none;
42
+ border: 0;
43
+ color: #faf6e4;
44
+ }
45
+ }
46
+
47
+ @mixin preview_a {
48
+ color: $primary;
49
+ border-bottom: 1px solid $primary;
50
+ &:hover {
51
+ color: $text_lt_default;
52
+ border-bottom: 1px solid $text_lt_default;
53
+ }
54
+ }
55
+
56
+ @mixin preview_blockquote {
57
+ font-size: $font_larger;
58
+ padding: $space_sm $space_md;
59
+ font-style: italic;
60
+ margin: 1rem 0 0 0;
61
+ p {
62
+ margin: 0;
63
+ }
64
+ }
65
+
66
+ @mixin preview_h1 {
67
+ font-size: $text_largest;
68
+ line-height: $text_larger;
69
+ font-weight: $bolder;
70
+ letter-spacing: $lspace_tight;
71
+ margin: 2.1rem 0 0 0;
72
+ }
73
+
74
+ @mixin preview_h2 {
75
+ font-size: $text_larger;
76
+ line-height: $text_larger;
77
+ font-weight: $bolder;
78
+ letter-spacing: $lspace_tight;
79
+ margin: 1.9rem 0 0 0;
80
+ }
81
+
82
+ @mixin preview_h3 {
83
+ font-size: $text_large;
84
+ line-height: $text_large;
85
+ font-weight: $bolder;
86
+ letter-spacing: $lspace_tight;
87
+ margin: 1.7rem 0 0 0;
88
+ }
89
+
90
+ @mixin preview_smaller_headings {
91
+ font-size: $text_base;
92
+ line-height: $text_base;
93
+ letter-spacing: $lspace_tight;
94
+ font-weight: $bolder;
95
+ margin: 1rem 0 0 0;
96
+ }
97
+
98
+ @mixin preview_hr {
99
+ margin: 2.2rem 0;
100
+ box-sizing: content-box;
101
+ overflow: hidden;
102
+ background: transparent;
103
+ border-bottom: 1px solid $transparent;
104
+ height: 1px;
105
+ padding: 0;
106
+ background-color: $border_light;
107
+ border: 0;
108
+ }
109
+
110
+ @mixin preview_ol {
111
+ margin: 1rem 0 0 0;
112
+ padding-left: $space_md;
113
+ list-style: decimal;
114
+ li {
115
+ margin: 2px 0;
116
+ p {
117
+ margin: 0;
118
+ }
119
+ }
120
+ }
121
+
122
+ @mixin preview_ul {
123
+ list-style-position: disc;
124
+ margin: 1rem 0 0 0;
125
+ padding-left: $space_md;
126
+ li {
127
+ margin: 2px 0;
128
+ p {
129
+ margin: 0;
130
+ }
131
+ }
132
+ }
@@ -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
- font-family: monospace;
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
- background: $bg_dark;
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
- color: $primary;
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
- font-size: $font_larger;
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
- font-size: $text_largest;
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
- font-size: $text_larger;
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
- font-size: $text_large;
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
- font-size: $text_base;
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
- margin: 2.2rem 0;
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
- margin: 1rem 0 0 0;
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
- list-style-position: disc;
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
@@ -24,3 +24,4 @@ examples:
24
24
  - rich_text_editor_toolbar_bottom: Toolbar Bottom
25
25
  - rich_text_editor_inline: Inline
26
26
  - rich_text_editor_preview: Preview
27
+ - rich_text_editor_advanced_preview: Advanced Preview
@@ -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'
@@ -9,10 +9,10 @@
9
9
  justify-content: flex-start;
10
10
 
11
11
  path {
12
- &.suble_star_dark {
12
+ &.subtle_star_dark {
13
13
  fill: $text_dk_default;
14
14
  }
15
- &.suble_star_light {
15
+ &.subtle_star_light {
16
16
  fill: $text_lt_default;
17
17
  }
18
18
  &.outline_star_dark {
@@ -49,9 +49,10 @@
49
49
 
50
50
  $star-styles: (
51
51
  yellow_star: (color: $yellow),
52
- primary_star: (color: $royal),
53
- suble_star_light: (color: $text_lt_default),
54
- suble_star_dark: (color: $text_dk_default),
52
+ primary_star_light: (color: $royal),
53
+ primary_star_dark: (color: $active_dark),
54
+ subtle_star_light: (color: $text_lt_default),
55
+ subtle_star_dark: (color: $text_dk_default),
55
56
  empty_star_dark: (color: $border_dark),
56
57
  empty_star_light: (color: $border_light),
57
58
  outline_empty_star_dark: (color: transparent),
@@ -111,13 +112,89 @@
111
112
  }
112
113
  }
113
114
  }
115
+
116
+ // Interactivity
117
+ path {
118
+ transition: fill 0.2s
119
+ }
120
+ // Rails selected styles
121
+ .interactive-star-icon {
122
+ cursor: pointer;
123
+ }
114
124
  .yellow-star-selected {
115
125
  color: $yellow;
116
126
  }
117
127
  .primary-star-selected {
118
128
  color: $royal
119
129
  }
120
- .suble-star-selected {
130
+ .subtle-star-selected {
121
131
  color: $text_lt_default;
122
132
  }
133
+ &.dark {
134
+ .primary-star-selected {
135
+ color: $active_dark;
136
+ }
137
+ .subtle-star-selected {
138
+ color: $text_dk_default;
139
+ }
140
+ }
141
+ // React selected styles
142
+ &.star-selected {
143
+ path {
144
+ animation: growColor 0.3s forwards;
145
+ }
146
+ .yellow-star-selected {
147
+ color: $yellow;
148
+ }
149
+ .primary-star-selected {
150
+ color: $royal;
151
+ }
152
+ .subtle-star-selected {
153
+ color: $text_lt_default;
154
+ }
155
+ &.dark {
156
+ .primary-star-selected {
157
+ color: $active_dark;
158
+ }
159
+ .subtle-star-selected {
160
+ color: $text_dk_default;
161
+ }
162
+ }
163
+ }
164
+ // Hover styles
165
+ .star-hovered {
166
+ path {
167
+ fill: mix($primary, $white, 20%);
168
+ }
169
+ }
170
+ &.dark{
171
+ .star-hovered {
172
+ path {
173
+ fill: mix($active_dark, $bg_dark, 50%);
174
+ }
175
+ }
176
+ }
177
+ // Focus styles
178
+ .pb_custom_icon {
179
+ &:focus {
180
+ outline: none;
181
+ }
182
+ &:focus-visible {
183
+ border-radius: 2px;
184
+ outline: 1px solid $primary;
185
+ outline-offset: 2px;
186
+ }
187
+ }
188
+ &.dark {
189
+ .pb_custom_icon {
190
+ &:focus {
191
+ outline: none;
192
+ }
193
+ &:focus-visible {
194
+ border-radius: 2px;
195
+ outline: 1px solid $active_dark;
196
+ outline-offset: 2px;
197
+ }
198
+ }
199
+ }
123
200
  }
@@ -6,6 +6,7 @@ examples:
6
6
  - star_rating_hide: Layout Options
7
7
  - star_rating_number_config: Number Config
8
8
  - star_rating_size_options: Size Options
9
+ - star_rating_interactive: Interactive
9
10
 
10
11
  react:
11
12
  - star_rating_default: Default
@@ -13,4 +14,5 @@ examples:
13
14
  - star_rating_background_options: Background Options
14
15
  - star_rating_hide: Layout Options
15
16
  - star_rating_number_config: Number Config
16
- - star_rating_size_options: Size Options
17
+ - star_rating_size_options: Size Options
18
+ - star_rating_interactive: Interactive
@@ -14,6 +14,29 @@ export default class PbStarRating extends PbEnhancedElement {
14
14
  this.updateStarColors(clickedStarId);
15
15
  this.updateHiddenInputValue(clickedStarId);
16
16
  });
17
+
18
+ document.querySelectorAll(STAR_RATING_SELECTOR).forEach(star => {
19
+ star.addEventListener("mouseenter", (event) => {
20
+ const hoveredStarId = event.currentTarget.id
21
+ this.updateStarHoverColors(hoveredStarId);
22
+ })
23
+
24
+ star.addEventListener("mouseleave", () => {
25
+ this.removeStarHoverColors();
26
+ })
27
+
28
+ star.addEventListener("keydown", (event) => {
29
+ if (event.key === 'Enter' || event.key === ' ') {
30
+ event.preventDefault();
31
+ this.handleStarClick(star.id);
32
+ }
33
+ })
34
+ })
35
+ }
36
+
37
+ handleStarClick(starId) {
38
+ this.updateStarColors(starId);
39
+ this.updateHiddenInputValue(starId);
17
40
  }
18
41
 
19
42
  updateStarColors(clickedStarId) {
@@ -27,16 +50,21 @@ export default class PbStarRating extends PbEnhancedElement {
27
50
  if (starId <= clickedStarId) {
28
51
  if (star.classList.contains("yellow_star")) {
29
52
  icon.classList.add("yellow-star-selected");
30
- } else if (star.classList.contains("primary_star")) {
53
+ } else if (star.classList.contains("primary_star_light")) {
31
54
  icon.classList.add("primary-star-selected");
32
- } else if (star.classList.contains("suble_star_light")) {
33
- icon.classList.add("suble-star-selected");
55
+ } else if (star.classList.contains("primary_star_dark")) {
56
+ icon.classList.add("primary-star-selected");
57
+ } else if (star.classList.contains("subtle_star_light")) {
58
+ icon.classList.add("subtle-star-selected");
59
+ } else if (star.classList.contains("subtle_star_dark")) {
60
+ icon.classList.add("subtle-star-selected");
34
61
  } else {
35
62
  icon.classList.add("yellow-star-selected");
36
63
  }
37
64
  } else {
38
- icon.classList.remove("yellow-star-selected", "primary-star-selected", "suble-star-selected");
65
+ icon.classList.remove("yellow-star-selected", "primary-star-selected", "subtle-star-selected");
39
66
  }
67
+ icon.classList.remove("star-hovered");
40
68
  }
41
69
  });
42
70
  }
@@ -47,4 +75,45 @@ export default class PbStarRating extends PbEnhancedElement {
47
75
  hiddenInput.value = value;
48
76
  }
49
77
  }
78
+
79
+ updateStarHoverColors(hoveredStarId) {
80
+ const allStars = document.querySelectorAll(STAR_RATING_SELECTOR);
81
+
82
+ allStars.forEach(star => {
83
+ const starId = star.id;
84
+ const icon = star.querySelector(".interactive-star-icon");
85
+
86
+ if (icon) {
87
+ if (starId <= hoveredStarId) {
88
+ if (!icon.classList.contains("yellow-star-selected") &&
89
+ !icon.classList.contains("primary-star-selected") &&
90
+ !icon.classList.contains("subtle-star-selected")) {
91
+ icon.classList.add("star-hovered");
92
+ }
93
+ } else {
94
+ icon.classList.remove("star-hovered");
95
+ }
96
+ }
97
+ });
98
+ }
99
+
100
+
101
+ removeStarHoverColors() {
102
+ const allStars = document.querySelectorAll(STAR_RATING_SELECTOR);
103
+
104
+ allStars.forEach(star => {
105
+ const icon = star.querySelector(".interactive-star-icon");
106
+ if (icon) {
107
+ if (!icon.classList.contains("yellow-star-selected") &&
108
+ !icon.classList.contains("primary-star-selected") &&
109
+ !icon.classList.contains("subtle-star-selected")) {
110
+ icon.classList.remove("star-hovered");
111
+ }
112
+ }
113
+ });
114
+ }
115
+
116
+ isStarSelected() {
117
+ return document.querySelectorAll(".yellow-star-selected, .primary-star-selected, .subtle-star-selected").length > 0;
118
+ }
50
119
  }
@@ -47,7 +47,7 @@
47
47
  <%= pb_rails("flex", props: { orientation: "row" }) do %>
48
48
  <% object.denominator.times do |index| %>
49
49
  <div data-pb-star-rating id="<%= index + 1 %>" class="<%= star_color %>">
50
- <%= pb_rails("icon", props: { classname: "#{background_star_color} pb_star_#{size} interactive-star-icon", custom_icon: Playbook::Engine.root.join(background_star_path)} ) %>
50
+ <%= pb_rails("icon", props: { classname: "#{background_star_color} pb_star_#{size} interactive-star-icon", custom_icon: Playbook::Engine.root.join(background_star_path), tabindex: 0 } ) %>
51
51
  </div>
52
52
  <% end %>
53
53
  <% end %>
@@ -52,9 +52,9 @@ module Playbook
52
52
  when "yellow"
53
53
  "yellow_star"
54
54
  when "primary"
55
- "primary_star"
55
+ dark ? "primary_star_dark" : "primary_star_light"
56
56
  when "subtle"
57
- dark ? "suble_star_dark" : "suble_star_light"
57
+ dark ? "subtle_star_dark" : "subtle_star_light"
58
58
  end
59
59
  end
60
60
 
@@ -53,7 +53,11 @@ const starOutline = (
53
53
  )
54
54
 
55
55
  export const getStarIconObject = (backgroundType: string, color: string, dark: boolean, size: string) => {
56
- const colorClassName = color === "subtle" ? (dark ? "suble_star_dark" : "suble_star_light") : `${color}_star`
56
+ const colorClassName = color === "subtle"
57
+ ? (dark ? "suble_star_dark" : "suble_star_light")
58
+ : color === "primary"
59
+ ? (dark ? "primary_star_dark" : "primary_star_light")
60
+ : `${color}_star`
57
61
  const backgroundClassName = backgroundType === "outline" ? (dark ? "outline_empty_star_dark" : "outline_empty_star_light") : (dark ? "empty_star_dark" : "empty_star_light")
58
62
 
59
63
  return {