11import * as Tabs from "@radix-ui/react-tabs" ;
2- import { FullscreenIcon , LinkIcon , SquareArrowOutUpRightIcon , ZoomIn } from "lucide-react" ;
2+ import { LinkIcon , SquareArrowOutUpRightIcon , ZoomIn } from "lucide-react" ;
33import styles from "./dimensions.module.css" ;
44
55import {
@@ -14,10 +14,9 @@ import {
1414 useDimension ,
1515} from "../../api" ;
1616
17- import { cls } from "../../utils" ;
18- import { Dialog } from "../dialog" ;
1917import { BrowserIcon , MobileDeviceIcon , OSIcon , ReferrerIcon } from "../icons" ;
2018import { countryCodeToFlag , formatFullUrl , formatHost , getHref , tryParseUrl } from "./utils" ;
19+ import { DetailsModal } from "./modal" ;
2120
2221export const cardStyles = styles . card ;
2322
@@ -120,67 +119,6 @@ export const DimensionTable = ({
120119 ) ;
121120} ;
122121
123- const DetailsModal = ( {
124- project,
125- dimension,
126- metric,
127- range,
128- } : { project : ProjectResponse ; dimension : Dimension ; metric : Metric ; range : DateRange } ) => {
129- const { data, biggest, order, isLoading } = useDimension ( { project, dimension, metric, range } ) ;
130-
131- return (
132- < Dialog
133- title = { `${ dimensionNames [ dimension ] } - ${ metricNames [ metric ] } ` }
134- description = { `Detailed breakdown of ${ dimensionNames [ dimension ] } by ${ metricNames [ metric ] } ` }
135- hideTitle
136- hideDescription
137- showClose
138- className = { styles . detailsModal }
139- trigger = { ( ) => (
140- < button
141- type = "button"
142- className = { cls ( styles . showMore , ( data ?. length ?? 0 ) === 0 && styles . showMoreHidden ) }
143- onClick = { ( ) => console . log ( "show more" ) }
144- >
145- < ZoomIn size = { 16 } />
146- Show details
147- </ button >
148- ) }
149- >
150- < div className = { styles . dimensionTable } style = { { "--count" : data ?. length } as React . CSSProperties } >
151- < div className = { styles . dimensionHeader } >
152- < div > { dimensionNames [ dimension ] } </ div >
153- < div > { metricNames [ metric ] } </ div >
154- </ div >
155- { data ?. map ( ( d ) => {
156- return (
157- < div
158- key = { d . dimensionValue }
159- style = { { order : order ?. indexOf ( d . dimensionValue ) } }
160- className = { styles . dimensionRow }
161- >
162- < DimensionValueBar value = { d . value } biggest = { biggest } >
163- < DimensionLabel dimension = { dimension } value = { d } />
164- </ DimensionValueBar >
165- < div > { formatMetricVal ( metric , d . value ) } </ div >
166- </ div >
167- ) ;
168- } ) }
169- { isLoading && data ?. length === 0 && (
170- < div className = { styles . dimensionEmpty } >
171- < div > Loading...</ div >
172- </ div >
173- ) }
174- { ! isLoading && data ?. length === 0 && (
175- < div className = { styles . dimensionEmpty } >
176- < div > No data available</ div >
177- </ div >
178- ) }
179- </ div >
180- </ Dialog >
181- ) ;
182- } ;
183-
184122const dimensionLabels : Record < Dimension , ( value : DimensionTableRow ) => React . ReactNode > = {
185123 platform : ( value ) => (
186124 < >
@@ -250,7 +188,7 @@ const dimensionLabels: Record<Dimension, (value: DimensionTableRow) => React.Rea
250188 { value . dimensionValue && isValidFqdn ( value . dimensionValue ) && (
251189 < >
252190
253- < a href = { `https://${ value . dimensionValue } ` } target = "_blank" rel = "noreferrer" >
191+ < a href = { `https://${ value . dimensionValue } ` } target = "_blank" rel = "noreferrer" className = { styles . external } >
254192 < SquareArrowOutUpRightIcon size = { 16 } />
255193 </ a >
256194 </ >
@@ -270,10 +208,10 @@ const isValidFqdn = (fqdn: string) => {
270208 }
271209} ;
272210
273- const DimensionLabel = ( { dimension, value } : { dimension : Dimension ; value : DimensionTableRow } ) =>
211+ export const DimensionLabel = ( { dimension, value } : { dimension : Dimension ; value : DimensionTableRow } ) =>
274212 dimensionLabels [ dimension ] ( value ) ;
275213
276- const DimensionValueBar = ( {
214+ export const DimensionValueBar = ( {
277215 value,
278216 biggest,
279217 children,
0 commit comments