Skip to content

Commit 7d1f5ef

Browse files
Immersive guides (#1354)
* Add icon and empty drawer * Move link and command styling to be reusable * Add help message in guide sidebar * Add types to documenation * Add carousel * Reset slide and add background * Basic guide resolving done * Remove dialog and support fullscreen * landing page * Move carousel to own file * Only render next slide buttons when we have lides * Revert "Remove dialog and support fullscreen" This reverts commit e66b02b. * Review comments * Add new slide for guides * Guide migration plumbing * Directives on index page * Icons * Index skeleton looks * Fix darkmode and scroll into view * Keep carousel at bottom * Wider sidebar * Add network error * Prevent title overflow * Start formatting movies guide * Update snapshots * Self review * Style indexpage * Improve title regex, list decoration and click effect on guides * Breakout styled comps * Add next and previous buttons * Update monaco to get rid of scrollbar * Code block look in darkmode * Move title to make sandbox example more natural * Migrate play movies * Remove squashing effect during sidebar animation * Update movie graph text * Add class for removing play icon * Rename force dark mode * update types * Migrate index * migrate concepts * AddSidebarSlide * Make sidebar slide its own component * Restore north-wind guide * Fix comments * Migrate northwind * Migrate cypher tutorial * Fix cypher guide issues * incorrect link * Keep track of current slide * Fix review comments * Update snapshots * Update not found page * Work on test * Rename file to solve capitalization issue * Update snapshots * Make inputs readable * Don't use theme in sidebar * Remove overflow on body * Drop manual link postfix * Update snapshot * Remove overflow on body * Move exception to cssfile * Remove bug that added many on click handlers
1 parent 812ffcc commit 7d1f5ef

File tree

78 files changed

+3389
-368
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+3389
-368
lines changed

src/browser/components/Directives.tsx

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,20 @@ import * as editor from 'shared/modules/editor/editorDuck'
2828
import { addClass, prependIcon } from 'shared/services/dom-helpers'
2929

3030
const directives = [
31+
{
32+
selector: '[data-exec]',
33+
valueExtractor: (elem: any) => {
34+
return `${elem.getAttribute('data-exec')}`
35+
},
36+
autoExec: true
37+
},
38+
{
39+
selector: '[data-populate]',
40+
valueExtractor: (elem: any) => {
41+
return `${elem.getAttribute('data-populate')}`
42+
},
43+
autoExec: false
44+
},
3145
{
3246
selector: '[exec-topic]',
3347
valueExtractor: (elem: any) => {
@@ -99,15 +113,20 @@ const bindDynamicInputToDom = (element: any) => {
99113
}
100114

101115
export const Directives = (props: any) => {
102-
const callback = (elem: any) => {
116+
const callback = (elem: HTMLDivElement | null) => {
103117
if (elem) {
104118
directives.forEach(directive => {
105119
const elems = elem.querySelectorAll(directive.selector)
106-
Array.from(elems).forEach((e: any) => {
107-
if (e.firstChild.nodeName !== 'I') {
120+
Array.from(elems).forEach(e => {
121+
if (
122+
e.firstChild?.nodeName !== 'I' &&
123+
!e.classList.contains('remove-play-icon')
124+
) {
108125
prependPlayIcon(e)
109126
}
110127

128+
// If we use add event listener we need to remove it afterwards
129+
// @ts-expect-error
111130
e.onclick = () => {
112131
addClass(e, 'clicked')
113132
return props.onItemClick(

src/browser/components/ManualLink.test.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020

2121
import React from 'react'
2222
import { render } from '@testing-library/react'
23-
24-
import { ManualLink } from './ManualLink'
23+
import { ManualLink } from 'browser-components/ManualLink'
2524

2625
const tests: [Record<string, string | null>, string][] = [
2726
[

src/browser/components/ManualLink.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import semver from 'semver'
2424

2525
import { getVersion } from 'shared/modules/dbMeta/dbMetaDuck'
2626
import { formatDocVersion } from 'browser/modules/Sidebar/Documents'
27+
import { DrawerExternalLink } from './drawer/drawer-styled'
2728

2829
const movedPages: { [key: string]: { oldPage: string; oldContent: string } } = {
2930
'/administration/indexes-for-search-performance/': {
@@ -52,7 +53,7 @@ export function ManualLink({
5253
children,
5354
neo4jVersion,
5455
minVersion
55-
}: any) {
56+
}: any): JSX.Element {
5657
let cleanPage = page.replace(/^\//, '')
5758
let content = children
5859
if (isPageMoved(chapter, page, neo4jVersion)) {
@@ -70,15 +71,11 @@ export function ManualLink({
7071

7172
const url = `https://neo4j.com/docs/${chapter}/${version}/${cleanPage}`
7273

73-
return (
74-
<a href={url} target="_blank" rel="noreferrer">
75-
{content}
76-
</a>
77-
)
74+
return <DrawerExternalLink href={url}>{content}</DrawerExternalLink>
7875
}
7976

8077
const mapStateToProps = (state: any) => ({
8178
neo4jVersion: getVersion(state)
8279
})
8380

84-
export default connect<any, any, any, any>(mapStateToProps, null)(ManualLink)
81+
export default connect(mapStateToProps)(ManualLink)

src/browser/components/SavedScripts/SavedScriptsFolder.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ interface SavedScriptsFolderProps {
5151
forceEdit: boolean
5252
onDoneEditing: () => void
5353
selectedScriptIds: string[]
54-
children: JSX.Element[]
54+
children: React.ReactNode
5555
}
5656

5757
function SavedScriptsFolder({

src/browser/components/TabNavigation/Navigation.tsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,14 @@ import {
3232
StyledTopNav,
3333
StyledBottomNav
3434
} from './styled'
35+
import { GUIDE_DRAWER_ID } from 'shared/modules/sidebar/sidebarDuck'
3536

3637
const Closing = 'CLOSING'
3738
const Closed = 'CLOSED'
3839
const Open = 'OPEN'
3940
const Opening = 'OPENING'
41+
export const LARGE_DRAWER_WIDTH = 500
42+
export const STANDARD_DRAWER_WIDTH = 300
4043

4144
export interface NavItem {
4245
name: string
@@ -169,17 +172,22 @@ class Navigation extends Component<NavigationProps, NavigationState> {
169172
this.state.drawerContent
170173
)
171174

175+
const drawerWidth =
176+
this.props.openDrawer === GUIDE_DRAWER_ID
177+
? LARGE_DRAWER_WIDTH
178+
: STANDARD_DRAWER_WIDTH
179+
const useFullWidth =
180+
this.state.transitionState === Open ||
181+
this.state.transitionState === Opening
182+
const width = useFullWidth ? drawerWidth : 0
172183
return (
173184
<StyledSidebar>
174185
<StyledTabsWrapper>
175186
<StyledTopNav>{topNavItemsList}</StyledTopNav>
176187
<StyledBottomNav>{bottomNavItemsList}</StyledBottomNav>
177188
</StyledTabsWrapper>
178189
<StyledDrawer
179-
open={
180-
this.state.transitionState === Open ||
181-
this.state.transitionState === Opening
182-
}
190+
width={width}
183191
ref={(ref: any) => {
184192
if (ref) {
185193
// Remove old listeners so we don't get multiple callbacks.

src/browser/components/TabNavigation/styled.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ export const StyledSidebar = styled.div`
2828
color: #fff;
2929
`
3030

31-
export const StyledDrawer: any = styled.div`
31+
export const StyledDrawer = styled.div<{ width: number }>`
3232
flex: 0 0 auto;
3333
background-color: #31333b;
3434
overflow-x: hidden;
3535
overflow-y: auto;
36-
width: ${(props: any) => (props.open ? '300px' : '0px')};
36+
width: ${props => props.width}px;
3737
transition: 0.2s ease-out;
3838
z-index: 1;
3939
`

src/browser/components/drawer/Drawer.tsx renamed to src/browser/components/drawer/drawer-styled.tsx

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
*/
2020

2121
import styled from 'styled-components'
22+
import linkIcon from 'icons/external-link.svg'
2223

2324
export const Drawer = styled.div`
2425
width: 290px;
@@ -43,6 +44,9 @@ export const DrawerHeader = styled.h4`
4344
export const DrawerToppedHeader = styled(DrawerHeader)`
4445
padding-top: 8px;
4546
`
47+
export const DrawerSeparator = styled.div`
48+
border-bottom: 1px solid #424650;
49+
`
4650

4751
export const DrawerSubHeader = styled.h5`
4852
color: ${props => props.theme.primaryHeaderText};
@@ -76,3 +80,41 @@ export const DrawerFooter = styled.div`
7680
margin-bottom: 20px;
7781
text-align: center;
7882
`
83+
84+
export const DrawerExternalLink = styled.a.attrs({
85+
target: '_blank',
86+
rel: 'noreferrer'
87+
})`
88+
cursor: pointer;
89+
text-decoration: none;
90+
color: #68bdf4;
91+
92+
&:active {
93+
text-decoration: none;
94+
}
95+
96+
&:before {
97+
display: inline-block;
98+
content: ' ';
99+
background-image: url("data:image/svg+xml;utf8,${linkIcon}");
100+
height: 12px;
101+
width: 12px;
102+
margin-right: 7px;
103+
}
104+
`
105+
106+
export const DrawerBrowserCommand = styled.span.attrs({
107+
className: 'remove-play-icon'
108+
})`
109+
background-color: #2a2c33;
110+
border-radius: 2px;
111+
padding: 3px;
112+
113+
color: #e36962;
114+
font-family: Fira Code;
115+
116+
overflow: hidden;
117+
white-space: nowrap;
118+
text-overflow: ellipsis;
119+
cursor: pointer;
120+
`

src/browser/components/icons/Icons.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import addCircle from 'icons/add-circle.svg'
2626
import appWindowCode from 'icons/app-window-code.svg'
2727
import arrowLeft from 'icons/arrow-left.svg'
2828
import arrowRight from 'icons/arrow-right.svg'
29+
import backArrow from 'icons/back-arrow.svg'
2930
import buttonRefreshArrow from 'icons/button-refresh-arrow.svg'
3031
import cannyFeedback from 'icons/canny-feedback.svg'
3132
import cannyNotifications from 'icons/canny-notifications.svg'
@@ -39,6 +40,7 @@ import expand from 'icons/expand.svg'
3940
import file from 'icons/file.svg'
4041
import folderEmpty from 'icons/folder-empty.svg'
4142
import help from 'icons/help.svg'
43+
import monitorPlay from 'icons/monitor-play.svg'
4244
import navigationMenuVertical from 'icons/navigation-menu-vertical.svg'
4345
import neo4j from 'icons/neo-world.svg'
4446
import newFolder from 'icons/folder-add.svg'
@@ -135,6 +137,17 @@ export const DatabaseIcon = (props: {
135137
)
136138
}
137139

140+
export const GuidesDrawerIcon = (props: { isOpen: boolean }): JSX.Element => (
141+
<IconContainer
142+
activeStyle={white}
143+
inactiveStyle={inactive}
144+
width={28}
145+
isOpen={props.isOpen}
146+
icon={monitorPlay}
147+
title="Guides"
148+
/>
149+
)
150+
138151
interface SidebarIconProps {
139152
isOpen: boolean
140153
title: string
@@ -339,6 +352,7 @@ export const MinusIcon = (): JSX.Element => (
339352
className="sl-minus-circle"
340353
/>
341354
)
355+
342356
export const RightArrowIcon = (): JSX.Element => (
343357
<IconContainer
344358
activeStyle={blue}
@@ -455,3 +469,7 @@ export const CannyFeedbackIcon = (): JSX.Element => (
455469
export const CannyNotificationsIcon = (): JSX.Element => (
456470
<IconContainer icon={cannyNotifications} />
457471
)
472+
473+
export const BackIcon = ({ width }: { width: number }): JSX.Element => (
474+
<IconContainer width={width} icon={backArrow} />
475+
)

0 commit comments

Comments
 (0)