@topkit/analytics-charts 1.1.4 → 1.1.5-alpha-fix-alpha-packages.2603

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 (161) hide show
  1. package/{dist-package/AnalyticsChart → AnalyticsChart}/AnalyticsChart.d.ts +0 -0
  2. package/{dist-package/AnalyticsChart → AnalyticsChart}/AnalyticsChart.js +0 -0
  3. package/{dist-package/AnalyticsChart → AnalyticsChart}/AnalyticsChart.js.map +0 -0
  4. package/{dist-package/AnalyticsChart → AnalyticsChart}/index.d.ts +0 -0
  5. package/{dist-package/AnalyticsChart → AnalyticsChart}/index.js +0 -0
  6. package/{dist-package/AnalyticsChart → AnalyticsChart}/index.js.map +0 -0
  7. package/{dist-package/CategoriesChart → CategoriesChart}/CategoriesChart.d.ts +0 -0
  8. package/{dist-package/CategoriesChart → CategoriesChart}/CategoriesChart.js +0 -0
  9. package/{dist-package/CategoriesChart → CategoriesChart}/CategoriesChart.js.map +0 -0
  10. package/{dist-package/CategoriesChart → CategoriesChart}/index.d.ts +0 -0
  11. package/{dist-package/CategoriesChart → CategoriesChart}/index.js +0 -0
  12. package/{dist-package/CategoriesChart → CategoriesChart}/index.js.map +0 -0
  13. package/{dist-package/CategoriesChart → CategoriesChart}/types.d.ts +0 -0
  14. package/{dist-package/CategoriesChart → CategoriesChart}/types.js +0 -0
  15. package/{dist-package/CategoriesChart → CategoriesChart}/types.js.map +0 -0
  16. package/{dist-package/CategoriesChart → CategoriesChart}/utils/format-data/format-data.d.ts +0 -0
  17. package/{dist-package/CategoriesChart → CategoriesChart}/utils/format-data/format-data.js +0 -0
  18. package/{dist-package/CategoriesChart → CategoriesChart}/utils/format-data/format-data.js.map +0 -0
  19. package/{dist-package/CategoriesChart → CategoriesChart}/utils/format-data/index.d.ts +0 -0
  20. package/{dist-package/CategoriesChart → CategoriesChart}/utils/format-data/index.js +0 -0
  21. package/{dist-package/CategoriesChart → CategoriesChart}/utils/format-data/index.js.map +0 -0
  22. package/{dist-package/CategoriesChart → CategoriesChart}/utils/get-color/get-color.d.ts +0 -0
  23. package/{dist-package/CategoriesChart → CategoriesChart}/utils/get-color/get-color.js +0 -0
  24. package/{dist-package/CategoriesChart → CategoriesChart}/utils/get-color/get-color.js.map +0 -0
  25. package/{dist-package/CategoriesChart → CategoriesChart}/utils/get-color/index.d.ts +0 -0
  26. package/{dist-package/CategoriesChart → CategoriesChart}/utils/get-color/index.js +0 -0
  27. package/{dist-package/CategoriesChart → CategoriesChart}/utils/get-color/index.js.map +0 -0
  28. package/{dist-package/CategoriesChart → CategoriesChart}/utils/index.d.ts +0 -0
  29. package/{dist-package/CategoriesChart → CategoriesChart}/utils/index.js +0 -0
  30. package/{dist-package/CategoriesChart → CategoriesChart}/utils/index.js.map +0 -0
  31. package/{dist-package/CategoriesChartTooltip → CategoriesChartTooltip}/CategoriesChartTooltip.d.ts +0 -0
  32. package/{dist-package/CategoriesChartTooltip → CategoriesChartTooltip}/CategoriesChartTooltip.js +0 -0
  33. package/{dist-package/CategoriesChartTooltip → CategoriesChartTooltip}/CategoriesChartTooltip.js.map +0 -0
  34. package/{dist-package/CategoriesChartTooltip → CategoriesChartTooltip}/index.d.ts +0 -0
  35. package/{dist-package/CategoriesChartTooltip → CategoriesChartTooltip}/index.js +0 -0
  36. package/{dist-package/CategoriesChartTooltip → CategoriesChartTooltip}/index.js.map +0 -0
  37. package/{dist-package/CategoriesChartTooltip → CategoriesChartTooltip}/utils/get-display-texts/get-display-texts.d.ts +0 -0
  38. package/{dist-package/CategoriesChartTooltip → CategoriesChartTooltip}/utils/get-display-texts/get-display-texts.js +0 -0
  39. package/{dist-package/CategoriesChartTooltip → CategoriesChartTooltip}/utils/get-display-texts/get-display-texts.js.map +0 -0
  40. package/{dist-package/CategoriesChartTooltip → CategoriesChartTooltip}/utils/get-display-texts/index.d.ts +0 -0
  41. package/{dist-package/CategoriesChartTooltip → CategoriesChartTooltip}/utils/get-display-texts/index.js +0 -0
  42. package/{dist-package/CategoriesChartTooltip → CategoriesChartTooltip}/utils/get-display-texts/index.js.map +0 -0
  43. package/{dist-package/CategoriesChartTooltip → CategoriesChartTooltip}/utils/index.d.ts +0 -0
  44. package/{dist-package/CategoriesChartTooltip → CategoriesChartTooltip}/utils/index.js +0 -0
  45. package/{dist-package/CategoriesChartTooltip → CategoriesChartTooltip}/utils/index.js.map +0 -0
  46. package/{dist-package/config.d.ts → config.d.ts} +0 -0
  47. package/{dist-package/config.js → config.js} +0 -0
  48. package/{dist-package/config.js.map → config.js.map} +0 -0
  49. package/{dist-package/index.d.ts → index.d.ts} +0 -0
  50. package/{dist-package/index.js → index.js} +0 -0
  51. package/{dist-package/index.js.map → index.js.map} +0 -0
  52. package/package.json +6 -4
  53. package/{dist-package/utils → utils}/format-y-axis-tick/format-y-axis-tick.d.ts +0 -0
  54. package/{dist-package/utils → utils}/format-y-axis-tick/format-y-axis-tick.js +0 -0
  55. package/{dist-package/utils → utils}/format-y-axis-tick/format-y-axis-tick.js.map +0 -0
  56. package/{dist-package/utils → utils}/format-y-axis-tick/index.d.ts +0 -0
  57. package/{dist-package/utils → utils}/format-y-axis-tick/index.js +0 -0
  58. package/{dist-package/utils → utils}/format-y-axis-tick/index.js.map +0 -0
  59. package/{dist-package/utils → utils}/generate-reference-key/generate-reference-key.d.ts +0 -0
  60. package/{dist-package/utils → utils}/generate-reference-key/generate-reference-key.js +0 -0
  61. package/{dist-package/utils → utils}/generate-reference-key/generate-reference-key.js.map +0 -0
  62. package/{dist-package/utils → utils}/generate-reference-key/index.d.ts +0 -0
  63. package/{dist-package/utils → utils}/generate-reference-key/index.js +0 -0
  64. package/{dist-package/utils → utils}/generate-reference-key/index.js.map +0 -0
  65. package/{dist-package/utils → utils}/get-x-axis-ticks/get-x-axis-ticks.d.ts +0 -0
  66. package/{dist-package/utils → utils}/get-x-axis-ticks/get-x-axis-ticks.js +0 -0
  67. package/{dist-package/utils → utils}/get-x-axis-ticks/get-x-axis-ticks.js.map +0 -0
  68. package/{dist-package/utils → utils}/get-x-axis-ticks/index.d.ts +0 -0
  69. package/{dist-package/utils → utils}/get-x-axis-ticks/index.js +0 -0
  70. package/{dist-package/utils → utils}/get-x-axis-ticks/index.js.map +0 -0
  71. package/{dist-package/utils → utils}/get-y-axis-ticks/get-y-axis-ticks.d.ts +0 -0
  72. package/{dist-package/utils → utils}/get-y-axis-ticks/get-y-axis-ticks.js +0 -0
  73. package/{dist-package/utils → utils}/get-y-axis-ticks/get-y-axis-ticks.js.map +0 -0
  74. package/{dist-package/utils → utils}/get-y-axis-ticks/index.d.ts +0 -0
  75. package/{dist-package/utils → utils}/get-y-axis-ticks/index.js +0 -0
  76. package/{dist-package/utils → utils}/get-y-axis-ticks/index.js.map +0 -0
  77. package/{dist-package/utils → utils}/index.d.ts +0 -0
  78. package/{dist-package/utils → utils}/index.js +0 -0
  79. package/{dist-package/utils → utils}/index.js.map +0 -0
  80. package/{dist-package/utils → utils}/to-chart-format/index.d.ts +0 -0
  81. package/{dist-package/utils → utils}/to-chart-format/index.js +0 -0
  82. package/{dist-package/utils → utils}/to-chart-format/index.js.map +0 -0
  83. package/{dist-package/utils → utils}/to-chart-format/to-chart-format.d.ts +0 -0
  84. package/{dist-package/utils → utils}/to-chart-format/to-chart-format.js +0 -0
  85. package/{dist-package/utils → utils}/to-chart-format/to-chart-format.js.map +0 -0
  86. package/{dist-package/utils → utils}/to-highlight-format/index.d.ts +0 -0
  87. package/{dist-package/utils → utils}/to-highlight-format/index.js +0 -0
  88. package/{dist-package/utils → utils}/to-highlight-format/index.js.map +0 -0
  89. package/{dist-package/utils → utils}/to-highlight-format/to-highlight-format.d.ts +0 -0
  90. package/{dist-package/utils → utils}/to-highlight-format/to-highlight-format.js +0 -0
  91. package/{dist-package/utils → utils}/to-highlight-format/to-highlight-format.js.map +0 -0
  92. package/{dist-package/utils → utils}/to-line-config-format/index.d.ts +0 -0
  93. package/{dist-package/utils → utils}/to-line-config-format/index.js +0 -0
  94. package/{dist-package/utils → utils}/to-line-config-format/index.js.map +0 -0
  95. package/{dist-package/utils → utils}/to-line-config-format/to-line-config-format.d.ts +0 -0
  96. package/{dist-package/utils → utils}/to-line-config-format/to-line-config-format.js +0 -0
  97. package/{dist-package/utils → utils}/to-line-config-format/to-line-config-format.js.map +0 -0
  98. package/CHANGELOG.md +0 -189
  99. package/dist-package/README.md +0 -5
  100. package/dist-package/package.json +0 -36
  101. package/src/AnalyticsChart/AnalyticsChart.tsx +0 -85
  102. package/src/AnalyticsChart/__image_snapshots__/analyticschart-custom-format-xaxis-label-snap.png +0 -0
  103. package/src/AnalyticsChart/__image_snapshots__/analyticschart-default-snap.png +0 -0
  104. package/src/AnalyticsChart/__image_snapshots__/analyticschart-granularity-snap.png +0 -0
  105. package/src/AnalyticsChart/__image_snapshots__/analyticschart-highlights-snap.png +0 -0
  106. package/src/AnalyticsChart/__image_snapshots__/analyticschart-multiple-snap.png +0 -0
  107. package/src/AnalyticsChart/__image_snapshots__/analyticschart-null-values-snap.png +0 -0
  108. package/src/AnalyticsChart/__image_snapshots__/analyticschart-reference-lines-snap.png +0 -0
  109. package/src/AnalyticsChart/index.ts +0 -2
  110. package/src/AnalyticsChart/story/Default.example.tsx +0 -44
  111. package/src/AnalyticsChart/story/FormatLabel.example.tsx +0 -46
  112. package/src/AnalyticsChart/story/Granularity.example.tsx +0 -104
  113. package/src/AnalyticsChart/story/Highlights.example.tsx +0 -54
  114. package/src/AnalyticsChart/story/Multiple.example.tsx +0 -72
  115. package/src/AnalyticsChart/story/NullValues.example.tsx +0 -103
  116. package/src/AnalyticsChart/story/ReferenceLines.example.tsx +0 -105
  117. package/src/AnalyticsChart/story/index.jsx +0 -74
  118. package/src/CategoriesChart/CategoriesChart.tsx +0 -51
  119. package/src/CategoriesChart/__image_snapshots__/categorieschart-default-snap.png +0 -0
  120. package/src/CategoriesChart/index.ts +0 -2
  121. package/src/CategoriesChart/story/Default.example.tsx +0 -234
  122. package/src/CategoriesChart/story/index.jsx +0 -61
  123. package/src/CategoriesChart/types.ts +0 -22
  124. package/src/CategoriesChart/utils/format-data/format-data.ts +0 -23
  125. package/src/CategoriesChart/utils/format-data/index.ts +0 -1
  126. package/src/CategoriesChart/utils/format-data/test.ts +0 -99
  127. package/src/CategoriesChart/utils/get-color/get-color.ts +0 -37
  128. package/src/CategoriesChart/utils/get-color/index.ts +0 -1
  129. package/src/CategoriesChart/utils/get-color/test.ts +0 -65
  130. package/src/CategoriesChart/utils/index.ts +0 -2
  131. package/src/CategoriesChartTooltip/CategoriesChartTooltip.tsx +0 -57
  132. package/src/CategoriesChartTooltip/index.ts +0 -1
  133. package/src/CategoriesChartTooltip/test.tsx +0 -27
  134. package/src/CategoriesChartTooltip/utils/get-display-texts/get-display-texts.ts +0 -61
  135. package/src/CategoriesChartTooltip/utils/get-display-texts/index.ts +0 -1
  136. package/src/CategoriesChartTooltip/utils/get-display-texts/test.ts +0 -81
  137. package/src/CategoriesChartTooltip/utils/index.ts +0 -1
  138. package/src/config.ts +0 -3
  139. package/src/index.ts +0 -3
  140. package/src/utils/format-y-axis-tick/format-y-axis-tick.ts +0 -23
  141. package/src/utils/format-y-axis-tick/index.ts +0 -1
  142. package/src/utils/format-y-axis-tick/test.ts +0 -13
  143. package/src/utils/generate-reference-key/generate-reference-key.ts +0 -4
  144. package/src/utils/generate-reference-key/index.ts +0 -1
  145. package/src/utils/get-x-axis-ticks/get-x-axis-ticks.ts +0 -24
  146. package/src/utils/get-x-axis-ticks/index.ts +0 -1
  147. package/src/utils/get-x-axis-ticks/test.ts +0 -37
  148. package/src/utils/get-y-axis-ticks/get-y-axis-ticks.ts +0 -25
  149. package/src/utils/get-y-axis-ticks/index.ts +0 -1
  150. package/src/utils/get-y-axis-ticks/test.ts +0 -22
  151. package/src/utils/index.ts +0 -7
  152. package/src/utils/to-chart-format/index.ts +0 -1
  153. package/src/utils/to-chart-format/test.ts +0 -200
  154. package/src/utils/to-chart-format/to-chart-format.ts +0 -60
  155. package/src/utils/to-highlight-format/index.ts +0 -1
  156. package/src/utils/to-highlight-format/test.ts +0 -56
  157. package/src/utils/to-highlight-format/to-highlight-format.ts +0 -26
  158. package/src/utils/to-line-config-format/index.ts +0 -1
  159. package/src/utils/to-line-config-format/test.ts +0 -50
  160. package/src/utils/to-line-config-format/to-line-config-format.ts +0 -19
  161. package/tsconfig.build.json +0 -7
