@pocketprep/ui-kit 3.8.5 → 3.9.0

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 (159) hide show
  1. package/dist/@pocketprep/ui-kit.css +1 -1
  2. package/dist/@pocketprep/ui-kit.js +14466 -17728
  3. package/dist/@pocketprep/ui-kit.js.map +1 -1
  4. package/dist/@pocketprep/ui-kit.umd.cjs +19 -29
  5. package/dist/@pocketprep/ui-kit.umd.cjs.map +1 -1
  6. package/eslint.config.ts +38 -11
  7. package/lib/SVGDefinitions.vue +32 -35
  8. package/lib/components/Banners/Banner.vue +10 -14
  9. package/lib/components/Blobs/Blob.vue +6 -14
  10. package/lib/components/Blobs/BlobEmptyState.vue +9 -8
  11. package/lib/components/Blobs/blob.d.ts +1 -1
  12. package/lib/components/BundleIcons/BundleIcon.vue +36 -63
  13. package/lib/components/BundleIcons/bundleIcon.d.ts +1 -1
  14. package/lib/components/Bundles/BundleList.vue +71 -59
  15. package/lib/components/Bundles/BundleSearch.vue +93 -117
  16. package/lib/components/Bundles/PremiumPill.vue +6 -12
  17. package/lib/components/Buttons/Button.vue +32 -35
  18. package/lib/components/Buttons/Link.vue +32 -31
  19. package/lib/components/Buttons/Tab.vue +14 -17
  20. package/lib/components/Calendar/Calendar.vue +87 -85
  21. package/lib/components/Charts/Bar.vue +192 -263
  22. package/lib/components/Charts/Pie.vue +55 -61
  23. package/lib/components/Charts/highcharts-wrap.ts +81 -0
  24. package/lib/components/Controls/SegmentControl.vue +26 -24
  25. package/lib/components/Controls/Slider.vue +51 -47
  26. package/lib/components/Controls/ToggleSwitch.vue +33 -31
  27. package/lib/components/EmptyStates/EmptyState.vue +69 -73
  28. package/lib/components/Exams/ExamCard.vue +59 -47
  29. package/lib/components/Exams/ExamMenuCard.vue +30 -28
  30. package/lib/components/Filters/FilterDropdown.vue +83 -86
  31. package/lib/components/Filters/FilterOptions.vue +83 -88
  32. package/lib/components/Forms/Checkbox.vue +27 -27
  33. package/lib/components/Forms/CheckboxOption.vue +30 -30
  34. package/lib/components/Forms/Errors.vue +21 -24
  35. package/lib/components/Forms/Input.vue +71 -59
  36. package/lib/components/Forms/Radio.vue +2 -2
  37. package/lib/components/Forms/RadioButton.vue +8 -8
  38. package/lib/components/Forms/Select.vue +265 -257
  39. package/lib/components/Forms/Textarea.vue +49 -35
  40. package/lib/components/Icons/IconAccordionArrow.vue +7 -9
  41. package/lib/components/Icons/IconActivity.vue +7 -9
  42. package/lib/components/Icons/IconAdd.vue +7 -11
  43. package/lib/components/Icons/IconAddCircle.vue +7 -9
  44. package/lib/components/Icons/IconArrow.vue +7 -9
  45. package/lib/components/Icons/IconBarChart.vue +7 -9
  46. package/lib/components/Icons/IconCalendar.vue +7 -9
  47. package/lib/components/Icons/IconCalendarPicker.vue +7 -9
  48. package/lib/components/Icons/IconChat.vue +7 -9
  49. package/lib/components/Icons/IconCheck.vue +7 -9
  50. package/lib/components/Icons/IconClose.vue +7 -9
  51. package/lib/components/Icons/IconConcept.vue +1 -1
  52. package/lib/components/Icons/IconCorrect.vue +7 -9
  53. package/lib/components/Icons/IconEdit.vue +7 -11
  54. package/lib/components/Icons/IconExam.vue +7 -9
  55. package/lib/components/Icons/IconExternalLink.vue +7 -9
  56. package/lib/components/Icons/IconEyeHide.vue +7 -9
  57. package/lib/components/Icons/IconEyeShow.vue +7 -9
  58. package/lib/components/Icons/IconFilter.vue +7 -9
  59. package/lib/components/Icons/IconFilterActive.vue +7 -9
  60. package/lib/components/Icons/IconFlag.vue +7 -9
  61. package/lib/components/Icons/IconFlagContent.vue +8 -9
  62. package/lib/components/Icons/IconFlagFeedback.vue +8 -10
  63. package/lib/components/Icons/IconFlagFilled.vue +7 -9
  64. package/lib/components/Icons/IconFullView.vue +7 -9
  65. package/lib/components/Icons/IconFullViewActive.vue +7 -9
  66. package/lib/components/Icons/IconGridDrag.vue +2 -2
  67. package/lib/components/Icons/IconHandle.vue +7 -9
  68. package/lib/components/Icons/IconHeart.vue +7 -9
  69. package/lib/components/Icons/IconHelp.vue +7 -9
  70. package/lib/components/Icons/IconHighlight.vue +2 -2
  71. package/lib/components/Icons/IconHourglass.vue +7 -9
  72. package/lib/components/Icons/IconImage.vue +7 -9
  73. package/lib/components/Icons/IconIncorrect.vue +7 -9
  74. package/lib/components/Icons/IconInfo.vue +7 -9
  75. package/lib/components/Icons/IconKeyboard.vue +7 -9
  76. package/lib/components/Icons/IconLaunch.vue +7 -9
  77. package/lib/components/Icons/IconLevelUp.vue +7 -9
  78. package/lib/components/Icons/IconLightbulb.vue +7 -9
  79. package/lib/components/Icons/IconLightning.vue +7 -9
  80. package/lib/components/Icons/IconLink.vue +7 -9
  81. package/lib/components/Icons/IconList.vue +7 -9
  82. package/lib/components/Icons/IconLoading.vue +7 -9
  83. package/lib/components/Icons/IconLoading2.vue +11 -11
  84. package/lib/components/Icons/IconLock.vue +7 -9
  85. package/lib/components/Icons/IconMissedQuestions.vue +7 -9
  86. package/lib/components/Icons/IconMoon.vue +7 -9
  87. package/lib/components/Icons/IconPaginationArrow.vue +7 -9
  88. package/lib/components/Icons/IconPaginationArrowDouble.vue +7 -9
  89. package/lib/components/Icons/IconPassage.vue +7 -9
  90. package/lib/components/Icons/IconPencil.vue +7 -9
  91. package/lib/components/Icons/IconPeople.vue +7 -9
  92. package/lib/components/Icons/IconPercent.vue +7 -9
  93. package/lib/components/Icons/IconPerson.vue +8 -9
  94. package/lib/components/Icons/IconPresent.vue +7 -9
  95. package/lib/components/Icons/IconPreview.vue +7 -9
  96. package/lib/components/Icons/IconQuestions.vue +7 -9
  97. package/lib/components/Icons/IconQuick10.vue +7 -9
  98. package/lib/components/Icons/IconQuickActions.vue +2 -2
  99. package/lib/components/Icons/IconRecommendedFilter.vue +1 -1
  100. package/lib/components/Icons/IconRemoveCircle.vue +7 -9
  101. package/lib/components/Icons/IconReviewFlag.vue +7 -9
  102. package/lib/components/Icons/IconSearch.vue +7 -9
  103. package/lib/components/Icons/IconShare.vue +7 -9
  104. package/lib/components/Icons/IconSideBar.vue +7 -9
  105. package/lib/components/Icons/IconSideBarActive.vue +7 -9
  106. package/lib/components/Icons/IconStar.vue +1 -1
  107. package/lib/components/Icons/IconStopwatch.vue +7 -9
  108. package/lib/components/Icons/IconStrike.vue +7 -9
  109. package/lib/components/Icons/IconSubject.vue +7 -9
  110. package/lib/components/Icons/IconText.vue +7 -9
  111. package/lib/components/Icons/IconTimer.vue +8 -9
  112. package/lib/components/Icons/IconWarning.vue +7 -9
  113. package/lib/components/Icons/icon.d.ts +1 -1
  114. package/lib/components/Loaders/SkeletonLoader.vue +1 -5
  115. package/lib/components/Modal/Modal.vue +23 -29
  116. package/lib/components/Modal/ModalContainer.vue +135 -135
  117. package/lib/components/Onboarding/EmailAuth.vue +66 -70
  118. package/lib/components/Onboarding/MagicCodeEntry.vue +88 -83
  119. package/lib/components/Pagination/QuestionReviewPagination.vue +3 -3
  120. package/lib/components/Pagination/TablePagination.vue +47 -44
  121. package/lib/components/PhonePerson/PhonePerson.vue +18 -18
  122. package/lib/components/PhonePerson/phonePerson.d.ts +1 -1
  123. package/lib/components/Quiz/FlagToggle.vue +45 -44
  124. package/lib/components/Quiz/GlobalMetricsToggle.vue +29 -28
  125. package/lib/components/Quiz/KeyboardShortcutsButton.vue +16 -23
  126. package/lib/components/Quiz/KeyboardShortcutsModal.vue +36 -37
  127. package/lib/components/Quiz/Question/BuildListChoicesContainer.vue +65 -65
  128. package/lib/components/Quiz/Question/ChoicesContainer.vue +5 -5
  129. package/lib/components/Quiz/Question/DropdownExplanation.vue +5 -5
  130. package/lib/components/Quiz/Question/Explanation.vue +6 -6
  131. package/lib/components/Quiz/Question/MPMCChoicesContainer.vue +17 -17
  132. package/lib/components/Quiz/Question/MPMCRadioGroup.vue +2 -2
  133. package/lib/components/Quiz/Question/MatrixChoicesContainer.vue +39 -39
  134. package/lib/components/Quiz/Question/MatrixRadioGroup.vue +6 -6
  135. package/lib/components/Quiz/Question/MobileMatrixChoicesContainer.vue +27 -28
  136. package/lib/components/Quiz/Question/MobileMatrixRadioGroup.vue +2 -2
  137. package/lib/components/Quiz/Question/PassageAndImage.vue +3 -3
  138. package/lib/components/Quiz/Question/PassageAndImageDropdown.vue +7 -7
  139. package/lib/components/Quiz/Question/Paywall.vue +2 -2
  140. package/lib/components/Quiz/Question/QuestionContext.vue +1 -1
  141. package/lib/components/Quiz/Question/StatsSummary.vue +2 -2
  142. package/lib/components/Quiz/Question/Summary.vue +11 -11
  143. package/lib/components/Quiz/Question.vue +90 -82
  144. package/lib/components/Quiz/QuizContainer.vue +1 -1
  145. package/lib/components/Quiz/QuizProgressBar.vue +23 -23
  146. package/lib/components/Quiz/question.d.ts +3 -3
  147. package/lib/components/Search/Pill.vue +16 -19
  148. package/lib/components/Search/Search.vue +52 -47
  149. package/lib/components/SidePanels/SidePanel.vue +168 -174
  150. package/lib/components/Tables/Table.vue +135 -122
  151. package/lib/components/Tables/TableActions.vue +81 -76
  152. package/lib/components/Tables/table.d.ts +1 -1
  153. package/lib/components/Tags/Tag.vue +49 -39
  154. package/lib/components/Toasts/Toast.vue +44 -42
  155. package/lib/components/Tooltips/OverflowTooltip.vue +39 -45
  156. package/lib/components/Tooltips/Tooltip.vue +69 -70
  157. package/lib/directives.ts +4 -4
  158. package/lib/utils.ts +13 -12
  159. package/package.json +27 -28
