@soul-refiner/design-system 0.0.14 → 0.0.16

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.
Files changed (271) hide show
  1. package/.eslintrc.js +4 -0
  2. package/.turbo/turbo-build.log +12 -0
  3. package/.turbo/turbo-test.log +4417 -0
  4. package/CHANGELOG.md +7 -0
  5. package/babel.config.js +6 -0
  6. package/custom.d.ts +4 -0
  7. package/package.json +1 -7
  8. package/src/actions/Button/Button.module.scss +205 -0
  9. package/src/actions/Button/Button.spec.js +56 -0
  10. package/src/actions/Button/Button.tsx +143 -0
  11. package/src/actions/Button/index.ts +1 -0
  12. package/src/actions/Dropdown/Dropdown.module.scss +77 -0
  13. package/src/actions/Dropdown/Dropdown.spec.js +149 -0
  14. package/src/actions/Dropdown/Dropdown.tsx +224 -0
  15. package/src/actions/Dropdown/index.ts +6 -0
  16. package/src/actions/Dropzone/Dropzone.module.scss +48 -0
  17. package/src/actions/Dropzone/Dropzone.spec.js +60 -0
  18. package/src/actions/Dropzone/Dropzone.tsx +191 -0
  19. package/src/actions/Dropzone/index.ts +1 -0
  20. package/src/actions/Rate/Rate.module.scss +17 -0
  21. package/src/actions/Rate/Rate.tsx +53 -0
  22. package/src/actions/Rate/index.ts +1 -0
  23. package/src/actions/Switch/Switch.module.scss +35 -0
  24. package/src/actions/Switch/Switch.spec.js +31 -0
  25. package/src/actions/Switch/Switch.tsx +34 -0
  26. package/src/actions/Switch/index.ts +1 -0
  27. package/src/actions/index.ts +5 -0
  28. package/src/cards/CourseCard/CourseCard.module.scss +219 -0
  29. package/src/cards/CourseCard/CourseCard.spec.js +60 -0
  30. package/src/cards/CourseCard/CourseCard.tsx +145 -0
  31. package/src/cards/CourseCard/index.ts +1 -0
  32. package/src/cards/EpisodeCard/EpisodeCard.module.scss +69 -0
  33. package/src/cards/EpisodeCard/EpisodeCard.tsx +53 -0
  34. package/src/cards/EpisodeCard/index.ts +1 -0
  35. package/src/cards/FeatureCard/FeatureCard.module.scss +116 -0
  36. package/src/cards/FeatureCard/FeatureCard.spec.js +70 -0
  37. package/src/cards/FeatureCard/FeatureCard.tsx +123 -0
  38. package/src/cards/FeatureCard/index.ts +1 -0
  39. package/src/cards/index.ts +3 -0
  40. package/src/data/Bar/Bar.module.scss +105 -0
  41. package/src/data/Bar/Bar.tsx +161 -0
  42. package/src/data/Bar/index.ts +1 -0
  43. package/src/data/Line/Line.module.scss +102 -0
  44. package/src/data/Line/Line.tsx +162 -0
  45. package/src/data/Line/index.ts +1 -0
  46. package/src/data/Pie/Pie.module.scss +56 -0
  47. package/src/data/Pie/Pie.spec.js +72 -0
  48. package/src/data/Pie/Pie.tsx +111 -0
  49. package/src/data/Pie/index.ts +1 -0
  50. package/src/data/index.ts +3 -0
  51. package/src/editor/Editor.module.scss +125 -0
  52. package/src/editor/Editor.tsx +327 -0
  53. package/src/editor/common/elements.ts +50 -0
  54. package/src/editor/common/index.ts +2 -0
  55. package/src/editor/common/marks.ts +27 -0
  56. package/src/editor/components/MediaDrawer/MediaDrawer.module.scss +316 -0
  57. package/src/editor/components/MediaDrawer/MediaDrawer.tsx +457 -0
  58. package/src/editor/components/MediaDrawer/index.ts +1 -0
  59. package/src/editor/components/index.ts +1 -0
  60. package/src/editor/config/default.ts +213 -0
  61. package/src/editor/config/index.ts +2 -0
  62. package/src/editor/config/props.ts +9 -0
  63. package/src/editor/index.ts +2 -0
  64. package/src/editor/plateUI.ts +82 -0
  65. package/src/editor/plugins/blocks.tsx +71 -0
  66. package/src/editor/plugins/custom/assets/DefaultThumbnail.tsx +57 -0
  67. package/src/editor/plugins/custom/assets/index.ts +1 -0
  68. package/src/editor/plugins/custom/buttons.tsx +289 -0
  69. package/src/editor/plugins/custom/example.tsx +64 -0
  70. package/src/editor/plugins/custom/exitBreak.ts +41 -0
  71. package/src/editor/plugins/custom/footnote.tsx +185 -0
  72. package/src/editor/plugins/custom/index.ts +14 -0
  73. package/src/editor/plugins/custom/paywall.tsx +156 -0
  74. package/src/editor/plugins/custom/qa.tsx +390 -0
  75. package/src/editor/plugins/custom/resetBlockType.ts +29 -0
  76. package/src/editor/plugins/custom/selectOnBackspace.ts +7 -0
  77. package/src/editor/plugins/custom/softBreak.ts +20 -0
  78. package/src/editor/plugins/custom/styles/Button.module.scss +51 -0
  79. package/src/editor/plugins/custom/styles/Footnote.module.scss +58 -0
  80. package/src/editor/plugins/custom/styles/Paywall.module.scss +67 -0
  81. package/src/editor/plugins/custom/styles/QA.module.scss +140 -0
  82. package/src/editor/plugins/custom/styles/Video.module.scss +79 -0
  83. package/src/editor/plugins/custom/video.tsx +163 -0
  84. package/src/editor/plugins/index.ts +18 -0
  85. package/src/editor/plugins/inline.ts +46 -0
  86. package/src/editor/plugins/marks.ts +25 -0
  87. package/src/editor/plugins/utils.ts +22 -0
  88. package/src/feedback/Chip/Chip.module.scss +23 -0
  89. package/src/feedback/Chip/Chip.tsx +58 -0
  90. package/src/feedback/Chip/index.ts +1 -0
  91. package/src/feedback/Loader/Loader.module.scss +18 -0
  92. package/src/feedback/Loader/Loader.spec.js +18 -0
  93. package/src/feedback/Loader/Loader.tsx +53 -0
  94. package/src/feedback/Loader/index.ts +1 -0
  95. package/src/feedback/ProgressBar/ProgressBar.module.scss +13 -0
  96. package/src/feedback/ProgressBar/ProgressBar.tsx +32 -0
  97. package/src/feedback/ProgressBar/index.ts +1 -0
  98. package/src/feedback/Toast/Toast.module.scss +44 -0
  99. package/src/feedback/Toast/Toast.tsx +76 -0
  100. package/src/feedback/Toast/index.ts +1 -0
  101. package/src/feedback/Tooltip/Tooltip.module.scss +47 -0
  102. package/src/feedback/Tooltip/Tooltip.tsx +10 -0
  103. package/src/feedback/Tooltip/index.ts +1 -0
  104. package/src/feedback/index.ts +5 -0
  105. package/src/global.d.ts +6 -0
  106. package/src/iconography/Avatar/Avatar.module.scss +90 -0
  107. package/src/iconography/Avatar/Avatar.spec.js +75 -0
  108. package/src/iconography/Avatar/Avatar.tsx +96 -0
  109. package/src/iconography/Avatar/DefaultIcon.svg +4 -0
  110. package/src/iconography/Avatar/DefaultIcon.tsx +12 -0
  111. package/src/iconography/Avatar/iconHelpers.tsx +186 -0
  112. package/src/iconography/Avatar/index.ts +1 -0
  113. package/src/iconography/ColoredIcon/ColoredIcon.module.scss +40 -0
  114. package/src/iconography/ColoredIcon/ColoredIcon.tsx +30 -0
  115. package/src/iconography/ColoredIcon/index.ts +5 -0
  116. package/src/iconography/DevicePreview/DevicePreview.module.scss +143 -0
  117. package/src/iconography/DevicePreview/DevicePreview.tsx +592 -0
  118. package/src/iconography/DevicePreview/index.ts +1 -0
  119. package/src/iconography/IconHeader/IconHeader.module.scss +42 -0
  120. package/src/iconography/IconHeader/IconHeader.tsx +42 -0
  121. package/src/iconography/IconHeader/index.ts +1 -0
  122. package/src/iconography/StarRating/StarRating.tsx +99 -0
  123. package/src/iconography/StarRating/index.ts +1 -0
  124. package/src/iconography/index.ts +5 -0
  125. package/src/implementations/BodyContent/BodyContent.module.scss +38 -0
  126. package/src/implementations/BodyContent/BodyContent.tsx +78 -0
  127. package/src/implementations/BodyContent/index.ts +2 -0
  128. package/src/implementations/JoinGroupModal/JoinGroupModal.module.scss +83 -0
  129. package/src/implementations/JoinGroupModal/JoinGroupModal.tsx +176 -0
  130. package/src/implementations/JoinGroupModal/index.ts +1 -0
  131. package/src/implementations/index.ts +2 -0
  132. package/src/index.ts +86 -0
  133. package/src/inputs/CalendarInput/CalendarInput.module.scss +38 -0
  134. package/src/inputs/CalendarInput/CalendarInput.spec.js +19 -0
  135. package/src/inputs/CalendarInput/CalendarInput.tsx +29 -0
  136. package/src/inputs/CalendarInput/index.ts +1 -0
  137. package/src/inputs/CheckboxInput/CheckboxInput.module.scss +23 -0
  138. package/src/inputs/CheckboxInput/CheckboxInput.tsx +39 -0
  139. package/src/inputs/CheckboxInput/index.ts +1 -0
  140. package/src/inputs/FeedInput/FeedInput.module.scss +48 -0
  141. package/src/inputs/FeedInput/FeedInput.spec.js +16 -0
  142. package/src/inputs/FeedInput/FeedInput.tsx +197 -0
  143. package/src/inputs/FeedInput/index.ts +1 -0
  144. package/src/inputs/InboxInput/InboxInput.module.scss +48 -0
  145. package/src/inputs/InboxInput/InboxInput.spec.js +19 -0
  146. package/src/inputs/InboxInput/InboxInput.tsx +97 -0
  147. package/src/inputs/InboxInput/index.ts +1 -0
  148. package/src/inputs/PostInput/PostInput.module.scss +49 -0
  149. package/src/inputs/PostInput/PostInput.spec.js +19 -0
  150. package/src/inputs/PostInput/PostInput.tsx +54 -0
  151. package/src/inputs/PostInput/index.ts +1 -0
  152. package/src/inputs/RadioInput/RadioInput.module.scss +68 -0
  153. package/src/inputs/RadioInput/RadioInput.tsx +55 -0
  154. package/src/inputs/RadioInput/index.ts +1 -0
  155. package/src/inputs/SearchInput/SearchInput.module.scss +40 -0
  156. package/src/inputs/SearchInput/SearchInput.tsx +61 -0
  157. package/src/inputs/SearchInput/index.ts +1 -0
  158. package/src/inputs/SelectInput/SelectInput.module.scss +66 -0
  159. package/src/inputs/SelectInput/SelectInput.tsx +145 -0
  160. package/src/inputs/SelectInput/index.ts +1 -0
  161. package/src/inputs/TagInput/TagInput.module.scss +75 -0
  162. package/src/inputs/TagInput/TagInput.tsx +115 -0
  163. package/src/inputs/TagInput/index.ts +1 -0
  164. package/src/inputs/TextInput/TextInput.module.scss +35 -0
  165. package/src/inputs/TextInput/TextInput.tsx +46 -0
  166. package/src/inputs/TextInput/index.ts +1 -0
  167. package/src/inputs/index.ts +10 -0
  168. package/src/lists/ContactDetails/ContactDetails.module.scss +70 -0
  169. package/src/lists/ContactDetails/ContactDetails.spec.js +69 -0
  170. package/src/lists/ContactDetails/ContactDetails.tsx +185 -0
  171. package/src/lists/ContactDetails/index.ts +1 -0
  172. package/src/lists/index.ts +1 -0
  173. package/src/navigation/Breadcrumbs/Breadcrumbs.module.scss +18 -0
  174. package/src/navigation/Breadcrumbs/Breadcrumbs.spec.js +38 -0
  175. package/src/navigation/Breadcrumbs/Breadcrumbs.tsx +43 -0
  176. package/src/navigation/Breadcrumbs/index.ts +1 -0
  177. package/src/navigation/Drawer/Drawer.module.scss +104 -0
  178. package/src/navigation/Drawer/Drawer.tsx +177 -0
  179. package/src/navigation/Drawer/index.ts +1 -0
  180. package/src/navigation/EditorBar/EditorBar.module.scss +118 -0
  181. package/src/navigation/EditorBar/EditorBar.tsx +416 -0
  182. package/src/navigation/EditorBar/components/AlignmentDropdown/AlignmentDropdown.tsx +106 -0
  183. package/src/navigation/EditorBar/components/AlignmentDropdown/index.ts +1 -0
  184. package/src/navigation/EditorBar/components/ButtonModal/ButtonModal.module.scss +85 -0
  185. package/src/navigation/EditorBar/components/ButtonModal/ButtonModal.tsx +314 -0
  186. package/src/navigation/EditorBar/components/ButtonModal/assets/Comment.tsx +28 -0
  187. package/src/navigation/EditorBar/components/ButtonModal/assets/GiftSubscription.tsx +28 -0
  188. package/src/navigation/EditorBar/components/ButtonModal/assets/Link.tsx +28 -0
  189. package/src/navigation/EditorBar/components/ButtonModal/assets/Share.tsx +28 -0
  190. package/src/navigation/EditorBar/components/ButtonModal/assets/ShareCommunity.tsx +42 -0
  191. package/src/navigation/EditorBar/components/ButtonModal/assets/Signup.tsx +68 -0
  192. package/src/navigation/EditorBar/components/ButtonModal/assets/Special.tsx +24 -0
  193. package/src/navigation/EditorBar/components/ButtonModal/assets/Subscribe.tsx +28 -0
  194. package/src/navigation/EditorBar/components/ButtonModal/assets/index.ts +8 -0
  195. package/src/navigation/EditorBar/components/ButtonModal/index.ts +1 -0
  196. package/src/navigation/EditorBar/components/FontDropdown/FontDropdown.module.scss +16 -0
  197. package/src/navigation/EditorBar/components/FontDropdown/FontDropdown.tsx +137 -0
  198. package/src/navigation/EditorBar/components/FontDropdown/index.ts +1 -0
  199. package/src/navigation/EditorBar/components/MoreDropdown/MoreDropdown.module.scss +43 -0
  200. package/src/navigation/EditorBar/components/MoreDropdown/MoreDropdown.tsx +124 -0
  201. package/src/navigation/EditorBar/components/MoreDropdown/index.ts +1 -0
  202. package/src/navigation/EditorBar/components/OutlineDropdown/OutlineDropdown.module.scss +21 -0
  203. package/src/navigation/EditorBar/components/OutlineDropdown/OutlineDropdown.tsx +37 -0
  204. package/src/navigation/EditorBar/components/OutlineDropdown/index.ts +1 -0
  205. package/src/navigation/EditorBar/components/TextTypeDropdown/TextTypeDropdown.module.scss +51 -0
  206. package/src/navigation/EditorBar/components/TextTypeDropdown/TextTypeDropdown.tsx +80 -0
  207. package/src/navigation/EditorBar/components/TextTypeDropdown/index.ts +1 -0
  208. package/src/navigation/EditorBar/components/VideoModal/VideoModal.module.scss +150 -0
  209. package/src/navigation/EditorBar/components/VideoModal/VideoModal.tsx +163 -0
  210. package/src/navigation/EditorBar/components/VideoModal/index.ts +1 -0
  211. package/src/navigation/EditorBar/components/index.ts +7 -0
  212. package/src/navigation/EditorBar/index.ts +1 -0
  213. package/src/navigation/MenuTabs/MenuTabs.module.scss +34 -0
  214. package/src/navigation/MenuTabs/MenuTabs.spec.js +36 -0
  215. package/src/navigation/MenuTabs/MenuTabs.tsx +52 -0
  216. package/src/navigation/MenuTabs/index.ts +1 -0
  217. package/src/navigation/Navigation/Navigation.module.scss +92 -0
  218. package/src/navigation/Navigation/Navigation.spec.js +144 -0
  219. package/src/navigation/Navigation/Navigation.tsx +111 -0
  220. package/src/navigation/Navigation/SubNavigation.module.scss +255 -0
  221. package/src/navigation/Navigation/SubNavigation.spec.js +112 -0
  222. package/src/navigation/Navigation/SubNavigation.tsx +443 -0
  223. package/src/navigation/Navigation/index.ts +15 -0
  224. package/src/navigation/Pagination/Pagination.module.scss +49 -0
  225. package/src/navigation/Pagination/Pagination.tsx +115 -0
  226. package/src/navigation/Pagination/index.ts +1 -0
  227. package/src/navigation/index.ts +21 -0
  228. package/src/surfaces/Comment/Comment.module.scss +106 -0
  229. package/src/surfaces/Comment/Comment.spec.js +105 -0
  230. package/src/surfaces/Comment/Comment.tsx +157 -0
  231. package/src/surfaces/Comment/index.ts +1 -0
  232. package/src/surfaces/Faq/Faq.module.scss +91 -0
  233. package/src/surfaces/Faq/Faq.spec.js +38 -0
  234. package/src/surfaces/Faq/Faq.tsx +156 -0
  235. package/src/surfaces/Faq/index.ts +1 -0
  236. package/src/surfaces/Message/Message.module.scss +37 -0
  237. package/src/surfaces/Message/Message.spec.js +47 -0
  238. package/src/surfaces/Message/Message.tsx +54 -0
  239. package/src/surfaces/Message/index.ts +1 -0
  240. package/src/surfaces/Modal/Modal.module.scss +52 -0
  241. package/src/surfaces/Modal/Modal.spec.js +38 -0
  242. package/src/surfaces/Modal/Modal.tsx +131 -0
  243. package/src/surfaces/Modal/index.ts +5 -0
  244. package/src/surfaces/Plan/Plan.module.scss +79 -0
  245. package/src/surfaces/Plan/Plan.tsx +75 -0
  246. package/src/surfaces/Plan/index.ts +1 -0
  247. package/src/surfaces/Post/Post.module.scss +46 -0
  248. package/src/surfaces/Post/Post.spec.js +103 -0
  249. package/src/surfaces/Post/Post.tsx +185 -0
  250. package/src/surfaces/Post/index.ts +1 -0
  251. package/src/surfaces/Post/postHelpers.ts +20 -0
  252. package/src/surfaces/ProfileHeader/ProfileHeader.module.scss +202 -0
  253. package/src/surfaces/ProfileHeader/ProfileHeader.tsx +103 -0
  254. package/src/surfaces/ProfileHeader/index.ts +1 -0
  255. package/src/surfaces/RatingsOverview/RatingsOverview.module.scss +54 -0
  256. package/src/surfaces/RatingsOverview/RatingsOverview.tsx +69 -0
  257. package/src/surfaces/RatingsOverview/index.ts +1 -0
  258. package/src/surfaces/Review/Review.module.scss +73 -0
  259. package/src/surfaces/Review/Review.tsx +88 -0
  260. package/src/surfaces/Review/index.ts +1 -0
  261. package/src/surfaces/index.ts +9 -0
  262. package/src/tables/Filter/Filter.module.scss +34 -0
  263. package/src/tables/Filter/Filter.tsx +30 -0
  264. package/src/tables/Filter/index.ts +1 -0
  265. package/src/tables/Table/Table.module.scss +126 -0
  266. package/src/tables/Table/Table.spec.js +113 -0
  267. package/src/tables/Table/Table.tsx +251 -0
  268. package/src/tables/Table/index.ts +7 -0
  269. package/src/tables/index.ts +7 -0
  270. package/tsconfig.json +14 -0
  271. package/vite.config.ts +28 -0
