Skip to content

Commit c7f5136

Browse files
committed
Berry Demo - Feb 2025
1 parent 5b81366 commit c7f5136

File tree

7 files changed

+231
-35
lines changed

7 files changed

+231
-35
lines changed

.github/workflows/pr.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,17 @@ jobs:
3232
env:
3333
NODE_OPTIONS: "--max-old-space-size=8192 --max-http-header-size=8192"
3434
run: yarn build
35+
deploy-to-review:
36+
uses: SumoLogic/sumologic-documentation/.github/workflows/build_and_deploy.yml@main
37+
with:
38+
hostname: https://d2t1s0ah22jxsa.cloudfront.net
39+
base_url: /${{ github.ref_name }}/
40+
environment: review/${{ github.ref_name }}
41+
secrets:
42+
S3_BUCKET_NAME: ${{ secrets.REVIEW_S3_BUCKET_NAME }}
43+
CLOUDFRONT_DISTRIBUTION_ID: ${{ secrets.REVIEW_CLOUDFRONT_DISTRIBUTION_ID }}
44+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
45+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
3546
spellcheck:
3647
runs-on: ubuntu-latest
3748
steps:

.github/workflows/review.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: deploy-to-review
2+
3+
on: workflow_dispatch
4+
5+
jobs:
6+
deploy-to-review:
7+
uses: SumoLogic/sumologic-documentation/.github/workflows/build_and_deploy.yml@main
8+
with:
9+
hostname: https://d2t1s0ah22jxsa.cloudfront.net
10+
base_url: /${{ github.ref_name }}/
11+
environment: review/${{ github.ref_name }}
12+
secrets:
13+
S3_BUCKET_NAME: ${{ secrets.REVIEW_S3_BUCKET_NAME }}
14+
CLOUDFRONT_DISTRIBUTION_ID: ${{ secrets.REVIEW_CLOUDFRONT_DISTRIBUTION_ID }}
15+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
16+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