@@ -2,15 +2,15 @@
2
2
  <div :id="chartId" class="uikit-bar" />
3
3
  </template>
4
4
 
5
- <script lang="ts">
6
- import { Component, Vue, Prop } from 'vue-facing-decorator'
5
+ <script setup lang="ts">
6
+ import './highcharts-wrap.ts'
7
7
  import Highcharts, { chart } from 'highcharts'
8
- import Accessibility from 'highcharts/modules/accessibility'
9
8
  import BrandColors from '../../pocketprep-export.module.scss'
9
+ import { nextTick, onMounted } from 'vue'
10
10
 
11
- type TCustomChartOptions = Highcharts.Options & {
12
- plotOptions: {
13
- series: {
11
+ type TCustomChartOptions = Highcharts.Options & {
12
+ plotOptions: {
13
+ series: {
14
14
  groupPadding: number
15
15
  pointPadding: number
16
16
  }
@@ -21,290 +21,219 @@ type TCustomChartOptions = Highcharts.Options & {
21
21
  }
22
22
  }
23
23
 
24
- type TCustomSeries = Highcharts.Series & {
25
- options: {
26
- borderRadiusTopLeft: number
27
- borderRadiusTopRight: number
28
- borderRadiusBottomRight: number
29
- borderRadiusBottomLeft: number
30
- }
31
- }
32
-
33
- type TShapeArgs = {
34
- d?: Highcharts.SVGPathArray
35
- width?: number
36
- height?: number
37
- x?: number
38
- y?: number
39
- }
40
-
41
- type TCustomPoint = Highcharts.Point & {
42
- shapeArgs: TShapeArgs
43
- shapeType: string
44
- dlBox: TShapeArgs
45
- }
46
-
47
- type TCustomHighcharts = typeof Highcharts & {
48
- seriesTypes: {
49
- column: {
50
- prototype: Record<string, unknown>
51
- }
52
- }
53
- }
54
-
55
- Accessibility(Highcharts);
56
- (function (H) {
57
- H.wrap((H.seriesTypes.column.prototype), 'translate', function (this: TCustomSeries, proceed: () => void) {
58
- const options = this.options
59
-
60
- proceed.call(this);
61
-
62
- (this.points as TCustomPoint[]).forEach(function (point) {
63
- if (options.borderRadiusTopLeft || options.borderRadiusTopRight) {
64
- const w = Number(point.shapeArgs.width)
65
- const h = Number(point.shapeArgs.height)
66
- const x = Number(point.shapeArgs.x)
67
- const y = Number(point.shapeArgs.y)
68
- const maxR = Math.min(w, h) / 2
69
-
70
- let radiusTopLeft = H.relativeLength(options.borderRadiusTopLeft || 0, w)
71
- let radiusTopRight = H.relativeLength(options.borderRadiusTopRight || 0, w)
72
-
73
-
74
- radiusTopLeft = radiusTopLeft > maxR ? maxR : radiusTopLeft
75
- radiusTopRight = radiusTopRight > maxR ? maxR : radiusTopRight
76
-
77
- point.dlBox = point.shapeArgs
78
-
79
- point.shapeType = 'path'
80
- const d = [
81
- 'M', x + radiusTopLeft, y,
82
- 'L', x + w - radiusTopRight, y,
83
- 'C', x + w - (radiusTopRight / 2), y, x + w, y + (radiusTopRight / 2), x + w, y + radiusTopRight,
84
- 'L', x + w, y + h,
85
- 'C', x + w, y + h, x + w, y + h, x + w, y + h,
86
- 'L', x, y + h,
87
- 'C', x, y + h, x, y + h, x, y + h,
88
- 'L', x, y + radiusTopLeft,
89
- 'C', x, y + (radiusTopLeft / 2), x + (radiusTopLeft / 2), y, x + radiusTopLeft, y,
90
- 'Z',
91
- ] as unknown as Highcharts.SVGPathArray
92
- point.shapeArgs = {
93
- d,
94
- }
95
- }
96
-
97
- })
98
- })
99
- }(Highcharts as TCustomHighcharts))
100
-
101
- /**
102
- * @see [Designs for Content - Student](https://marvelapp.com/adf8ab3/screen/68221510)
103
- */
104
- @Component
105
- export default class Bar extends Vue {
106
- @Prop({ default: '' }) title!: string
107
- @Prop() data!: Highcharts.PointOptionsObject[]
108
- @Prop() formatterFunc!:
109
- Highcharts.FormatterCallbackFunction<Highcharts.AxisLabelsFormatterContextObject>
110
- @Prop() type!: 'percent' | 'distribution'
111
- @Prop({ default: null }) yAxisTitle!: string
112
- @Prop({ default: null }) max!: number
113
- @Prop({ default: false }) hideAverageLine!: boolean
114
- @Prop({ default: 'normal' }) size!: 'normal' | 'small'
115
- @Prop() barColor?: string
116
- @Prop({ default: '' }) description!: string
117
- @Prop({ default: false }) isDarkMode!: boolean
118
-
119
- chartId = `chart${Math.round(Math.random() * 10000)}`
120
-
121
- mounted () {
122
- // eslint-disable-next-line @typescript-eslint/no-this-alias
123
- const self = this
124
-
125
- const chartOptions: TCustomChartOptions = {
126
- accessibility: {
127
- description: this.description,
24
+ const {
25
+ title = '',
26
+ data,
27
+ formatterFunc = null,
28
+ type,
29
+ yAxisTitle = null,
30
+ max = null,
31
+ hideAverageLine,
32
+ size = 'normal',
33
+ barColor = null,
34
+ description = '',
35
+ isDarkMode,
36
+ } = defineProps<{
37
+ title?: string
38
+ data: Highcharts.PointOptionsObject[]
39
+ formatterFunc?: Highcharts.FormatterCallbackFunction<Highcharts.AxisLabelsFormatterContextObject> | null
40
+ type: 'percent' | 'distribution'
41
+ yAxisTitle?: string | null
42
+ max?: number | null
43
+ hideAverageLine?: boolean
44
+ size?: 'normal' | 'small'
45
+ barColor?: string | null
46
+ description?: string
47
+ isDarkMode?: boolean
48
+ }>()
49
+
50
+ const chartId = `chart${Math.round(Math.random() * 10000)}`
51
+
52
+ onMounted(() => {
53
+ const chartOptions: TCustomChartOptions = {
54
+ accessibility: {
55
+ description: description,
56
+ },
57
+ tooltip: {
58
+ formatter: function () {
59
+ return String(this.y)
128
60
  },
129
- tooltip: {
130
- formatter: function () {
131
- return String(this.y)
61
+ },
62
+ legend: {
63
+ enabled: false,
64
+ },
65
+ credits: {
66
+ enabled: false,
67
+ },
68
+ chart: {
69
+ type: 'column',
70
+ spacingLeft: 0,
71
+ spacingRight: 0,
72
+ spacingBottom: 6,
73
+ backgroundColor: 'transparent',
74
+ },
75
+ title: {
76
+ text: title,
77
+ align: 'left',
78
+ style: {
79
+ color: !isDarkMode ? BrandColors.brandBlack : BrandColors.fog,
80
+ },
81
+ },
82
+ xAxis: {
83
+ tickLength: 0,
84
+ type: 'category',
85
+ },
86
+ yAxis: {
87
+ min: 0,
88
+ max: max,
89
+ opposite: true,
90
+ labels: {
91
+ formatter: formatterFunc || function () {
92
+ return String(this.value)
132
93
  },
133
94
  },
134
- legend: {
135
- enabled: false,
95
+ title: {
96
+ text: yAxisTitle,
136
97
  },
137
- credits: {
138
- enabled: false,
98
+ },
99
+ colors: [
100
+ barColor
101
+ ? barColor || ''
102
+ : isDarkMode
103
+ ? BrandColors.grayBackground || ''
104
+ : BrandColors.brandBlack || '',
105
+ ],
106
+ plotOptions: {
107
+ series: {
108
+ groupPadding: 0.1,
109
+ pointPadding: 0,
139
110
  },
140
- chart: {
141
- type: 'column',
142
- spacingLeft: 0,
143
- spacingRight: 0,
144
- spacingBottom: 6,
145
- backgroundColor: 'transparent',
111
+ column: {
112
+ minPointLength: 3,
113
+ maxPointWidth: 100,
114
+ borderWidth: 0,
115
+ borderRadiusTopLeft: 3,
116
+ borderRadiusTopRight: 3,
146
117
  },
147
- title: {
148
- text: this.title,
149
- align: 'left',
150
- style: {
151
- color: !this.isDarkMode ? BrandColors.brandBlack : BrandColors.fog,
118
+ },
119
+ series: [
120
+ {
121
+ type: 'column',
122
+ data: data,
123
+ borderColor: barColor
124
+ ? barColor
125
+ : isDarkMode
126
+ ? BrandColors.grayBackground
127
+ : BrandColors.brandBlack,
128
+ states: {
129
+ hover: {
130
+ borderColor: BrandColors.bananaBread,
131
+ color: BrandColors.bananaBread,
132
+ },
152
133
  },
153
134
  },
154
- xAxis: {
155
- tickLength: 0,
156
- type: 'category',
135
+ ],
136
+ }
137
+
138
+ if (type === 'percent') {
139
+ chartOptions.tooltip = {
140
+ useHTML: true,
141
+ borderWidth: 0,
142
+ padding: 0,
143
+ borderRadius: 12,
144
+ backgroundColor: 'rgba(28, 47, 60, 0.95)',
145
+ shadow: false,
146
+ style: {
147
+ fontFamily: '\'Avenir Next\', \'Muli\', sans-serif',
157
148
  },
158
- yAxis: {
159
- min: 0,
160
- max: this.max,
161
- opposite: true,
162
- labels: {
163
- formatter: this.formatterFunc || function () {
164
- return String(this.value)
165
- },
166
- },
167
- title: {
168
- text: this.yAxisTitle,
169
- },
149
+ formatter: function () {
150
+ const customInfo = (this.point as unknown as { info: string }).info
151
+ return `
152
+ <div class="uikit-bar__tooltip">
153
+ <div class="uikit-bar__tooltip-percent">${this.y}%</div>
154
+ ${customInfo ? `<div class="uikit-bar__tooltip-date">${customInfo}</div>` : ''}
155
+ </div>
156
+ `
170
157
  },
171
- colors: [
172
- this.barColor
173
- ? this.barColor || ''
174
- : this.isDarkMode
175
- ? BrandColors.grayBackground || ''
176
- : BrandColors.brandBlack || '',
177
- ],
178
- plotOptions: {
179
- series: {
180
- groupPadding: 0.1,
181
- pointPadding: 0,
182
- },
183
- column: {
184
- minPointLength: 3,
185
- maxPointWidth: 100,
186
- borderWidth: 0,
187
- borderRadiusTopLeft: 3,
188
- borderRadiusTopRight: 3,
189
- },
158
+ }
159
+ chartOptions.xAxis = {
160
+ tickLength: 0,
161
+ lineColor: !isDarkMode ? BrandColors.fog : BrandColors.ash,
162
+ labels: {
163
+ enabled: false,
190
164
  },
191
- series: [
192
- {
193
- type: 'column',
194
- data: this.data,
195
- borderColor: this.barColor
196
- ? this.barColor
197
- : this.isDarkMode
198
- ? BrandColors.grayBackground
199
- : BrandColors.brandBlack,
200
- states: {
201
- hover: {
202
- borderColor: BrandColors.bananaBread,
203
- color: BrandColors.bananaBread,
204
- },
205
- },
206
- },
207
- ],
208
165
  }
209
-
210
- if (this.type === 'percent') {
211
- chartOptions.tooltip = {
212
- useHTML: true,
213
- borderWidth: 0,
214
- padding: 0,
215
- borderRadius: 12,
216
- backgroundColor: 'rgba(28, 47, 60, 0.95)',
217
- shadow: false,
218
- style: {
219
- fontFamily: '\'Avenir Next\', \'Muli\', sans-serif',
220
- },
221
- formatter: function () {
222
- const customInfo = (this.point as unknown as { info: string }).info
223
- return `
224
- <div class="uikit-bar__tooltip">
225
- <div class="uikit-bar__tooltip-percent">${this.y}%</div>
226
- ${customInfo ? `<div class="uikit-bar__tooltip-date">${customInfo}</div>` : ''}
227
- </div>
228
- `
229
- },
230
- }
231
- chartOptions.xAxis = {
232
- tickLength: 0,
233
- lineColor: !this.isDarkMode ? BrandColors.fog : BrandColors.ash,
234
- labels: {
235
- enabled: false,
236
- },
237
- }
238
- chartOptions.yAxis = {
239
- min: 0,
240
- max: 100,
241
- opposite: true,
242
- gridLineColor: !this.isDarkMode ? BrandColors.fog : BrandColors.ash,
243
- plotLines: (this.data.length > 1 && !this.hideAverageLine) ? [
166
+ chartOptions.yAxis = {
167
+ min: 0,
168
+ max: 100,
169
+ opposite: true,
170
+ gridLineColor: !isDarkMode ? BrandColors.fog : BrandColors.ash,
171
+ plotLines: (data.length > 1 && !hideAverageLine)
172
+ ? [
244
173
  {
245
174
  dashStyle: 'Dash',
246
175
  value: Math.round(
247
- (this.data.reduce((accum, data) => accum + Number(data.y), 0) / this.data.length)
176
+ (data.reduce((accum, d) => accum + Number(d.y), 0) / data.length)
248
177
  ),
249
178
  width: 2,
250
179
  zIndex: 5,
251
180
  color: BrandColors.electricViolet,
252
181
  },
253
- ] : [],
254
- labels: {
255
- useHTML: true,
256
- y: 4,
257
- style: {
258
- textAlign: 'right',
259
- color: this.isDarkMode ? 'rgba(255, 255, 255, 0.85)' : BrandColors.ash,
260
- },
261
- formatter: this.formatterFunc || function () {
262
- if (this.value === 0) {
263
- return `${String(this.value)}%`
264
- }
265
- return `
266
- <div>${String(this.value)}%</div>
267
- <div class="
268
- uikit-bar__label-circle
269
- ${self.getScoreColor(Number(this.value))}
270
- " />
271
- `
272
- },
182
+ ]
183
+ : [],
184
+ labels: {
185
+ useHTML: true,
186
+ y: 4,
187
+ style: {
188
+ textAlign: 'right',
189
+ color: isDarkMode ? 'rgba(255, 255, 255, 0.85)' : BrandColors.ash,
273
190
  },
274
- tickPositions: [ 0, 50, 75, 100 ],
275
- title: {
276
- text: null,
191
+ formatter: formatterFunc || function () {
192
+ if (this.value === 0) {
193
+ return `${String(this.value)}%`
194
+ }
195
+ return `
196
+ <div>${String(this.value)}%</div>
197
+ <div class="
198
+ uikit-bar__label-circle
199
+ ${getScoreColor(Number(this.value))}
200
+ " />
201
+ `
277
202
  },
278
- }
203
+ },
204
+ tickPositions: [ 0, 50, 75, 100 ],
205
+ title: {
206
+ text: null,
207
+ },
279
208
  }
209
+ }
280
210
 
281
- if (this.size === 'small') {
282
- chartOptions.plotOptions.column = {
283
- minPointLength: 3,
284
- maxPointWidth: 100,
285
- borderRadiusTopLeft: 8,
286
- borderRadiusTopRight: 8,
287
- }
288
- chartOptions.yAxis = {
289
- ...(chartOptions.yAxis as Highcharts.YAxisOptions || {}),
290
- labels: {
291
- ...((chartOptions.yAxis as Highcharts.YAxisOptions)?.labels),
292
- formatter: function () {
293
- return `${String(this.value)}%`
294
- },
211
+ if (size === 'small') {
212
+ chartOptions.plotOptions.column = {
213
+ minPointLength: 3,
214
+ maxPointWidth: 100,
215
+ borderRadiusTopLeft: 8,
216
+ borderRadiusTopRight: 8,
217
+ }
218
+ chartOptions.yAxis = {
219
+ ...(chartOptions.yAxis as Highcharts.YAxisOptions || {}),
220
+ labels: {
221
+ ...((chartOptions.yAxis as Highcharts.YAxisOptions)?.labels),
222
+ formatter: function () {
223
+ return `${String(this.value)}%`
295
224
  },
296
- }
225
+ },
297
226
  }
298
-
299
- const renderedChart = chart(this.chartId, chartOptions)
300
- this.$nextTick(() => {
301
- renderedChart.reflow()
302
- })
303
227
  }
304
228
 
305
- getScoreColor (score: number) {
306
- return score <= 50 ? 'red' : score < 75 ? 'yellow' : 'green'
307
- }
229
+ const renderedChart = chart(chartId, chartOptions)
230
+ nextTick(() => {
231
+ renderedChart.reflow()
232
+ })
233
+ })
234
+
235
+ const getScoreColor = (score: number) => {
236
+ return score <= 50 ? 'red' : score < 75 ? 'yellow' : 'green'
308
237
  }
309
238
  </script>
310
239
 
@@ -361,4 +290,4 @@ export default class Bar extends Vue {
361
290
  }
362
291
  }
363
292
  }
364
- </style>
293
+ </style>
@@ -2,77 +2,71 @@
2
2
  <div :id="chartId" class="uikit-pie" />
3
3
  </template>
4
4
 
5
- <script lang="ts">
6
- import { Component, Vue, Prop } from 'vue-facing-decorator'
5
+ <script setup lang="ts">
6
+ import { nextTick, onMounted } from 'vue'
7
7
  import Highcharts, { chart } from 'highcharts'
8
8
  import BrandColors from '../../pocketprep-export.module.scss'
9
9
 
10
- @Component
11
- export default class Pie extends Vue {
12
- @Prop({ default: '' }) title!: string
13
- @Prop() data!: Highcharts.PointOptionsObject[]
14
- @Prop() formatterFunc!:
15
- Highcharts.FormatterCallbackFunction<Highcharts.AxisLabelsFormatterContextObject>
16
- @Prop() type!: 'percent' | 'distribution'
17
- @Prop({ default: null }) yAxisTitle!: string
18
- @Prop({ default: null }) max!: number
19
- @Prop({ default: 'normal' }) size!: 'normal' | 'small'
10
+ const {
11
+ data,
12
+ } = defineProps<{
13
+ data: Highcharts.PointOptionsObject[]
14
+ }>()
20
15
 
21
- chartId = `chart${Math.round(Math.random() * 10000)}`
16
+ const chartId = `chart${Math.round(Math.random() * 10000)}`
22
17
 
23
- mounted () {
24
- const chartOptions: Highcharts.Options = {
25
- chart: {
26
- plotShadow: false,
27
- type: 'pie',
28
- margin: [ 0, 0, 0, 0 ],
29
- spacing: [ 0, 0, 0, 0 ],
30
- },
31
- title: undefined,
32
- tooltip: {
33
- enabled: false,
34
- },
35
- plotOptions: {
36
- pie: {
37
- slicedOffset: 0,
38
- allowPointSelect: false,
39
- size: '100%',
40
- dataLabels: {
41
- enabled: false,
18
+ onMounted(() => {
19
+ const chartOptions: Highcharts.Options = {
20
+ chart: {
21
+ plotShadow: false,
22
+ type: 'pie',
23
+ margin: [ 0, 0, 0, 0 ],
24
+ spacing: [ 0, 0, 0, 0 ],
25
+ },
26
+ title: undefined,
27
+ tooltip: {
28
+ enabled: false,
29
+ },
30
+ plotOptions: {
31
+ pie: {
32
+ slicedOffset: 0,
33
+ allowPointSelect: false,
34
+ size: '100%',
35
+ dataLabels: {
36
+ enabled: false,
37
+ },
38
+ states: {
39
+ inactive: {
40
+ opacity: 1,
42
41
  },
43
- states: {
44
- inactive: {
45
- opacity: 1,
46
- },
47
- hover: {
48
- enabled: false,
49
- },
42
+ hover: {
43
+ enabled: false,
50
44
  },
51
45
  },
52
- series: {
53
- color: BrandColors.brandBlue,
54
- borderWidth: 3,
55
- },
56
46
  },
57
- series: [{
58
- colors: [
59
- BrandColors.green || '',
60
- BrandColors.butterscotch || '',
61
- BrandColors.electricViolet || '',
62
- BrandColors.brandBlue || '',
63
- ],
64
- type: 'pie',
65
- data: this.data,
66
- }],
67
- }
47
+ series: {
48
+ color: BrandColors.brandBlue,
49
+ borderWidth: 3,
50
+ },
51
+ },
52
+ series: [{
53
+ colors: [
54
+ BrandColors.green || '',
55
+ BrandColors.butterscotch || '',
56
+ BrandColors.electricViolet || '',
57
+ BrandColors.brandBlue || '',
58
+ ],
59
+ type: 'pie',
60
+ data: data,
61
+ }],
62
+ }
68
63
 
69
- const pieChart = chart(this.chartId, chartOptions)
64
+ const pieChart = chart(chartId, chartOptions)
70
65
 
71
- this.$nextTick(() => {
72
- pieChart.reflow()
73
- })
74
- }
75
- }
66
+ nextTick(() => {
67
+ pieChart.reflow()
68
+ })
69
+ })
76
70
  </script>
77
71
 
78
72
  <style lang="scss">
@@ -102,4 +96,4 @@ export default class Pie extends Vue {
102
96
  display: none;
103
97
  }
104
98
  }
105
- </style>
99
+ </style>