11import { useState } from 'react' ;
22import isPropValid from '@emotion/is-prop-valid' ;
3+ import { useTheme } from '@emotion/react' ;
34import styled from '@emotion/styled' ;
45import { AnimatePresence , motion } from 'framer-motion' ;
56import type { LocationDescriptor } from 'history' ;
67
78import type { TagSegment } from 'sentry/actionCreators/events' ;
89import { Button } from 'sentry/components/core/button' ;
910import { Link } from 'sentry/components/core/link' ;
11+ import { Text } from 'sentry/components/core/text' ;
1012import { Tooltip } from 'sentry/components/core/tooltip' ;
1113import { IconChevron } from 'sentry/icons/iconChevron' ;
1214import { t } from 'sentry/locale' ;
@@ -19,7 +21,6 @@ import {appendExcludeTagValuesCondition} from 'sentry/utils/queryString';
1921import { useLocation } from 'sentry/utils/useLocation' ;
2022import useOrganization from 'sentry/utils/useOrganization' ;
2123
22- const COLORS = [ '#402A65' , '#694D99' , '#9A81C4' , '#BBA6DF' , '#EAE2F8' ] ;
2324const MAX_SEGMENTS = 4 ;
2425const TOOLTIP_DELAY = 800 ;
2526
@@ -36,7 +37,6 @@ type Props = {
3637} ;
3738
3839function TagFacetsDistributionMeter ( {
39- colors = COLORS ,
4040 segments,
4141 title,
4242 totalValues,
@@ -46,6 +46,8 @@ function TagFacetsDistributionMeter({
4646 expandByDefault,
4747 otherUrl,
4848} : Props ) {
49+ const theme = useTheme ( ) ;
50+ const colors = theme . chart . getColorPalette ( 4 ) ;
4951 const location = useLocation ( ) ;
5052 const organization = useOrganization ( ) ;
5153 const [ expanded , setExpanded ] = useState < boolean > ( ! ! expandByDefault ) ;
@@ -124,7 +126,7 @@ function TagFacetsDistributionMeter({
124126 { value . isOther ? (
125127 < OtherSegment
126128 aria-label = { t ( 'Other segment' ) }
127- color = { colors [ colors . length - 1 ] ! }
129+ color = { theme . chart . neutral }
128130 />
129131 ) : (
130132 < Segment
@@ -180,14 +182,12 @@ function TagFacetsDistributionMeter({
180182 onMouseLeave = { ( ) => setHoveredValue ( null ) }
181183 >
182184 < LegendDot
183- color = { colors [ segment . isOther ? colors . length - 1 : index ] ! }
185+ color = { segment . isOther ? theme . chart . neutral : colors [ index ] ! }
184186 focus = { focus }
185187 />
186188 < Tooltip skipWrapper delay = { TOOLTIP_DELAY } title = { segment . name } >
187189 < LegendText unfocus = { unfocus } >
188- { segment . name ?? (
189- < NotApplicableLabel > { t ( 'n/a' ) } </ NotApplicableLabel >
190- ) }
190+ { segment . name ?? < Text variant = "muted" > { t ( 'n/a' ) } </ Text > }
191191 </ LegendText >
192192 </ Tooltip >
193193 < LegendPercent > { `${ pctLabel } %` } </ LegendPercent >
@@ -282,7 +282,7 @@ const Title = styled('div')`
282282
283283const TitleType = styled ( 'div' ) `
284284 flex: none;
285- color: ${ p => p . theme . textColor } ;
285+ color: ${ p => p . theme . tokens . content . primary } ;
286286 font-weight: ${ p => p . theme . fontWeight . bold } ;
287287 font-size: ${ p => p . theme . fontSize . md } ;
288288 margin-right: ${ space ( 1 ) } ;
@@ -292,7 +292,7 @@ const TitleType = styled('div')`
292292const TitleDescription = styled ( 'div' ) `
293293 ${ p => p . theme . overflowEllipsis } ;
294294 display: flex;
295- color: ${ p => p . theme . subText } ;
295+ color: ${ p => p . theme . tokens . content . primary } ;
296296 text-align: right;
297297 font-size: ${ p => p . theme . fontSize . md } ;
298298 ${ p => p . theme . overflowEllipsis } ;
@@ -368,26 +368,23 @@ const LegendText = styled('span')<{unfocus: boolean}>`
368368 white-space: nowrap;
369369 text-overflow: ellipsis;
370370 transition: color 0.3s;
371- color: ${ p => ( p . unfocus ? p . theme . gray300 : p . theme . gray400 ) } ;
371+ color: ${ p =>
372+ p . unfocus ? p . theme . tokens . content . muted : p . theme . tokens . content . primary } ;
372373` ;
373374
374375const LegendPercent = styled ( 'span' ) `
375376 font-size: ${ p => p . theme . fontSize . sm } ;
376377 margin-left: ${ space ( 1 ) } ;
377- color: ${ p => p . theme . subText } ;
378+ color: ${ p => p . theme . tokens . content . primary } ;
378379 text-align: right;
379380 flex-grow: 1;
380381` ;
381382
382383const ExpandToggleButton = styled ( Button ) `
383- color: ${ p => p . theme . subText } ;
384+ color: ${ p => p . theme . tokens . content . muted } ;
384385 margin-left: ${ space ( 0.5 ) } ;
385386` ;
386387
387- const NotApplicableLabel = styled ( 'span' ) `
388- color: ${ p => p . theme . subText } ;
389- ` ;
390-
391388const StyledSummary = styled ( 'summary' ) `
392389 &::-webkit-details-marker {
393390 display: none;
0 commit comments