@@ -0,0 +1,162 @@
1
+ import React from "react";
2
+
3
+ import { IconHeader, IconHeaderProps } from "../../iconography";
4
+ import styles from "./Line.module.scss";
5
+
6
+ type Data = {
7
+ name: string;
8
+ value: number;
9
+ };
10
+
11
+ type DataSet = {
12
+ groupName?: string;
13
+ data: Required<Data>[];
14
+ };
15
+
16
+ export interface LineProps {
17
+ width?: string;
18
+ height?: string;
19
+ iconHeader: IconHeaderProps;
20
+ dataSets: DataSet[];
21
+ }
22
+
23
+ export const Line = ({
24
+ height = "200px",
25
+ width = "686px",
26
+ iconHeader,
27
+ dataSets,
28
+ }: LineProps) => {
29
+ const [min, max] = dataSets.reduce(
30
+ (prev, curr) => {
31
+ const [currMin, currMax] = curr.data.reduce(
32
+ (currPrev, currCurr) => {
33
+ if (currCurr.value < currPrev[0]) {
34
+ currPrev[0] = currCurr.value;
35
+ }
36
+ if (currCurr.value > currPrev[1]) {
37
+ currPrev[1] = currCurr.value;
38
+ }
39
+ return currPrev;
40
+ },
41
+ [Infinity, -Infinity]
42
+ );
43
+ if (currMin < prev[0]) {
44
+ prev[0] = currMin;
45
+ }
46
+ if (currMax > prev[1]) {
47
+ prev[1] = currMax;
48
+ }
49
+ return prev;
50
+ },
51
+ [Infinity, -Infinity]
52
+ );
53
+ const yMin = 0;
54
+ let yCap = 10 ** Math.floor(Math.log10(max));
55
+ if (max > yCap) {
56
+ yCap = Math.ceil(max / yCap / 0.5) * 0.5 * yCap;
57
+ }
58
+ let step = 10 ** Math.floor(Math.log10(max));
59
+ if (Math.floor(step / yCap) <= 1) {
60
+ step = Math.ceil(step / 2 / 0.5) * 0.5;
61
+ }
62
+ while (yCap / step > 5) {
63
+ step = step * 2;
64
+ }
65
+
66
+ return (
67
+ <section
68
+ className={styles.line}
69
+ style={
70
+ {
71
+ "--graph-height": height,
72
+ "--graph-width": width,
73
+ } as React.CSSProperties
74
+ }
75
+ >
76
+ {iconHeader && <IconHeader {...iconHeader} />}
77
+ <div className="graph">
78
+ <div className="grid">
79
+ {Array.from(
80
+ { length: yCap / step },
81
+ (_, index) => (yCap / step - index) * step
82
+ ).map((element) => (
83
+ <div key={element.toString(36)}>
84
+ <p>{element}</p>
85
+ <div />
86
+ </div>
87
+ ))}
88
+ </div>
89
+ <div className="info">
90
+ {dataSets.map((set, setIndex) => (
91
+ <div className="set" key={"set-" + setIndex.toString(36)}>
92
+ {set.data.map((line, lineIndex) => {
93
+ let barHeight, nextBarHeight: string;
94
+ let dX, dY: number;
95
+ if (width.endsWith("px")) {
96
+ barHeight =
97
+ Math.round(
98
+ (line.value * parseInt(height.replace("px", ""))) / yCap
99
+ ) + "px";
100
+ nextBarHeight =
101
+ Math.round(
102
+ ((set.data[lineIndex + 1]?.value ?? 0) *
103
+ parseInt(height.replace("px", ""))) /
104
+ yCap
105
+ ) + "px";
106
+ dX = Math.round(
107
+ parseInt(width.replace("px", "")) / set.data.length
108
+ );
109
+ dY =
110
+ parseInt(barHeight.replace("px", "")) -
111
+ parseInt(nextBarHeight.replace("px", ""));
112
+ } else {
113
+ barHeight =
114
+ Math.round(
115
+ (line.value * parseInt(height.replace("%", ""))) / yCap
116
+ ) + "%";
117
+ nextBarHeight =
118
+ Math.round(
119
+ ((set.data[lineIndex + 1]?.value ?? 0) *
120
+ parseInt(height.replace("%", ""))) /
121
+ yCap
122
+ ) + "%";
123
+ dX = Math.round(
124
+ parseInt(width.replace("%", "")) / set.data.length
125
+ );
126
+ dY =
127
+ parseInt(nextBarHeight.replace("%", "")) -
128
+ parseInt(barHeight.replace("%", ""));
129
+ }
130
+ const length = Math.ceil(Math.sqrt(dX ** 2 + dY ** 2));
131
+ const rotation = Math.round(
132
+ Math.atan2(dY, dX) * (180 / Math.PI)
133
+ );
134
+
135
+ return (
136
+ <div
137
+ className="line"
138
+ key={"line-" + lineIndex.toString(36)}
139
+ style={
140
+ {
141
+ "--bar-height": barHeight,
142
+ "--line-length":
143
+ length + (width.endsWith("px") ? "px" : "%"),
144
+ "--rotation": rotation + "deg",
145
+ "--from-top": dY / 2 - 0.5 * lineIndex + "px",
146
+ } as React.CSSProperties
147
+ }
148
+ >
149
+ <div className="point" />
150
+ {lineIndex !== set.data.length - 1 && (
151
+ <div className="segment" />
152
+ )}
153
+ </div>
154
+ );
155
+ })}
156
+ </div>
157
+ ))}
158
+ </div>
159
+ </div>
160
+ </section>
161
+ );
162
+ };
@@ -0,0 +1 @@
1
+ export { Line, type LineProps } from "./Line";
@@ -0,0 +1,56 @@
1
+ @use "@soul-refiner/styles/mixins";
2
+
3
+ .wrapper {
4
+ @include mixins.flex($gap: 32px, $dir: column);
5
+ padding: 32px;
6
+ background-color: #ffffff;
7
+ border-radius: 25px;
8
+ max-width: 833px;
9
+
10
+ & > figure {
11
+ @include mixins.flex($gap: 94px);
12
+ width: 100%;
13
+
14
+ & > figcaption {
15
+ flex: 1;
16
+ & > div {
17
+ @include mixins.flex($gap: 16px);
18
+ padding: 10px;
19
+ & > p {
20
+ font-size: 16px;
21
+ &:first-of-type {
22
+ margin-right: auto;
23
+ }
24
+ }
25
+
26
+ [class~="color"] {
27
+ width: 19px;
28
+ height: 19px;
29
+ border-radius: 50%;
30
+ }
31
+ }
32
+ }
33
+ }
34
+ }
35
+
36
+ .pie {
37
+ position: relative;
38
+ display: block;
39
+ width: 170px;
40
+ height: 170px;
41
+ border-radius: 50%;
42
+ background: var(--gradient);
43
+
44
+ &::after {
45
+ content: "";
46
+ position: absolute;
47
+ width: calc(100% - 60px);
48
+ height: calc(100% - 60px);
49
+ top: 30px;
50
+ right: 30px;
51
+ left: 30px;
52
+ bottom: 30px;
53
+ background-color: #ffffff;
54
+ border-radius: 50%;
55
+ }
56
+ }
@@ -0,0 +1,72 @@
1
+ import React from "react";
2
+ import "@testing-library/jest-dom";
3
+ import { render, screen } from "@testing-library/react";
4
+
5
+ import { BarGraph } from "@soul-refiner/icons/src";
6
+ import { Pie } from "./Pie";
7
+
8
+ const generateMockProps = (props) => ({
9
+ iconHeader: {
10
+ as: "h5",
11
+ color: "blue",
12
+ icon: <BarGraph iconSize={18} size={24} fill="var(--color-blue-3)" />,
13
+ title: "Summary",
14
+ },
15
+ data: [
16
+ {
17
+ label: "Option 1",
18
+ amount: 2,
19
+ },
20
+ {
21
+ label: "Option 2",
22
+ amount: 5,
23
+ },
24
+ {
25
+ label: "Option 3",
26
+ amount: 14,
27
+ },
28
+ {
29
+ label: "Option 4",
30
+ amount: 3,
31
+ },
32
+ {
33
+ label: "Option 5",
34
+ amount: 7,
35
+ },
36
+ {
37
+ label: "Option 6",
38
+ amount: 4,
39
+ },
40
+ {
41
+ label: "Option 7",
42
+ amount: 24,
43
+ },
44
+ {
45
+ label: "Option 8",
46
+ amount: 1,
47
+ },
48
+ {
49
+ label: "Option 9",
50
+ amount: 1,
51
+ },
52
+ ],
53
+ ...props,
54
+ });
55
+
56
+ describe("Pie Chart", () => {
57
+ it("renders the appropriate radios and colors", () => {
58
+ const props = generateMockProps({});
59
+ render(<Pie {...props} />);
60
+ expect(screen.getByTestId("pie-chart")).toHaveStyle(
61
+ `background: conic-gradient(var(--color-turquoise-5) 0deg 140deg, #FFFFFF 140deg 141deg, var(--color-orange-5) 141deg 222deg, #FFFFFF 222deg 223deg, var(--color-blue-5) 223deg 263deg, #FFFFFF 263deg 264deg, var(--color-yellow-5) 264deg 292deg, #FFFFFF 292deg 293deg, var(--color-purple-5) 293deg 315deg, #FFFFFF 315deg 316deg, var(--color-green-5) 316deg 332deg, #FFFFFF 332deg 333deg, var(--color-red-6) 333deg 359deg, #FFFFFF 359deg 0deg)`
62
+ );
63
+ });
64
+
65
+ it("renders seven or more options together", () => {
66
+ const props = generateMockProps({});
67
+ render(<Pie {...props} />);
68
+ const other = screen.getByText("Other");
69
+ expect(other);
70
+ expect(other.nextSibling).toHaveTextContent("4");
71
+ });
72
+ });
@@ -0,0 +1,111 @@
1
+ import React from "react";
2
+ import styles from "./Pie.module.scss";
3
+ import { COLOR_ORDER } from "@soul-refiner/utils/src";
4
+ import { IconHeader, IconHeaderProps } from "../../iconography";
5
+
6
+ type Data = {
7
+ label: string;
8
+ amount: number;
9
+ color?: string;
10
+ };
11
+
12
+ export interface PieProps {
13
+ data: Data[];
14
+ iconHeader?: IconHeaderProps;
15
+ header?: React.ReactNode;
16
+ }
17
+
18
+ export const Pie = ({ data, iconHeader, header }: PieProps) => {
19
+ const total = data.reduce(
20
+ (prev, curr) => (curr.amount > 0 ? prev + curr.amount : prev),
21
+ 0
22
+ );
23
+ const sortedData = data
24
+ .filter((data) => data.amount > 0)
25
+ .sort((a, b) => b.amount - a.amount);
26
+ let current = 0;
27
+
28
+ const gradient = sortedData.reduce((prev, curr, index) => {
29
+ if (curr.color) {
30
+ COLOR_ORDER[index] = curr.color;
31
+ }
32
+ if (sortedData.length === 1) {
33
+ return `${COLOR_ORDER[0]} 0 0`;
34
+ }
35
+ if (index === 0) {
36
+ const degrees = Math.floor((360 * curr.amount) / total) - 1;
37
+ current = current + degrees + 1;
38
+ return `${COLOR_ORDER[0]} 0deg ${degrees}deg, #FFFFFF ${degrees}deg ${
39
+ degrees + 1
40
+ }deg`;
41
+ }
42
+ if (
43
+ index === 6 ||
44
+ (sortedData.length < 7 && index === sortedData.length - 1)
45
+ ) {
46
+ return `${prev}, ${COLOR_ORDER[index]} ${current}deg 359deg, #FFFFFF 359deg 0deg`;
47
+ }
48
+ if (index > 6) {
49
+ return prev;
50
+ }
51
+ const degrees = Math.floor((360 * curr.amount) / total) - 1;
52
+ const next = `${prev}, ${COLOR_ORDER[index]} ${current}deg ${
53
+ current + degrees
54
+ }deg, #FFFFFF ${current + degrees}deg ${current + degrees + 1}deg`;
55
+ current = current + degrees + 1;
56
+ return next;
57
+ }, "");
58
+
59
+ const textElements = sortedData.map((element, index) => {
60
+ if (index === 6) {
61
+ const otherAmount = sortedData
62
+ .slice(6)
63
+ .reduce(
64
+ (prev, curr) => (curr.amount > 0 ? prev + curr.amount : prev),
65
+ 0
66
+ );
67
+ return (
68
+ <div key={index + JSON.stringify(element)}>
69
+ <div
70
+ className="color"
71
+ style={{ backgroundColor: COLOR_ORDER[index] }}
72
+ />
73
+ <p>Other</p>
74
+ <p>{otherAmount}</p>
75
+ </div>
76
+ );
77
+ }
78
+ if (index > 6) {
79
+ return;
80
+ }
81
+ return (
82
+ <div key={index + JSON.stringify(element)}>
83
+ <div
84
+ className="color"
85
+ style={{ backgroundColor: COLOR_ORDER[index] }}
86
+ />
87
+ <p>{element.label}</p>
88
+ <p>{element.amount}</p>
89
+ </div>
90
+ );
91
+ });
92
+
93
+ return (
94
+ <article className={`${styles.wrapper}`}>
95
+ {!!iconHeader && <IconHeader {...iconHeader} />}
96
+ {!!header && header}
97
+ <figure>
98
+ <figcaption>{textElements}</figcaption>
99
+ <div
100
+ className={`${styles.pie}`}
101
+ data-testid="pie-chart"
102
+ style={
103
+ {
104
+ "--gradient": `conic-gradient(${gradient})`,
105
+ } as React.CSSProperties
106
+ }
107
+ />
108
+ </figure>
109
+ </article>
110
+ );
111
+ };
@@ -0,0 +1 @@
1
+ export { Pie, type PieProps } from "./Pie";
@@ -0,0 +1,3 @@
1
+ export { Bar, type BarProps } from "./Bar";
2
+ export { Line, type LineProps } from "./Line";
3
+ export { Pie, type PieProps } from "./Pie";
@@ -0,0 +1,125 @@
1
+ .editor {
2
+ position: relative;
3
+ padding: 24px;
4
+ max-width: 1200px;
5
+ margin: 98px auto 0px;
6
+
7
+ * {
8
+ line-height: 150%;
9
+ color: var(--color-grey-3);
10
+ }
11
+
12
+ h1,
13
+ h2,
14
+ h3,
15
+ h4,
16
+ h5,
17
+ h6 {
18
+ line-height: 125%;
19
+ }
20
+
21
+ & > [data-slate-editor="true"] > * {
22
+ margin: 24px 0px;
23
+ }
24
+
25
+ h1,
26
+ h2,
27
+ h3,
28
+ h4,
29
+ h5,
30
+ h6,
31
+ p,
32
+ a,
33
+ li,
34
+ div,
35
+ label,
36
+ figure,
37
+ figcaption,
38
+ sub,
39
+ sup,
40
+ button {
41
+ font-weight: 400;
42
+ }
43
+
44
+ code {
45
+ font-family: var(--font-mono);
46
+ & > * {
47
+ font-family: var(--font-mono);
48
+ span {
49
+ font-family: var(--font-mono) !important;
50
+ }
51
+ }
52
+ }
53
+
54
+ button > span {
55
+ [data-slate-string] {
56
+ color: var(--color);
57
+ }
58
+ }
59
+
60
+ hr {
61
+ border-top: 1px solid var(--color-grey-8);
62
+ }
63
+
64
+ [data-slate-node="text"] {
65
+ cursor: text;
66
+ }
67
+
68
+ [class~="slate-p"] {
69
+ padding: 0px;
70
+ }
71
+
72
+ [class~="slate-footnote"] {
73
+ counter-increment: footnote_counter 1;
74
+ outline: none;
75
+
76
+ & > span:first-of-type {
77
+ position: relative;
78
+ display: inline-block;
79
+ margin-right: 1ch;
80
+
81
+ &::before {
82
+ position: absolute;
83
+ content: counter(footnote_counter);
84
+ left: 0px;
85
+ top: 0px;
86
+ text-decoration: underline;
87
+ color: var(--color-blue-5);
88
+ }
89
+ }
90
+ }
91
+
92
+ [class~="slate-img"] {
93
+ textarea {
94
+ max-height: 96px;
95
+ }
96
+ & + [contentEditable="false"] {
97
+ display: none;
98
+ }
99
+ }
100
+ [class~="slate-listStyleType-decimals"],
101
+ [class~="slate-listStyleType-disc"] {
102
+ margin: 0px;
103
+ &:first-of-type {
104
+ margin: 24px 0px 0px;
105
+ }
106
+ &:last-of-type {
107
+ margin: 0px 0px 24px;
108
+ }
109
+ }
110
+
111
+ [class~="slate-blockquote"] {
112
+ margin-left: 24px;
113
+ padding: 4px 0px 4px 20px;
114
+ border-left: 4px solid var(--color-grey-7);
115
+ }
116
+
117
+ [class~="slate-a"] {
118
+ span {
119
+ color: var(--color-blue-5);
120
+ &:hover {
121
+ cursor: pointer;
122
+ }
123
+ }
124
+ }
125
+ }