1+ /* eslint-disable no-template-curly-in-string */
12import { useQuery } from "@apollo/client" ;
23import { gql } from './__generated__/gql' ;
34import React from "react" ;
4- import { theme } from "@diamondlightsource/ui-components "
5- import { ChakraProvider , Alert , AlertIcon , AlertTitle , AlertDescription , Button , HStack } from "@chakra-ui/react" ;
5+ import { theme } from "./styles/theme "
6+ import { ChakraProvider , Alert , AlertIcon , AlertTitle , AlertDescription , Button , HStack , useColorMode } from "@chakra-ui/react" ;
67import { Table } from "./components/Table" ;
8+ import { Helmet } from 'react-helmet' ;
9+ import { DarkModeSwitch } from 'react-toggle-dark-mode' ;
710
811const GET_INFO = gql ( `
912query pinInfo ($after: String) {
@@ -34,7 +37,16 @@ function DisplayPinInfo(): React.JSX.Element {
3437 notifyOnNetworkStatusChange : true ,
3538 } ) ;
3639
40+ //const [isDarkMode, setDarkMode] = React.useState(false);
41+
42+ /* const toggleDarkMode = (checked: boolean) => {
43+ setDarkMode(checked);
44+ };*/
45+
46+ const { colorMode, toggleColorMode } = useColorMode ( )
47+
3748 var loadingRows = loading ? 2 : 0
49+ var bgColour = colorMode === 'dark' ? "black" : "white"
3850
3951 if ( error ) return (
4052 < Alert status = 'error' >
@@ -77,6 +89,16 @@ function DisplayPinInfo(): React.JSX.Element {
7789
7890 return (
7991 < >
92+ < div >
93+ < DarkModeSwitch
94+ style = { { marginBottom : '1rem' , marginLeft : '.25rem' , marginTop : '.25rem' , position : 'relative' , left : '1875px' } }
95+ checked = { colorMode === 'dark' }
96+ onChange = { toggleColorMode }
97+ size = { 30 }
98+ />
99+ < Helmet >
100+ < style > { `body { background-color: ${ bgColour } }` } </ style >
101+ </ Helmet >
80102 < Table
81103 headers = { [
82104 {
@@ -97,9 +119,10 @@ function DisplayPinInfo(): React.JSX.Element {
97119 ] }
98120 data = { data ? data . libraryPins . edges . map ( ( edge ) => edge . node ) : [ ] }
99121 loadingRows = { loadingRows }
122+ rowVariant = { "diamondStriped" }
100123 />
101124 < HStack justify = 'center' width = '100%' >
102- < Button
125+ < Button marginTop = { '10px' }
103126 colorScheme = 'teal'
104127 variant = 'outline'
105128 onClick = { loadMore }
@@ -110,6 +133,7 @@ function DisplayPinInfo(): React.JSX.Element {
110133 Load More
111134 </ Button >
112135 </ HStack >
136+ </ div >
113137 </ >
114138 ) ;
115139}
0 commit comments