@@ -1,234 +0,0 @@
1
- import React from 'react'
2
- import { DataItem, CategoriesChart } from '@topkit/analytics-charts'
3
-
4
- const CHART_DATA: DataItem[] = [
5
- {
6
- id: 'claimed',
7
- values: [
8
- {
9
- id: 'team',
10
- values: [
11
- {
12
- id: 'viable',
13
- value: 252
14
- },
15
- {
16
- id: 'bad_leads',
17
- value: 0
18
- },
19
- {
20
- id: 'rejected',
21
- value: 11
22
- }
23
- ]
24
- },
25
- {
26
- id: 'user',
27
- values: [
28
- {
29
- id: 'viable',
30
- value: 595
31
- },
32
- {
33
- id: 'bad_leads',
34
- value: 0
35
- },
36
- {
37
- id: 'rejected',
38
- value: 24
39
- }
40
- ]
41
- }
42
- ]
43
- },
44
- {
45
- id: 'contacted',
46
- values: [
47
- {
48
- id: 'team',
49
- values: [
50
- {
51
- id: 'contacted',
52
- value: 189
53
- }
54
- ]
55
- },
56
- {
57
- id: 'user',
58
- values: [
59
- {
60
- id: 'contacted',
61
- value: 421
62
- }
63
- ]
64
- }
65
- ]
66
- },
67
- {
68
- id: 'approved',
69
- values: [
70
- {
71
- id: 'team',
72
- values: [
73
- {
74
- id: 'approved',
75
- value: 29
76
- }
77
- ]
78
- },
79
- {
80
- id: 'user',
81
- values: [
82
- {
83
- id: 'approved',
84
- value: 27
85
- }
86
- ]
87
- }
88
- ]
89
- },
90
- {
91
- id: 'verified',
92
- values: [
93
- {
94
- id: 'team',
95
- values: [
96
- {
97
- id: 'verified',
98
- value: 22
99
- }
100
- ]
101
- },
102
- {
103
- id: 'user',
104
- values: [
105
- {
106
- id: 'verified',
107
- value: 21
108
- }
109
- ]
110
- }
111
- ]
112
- },
113
- {
114
- id: 'with_deposit',
115
- values: [
116
- {
117
- id: 'team',
118
- values: [
119
- {
120
- id: 'with_deposit',
121
- value: 16
122
- }
123
- ]
124
- },
125
- {
126
- id: 'user',
127
- values: [
128
- {
129
- id: 'with_deposit',
130
- value: 17
131
- }
132
- ]
133
- }
134
- ]
135
- },
136
- {
137
- id: 'with_active_engagement',
138
- values: [
139
- {
140
- id: 'team',
141
- values: [
142
- {
143
- id: 'with_active_engagement',
144
- value: 7
145
- }
146
- ]
147
- },
148
- {
149
- id: 'user',
150
- values: [
151
- {
152
- id: 'with_active_engagement',
153
- value: 5
154
- }
155
- ]
156
- }
157
- ]
158
- }
159
- ]
160
-
161
- const CHART_LABELS = {
162
- claimed: 'Claimed',
163
- contacted: 'Contacted',
164
- approved: 'Approved',
165
- verified: 'Verified',
166
- with_deposit: 'With a Deposit',
167
- with_active_engagement: 'With an Active Engagement'
168
- }
169
-
170
- const CHART_TOOLTIPS = {
171
- claimed: {
172
- team: {
173
- viable: 'Team Viable Average',
174
- bad_leads: 'Team Bad Leads (Unresponsive) Average',
175
- rejected: 'Team Removed Average'
176
- },
177
- user: {
178
- viable: 'Your Viable',
179
- bad_leads: 'Your Bad Leads (Unresponsive)',
180
- rejected: 'Your Removed'
181
- }
182
- },
183
- contacted: {
184
- team: {
185
- contacted: 'Team Contacted Average'
186
- },
187
- user: {
188
- contacted: 'Your Contacted'
189
- }
190
- },
191
- approved: {
192
- team: {
193
- approved: 'Team Approved Average'
194
- },
195
- user: {
196
- approved: 'Your Approved'
197
- }
198
- },
199
- verified: {
200
- team: {
201
- verified: 'Team Verified Average'
202
- },
203
- user: {
204
- verified: 'Your Verified'
205
- }
206
- },
207
- with_deposit: {
208
- team: {
209
- with_deposit: 'Team With a Deposit Average'
210
- },
211
- user: {
212
- with_deposit: 'Your With a Deposit'
213
- }
214
- },
215
- with_active_engagement: {
216
- team: {
217
- with_active_engagement: 'Team With an Active Engagement Average'
218
- },
219
- user: {
220
- with_active_engagement: 'Your With an Active Engagement'
221
- }
222
- }
223
- }
224
-
225
- const Example = () => (
226
- <CategoriesChart
227
- data={CHART_DATA}
228
- labels={CHART_LABELS}
229
- tooltips={CHART_TOOLTIPS}
230
- width={720}
231
- />
232
- )
233
-
234
- export default Example
@@ -1,61 +0,0 @@
1
- import CategoriesChart from '../CategoriesChart'
2
- import PicassoBook from '~/.storybook/components/PicassoBook'
3
-
4
- const page = PicassoBook.section('Picasso Charts').createPage(
5
- 'CategoriesChart',
6
- 'Use BarChart with analytics data'
7
- )
8
-
9
- page.createTabChapter('Props').addComponentDocs({
10
- component: CategoriesChart,
11
- name: 'CategoriesChart',
12
- additionalDocs: Object.assign(
13
- {},
14
- {
15
- data: {
16
- name: 'data',
17
- type: {
18
- name: '[]',
19
- description: `{
20
- id: string
21
- values: [
22
- {
23
- id: 'team'
24
- values: Value[]
25
- },
26
- {
27
- id: 'user'
28
- values: Value[]
29
- }
30
- ]
31
- }`
32
- },
33
- description: 'A record of kipper data to be rendered as a bar chart',
34
- required: true
35
- },
36
- labels: {
37
- name: 'labels',
38
- type: {
39
- name: '{}',
40
- description: `Record<string, string>`
41
- },
42
- description: 'A record of labels from kipper data',
43
- required: true
44
- },
45
- tooltips: {
46
- name: 'tooltips',
47
- type: {
48
- name: '{}',
49
- description: 'Record<string, Record<string, Record<string, string>>>'
50
- },
51
- description: 'A record of tooltips data from kipper data',
52
- required: true
53
- }
54
- }
55
- )
56
- })
57
-
58
- page.createChapter().addExample('CategoriesChart/story/Default.example.tsx', {
59
- title: 'Default',
60
- delay: 500
61
- })
@@ -1,22 +0,0 @@
1
- export type Value = {
2
- id: string
3
- value: number
4
- }
5
-
6
- export type DataItem = {
7
- id: string
8
- values: [
9
- {
10
- id: string
11
- values: Value[]
12
- },
13
- {
14
- id: string
15
- values: Value[]
16
- }
17
- ]
18
- }
19
-
20
- export type LabelMap = Record<string, string>
21
-
22
- export type TooltipMap = Record<string, Record<string, Record<string, string>>>
@@ -1,23 +0,0 @@
1
- import { sum } from '@toptal/picasso/utils'
2
-
3
- import { DataItem, LabelMap } from '../../types'
4
-
5
- const formatData = (data: DataItem[], labels: LabelMap) => {
6
- return data.map(({ id, values }) => {
7
- const [team, user] = values
8
-
9
- const sumTeam = sum(team.values.map(({ value }) => value))
10
- const sumUser = sum(user.values.map(({ value }) => value))
11
-
12
- return {
13
- name: id,
14
- label: labels[id],
15
- value: {
16
- team: sumTeam,
17
- user: sumUser
18
- }
19
- }
20
- })
21
- }
22
-
23
- export default formatData
@@ -1 +0,0 @@
1
- export { default } from './format-data'
@@ -1,99 +0,0 @@
1
- import formatData from './format-data'
2
- import { DataItem } from '../../types'
3
-
4
- describe('formatData', () => {
5
- it('formats categories chart data', () => {
6
- const ORIGINAL_DATA: DataItem[] = [
7
- {
8
- id: 'claimed',
9
- values: [
10
- {
11
- id: 'team',
12
- values: [
13
- {
14
- id: 'viable',
15
- value: 252
16
- },
17
- {
18
- id: 'bad_leads',
19
- value: 0
20
- },
21
- {
22
- id: 'rejected',
23
- value: 11
24
- }
25
- ]
26
- },
27
- {
28
- id: 'user',
29
- values: [
30
- {
31
- id: 'viable',
32
- value: 595
33
- },
34
- {
35
- id: 'bad_leads',
36
- value: 0
37
- },
38
- {
39
- id: 'rejected',
40
- value: 24
41
- }
42
- ]
43
- }
44
- ]
45
- },
46
- {
47
- id: 'contacted',
48
- values: [
49
- {
50
- id: 'team',
51
- values: [
52
- {
53
- id: 'contacted',
54
- value: 189
55
- }
56
- ]
57
- },
58
- {
59
- id: 'user',
60
- values: [
61
- {
62
- id: 'contacted',
63
- value: 421
64
- }
65
- ]
66
- }
67
- ]
68
- }
69
- ]
70
-
71
- const CHART_LABELS = {
72
- claimed: 'Claimed',
73
- contacted: 'Contacted'
74
- }
75
-
76
- const EXPECTED_RESULT = [
77
- {
78
- name: 'claimed',
79
- label: 'Claimed',
80
- value: {
81
- team: 263,
82
- user: 619
83
- }
84
- },
85
- {
86
- name: 'contacted',
87
- label: 'Contacted',
88
- value: {
89
- team: 189,
90
- user: 421
91
- }
92
- }
93
- ]
94
-
95
- expect(formatData(ORIGINAL_DATA, CHART_LABELS)).toStrictEqual(
96
- EXPECTED_RESULT
97
- )
98
- })
99
- })
@@ -1,37 +0,0 @@
1
- import { palette } from '@toptal/picasso/utils'
2
-
3
- const DEFAULT_COLORS = [palette.blue.main, palette.blue.darker]
4
-
5
- const COLOR_MAP: Record<string, string[]> = {
6
- bad_leads: [palette.red.main, palette.red.main],
7
- paused: [palette.yellow.main, palette.yellow.main],
8
- removed: [palette.green.main, palette.green.main],
9
- collections: [palette.red.main, palette.red.main],
10
- pending: [palette.yellow.main, palette.yellow.main]
11
- }
12
-
13
- const BAD_RESULT_COLOR = palette.red.main
14
-
15
- const getColor = ({
16
- dataKey,
17
- entry
18
- }: {
19
- dataKey: string
20
- entry?: { name: string; value: { team: number; user: number } }
21
- }) => {
22
- if (!entry) {
23
- return DEFAULT_COLORS[0]
24
- }
25
-
26
- if (dataKey === 'team') {
27
- return COLOR_MAP[entry.name]?.[0] || DEFAULT_COLORS[0]
28
- }
29
-
30
- if (entry.value.team > entry.value.user && entry.name !== 'claimed') {
31
- return BAD_RESULT_COLOR
32
- }
33
-
34
- return COLOR_MAP[entry.name]?.[1] || DEFAULT_COLORS[1]
35
- }
36
-
37
- export default getColor
@@ -1 +0,0 @@
1
- export { default } from './get-color'
@@ -1,65 +0,0 @@
1
- import { palette } from '@toptal/picasso/utils'
2
-
3
- import getColor from './get-color'
4
-
5
- describe('getColor', () => {
6
- const TEAM_COLOR_CHECK_LIST = [
7
- ['claimed', palette.blue.main],
8
- ['bad_leads', palette.red.main],
9
- ['paused', palette.yellow.main],
10
- ['removed', palette.green.main],
11
- ['collections', palette.red.main],
12
- ['pending', palette.yellow.main]
13
- ]
14
-
15
- it.each(TEAM_COLOR_CHECK_LIST)(
16
- 'returns correct color for team under status of %s',
17
- (status, color) => {
18
- expect(
19
- getColor({
20
- dataKey: 'team',
21
- entry: { name: status, value: { team: 5, user: 6 } }
22
- })
23
- ).toBe(color)
24
- }
25
- )
26
-
27
- const USER_COLOR_CHECK_LIST = [
28
- ['claimed', palette.blue.darker],
29
- ['bad_leads', palette.red.main],
30
- ['paused', palette.yellow.main],
31
- ['removed', palette.green.main],
32
- ['collections', palette.red.main],
33
- ['pending', palette.yellow.main]
34
- ]
35
-
36
- it.each(USER_COLOR_CHECK_LIST)(
37
- 'returns correct color for user under status of %s',
38
- (status, color) => {
39
- expect(
40
- getColor({
41
- dataKey: 'user',
42
- entry: { name: status, value: { team: 5, user: 6 } }
43
- })
44
- ).toBe(color)
45
- }
46
- )
47
-
48
- it('renders bad result color when user value is lower than team value', () => {
49
- expect(
50
- getColor({
51
- dataKey: 'user',
52
- entry: { name: 'some status', value: { team: 5, user: 4 } }
53
- })
54
- ).toBe(palette.red.main)
55
- })
56
-
57
- it('renders normal color when user value is lower than team value and status is claimed', () => {
58
- expect(
59
- getColor({
60
- dataKey: 'user',
61
- entry: { name: 'claimed', value: { team: 5, user: 4 } }
62
- })
63
- ).toBe(palette.blue.darker)
64
- })
65
- })
@@ -1,2 +0,0 @@
1
- export { default as formatData } from './format-data'
2
- export { default as getColor } from './get-color'
@@ -1,57 +0,0 @@
1
- import React, { FC } from 'react'
2
- import { Paper, Container, Typography } from '@toptal/picasso'
3
-
4
- import { DataItem, TooltipMap } from '../CategoriesChart/types'
5
- import { getDisplayTexts } from './utils'
6
-
7
- export type Props = {
8
- active: boolean
9
- payload: { payload: { name: string; team: number; user: number } }[]
10
- tooltips: TooltipMap
11
- originalData: DataItem[]
12
- }
13
-
14
- const CategoriesChartTooltip: FC<Props> = ({
15
- active,
16
- payload,
17
- tooltips,
18
- originalData
19
- }) => {
20
- if (active && payload && payload.length > 0) {
21
- const currentData = originalData.find(
22
- ({ id: dataId }) => dataId === payload[0].payload.name
23
- )
24
-
25
- if (!currentData) {
26
- return null
27
- }
28
-
29
- const { teamTexts, userTexts } = getDisplayTexts({
30
- currentData,
31
- tooltips,
32
- currentPayload: payload[0].payload
33
- })
34
-
35
- return (
36
- <Paper data-testid='tooltip-content'>
37
- <Container padded='xsmall'>
38
- {teamTexts.map(({ key, label, value, color }) => (
39
- <Typography size='medium' style={{ color }} key={key}>
40
- {label}: {value}
41
- </Typography>
42
- ))}
43
-
44
- {userTexts.map(({ key, label, value, color }) => (
45
- <Typography size='medium' style={{ color }} key={key}>
46
- {label}: {value}
47
- </Typography>
48
- ))}
49
- </Container>
50
- </Paper>
51
- )
52
- }
53
-
54
- return null
55
- }
56
-
57
- export default CategoriesChartTooltip
@@ -1 +0,0 @@
1
- export { default } from './CategoriesChartTooltip'
@@ -1,27 +0,0 @@
1
- import React from 'react'
2
- import { render, screen, TestingPicasso } from '@toptal/picasso/test-utils'
3
-
4
- import CategoriesChartTooltip, { Props } from './CategoriesChartTooltip'
5
-
6
- const renderTooltip = (props: Partial<Props>) => {
7
- const defaultProps = {
8
- active: true,
9
- payload: [],
10
- tooltips: {},
11
- originalData: []
12
- }
13
-
14
- return render(
15
- <TestingPicasso>
16
- <CategoriesChartTooltip {...{ ...defaultProps, ...props }} />
17
- </TestingPicasso>
18
- )
19
- }
20
-
21
- describe('CategoriesChartTooltip', () => {
22
- it('renders nothing when not active', () => {
23
- renderTooltip({ active: false })
24
-
25
- expect(screen.queryByTestId('tooltip')).not.toBeInTheDocument()
26
- })
27
- })
@@ -1,61 +0,0 @@
1
- import { DataItem, Value, TooltipMap } from '../../../CategoriesChart/types'
2
- import { getColor } from '../../../CategoriesChart/utils'
3
-
4
- type CurrentPayload = { name: string; user: number; team: number }
5
-
6
- export type GetDisplayTextsParams = {
7
- currentData: DataItem
8
- tooltips: TooltipMap
9
- currentPayload: CurrentPayload
10
- }
11
-
12
- const getText = ({
13
- originalValues,
14
- currentPayload: { name, user, team },
15
- tooltips,
16
- dataKey
17
- }: {
18
- originalValues: Value[]
19
- currentPayload: CurrentPayload
20
- tooltips: TooltipMap
21
- dataKey: string
22
- }) =>
23
- originalValues
24
- .filter(({ value }) => !!value)
25
- .map(({ id, value }) => ({
26
- key: `${dataKey}-${id}`,
27
- label: tooltips[name][dataKey][id],
28
- value,
29
- color: getColor({
30
- dataKey,
31
- entry: { name, value: { user, team } }
32
- })
33
- }))
34
-
35
- const getDisplayTexts = ({
36
- currentData,
37
- tooltips,
38
- currentPayload
39
- }: GetDisplayTextsParams) => {
40
- const [
41
- { values: originalTeamValues },
42
- { values: originalUserValues }
43
- ] = currentData.values
44
-
45
- return {
46
- teamTexts: getText({
47
- originalValues: originalTeamValues,
48
- currentPayload,
49
- tooltips,
50
- dataKey: 'team'
51
- }),
52
- userTexts: getText({
53
- originalValues: originalUserValues,
54
- currentPayload,
55
- tooltips,
56
- dataKey: 'user'
57
- })
58
- }
59
- }
60
-
61
- export default getDisplayTexts
@@ -1 +0,0 @@
1
- export { default } from './get-display-texts'