Skip to content

Commit 474d4f9

Browse files
committed
chore: css parent defined
1 parent 1e1c066 commit 474d4f9

File tree

6 files changed

+335
-314
lines changed

6 files changed

+335
-314
lines changed

src/components/charts/ChartCard.tsx

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
ButtonStyleType,
2020
ButtonVariantType,
2121
ComponentSizeType,
22+
handleAnalyticsEvent,
2223
Icon,
2324
noop,
2425
stopPropagation,
@@ -54,15 +55,18 @@ const ChartCard = ({
5455
const addChartTab = (e): void => {
5556
stopPropagation(e)
5657
addChart(chart.id)
58+
handleAnalyticsEvent({ category: 'Chart store add icon', action: 'CS_BULK_DEPLOY_ADD_CHART' })
5759
}
5860

5961
const removeChartTab = (e): void => {
6062
stopPropagation(e)
6163
subtractChart(chart.id)
64+
handleAnalyticsEvent({ category: 'Chart store remove icon', action: 'CS_BULK_DEPLOY_REMOVE_CHART' })
6265
}
6366

6467
const onClickChartSelect = (): void => {
6568
onClick(chart.id)
69+
handleAnalyticsEvent({ category: 'Chart store card', action: 'CS_CHART_CARD_CLICKED' })
6670
}
6771

6872
const renderAddIcon = () => (
@@ -74,7 +78,7 @@ const ChartCard = ({
7478
variant={ButtonVariantType.borderLess}
7579
size={ComponentSizeType.small}
7680
style={ButtonStyleType.default}
77-
ariaLabel="Add charts to deploy"
81+
ariaLabel="Add chart to selection"
7882
/>
7983
</div>
8084
)
@@ -88,7 +92,7 @@ const ChartCard = ({
8892
size={ComponentSizeType.small}
8993
style={ButtonStyleType.negativeGrey}
9094
showAriaLabelInTippy={selectedCount > 0}
91-
ariaLabel="Remove charts from selection"
95+
ariaLabel="Remove chart from selection"
9296
/>
9397
)
9498

@@ -102,6 +106,15 @@ const ChartCard = ({
102106
</div>
103107
)
104108

109+
const getDescriptionTruncate = () => {
110+
if (isListView) {
111+
return 'dc__truncate--clamp-4'
112+
}
113+
114+
if (chart.deprecated) return 'dc__truncate'
115+
return 'dc__truncate--clamp-2'
116+
}
117+
105118
const renderCardInfo = () => (
106119
<div className="flexbox-col flex-grow-1 dc__gap-8">
107120
<div className="flexbox-col dc__gap-2">
@@ -118,7 +131,7 @@ const ChartCard = ({
118131
{chart.deprecated && renderDeprecatedWarning()}
119132
</div>
120133

121-
<span className={`fw-4 fs-13 lh-20 ${chart.deprecated ? 'dc__truncate' : 'dc__truncate--clamp-2'}`}>
134+
<span className={`fw-4 fs-13 lh-20 ${getDescriptionTruncate()}`}>
122135
{chart.description || 'No description'}
123136
</span>
124137
</div>

src/components/charts/ChartHeaderFilters.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ const ChartHeaderFilter = ({
3737
setIsGrid,
3838
chartCategoryIds,
3939
setChartCategoryIds,
40+
chartStoreRef,
4041
}: ChartHeaderFilterProps) => {
4142
const match = useRouteMatch()
4243
const history = useHistory()
@@ -168,21 +169,27 @@ const ChartHeaderFilter = ({
168169
}
169170
}
170171

172+
const getScrollToInitial = () => {
173+
chartStoreRef.current?.scrollTo({ top: 0, behavior: 'smooth' })
174+
}
175+
171176
const setGrid = (): void => {
172177
setIsGrid(true)
173-
handleAnalyticsEvent({category: 'Chart Store', action: 'CS_VIEW_GRID'})
178+
handleAnalyticsEvent({ category: 'Chart Store', action: 'CS_VIEW_GRID' })
179+
getScrollToInitial()
174180
}
175181

176182
const setList = (): void => {
177183
setIsGrid(false)
178-
handleAnalyticsEvent({category: 'Chart Store', action: 'CS_VIEW_LIST'})
184+
handleAnalyticsEvent({ category: 'Chart Store', action: 'CS_VIEW_LIST' })
185+
getScrollToInitial()
179186
}
180187

181188
const toggleDeprecated = (): void => {
182189
const value = (includeDeprecated + 1) % 2
183190
handleFilterChanges(value, CHART_KEYS.DEPRECATED)
184191
if (value) {
185-
handleAnalyticsEvent({category: 'Chart Store', action: 'CS_SHOW_DEPRECATED'})
192+
handleAnalyticsEvent({ category: 'Chart Store', action: 'CS_SHOW_DEPRECATED' })
186193
}
187194
}
188195

0 commit comments

Comments
 (0)