docusaurus.config.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -271,12 +271,6 @@ module.exports = {
271271
return `https://github.com/SumoLogic/sumologic-documentation/issues/new?title=${query}`;
272272
},
273273
},
274-
announcementBar: {
275-
id: 'copilot',
276-
content: 'Check out 🤖 <b><a target="_blank" rel="noopener noreferrer" href="/docs/search/copilot">Sumo Logic Copilot</a></b>, our new AI-powered logs assistant!',
277-
backgroundColor: '#D3BAF7',
278-
textColor: '#000',
279-
},
280274
prism: {
281275
theme: lightCodeTheme,
282276
darkTheme: darkCodeTheme,

src/components/Berry/index.tsx

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
import React, { useEffect } from "react";
2+
3+
export type BerryMode = "inline" | "popup";
4+
export interface BerryProps {
5+
mode: BerryMode;
6+
};
7+
8+
declare global {
9+
interface Window {
10+
Berry: any;
11+
}
12+
}
13+
14+
export default function Berry({ mode }: BerryProps) {
15+
useEffect(() => {
16+
function onColorModeChange(newColorMode) {
17+
if (!window.Berry) {
18+
return;
19+
}
20+
21+
window.Berry.update({
22+
colorMode: newColorMode,
23+
})
24+
}
25+
26+
const observer = new MutationObserver((mutations) => {
27+
mutations.forEach((mutation) => {
28+
if (mutation.attributeName === 'data-theme') {
29+
const newColorMode = getCurrentColorMode();
30+
onColorModeChange(newColorMode);
31+
}
32+
});
33+
});
34+
35+
observer.observe(document.documentElement, { attributes: true });
36+
}, []);
37+
38+
useEffect(() => {
39+
loadBerry(mode);
40+
}, [mode]);
41+
return null;
42+
}
43+
44+
function loadBerry(mode: BerryMode) {
45+
if (!document.getElementById('berry-widget-script')) {
46+
const script = document.createElement('script');
47+
script.id = 'berry-widget-script';
48+
script.src = 'https://www.berryapp.io/js/berry-widget.min.js';
49+
script.async = true;
50+
document.head.appendChild(script);
51+
52+
script.onload = () => {
53+
initBerry(mode);
54+
}
55+
56+
script.onerror = () => console.error('Failed to load Berry widget script');
57+
} else {
58+
initBerry(mode);
59+
}
60+
}
61+
62+
function initBerry(mode: BerryMode) {
63+
if (!window.Berry) {
64+
console.error("Berry not defined");
65+
return;
66+
}
67+
68+
const colorMode = getCurrentColorMode();
69+
const config = {
70+
...(mode === 'inline' ? inlineConfig : popupConfig),
71+
colorMode: colorMode,
72+
};
73+
74+
window.Berry.init(config);
75+
};
76+
77+
function getCurrentColorMode(): 'light' | 'dark' {
78+
const theme = document.documentElement.getAttribute('data-theme');
79+
if (theme === 'light' || theme === 'dark') {
80+
return theme;
81+
} else {
82+
return 'light';
83+
}
84+
}
85+
86+
87+
const commonConfig = {
88+
token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3MjU5NDg5MTcsImV4cCI6MTc0MTYwODkxNywiYXVkIjoiV2lkZ2V0SW5pdGlhbGl6YXRpb24iLCJvcmdhbml6YXRpb25JZCI6NjN9.oJEGkGq1q3uFD66J916f_ZBrqQjPHP9orUOKFxInG38',
89+
primaryColor: '#021b9a',
90+
botUrlPath: 'nova',
91+
showNewChat: true,
92+
resumeChat: true,
93+
}
94+
95+
const inlineConfig = {
96+
...commonConfig,
97+
isOpenByDefault: true,
98+
parentElementId: 'inline-berry-chatbot-container',
99+
hideToggle: true,
100+
height: 700,
101+
showResize: false,
102+
}
103+
104+
const popupConfig = {
105+
...commonConfig,
106+
position: { side: 'right', offsetX: 25, offsetY: 100 },
107+
isOpenByDefault: false,
108+
}

src/css/sumo.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,11 @@ html[data-theme='light'] {
227227
min-width: 100px;
228228
}
229229

230+
/* Berry CSS override to force global styles back to normal */
231+
body, .MuiTypography-root, button, input, select, textarea {
232+
font-family: 'Lab Grotesque', sans-serif !important;
233+
}
234+
230235
//GitHub icon
231236
.header-github-link:hover {
232237
opacity: 0.6;

src/pages/index.tsx

Lines changed: 78 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState } from 'react';
1+
import React, { useState, useEffect } from 'react';
22
import Layout from '@theme/Layout';
33
import { Box, Button, Container, Grid, Stack, Tab, Tabs, Typography } from '@mui/material';
44
import { TabContext, TabPanel } from '@mui/lab';
@@ -7,45 +7,94 @@ import heroImage from '../../static/img/hero-secondary-graphic.webp';
77
import SumoLogicDocsLogo from '../../static/img/sumo-logic-docs.svg';
88
import { Feature } from '../components/Feature';
99
import { features } from '../helper/features';
10-
import ErrorBoundary from '../components/ErrorBoundary'; // Import the ErrorBoundary component
10+
import ErrorBoundary from '../components/ErrorBoundary';
11+
import Berry from '../components/Berry';
1112

1213
export const Home = () => {
1314
const [tab, setTab] = useState('0');
1415

16+
const questions = [
17+
'✨ timestamps',
18+
'✨ how do you write a log search query?',
19+
'✨ how do I set up alerts?',
20+
'✨ what types of logs can I analyze?',
21+
'✨ what is copilot?',
22+
'✨ cloud siem',
23+
'✨ how do I change my password?',
24+
'✨ what is the parse operator?'
25+
];
26+
27+
const handleQuestionClick = (question) => {
28+
if (window.Berry) {
29+
if (window.Berry.sendMessage) {
30+
window.Berry.sendMessage(question);
31+
}
32+
}
33+
};
34+
1535
return (
1636
<ErrorBoundary>
1737
<Layout
1838
description='Sumo Logic docs - real-time alerting, security, dashboards, and machine-learning-powered analytics for all three types of telemetry — logs, metrics, and traces.'
1939
title='Home'
2040
>
21-
{/* Header */}
22-
<Typography
23-
bgcolor='#0045BE'
24-
color='#e3e3e3'
25-
fontFamily='Lab Grotesque'
26-
fontSize={28}
27-
fontWeight={700}
28-
pt={3}
29-
px={2}
30-
pb={1}
31-
sx={{
32-
backgroundImage: 'linear-gradient(to right, rgb(0,0,153), rgb(0,70,190) 30%)',
33-
}}
34-
textAlign='center'
35-
>
36-
<Box
37-
component={SumoLogicDocsLogo}
38-
alt="Sumo Logic Docs logo"
39-
role="<img>"
40-
aria-hidden="true"
41-
height={{
42-
md: 36,
43-
xs: 28,
44-
}}
45-
width='100%'
46-
/>
47-
</Typography>
4841

42+
<Berry mode='inline' />
43+
44+
{/* Suggested Questions */}
45+
<Box sx={{ width: '100%', background: '#2a2a2a', color: '#fff', py: 4 }}>
46+
47+
<Container maxWidth="md" sx={{ textAlign: 'center' }}>
48+
<Typography variant="h4" fontWeight={600} mt={1} mb={3}>
49+
Sumo Logic Documentation
50+
</Typography>
51+
<Typography variant="h5" fontFamily="Lab Grotesque" fontWeight={300} mb={2} sx={{ background: 'linear-gradient(90deg, #9900ED, #C04CF4, #00C8E0)', WebkitBackgroundClip: 'text', WebkitTextFillColor: 'transparent' }}>
52+
Our Docs Assistant is here to help!
53+
</Typography>
54+
<Typography fontFamily="Lab Grotesque" fontSize={13} fontWeight={300} mb={2}>
55+
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:
56+
</Typography>
57+
<Stack
58+
direction="row"
59+
spacing={1} // Reduced horizontal spacing between buttons
60+
justifyContent="center"
61+
flexWrap="wrap"
62+
rowGap={1} // Reduced vertical spacing between rows
63+
>
64+
65+
{questions.map((question, index) => (
66+
<Button
67+
key={index}
68+
onClick={() => handleQuestionClick(question)}
69+
variant="outlined"
70+
sx={{
71+
bgcolor: 'transparent',
72+
color: '#DDDDDD',
73+
fontFamily: 'Lab Grotesque',
74+
borderColor: '#808080',
75+
borderRadius: '5px',
76+
textTransform: 'lowercase',
77+
fontSize: '12px',
78+
fontWeight: '300',
79+
padding: '4px 6px',
80+
minWidth: 'auto',
81+
'&:hover': {
82+
bgcolor: '#2a2a2a',
83+
color: '#DDDDDD',
84+
},
85+
}}
86+
>
87+
{question}
88+
</Button>
89+
))}
90+
</Stack>
91+
92+
{/* Inline Chatbot Container */}
93+
<Box id="inline-berry-chatbot-container" sx={{ my: 4, p: 2, margin: '0 auto', textAlign: 'center' }}>
94+
{/* The chatbot will render here */}
95+
</Box>
96+
</Container>
97+
</Box>
4998
{/* Hero */}
5099
<Stack
51100
sx={{

src/theme/Root.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import React from 'react';
2+
import Berry from '../components/Berry';
3+
import { useLocation } from '@docusaurus/router';
4+
5+
export default function Root({ children }: { children: React.ReactNode }) {
6+
const location = useLocation();
7+
return (
8+
<>
9+
{children}
10+
{location.pathname !== '/' && <Berry mode='popup' />}
11+
</>
12+
);
13+
}

0 commit comments

Comments
 (0)