playbook_ui 13.10.0 → 13.11.1.pre.alpha.play900startratingasinput1530

Sign up to get free protection for your applications and to get access to all the features.
Files changed (124) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_button/docs/_button_circle_swift.md +28 -0
  3. data/app/pb_kits/playbook/pb_button/docs/_button_default_swift.md +23 -0
  4. data/app/pb_kits/playbook/pb_button/docs/_button_full_width_swift.md +9 -0
  5. data/app/pb_kits/playbook/pb_button/docs/_button_icon_options_swift.md +18 -0
  6. data/app/pb_kits/playbook/pb_button/docs/_button_props_swift.md +11 -0
  7. data/app/pb_kits/playbook/pb_button/docs/_button_size_swift.md +20 -0
  8. data/app/pb_kits/playbook/pb_button/docs/example.yml +8 -0
  9. data/app/pb_kits/playbook/pb_card/docs/_card_background_swift.md +29 -0
  10. data/app/pb_kits/playbook/pb_card/docs/_card_border_none_swift.md +7 -0
  11. data/app/pb_kits/playbook/pb_card/docs/_card_border_radius_swift.md +33 -0
  12. data/app/pb_kits/playbook/pb_card/docs/_card_header_swift.md +33 -0
  13. data/app/pb_kits/playbook/pb_card/docs/_card_highlight_swift.md +17 -0
  14. data/app/pb_kits/playbook/pb_card/docs/_card_light_swift.md +7 -0
  15. data/app/pb_kits/playbook/pb_card/docs/_card_padding_swift.md +33 -0
  16. data/app/pb_kits/playbook/pb_card/docs/_card_props_swift.md +10 -0
  17. data/app/pb_kits/playbook/pb_card/docs/_card_selected_swift.md +0 -0
  18. data/app/pb_kits/playbook/pb_card/docs/_card_separator_swift.md +11 -0
  19. data/app/pb_kits/playbook/pb_card/docs/_card_shadow_swift.md +21 -0
  20. data/app/pb_kits/playbook/pb_card/docs/_card_styles_swift.md +17 -0
  21. data/app/pb_kits/playbook/pb_card/docs/_card_tag_swift.md +0 -0
  22. data/app/pb_kits/playbook/pb_card/docs/example.yml +12 -0
  23. data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_default_swift.md +10 -0
  24. data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_error_swift.md +12 -0
  25. data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_indeterminate_swift.md +12 -0
  26. data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_props_swift.md +7 -0
  27. data/app/pb_kits/playbook/pb_checkbox/docs/example.yml +7 -0
  28. data/app/pb_kits/playbook/pb_collapsible/collapsible_content.rb +3 -1
  29. data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_external_controls.html.erb +22 -0
  30. data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_external_controls.md +3 -0
  31. data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_external_controls_multiple.html.erb +40 -0
  32. data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_external_controls_multiple.md +1 -0
  33. data/app/pb_kits/playbook/pb_collapsible/docs/example.yml +2 -0
  34. data/app/pb_kits/playbook/pb_collapsible/index.js +4 -0
  35. data/app/pb_kits/playbook/pb_docs/kit_example.html.erb +3 -3
  36. data/app/pb_kits/playbook/pb_icon/docs/_icon_border_swift.md +7 -0
  37. data/app/pb_kits/playbook/pb_icon/docs/_icon_default_swift.md +7 -0
  38. data/app/pb_kits/playbook/pb_icon/docs/_icon_flip_swift.md +11 -0
  39. data/app/pb_kits/playbook/pb_icon/docs/_icon_props_swift.md +8 -0
  40. data/app/pb_kits/playbook/pb_icon/docs/_icon_rotate_swift.md +11 -0
  41. data/app/pb_kits/playbook/pb_icon/docs/_icon_sizes_swift.md +46 -0
  42. data/app/pb_kits/playbook/pb_icon/docs/example.yml +8 -0
  43. data/app/pb_kits/playbook/pb_icon_circle/docs/_icon_circle_color_props.md +6 -0
  44. data/app/pb_kits/playbook/pb_icon_circle/docs/_icon_circle_color_swift.md +16 -0
  45. data/app/pb_kits/playbook/pb_icon_circle/docs/_icon_circle_defaul_swift.md +7 -0
  46. data/app/pb_kits/playbook/pb_icon_circle/docs/_icon_circle_sizes_swift.md +11 -0
  47. data/app/pb_kits/playbook/pb_icon_circle/docs/example.yml +7 -0
  48. data/app/pb_kits/playbook/pb_image/docs/_image_props_swift.md +7 -0
  49. data/app/pb_kits/playbook/pb_image/docs/_rounded_image_swift.md +47 -0
  50. data/app/pb_kits/playbook/pb_image/docs/_size_image_swift.md +47 -0
  51. data/app/pb_kits/playbook/pb_image/docs/_size_none_image_swift.md +15 -0
  52. data/app/pb_kits/playbook/pb_image/docs/example.yml +5 -0
  53. data/app/pb_kits/playbook/pb_label_value/docs/_label_value_default_swift.md +11 -0
  54. data/app/pb_kits/playbook/pb_label_value/docs/_label_value_details_examples_swift.md +72 -0
  55. data/app/pb_kits/playbook/pb_label_value/docs/_label_value_details_swift.md +41 -0
  56. data/app/pb_kits/playbook/pb_label_value/docs/_label_value_props_swift.md +11 -0
  57. data/app/pb_kits/playbook/pb_label_value/docs/example.yml +6 -0
  58. data/app/pb_kits/playbook/pb_message/docs/_message_default_swift.md +57 -0
  59. data/app/pb_kits/playbook/pb_message/docs/_message_props_swift.md +12 -0
  60. data/app/pb_kits/playbook/pb_message/docs/example.yml +4 -0
  61. data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.tsx +27 -20
  62. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_selected_ids.html.erb +0 -1
  63. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_single.html.erb +104 -45
  64. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_single.jsx +100 -43
  65. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_single.md +1 -0
  66. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_single_children_only.html.erb +138 -0
  67. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_single_children_only.jsx +150 -0
  68. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_single_children_only.md +1 -0
  69. data/app/pb_kits/playbook/pb_multi_level_select/docs/example.yml +2 -0
  70. data/app/pb_kits/playbook/pb_multi_level_select/docs/index.js +1 -0
  71. data/app/pb_kits/playbook/pb_rich_text_editor/_rich_text_editor.tsx +10 -2
  72. data/app/pb_kits/playbook/pb_rich_text_editor/_tiptap_styles.scss +8 -4
  73. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_toolbar_disabled.jsx +33 -0
  74. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_toolbar_disabled.md +3 -0
  75. data/app/pb_kits/playbook/pb_rich_text_editor/docs/example.yml +1 -0
  76. data/app/pb_kits/playbook/pb_rich_text_editor/docs/index.js +2 -1
  77. data/app/pb_kits/playbook/pb_rich_text_editor/rich_text_editor_advanced.test.js +47 -0
  78. data/app/pb_kits/playbook/pb_star_rating/_star_rating.scss +61 -49
  79. data/app/pb_kits/playbook/pb_star_rating/_star_rating.tsx +151 -54
  80. data/app/pb_kits/playbook/pb_star_rating/custom-icons.js +356 -0
  81. data/app/pb_kits/playbook/pb_star_rating/docs/_star_rating_color_options.html.erb +7 -0
  82. data/app/pb_kits/playbook/pb_star_rating/docs/_star_rating_color_options.jsx +40 -0
  83. data/app/pb_kits/playbook/pb_star_rating/docs/_star_rating_default.html.erb +11 -1
  84. data/app/pb_kits/playbook/pb_star_rating/docs/_star_rating_default.jsx +17 -2
  85. data/app/pb_kits/playbook/pb_star_rating/docs/_star_rating_hide.html.erb +6 -1
  86. data/app/pb_kits/playbook/pb_star_rating/docs/_star_rating_hide.jsx +22 -5
  87. data/app/pb_kits/playbook/pb_star_rating/docs/_star_rating_number_config.html.erb +12 -0
  88. data/app/pb_kits/playbook/pb_star_rating/docs/_star_rating_number_config.jsx +57 -0
  89. data/app/pb_kits/playbook/pb_star_rating/docs/_star_rating_size_options.html.erb +23 -0
  90. data/app/pb_kits/playbook/pb_star_rating/docs/_star_rating_size_options.jsx +59 -0
  91. data/app/pb_kits/playbook/pb_star_rating/docs/example.yml +10 -5
  92. data/app/pb_kits/playbook/pb_star_rating/docs/index.js +6 -0
  93. data/app/pb_kits/playbook/pb_star_rating/star.svg +3 -0
  94. data/app/pb_kits/playbook/pb_star_rating/star_rating.html.erb +56 -15
  95. data/app/pb_kits/playbook/pb_star_rating/star_rating.rb +49 -6
  96. data/app/pb_kits/playbook/pb_star_rating/star_rating.test.js +33 -34
  97. data/app/pb_kits/playbook/pb_table/docs/_table_header.html.erb +47 -31
  98. data/app/pb_kits/playbook/pb_table/docs/_table_header.md +5 -0
  99. data/app/pb_kits/playbook/pb_table/styles/_hover.scss +26 -2
  100. data/app/pb_kits/playbook/pb_table/styles/_table-dark.scss +1 -17
  101. data/app/pb_kits/playbook/pb_table/table_header.html.erb +5 -4
  102. data/app/pb_kits/playbook/pb_table/table_header.rb +28 -5
  103. data/app/pb_kits/playbook/pb_tooltip/_tooltip.tsx +25 -9
  104. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_default.html.erb +1 -1
  105. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_default_react.jsx +0 -2
  106. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_delay.jsx +0 -1
  107. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_interaction.jsx +0 -1
  108. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_margin.jsx +0 -1
  109. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_selectors.html.erb +1 -1
  110. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_show_tooltip.html.erb +39 -0
  111. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_show_tooltip.md +5 -0
  112. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_show_tooltip_react.jsx +45 -0
  113. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_show_tooltip_react.md +3 -0
  114. data/app/pb_kits/playbook/pb_tooltip/docs/example.yml +3 -0
  115. data/app/pb_kits/playbook/pb_tooltip/docs/index.js +1 -0
  116. data/app/pb_kits/playbook/pb_tooltip/index.js +6 -0
  117. data/app/pb_kits/playbook/pb_tooltip/tooltip.rb +2 -1
  118. data/app/pb_kits/playbook/pb_tooltip/tooltip.test.jsx +34 -0
  119. data/app/pb_kits/playbook/playbook-doc.js +1 -1
  120. data/dist/menu.yml +284 -110
  121. data/dist/playbook-rails.js +5 -5
  122. data/lib/playbook/pb_doc_helper.rb +12 -1
  123. data/lib/playbook/version.rb +2 -2
  124. metadata +73 -7
