11import React , { useState , useEffect } from 'react' ;
22import Layout from '@theme/Layout' ;
3- import { Box , Button , Container , Grid , Stack , Tab , Tabs , Typography } from '@mui/material' ;
3+ import {
4+ Box ,
5+ Button ,
6+ Container ,
7+ Grid ,
8+ Stack ,
9+ Tab ,
10+ Tabs ,
11+ Typography ,
12+ Switch
13+ } from '@mui/material' ;
414import { TabContext , TabPanel } from '@mui/lab' ;
15+ import { LightMode , DarkMode } from '@mui/icons-material' ; // <-- Icons
516import bgImage from '../../static/img/hero-secondary-background.webp' ;
617import heroImage from '../../static/img/hero-secondary-graphic.webp' ;
718import SumoLogicDocsLogo from '../../static/img/sumo-logic-docs.svg' ;
@@ -12,6 +23,9 @@ import ErrorBoundary from '../components/ErrorBoundary';
1223export const Home = ( ) => {
1324 const [ tab , setTab ] = useState ( '0' ) ;
1425
26+ // Track whether we're in dark mode:
27+ const [ isDark , setIsDark ] = useState ( false ) ;
28+
1529 const questions = [
1630 '✨ timestamps' ,
1731 '✨ how do you write a log search query?' ,
@@ -41,13 +55,16 @@ export const Home = () => {
4155 botUrlPath : 'nova' ,
4256 showNewChat : true ,
4357 parentElementId : 'inline-berry-chatbot-container' ,
58+ // If you want to start in dark mode by default, uncomment:
59+ // colorMode: 'dark',
4460 } ) ;
4561 } ;
4662
4763 script . onerror = ( ) => console . error ( 'Failed to load Berry widget script' ) ;
4864 }
4965 } , [ ] ) ;
5066
67+ // Send a question to Berry:
5168 const handleQuestionClick = ( question ) => {
5269 if ( window . Berry ) {
5370 if ( window . Berry . sendMessage ) {
@@ -59,68 +76,125 @@ export const Home = () => {
5976 }
6077 } ;
6178
79+ // Toggle Berry's theme on switch change:
80+ const handleToggle = ( event ) => {
81+ const newValue = event . target . checked ; // true = dark mode, false = light mode
82+ setIsDark ( newValue ) ;
83+
84+ if ( window . Berry && window . Berry . update ) {
85+ window . Berry . update ( {
86+ colorMode : newValue ? 'dark' : 'light'
87+ } ) ;
88+ }
89+ } ;
90+
6291 return (
6392 < ErrorBoundary >
6493 < Layout
6594 description = 'Sumo Logic docs - real-time alerting, security, dashboards, and machine-learning-powered analytics for all three types of telemetry — logs, metrics, and traces.'
6695 title = 'Home'
6796 >
68-
69-
7097 { /* Suggested Questions */ }
7198 < Box sx = { { width : '100%' , background : '#2a2a2a' , color : '#fff' , py : 4 } } >
72-
7399 < Container maxWidth = "md" sx = { { textAlign : 'center' } } >
74- < Typography variant = "h4" fontWeight = { 600 } mt = { 1 } mb = { 3 } >
75- Sumo Logic Documentation
76- </ Typography >
77- < Typography variant = "h5" fontFamily = "Lab Grotesque" fontWeight = { 300 } mb = { 2 } sx = { { background : 'linear-gradient(90deg, #9900ED, #C04CF4, #00C8E0)' , WebkitBackgroundClip : 'text' , WebkitTextFillColor : 'transparent' } } >
100+ < Box
101+ component = { SumoLogicDocsLogo }
102+ alt = "Sumo Logic Docs logo"
103+ role = "<img>"
104+ aria-hidden = "true"
105+ height = { {
106+ md : 30 ,
107+ xs : 22 ,
108+ } }
109+ width = '100%'
110+ />
111+ < Typography
112+ fontFamily = "Lab Grotesque"
113+ variant = 'h3'
114+ fontSize = { 32 }
115+ fontWeight = { 700 }
116+ mt = { 2 }
117+ mb = { 2 }
118+ sx = { {
119+ background : 'linear-gradient(90deg, #9900ED, #C04CF4, #00C8E0)' ,
120+ WebkitBackgroundClip : 'text' ,
121+ WebkitTextFillColor : 'transparent'
122+ } }
123+ >
78124 Our Docs Assistant is here to help!
79125 </ Typography >
80- < Typography fontFamily = "Lab Grotesque" fontSize = { 13 } fontWeight = { 300 } mb = { 2 } >
126+ < Typography
127+ fontFamily = "Lab Grotesque"
128+ fontSize = { 13 }
129+ fontWeight = { 300 }
130+ mb = { 2 }
131+ >
81132 Ask me anything! You can type full questions, sentences, or just keywords, and I'll help you find the information you need. Try these to get started:
82133 </ Typography >
83134 < Stack
84- direction = "row"
85- spacing = { 1 } // Reduced horizontal spacing between buttons
86- justifyContent = "center"
87- flexWrap = "wrap"
88- rowGap = { 1 } // Reduced vertical spacing between rows
135+ direction = "row"
136+ spacing = { 1 }
137+ justifyContent = "center"
138+ flexWrap = "wrap"
139+ rowGap = { 1 }
89140 >
90-
91- { questions . map ( ( question , index ) => (
92- < Button
93- key = { index }
94- onClick = { ( ) => handleQuestionClick ( question ) }
95- variant = "outlined"
96- sx = { {
97- bgcolor : 'transparent' ,
98- color : '#DDDDDD' ,
99- fontFamily : 'Lab Grotesque' ,
100- borderColor : '#808080' ,
101- borderRadius : '5px' ,
102- textTransform : 'lowercase' ,
103- fontSize : '12px' ,
104- fontWeight : '300' ,
105- padding : '4px 6px' ,
106- minWidth : 'auto' ,
107- '&:hover' : {
108- bgcolor : '#2a2a2a' ,
109- color : '#DDDDDD' ,
110- } ,
111- } }
112- >
113- { question }
114- </ Button >
115- ) ) }
116- </ Stack >
141+ { questions . map ( ( question , index ) => (
142+ < Button
143+ key = { index }
144+ onClick = { ( ) => handleQuestionClick ( question ) }
145+ variant = "outlined"
146+ sx = { {
147+ bgcolor : 'transparent' ,
148+ color : '#DDDDDD' ,
149+ fontFamily : 'Lab Grotesque' ,
150+ borderColor : '#808080' ,
151+ borderRadius : '5px' ,
152+ textTransform : 'lowercase' ,
153+ fontSize : '12px' ,
154+ fontWeight : '300' ,
155+ padding : '4px 6px' ,
156+ minWidth : 'auto' ,
157+ '&:hover' : {
158+ bgcolor : '#2a2a2a' ,
159+ color : '#DDDDDD' ,
160+ } ,
161+ } }
162+ >
163+ { question }
164+ </ Button >
165+ ) ) }
166+ </ Stack >
117167
118168 { /* Inline Chatbot Container */ }
119- < Box id = "inline-berry-chatbot-container" sx = { { my : 4 , p : 2 , margin : '0 auto' , textAlign : 'center' } } >
120- { /* The chatbot will render here */ }
169+ < Box
170+ id = "inline-berry-chatbot-container"
171+ sx = { { my : 4 , p : 2 , margin : '0 auto' , textAlign : 'center' } }
172+ >
173+ { /* Berry chatbot will render here */ }
121174 </ Box >
175+
176+ { /* Light/Dark Toggle Switch with icons */ }
177+ < Stack direction = "row" spacing = { 1 } alignItems = "center" justifyContent = "center" >
178+ { /* Label: Light */ }
179+ < Typography variant = "body2" color = "#fff" >
180+ Light
181+ </ Typography >
182+ < Switch
183+ checked = { isDark }
184+ onChange = { handleToggle }
185+ color = "default"
186+ // Sun icon when off (light), moon icon when on (dark)
187+ icon = { < LightMode /> } // Unchecked icon
188+ checkedIcon = { < DarkMode /> } // Checked icon
189+ />
190+ { /* Label: Dark */ }
191+ < Typography variant = "body2" color = "#fff" >
192+ Dark
193+ </ Typography >
194+ </ Stack >
122195 </ Container >
123196 </ Box >
197+
124198 { /* Hero */ }
125199 < Stack
126200 sx = { {
@@ -158,10 +232,7 @@ export const Home = () => {
158232 } }
159233 height = '100%'
160234 >
161- < Grid
162- item
163- md = { 6 }
164- >
235+ < Grid item md = { 6 } >
165236 < Stack
166237 alignItems = { {
167238 md : 'flex-start' ,
@@ -258,7 +329,6 @@ export const Home = () => {
258329
259330 { /* Main */ }
260331 < Container maxWidth = 'xl' >
261-
262332 { /* Product Guides */ }
263333 < Stack
264334 alignItems = 'center'
@@ -335,7 +405,7 @@ export const Home = () => {
335405 {
336406 label : 'Other Solutions' ,
337407 } ,
338- ] . map ( ( { label, ... rest } , index ) => (
408+ ] . map ( ( { label } , index ) => (
339409 < Tab
340410 key = { label }
341411 label = { label }
@@ -345,40 +415,40 @@ export const Home = () => {
345415 fontWeight : 'bold' ,
346416 } }
347417 value = { String ( index ) }
348- { ...rest }
349418 />
350419 ) ) }
351420 </ Tabs >
352- { features . map ( ( feature , index ) => tab === String ( index ) && (
353- < Grid
354- component = { TabPanel }
355- container
356- direction = 'row'
357- justifyContent = 'center'
358- key = { index }
359- py = { 6 }
360- spacing = { 4 }
361- value = { String ( index ) }
362- >
363- { feature . map ( ( config ) => (
364- < Grid
365- item
366- key = { config . link }
367- lg = { 4 }
368- md = { 6 }
369- xs = { 12 }
370- >
371- < Feature
372- length = { feature . length }
373- { ...config }
374- />
375- </ Grid >
376- ) ) }
377- </ Grid >
421+ { features . map ( ( feature , index ) => (
422+ tab === String ( index ) && (
423+ < Grid
424+ component = { TabPanel }
425+ container
426+ direction = 'row'
427+ justifyContent = 'center'
428+ key = { index }
429+ py = { 6 }
430+ spacing = { 4 }
431+ value = { String ( index ) }
432+ >
433+ { feature . map ( ( config ) => (
434+ < Grid
435+ item
436+ key = { config . link }
437+ lg = { 4 }
438+ md = { 6 }
439+ xs = { 12 }
440+ >
441+ < Feature
442+ length = { feature . length }
443+ { ...config }
444+ />
445+ </ Grid >
446+ ) ) }
447+ </ Grid >
448+ )
378449 ) ) }
379450 </ TabContext >
380451 </ Stack >
381-
382452 </ Container >
383453 </ Layout >
384454 </ ErrorBoundary >
0 commit comments