Skip to content

Commit 50ad804

Browse files
committed
Removed depdenencies and merged back code
2 parents 4ee3d35 + 181a11f commit 50ad804

4 files changed

Lines changed: 320 additions & 549 deletions

File tree

webapp/components/general/TutorialBubble.js

Lines changed: 45 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useState, useRef, useEffect } from 'react';
2-
import { Button, Grid } from '@material-ui/core';
2+
import { Box, Button, Grid, Typography } from '@material-ui/core';
33
import {
44
primaryColor, secondaryColor, bgLight, bgDark, primaryTextColor, secondaryTextColor, fontColor,
55
} from '../../theme';
@@ -37,7 +37,7 @@ const TutorialBubble = ({
3737
return DOMtargets[config?.collectionIndex || 0];
3838
};
3939

40-
function calculateVisiblePosition (rect1, width2, height2) {
40+
function calculateVisiblePosition(rect1, width2, height2) {
4141
const windowHeight = window.innerHeight;
4242
const windowWidth = window.innerWidth;
4343

@@ -68,7 +68,7 @@ const TutorialBubble = ({
6868
}
6969

7070
const nextTourStep = steps[requestedTourStep];
71-
const { target: nextTarget } = nextTourStep? nextTourStep: {target: undefined};
71+
const { target: nextTarget } = nextTourStep ? nextTourStep : { target: undefined };
7272

7373
const { target, title, content } = tourStep;
7474

@@ -83,11 +83,11 @@ const TutorialBubble = ({
8383

8484
// validateTutorialStep({ tourStep: requestedTourStep });
8585
const isEditable = (el) => {
86-
if (el && ~['input','textarea'].indexOf(el.tagName.toLowerCase())) {
86+
if (el && ~['input', 'textarea'].indexOf(el.tagName.toLowerCase())) {
8787
return !el.readOnly && !el.disabled;
8888
}
8989
el = getSelection().anchorNode;
90-
if (!el){
90+
if (!el) {
9191
return false;
9292
}
9393
return el.parentNode.isContentEditable;
@@ -129,9 +129,9 @@ const TutorialBubble = ({
129129
switch (waitFor) {
130130
case 'click':
131131
if (requestedTourStep === steps.length) {
132-
DOMtarget.addEventListener('click', stop, {once: true, capture: true});
132+
DOMtarget.addEventListener('click', stop, { once: true, capture: true });
133133
} else {
134-
DOMtarget.addEventListener('click', listen, {once: true, capture: true});
134+
DOMtarget.addEventListener('click', listen, { once: true, capture: true });
135135
}
136136
break;
137137
case 'fieldEdition': // Do nothing, we wait for a click on "next"
@@ -148,136 +148,61 @@ const TutorialBubble = ({
148148
const nextIsVisible = nextDOMtarget?.checkVisibility();
149149

150150
return (
151-
<div>
152-
<div
151+
<Box className='tutorials'>
152+
<Box
153+
className='tutorials_highlight'
153154
id="tutorialTargetRectangle"
154155
style={{
155-
position: 'absolute',
156156
top: targetRect.top - rectMargin,
157157
left: targetRect.left - rectMargin,
158158
width: targetRect.width + (2 * rectMargin),
159159
height: targetRect.height + (2 * rectMargin),
160-
borderRadius: '4px',
161-
pointerEvents: 'none',
162-
border: `solid 3px ${primaryColor}`,
163-
zIndex: 1501, // Just over the menus items (1500)
160+
borderColor: primaryColor,
161+
164162
}}
165163
/>
166-
<div style={{ position: 'relative' }} id="tutorialBubble">
164+
165+
<Box className='tutorials_wrapper' id="tutorialBubble">
167166
{lastCheckRender}
168-
<div
169-
style={{
170-
position: 'absolute',
171-
top: y,
172-
left: x,
173-
backgroundColor: '#434343',
174-
borderRadius: '4px',
175-
boxShadow: '0 2px 8px rgba(0, 0, 0, 0.2)',
176-
border: `solid 1px ${primaryColor}`,
177-
padding: '16px',
178-
minWidth: '150px',
179-
minHeight: '150px',
180-
maxWidth: '300px',
181-
maxHeight: '450px',
182-
fontSize: '16px',
183-
lineHeight: '1.5',
184-
zIndex: 1501, // Just over the menus items (1500)
185-
}}
186-
>
187-
<h3
188-
style={{
189-
marginTop: 0,
190-
color: fontColor,
191-
}}
192-
>
167+
168+
<Box className='tutorials_content' style={{
169+
top: y,
170+
left: x,
171+
}}>
172+
<Typography component='h3'>
193173
{title}
194-
</h3>
195-
196-
<div
197-
style={{
198-
color: fontColor,
199-
paddingBottom: '20px',
200-
}}
201-
>
202-
{content}
203-
</div>
204-
205-
<Grid alignItems="flex-start" container spacing={1}>
206-
<Grid
207-
container
208-
direction="column"
209-
item
210-
xs={3}
211-
spacing={1}
212-
alignItems="flex-start"
213-
justifyContent="flex-start"
214-
>
215-
<Grid item xs={12}>
216-
<p style={{ color: '#fff' }}>
217-
{requestedTourStep}
218-
/
219-
{steps.length}
220-
</p>
221-
</Grid>
222-
</Grid>
223-
<Grid
224-
container
225-
direction="column"
226-
item
227-
xs={9}
228-
spacing={1}
229-
alignItems="flex-end"
230-
justifyContent="flex-end"
231-
>
232-
<Grid item xs={12}>
174+
</Typography>
175+
176+
{content}
177+
178+
<Box pt={2.5} display='flex' alignItems='center' justifyContent='space-between'>
179+
<Typography>
180+
{requestedTourStep}/{steps.length}
181+
</Typography>
182+
183+
<Box display='flex' alignItems='center'>
184+
<Button
185+
onClick={stop}
186+
color="primary"
187+
>
188+
{hasOtherSteps ? 'Skip' : 'Close'}
189+
</Button>
190+
191+
{hasOtherSteps && (
233192
<Button
234-
onClick={stop}
193+
variant='contained'
235194
color="primary"
236-
style={{
237-
display: 'block',
238-
margin: '0 auto',
239-
color: primaryColor,
240-
border: 'none',
241-
padding: '8px 16px',
242-
borderRadius: '4px',
243-
fontSize: '16px',
244-
cursor: 'pointer',
245-
position: 'absolute',
246-
right: '85px',
247-
bottom: '25px',
248-
}}
249-
>
250-
{hasOtherSteps ? 'Skip' : 'Close'}
251-
</Button>
252-
{(hasOtherSteps)
253-
&& (
254-
<Button
255195
onClick={listen}
256196
disabled={!nextIsVisible}
257-
style={{
258-
display: 'block',
259-
margin: '0 auto',
260-
backgroundColor: primaryColor,
261-
color: !nextIsVisible ? secondaryTextColor : primaryTextColor,
262-
border: 'none',
263-
padding: '8px 16px',
264-
borderRadius: '4px',
265-
fontSize: '16px',
266-
cursor: 'pointer',
267-
position: 'absolute',
268-
right: '15px',
269-
bottom: '25px',
270-
}}
271197
>
272198
Next
273199
</Button>
274-
)}
275-
</Grid>
276-
</Grid>
277-
</Grid>
278-
</div>
279-
</div>
280-
</div>
200+
)}
201+
</Box>
202+
</Box>
203+
</Box>
204+
</Box>
205+
</Box>
281206
);
282207
};
283208

webapp/css/netpyne.less

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,3 +618,55 @@ body {
618618
}
619619
}
620620
}
621+
622+
.tutorials {
623+
&_highlight {
624+
position: absolute;
625+
border-radius: 0.25rem;
626+
pointer-events: none;
627+
border: solid 0.125rem;
628+
z-index: 1501; // Just over the menus items (1500)
629+
}
630+
631+
&_wrapper {
632+
position: relative;
633+
}
634+
635+
&_content {
636+
position: absolute;
637+
background: @bgRegular;
638+
box-shadow: @tutorialShadow;
639+
backdrop-filter: blur(1.25rem);
640+
border-radius: 0.25rem;
641+
padding: 1.25rem;
642+
width: 25rem;
643+
z-index: 1501; // Just over the menus items (1500)
644+
645+
h3 {
646+
margin: 0 0 0.75rem;
647+
font-weight: 600;
648+
font-size: 1.25rem;
649+
line-height: 1.5rem;
650+
color: @textColor;
651+
}
652+
653+
p {
654+
font-weight: 400;
655+
font-size: 1rem;
656+
margin: 0;
657+
line-height: 1.5rem;
658+
color: rgba(@textColor, 0.8);
659+
660+
& + p {
661+
margin-top: 0.5rem;
662+
}
663+
}
664+
665+
.MuiButton-root {
666+
font-weight: 600;
667+
&:not(:first-child) {
668+
margin-left: 0.5rem;
669+
}
670+
}
671+
}
672+
}

webapp/css/variables.less

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,4 @@
3838
@fabDisableColor: rgba(255, 255, 255, 0.3);
3939
@navShadow: rgba(255, 255, 255, 0.2);
4040
@tabsTextColor: rgba(255, 255, 255, 0.7);
41+
@tutorialShadow: 0px 10px 60px rgba(0, 0, 0, 0.5);

0 commit comments

Comments
 (0)