@@ -65,9 +65,7 @@
65
65
  .ProseMirror {
66
66
  background: $white;
67
67
  border: 1px solid $border_light;
68
- border-top-color: transparent;
69
- border-bottom-right-radius: $border_rad_heaviest;
70
- border-bottom-left-radius: $border_rad_heaviest;
68
+ border-radius: $border_rad_heaviest;
71
69
  height: 100%;
72
70
  padding: 1rem 1.5rem 1.5rem 1.5rem;
73
71
  line-height: $lh_loose;
@@ -127,7 +125,6 @@
127
125
  }
128
126
  &:focus-visible {
129
127
  outline: unset;
130
- border-top-color: $primary;
131
128
  @include transition_default;
132
129
  }
133
130
  h1 {
@@ -228,4 +225,11 @@
228
225
  border-radius: $border_rad_heaviest;
229
226
  transition: box-shadow 0.3s ease-in-out, border-radius 0.3s ease-in-out;
230
227
  }
228
+ &.toolbar-active {
229
+ .ProseMirror {
230
+ border-top: none;
231
+ border-top-left-radius: initial;
232
+ border-top-right-radius: initial;
233
+ }
234
+ }
231
235
  }
@@ -0,0 +1,33 @@
1
+ import React from "react";
2
+ import { useEditor, EditorContent } from "@tiptap/react";
3
+
4
+ import { RichTextEditor } from "../..";
5
+
6
+ import Document from "@tiptap/extension-document";
7
+ import Paragraph from "@tiptap/extension-paragraph";
8
+ import Text from "@tiptap/extension-text";
9
+
10
+ const RichTextEditorToolbarDisabled = (props) => {
11
+ const editor = useEditor({
12
+ extensions: [Document, Paragraph, Text],
13
+ content:
14
+ "Add your text here. You can format your text, add links, quotes, and bullets.",
15
+ });
16
+ if (!editor) {
17
+ return null;
18
+ }
19
+
20
+ return (
21
+ <div>
22
+ <RichTextEditor
23
+ advancedEditor={editor}
24
+ advancedEditorToolbar={false}
25
+ {...props}
26
+ >
27
+ <EditorContent editor={editor} />
28
+ </RichTextEditor>
29
+ </div>
30
+ );
31
+ };
32
+
33
+ export default RichTextEditorToolbarDisabled;
@@ -0,0 +1,3 @@
1
+ Because our default variant's toolbar requires [Tiptap's StarterKit](https://tiptap.dev/api/extensions/starter-kit) which may include features that are not relevant to your project or even block some custom extensions, optionally setting `advancedEditorToolbar` to `false` creates an editor without a toolbar, using only the minimum requirements.
2
+
3
+ __NOTE__: Omitting the Starter Kit requires that the editor’s default extensions (`document`, `paragraph`, and `text`) __must__ be imported directly from Tiptap or as a custom extensions.
@@ -15,6 +15,7 @@ examples:
15
15
  - rich_text_editor_default: Default
16
16
  - rich_text_editor_advanced_default: Advanced Default
17
17
  - rich_text_editor_more_extensions: Advanced (Extra Extensions)
18
+ - rich_text_editor_toolbar_disabled: Advanced (Toolbar disabled)
18
19
  - rich_text_editor_simple: Simple
19
20
  - rich_text_editor_attributes: Attributes
20
21
  - rich_text_editor_focus: Focus
@@ -8,4 +8,5 @@ export { default as RichTextEditorToolbarBottom } from './_rich_text_editor_tool
8
8
  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
- export { default as RichTextEditorMoreExtensions } from './_rich_text_editor_more_extensions.jsx'
11
+ export { default as RichTextEditorMoreExtensions } from './_rich_text_editor_more_extensions.jsx'
12
+ export { default as RichTextEditorToolbarDisabled } from './_rich_text_editor_toolbar_disabled.jsx'
@@ -0,0 +1,47 @@
1
+ import React from "react";
2
+ import { render } from "../utilities/test-utils";
3
+ import { useEditor, EditorContent } from "@tiptap/react";
4
+ import StarterKit from "@tiptap/starter-kit";
5
+ import Link from "@tiptap/extension-link";
6
+
7
+ import RichTextEditor from "./_rich_text_editor";
8
+
9
+ const kitClass = "pb_rich_text_editor_advanced_container";
10
+
11
+ const EditorTest = (props) => {
12
+ const editor = useEditor({
13
+ extensions: [StarterKit, Link],
14
+ content: "",
15
+ });
16
+
17
+ return (
18
+ <RichTextEditor
19
+ advancedEditor={editor}
20
+ {...props}
21
+ >
22
+ <EditorContent editor={editor} />
23
+ </RichTextEditor>
24
+ );
25
+ };
26
+
27
+ test("returns namespaced class name", () => {
28
+ const { container } = render(<EditorTest />);
29
+
30
+ expect(container.getElementsByClassName(kitClass).length).toBeGreaterThan(0);
31
+ });
32
+
33
+ test("returns toolbar class name", () => {
34
+ const { container } = render(<EditorTest />);
35
+
36
+ expect(
37
+ container.getElementsByClassName(`${kitClass} toolbar-active`).length
38
+ ).toBeGreaterThan(0);
39
+ });
40
+
41
+ test("doesn't returns toolbar class name", () => {
42
+ const { container } = render(<EditorTest advancedEditorToolbar={false} />);
43
+
44
+ expect(
45
+ container.getElementsByClassName(`${kitClass} toolbar-active`).length
46
+ ).toBe(0);
47
+ });
@@ -2,61 +2,73 @@
2
2
  @import "../tokens/opacity";
3
3
  @import "../tokens/spacing";
4
4
 
5
- $pb_star_rating_number_width: 30px;
6
- $pb_star_rating_wrapper_width: 90px;
7
- $pb_star_rating_height: 26px;
8
5
 
9
- [class^=pb_star_rating_kit] {
10
- position: relative;
11
- display: inline-flex;
6
+ [class*=pb_star_rating_kit] {
7
+ display: flex;
8
+ align-items: flex-end;
12
9
  justify-content: flex-start;
13
- align-items: flex-start;
14
-
15
- .pb_star_rating_number {
16
- flex-shrink: 0;
17
- flex-grow: 0;
18
- flex-basis: $pb_star_rating_number_width;
19
- width: $pb_star_rating_number_width;
20
- min-height: $pb_star_rating_height;
21
- padding: 0 $space-xs 0;
22
- color: $text_lt_light;
23
- font-size: $text-small;
10
+
11
+ .number_rails_xs {
12
+ height: 22px !important;
13
+ }
14
+
15
+ .number_rails_sm {
16
+ height: 22px !important;
17
+ }
18
+
19
+ .number_rails_md {
20
+ height: 26px;
21
+ }
22
+
23
+ .number_rails_lg {
24
+ height: 38px;
25
+ }
26
+
27
+ .pb_star_rating_wrapper {
24
28
  display: flex;
29
+ }
30
+
31
+ .pb_star_rating_number_xs {
32
+ max-height: 16px;
33
+ }
34
+
35
+ .pb_star_rating_number_sm {
36
+ max-height: 16px;
37
+ }
38
+
39
+ .pb_star_rating_number_md {
40
+ max-height: 32px;
41
+ }
42
+
43
+ .pb_star_rating_number_lg {
44
+ max-height: 56px;
45
+ }
46
+
47
+ .pb_star_xs {
48
+ display: flex;
49
+ align-items: center;
25
50
  justify-content: center;
51
+ padding-right: 4px;
52
+ }
53
+
54
+ .pb_star_sm {
55
+ display: flex;
26
56
  align-items: center;
57
+ justify-content: center;
58
+ padding-right: 4px;
27
59
  }
28
60
 
29
- .pb_star_rating_wrapper {
30
- position: relative;
31
- width: $pb_star_rating_wrapper_width;
32
- flex-basis: $pb_star_rating_wrapper_width;
33
- flex-shrink: 0;
34
- flex-grow: 1;
35
- min-height: $pb_star_rating_height;
36
-
37
- .pb_star_rating_highlight {
38
- display: flex;
39
- position: absolute;
40
- top: 5px;
41
- left: 0;
42
- z-index: 5;
43
- color: $yellow;
44
- line-height: $pb_star_rating_height;
45
- }
46
- .pb_star_rating_base {
47
- display: flex;
48
- position: absolute;
49
- top: 5px;
50
- left: 0;
51
- z-index: 0;
52
- color: rgba($slate, $opacity-4);
53
- line-height: $pb_star_rating_height;
54
- }
55
- }
56
-
57
- &[class*=_hide_rating] {
58
- .pb_star_rating_number {
59
- display: none;
60
- }
61
+ .pb_star_md {
62
+ display: flex;
63
+ align-items: center;
64
+ justify-content: center;
65
+ padding-right: 6px;
66
+ }
67
+
68
+ .pb_star_lg {
69
+ display: flex;
70
+ align-items: center;
71
+ justify-content: center;
72
+ padding-right: 12px;
61
73
  }
62
74
  }
@@ -2,27 +2,36 @@ import React from "react"
2
2
  import classnames from "classnames"
3
3
 
4
4
  import { buildAriaProps, buildDataProps } from "../utilities/props"
5
-
6
- import Icon from "../pb_icon/_icon"
5
+ import Caption from '../pb_caption/_caption'
6
+ import Body from '../pb_body/_body'
7
+ import Title from '../pb_title/_title'
7
8
 
8
9
  type StarRatingProps = {
9
10
  aria?: {[key: string]: string},
10
11
  className?: string,
11
12
  data?: object,
13
+ dark?: boolean,
12
14
  fixedWidth?: boolean,
13
- hideRating: boolean,
15
+ layoutOption?: "default" | "number" | "onestar",
14
16
  icon?: string,
15
17
  id?: string,
16
18
  rating: number,
19
+ denominator: number,
20
+ colorOption?: "yellow" | "primary" | "subtle" | "outline",
21
+ size?: "xs" | "sm" | "md" | "lg";
17
22
  };
18
23
 
19
24
  const StarRating = ({
20
25
  aria = {},
21
26
  className,
22
27
  data = {},
23
- hideRating = false,
28
+ dark = false,
29
+ layoutOption = "default",
24
30
  id,
25
31
  rating = 0,
32
+ denominator = 5,
33
+ colorOption = "yellow",
34
+ size = "sm",
26
35
  }: StarRatingProps) => {
27
36
  const ariaProps = buildAriaProps(aria)
28
37
  const dataProps = buildDataProps(data)
@@ -30,12 +39,51 @@ const StarRating = ({
30
39
  "pb_star_rating_kit", className,
31
40
  ])
32
41
 
33
- const starCount = () => (
34
- [...Array(Math.floor(rating))]
42
+ const denominatorStyle = layoutOption === "onestar" ? 1 : denominator
43
+ const activeStars = Math.round(rating) > denominatorStyle ? denominatorStyle : Math.round(rating)
44
+ const emptyStars = denominatorStyle - Math.round(rating) < 0 ? 0 : denominatorStyle - Math.round(rating)
45
+ let svgSize
46
+
47
+ if (size === 'xs') {
48
+ svgSize = 14;
49
+ } else if (size === 'sm') {
50
+ svgSize = 16;
51
+ } else if (size === 'md') {
52
+ svgSize = 24;
53
+ } else if (size === 'lg') {
54
+ svgSize = 48;
55
+ } else {
56
+ svgSize = 16;
57
+ }
58
+
59
+ const starYellow = (
60
+ <svg width={svgSize} height={svgSize} viewBox="0 0 18 16" fill="none" xmlns="http://www.w3.org/2000/svg">
61
+ <path fillRule="evenodd" clipRule="evenodd" d="M9.86015 0.4371C9.73527 0.187329 9.4855 0 9.17328 0C8.89229 0 8.64252 0.187329 8.51763 0.4371L6.36335 4.83932L1.58647 5.55742C1.30547 5.58864 1.08692 5.80719 0.99326 6.05696C0.899595 6.33795 0.962038 6.61895 1.18059 6.8375L4.64617 10.2719L3.80319 15.1112C3.77197 15.3922 3.89685 15.7044 4.11541 15.8605C4.36518 16.0166 4.64617 16.0478 4.89594 15.9229L9.17328 13.6126L13.4506 15.9229C13.7004 16.0478 14.0126 16.0166 14.2624 15.8605C14.4809 15.7044 14.6058 15.3922 14.5434 15.1112L13.7316 10.2719L17.1972 6.8375C17.4157 6.61895 17.4782 6.33795 17.3845 6.05696C17.2909 5.80719 17.0723 5.58864 16.7913 5.55742L12.0144 4.83932L9.86015 0.4371Z" fill="#F9BB00"/>
62
+ </svg>
63
+ )
64
+
65
+ const starPrimary = (
66
+ <svg width={svgSize} height={svgSize} viewBox="0 0 18 16" fill="none" xmlns="http://www.w3.org/2000/svg">
67
+ <path fillRule="evenodd" clipRule="evenodd" d="M9.86015 0.4371C9.73527 0.187329 9.4855 0 9.17328 0C8.89229 0 8.64252 0.187329 8.51763 0.4371L6.36335 4.83932L1.58647 5.55742C1.30547 5.58864 1.08692 5.80719 0.99326 6.05696C0.899595 6.33795 0.962038 6.61895 1.18059 6.8375L4.64617 10.2719L3.80319 15.1112C3.77197 15.3922 3.89685 15.7044 4.11541 15.8605C4.36518 16.0166 4.64617 16.0478 4.89594 15.9229L9.17328 13.6126L13.4506 15.9229C13.7004 16.0478 14.0126 16.0166 14.2624 15.8605C14.4809 15.7044 14.6058 15.3922 14.5434 15.1112L13.7316 10.2719L17.1972 6.8375C17.4157 6.61895 17.4782 6.33795 17.3845 6.05696C17.2909 5.80719 17.0723 5.58864 16.7913 5.55742L12.0144 4.83932L9.86015 0.4371Z" fill="#0056CF"/>
68
+ </svg>
69
+ );
70
+
71
+ const starSubtle = (
72
+ <svg width={svgSize} height={svgSize} viewBox="0 0 17 16" fill="none" xmlns="http://www.w3.org/2000/svg">
73
+ <path fill={dark === true ? "$text_dk_default" : "#242B42"} fillRule="evenodd" clipRule="evenodd" d="M8.90904 0.4371C8.78416 0.187329 8.53438 0 8.22217 0C7.94118 0 7.69141 0.187329 7.56652 0.4371L5.41224 4.83932L0.635357 5.55742C0.354364 5.58864 0.135813 5.80719 0.042149 6.05696C-0.0515154 6.33795 0.0109275 6.61895 0.229478 6.8375L3.69506 10.2719L2.85208 15.1112C2.82086 15.3922 2.94574 15.7044 3.16429 15.8605C3.41407 16.0166 3.69506 16.0478 3.94483 15.9229L8.22217 13.6126L12.4995 15.9229C12.7493 16.0478 13.0615 16.0166 13.3113 15.8605C13.5298 15.7044 13.6547 15.3922 13.5923 15.1112L12.7805 10.2719L16.2461 6.8375C16.4646 6.61895 16.5271 6.33795 16.4334 6.05696C16.3397 5.80719 16.1212 5.58864 15.8402 5.55742L11.0633 4.83932L8.90904 0.4371Z" />
74
+ </svg>
75
+ );
76
+
77
+ const starBackground = (
78
+ <svg width={svgSize} height={svgSize} viewBox="0 0 17 16" fill="none" xmlns="http://www.w3.org/2000/svg">
79
+ <path fill={dark === true ? "$border_dark" : "#E4E8F0"} fillRule="evenodd" clipRule="evenodd" d="M9.31126 0.4371C9.18638 0.187329 8.93661 0 8.62439 0C8.3434 0 8.09363 0.187329 7.96874 0.4371L5.81446 4.83932L1.03758 5.55742C0.756585 5.58864 0.538035 5.80719 0.444371 6.05696C0.350706 6.33795 0.413149 6.61895 0.631699 6.8375L4.09728 10.2719L3.2543 15.1112C3.22308 15.3922 3.34797 15.7044 3.56652 15.8605C3.81629 16.0166 4.09728 16.0478 4.34705 15.9229L8.62439 13.6126L12.9017 15.9229C13.1515 16.0478 13.4637 16.0166 13.7135 15.8605C13.932 15.7044 14.0569 15.3922 13.9945 15.1112L13.1827 10.2719L16.6483 6.8375C16.8669 6.61895 16.9293 6.33795 16.8356 6.05696C16.742 5.80719 16.5234 5.58864 16.2424 5.55742L11.4655 4.83932L9.31126 0.4371Z" />
80
+ </svg>
35
81
  )
36
82
 
37
- const hasHalfStar = () => (
38
- rating % 1 !== 0
83
+ const starOutline = (
84
+ <svg width={svgSize} height={svgSize} fill="none" xmlns="http://www.w3.org/2000/svg">
85
+ <path stroke={dark === true ? "$text_dk_lighter" : "#C1CDD6"} d="M5.91323 5.33377L6.17269 5.29477L6.28801 5.0591L8.44116 0.659187C8.49971 0.543364 8.59517 0.5 8.64884 0.5C8.74499 0.5 8.83506 0.555009 8.88775 0.659235L11.0409 5.0591L11.1562 5.29477L11.4157 5.33377L16.1925 6.05186L16.2021 6.0533L16.2117 6.05436C16.2359 6.05706 16.2671 6.06847 16.3024 6.09973C16.3374 6.13062 16.3686 6.17476 16.3886 6.22412C16.4186 6.32162 16.401 6.40181 16.3198 6.48332C16.3196 6.48353 16.3194 6.48374 16.3192 6.48394L12.8552 9.91671L12.6712 10.0991L12.7141 10.3546L13.5258 15.1939L13.528 15.2068L13.5308 15.2196C13.5488 15.3004 13.5074 15.402 13.4567 15.4462C13.3391 15.5132 13.2227 15.5096 13.1546 15.4781L8.88646 13.1726L8.64884 13.0443L8.41121 13.1726L4.14274 15.4782C4.07877 15.5083 3.99031 15.5147 3.87267 15.4466C3.82302 15.4033 3.76655 15.2914 3.77463 15.1781L4.61431 10.3577L4.65911 10.1005L4.47368 9.91671L1.0097 6.48394C1.00947 6.48372 1.00925 6.4835 1.00903 6.48327C0.927878 6.40178 0.910311 6.3216 0.94026 6.22412C0.960274 6.17476 0.99154 6.13062 1.02646 6.09973C1.0618 6.06847 1.09296 6.05706 1.11724 6.05436L1.12682 6.0533L1.13635 6.05186L5.91323 5.33377Z"/>
86
+ </svg>
39
87
  )
40
88
 
41
89
  return (
@@ -45,53 +93,102 @@ const StarRating = ({
45
93
  className={css}
46
94
  id={id}
47
95
  >
48
- {!hideRating && (
49
- <div className="pb_star_rating_number">
50
- {rating}
51
- </div>
52
- )}
53
- <div className="pb_star_rating_wrapper">
54
- <div className="pb_star_rating_highlight">
55
- {starCount().map((_, index) => (
56
- <Icon
57
- fixedWidth={false}
58
- icon="star"
59
- key={index}
60
- />
61
- ))}
62
- {hasHalfStar() && (
63
- <Icon
64
- fixedWidth={false}
65
- icon="star-half"
66
- />
67
- )}
68
- </div>
69
-
70
- <div className="pb_star_rating_base">
71
- <Icon
72
- fixedWidth={false}
73
- icon="star"
74
- />
75
- <Icon
76
- fixedWidth={false}
77
- icon="star"
78
- />
79
- <Icon
80
- fixedWidth={false}
81
- icon="star"
82
- />
83
- <Icon
84
- fixedWidth={false}
85
- icon="star"
86
- />
87
- <Icon
88
- fixedWidth={false}
89
- icon="star"
90
- />
96
+ {layoutOption === "number" && (
97
+ <div className={`pb_star_rating_number_${size}`}>
98
+ {size === 'xs' && (
99
+ <Caption
100
+ text={rating.toString()}
101
+ size="xs"
102
+ paddingRight="xs"
103
+ dark={dark}
104
+ />
105
+ )}
106
+ {size === 'sm' && (
107
+ <Caption
108
+ text={rating.toString()}
109
+ size="xs"
110
+ paddingRight="xs"
111
+ dark={dark}
112
+ />
113
+ )}
114
+ {size === 'md' && (
115
+ <Body
116
+ text={rating.toString()}
117
+ paddingRight="xs"
118
+ dark={dark}
119
+ />
120
+ )}
121
+ {size === 'lg' && (
122
+ <Title
123
+ text={rating.toString()}
124
+ size={2}
125
+ paddingRight="sm"
126
+ dark={dark}
127
+ />
128
+ )}
91
129
  </div>
130
+ )}
131
+ <div className={`pb_star_rating_wrapper ${layoutOption}`}>
132
+ {[...Array(activeStars)].map((_, index) => (
133
+ <div className={`pb_star_${size}`} key={index}>
134
+ {colorOption === 'yellow' && (
135
+ starYellow
136
+ ) }
137
+ {colorOption === 'primary' && (
138
+ starPrimary
139
+ ) }
140
+ {colorOption === 'outline' && (
141
+ starPrimary
142
+ ) }
143
+ {colorOption === 'subtle' && (
144
+ starSubtle
145
+ ) }
146
+ </div>
147
+ ))}
148
+ {[...Array(emptyStars)].map((_, index) => (
149
+ <div className={`pb_star_${size}`} key={index}>
150
+ {colorOption === 'outline' && (
151
+ starOutline
152
+ ) }
153
+ {colorOption !== 'outline' && (
154
+ starBackground
155
+ ) }
156
+ </div>
157
+ ))}
92
158
  </div>
93
- </div>
94
- )
95
- }
159
+ {layoutOption === "onestar" && (
160
+ <div className={`pb_star_rating_number_${size}`}>
161
+ {size === 'xs' && (
162
+ <Caption
163
+ text={`${rating.toString()} of ${denominator}`}
164
+ size="xs"
165
+ dark={dark}
166
+ />
167
+ )}
168
+ {size === 'sm' && (
169
+ <Caption
170
+ text={`${rating.toString()} of ${denominator}`}
171
+ size="xs"
172
+ dark={dark}
173
+ />
174
+ )}
175
+ {size === 'md' && (
176
+ <Body
177
+ text={`${rating.toString()} of ${denominator}`}
178
+ dark={dark}
179
+ />
180
+ )}
181
+ {size === 'lg' && (
182
+ <Title
183
+ text={`${rating.toString()} of ${denominator}`}
184
+ size={2}
185
+ dark={dark}
186
+ />
187
+ )}
188
+ </div>
189
+ )}
190
+ </div>
191
+ )
192
+ }
96
193
 
97
194
  export default StarRating