@@ -7,12 +7,14 @@ import { ContentPage } from "~/layouts";
77import { usePageContext } from 'vike-react/usePageContext' ;
88import { Timescale } from "@macrostrat/timescale" ;
99import { titleCase } from "../../index" ;
10+ import { useState , useEffect } from "react" ;
1011
1112
1213export function Page ( ) {
1314 const pageContext = usePageContext ( ) ;
1415 const id = parseInt ( pageContext . urlParsed . pathname . split ( "/" ) [ 3 ] ) ;
1516 const res = useAPIResult ( SETTINGS . apiV2Prefix + "/defs/timescales?all" ) ?. success . data ;
17+ const [ clickedInterval , setClickedInterval ] = useState ( null ) ;
1618
1719 if ( res == null ) return h ( "div" , "Loading..." ) ;
1820
@@ -22,15 +24,33 @@ export function Page() {
2224 if ( timeRes == null ) return h ( "div" , "Timescale not found" ) ;
2325
2426 const { min_age, max_age, timescale } = timeRes ;
25- const width = window . screen . width ;
26- const timescaleWidth = width * .6 ;
27+
28+ const handleClick = ( timescale ) => {
29+ console . log ( "Clicked timescale:" , timescale ) ;
30+ /*
31+ const parent = timescale.target.parentElement;
32+ let selected;
33+
34+ // container clicked
35+ const containerClickedData = parent.className.split(" ")[1];
36+
37+ if(containerClickedData === "interval-label") {
38+ const labelClickedData = parent.parentElement.parentElement.className.split(" ")[1];
39+ selected = labelClickedData
40+ } else {
41+ selected = containerClickedData
42+ }
43+
44+ setClickedInterval(selected);
45+ */
46+ }
2747
2848 return h ( ContentPage , [
2949 h ( PageBreadcrumbs , { title : "#" + id } ) ,
3050 h ( 'div.timescale-content' , [
3151 h ( 'h1' , titleCase ( timescale ) ) ,
3252 h ( 'h3' , max_age + " - " + min_age + " Ma" ) ,
33- h ( Timescale , { levels : [ 0 , 5 ] , ageRange : [ min_age , max_age ] , orientation : "vertical" } ) ,
53+ h ( 'div.timescale' , h ( Timescale , { levels : [ 0 , 5 ] , ageRange : [ min_age , max_age ] , orientation : "vertical" } ) ) ,
3454 ] )
3555 ] ) ;
3656}
0 commit comments