Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add guides to sidebar #1354

Merged
merged 64 commits into from
Apr 20, 2021
Merged
Show file tree
Hide file tree
Changes from 53 commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
9d56eea
Add icon and empty drawer
OskarDamkjaer Mar 16, 2021
aed65fd
Move link and command styling to be reusable
OskarDamkjaer Mar 16, 2021
d15bb87
Add help message in guide sidebar
OskarDamkjaer Mar 16, 2021
6196260
Add types to documenation
OskarDamkjaer Mar 16, 2021
2d66742
Add carousel
OskarDamkjaer Mar 18, 2021
4211d0f
Reset slide and add background
OskarDamkjaer Mar 19, 2021
b700380
Basic guide resolving done
OskarDamkjaer Apr 10, 2021
c594181
Remove dialog and support fullscreen
OskarDamkjaer Apr 10, 2021
c11ccc9
landing page
OskarDamkjaer Apr 10, 2021
fda3cf8
Move carousel to own file
OskarDamkjaer Apr 11, 2021
2d86d5b
Only render next slide buttons when we have lides
OskarDamkjaer Apr 11, 2021
a2de5c6
Revert "Remove dialog and support fullscreen"
OskarDamkjaer Apr 12, 2021
f2f5d57
Review comments
OskarDamkjaer Apr 12, 2021
3d577a3
Add new slide for guides
OskarDamkjaer Apr 12, 2021
d935a09
Guide migration plumbing
OskarDamkjaer Apr 12, 2021
f613e17
Directives on index page
OskarDamkjaer Apr 12, 2021
02325dd
Icons
OskarDamkjaer Apr 13, 2021
47e3a9d
Index skeleton looks
OskarDamkjaer Apr 13, 2021
e9e4b5a
Fix darkmode and scroll into view
OskarDamkjaer Apr 13, 2021
7cd4672
Keep carousel at bottom
OskarDamkjaer Apr 13, 2021
bbac607
Wider sidebar
OskarDamkjaer Apr 13, 2021
a35193a
Add network error
OskarDamkjaer Apr 13, 2021
34f4fcd
Prevent title overflow
OskarDamkjaer Apr 13, 2021
375706a
Start formatting movies guide
OskarDamkjaer Apr 13, 2021
69c5471
Update snapshots
OskarDamkjaer Apr 14, 2021
197adbb
Self review
OskarDamkjaer Apr 14, 2021
e0dbca9
Style indexpage
OskarDamkjaer Apr 15, 2021
54ab451
Improve title regex, list decoration and click effect on guides
OskarDamkjaer Apr 15, 2021
ff7de27
Breakout styled comps
OskarDamkjaer Apr 15, 2021
ee37d7e
Add next and previous buttons
OskarDamkjaer Apr 19, 2021
d80629c
Update monaco to get rid of scrollbar
OskarDamkjaer Apr 19, 2021
c9c31b2
Code block look in darkmode
OskarDamkjaer Apr 19, 2021
b289a83
Move title to make sandbox example more natural
OskarDamkjaer Apr 19, 2021
1b981c8
Migrate play movies
OskarDamkjaer Apr 19, 2021
58d96ee
Remove squashing effect during sidebar animation
OskarDamkjaer Apr 19, 2021
00a4eea
Update movie graph text
OskarDamkjaer Apr 19, 2021
5cd38d3
Add class for removing play icon
OskarDamkjaer Apr 19, 2021
6a4fd10
Rename force dark mode
OskarDamkjaer Apr 19, 2021
0799a6b
update types
OskarDamkjaer Apr 19, 2021
31316f4
Migrate index
OskarDamkjaer Apr 19, 2021
30f0427
migrate concepts
OskarDamkjaer Apr 19, 2021
e20c949
AddSidebarSlide
OskarDamkjaer Apr 19, 2021
41ec95c
Make sidebar slide its own component
OskarDamkjaer Apr 19, 2021
cf0089c
Restore north-wind guide
OskarDamkjaer Apr 19, 2021
76aa1bd
Fix comments
OskarDamkjaer Apr 19, 2021
c5b4e5c
Migrate northwind
OskarDamkjaer Apr 19, 2021
023c5fc
Migrate cypher tutorial
OskarDamkjaer Apr 19, 2021
0a1830f
Fix cypher guide issues
OskarDamkjaer Apr 19, 2021
39a2b06
incorrect link
OskarDamkjaer Apr 19, 2021
6c6a48c
Keep track of current slide
OskarDamkjaer Apr 19, 2021
94687b4
Fix review comments
OskarDamkjaer Apr 20, 2021
3d7dd75
Update snapshots
OskarDamkjaer Apr 20, 2021
a5be0ec
Update not found page
OskarDamkjaer Apr 20, 2021
4a1fcef
Work on test
OskarDamkjaer Apr 20, 2021
0a078c5
Rename file to solve capitalization issue
OskarDamkjaer Apr 20, 2021
4195f3c
Update snapshots
OskarDamkjaer Apr 20, 2021
de90c52
Make inputs readable
OskarDamkjaer Apr 20, 2021
b1167fe
Don't use theme in sidebar
OskarDamkjaer Apr 20, 2021
0b46084
Remove overflow on body
OskarDamkjaer Apr 20, 2021
b4cd6a0
Drop manual link postfix
OskarDamkjaer Apr 20, 2021
2f11ac9
Update snapshot
OskarDamkjaer Apr 20, 2021
d19fa0b
Remove overflow on body
OskarDamkjaer Apr 20, 2021
aa522e4
Move exception to cssfile
OskarDamkjaer Apr 20, 2021
60321e9
Remove bug that added many on click handlers
OskarDamkjaer Apr 20, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 22 additions & 5 deletions src/browser/components/Directives.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,20 @@ import * as editor from 'shared/modules/editor/editorDuck'
import { addClass, prependIcon } from 'shared/services/dom-helpers'

const directives = [
{
selector: '[data-exec]',
OskarDamkjaer marked this conversation as resolved.
Show resolved Hide resolved
valueExtractor: (elem: any) => {
return `${elem.getAttribute('data-exec')}`
},
autoExec: true
},
{
selector: '[data-populate]',
valueExtractor: (elem: any) => {
return `${elem.getAttribute('data-populate')}`
},
autoExec: false
},
{
selector: '[exec-topic]',
valueExtractor: (elem: any) => {
Expand Down Expand Up @@ -99,23 +113,26 @@ const bindDynamicInputToDom = (element: any) => {
}

export const Directives = (props: any) => {
const callback = (elem: any) => {
const callback = (elem: HTMLDivElement | null) => {
if (elem) {
directives.forEach(directive => {
const elems = elem.querySelectorAll(directive.selector)
Array.from(elems).forEach((e: any) => {
if (e.firstChild.nodeName !== 'I') {
Array.from(elems).forEach(e => {
if (
e.firstChild?.nodeName !== 'I' &&
!e.classList.contains('remove-play-icon')
) {
prependPlayIcon(e)
}

e.onclick = () => {
e.addEventListener('click', () => {
addClass(e, 'clicked')
return props.onItemClick(
directive.valueExtractor(e),
directive.autoExec,
props.originFrameId
)
}
})
})
})
bindDynamicInputToDom(elem)
Expand Down
11 changes: 4 additions & 7 deletions src/browser/components/ManualLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import semver from 'semver'

import { getVersion } from 'shared/modules/dbMeta/dbMetaDuck'
import { formatDocVersion } from 'browser/modules/Sidebar/Documents'
import { DrawerExternalLink } from './drawer/drawer'

const movedPages: { [key: string]: { oldPage: string; oldContent: string } } = {
'/administration/indexes-for-search-performance/': {
Expand Down Expand Up @@ -52,7 +53,7 @@ export function ManualLink({
children,
neo4jVersion,
minVersion
}: any) {
}: any): JSX.Element {
let cleanPage = page.replace(/^\//, '')
let content = children
if (isPageMoved(chapter, page, neo4jVersion)) {
Expand All @@ -70,15 +71,11 @@ export function ManualLink({

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

return (
<a href={url} target="_blank" rel="noreferrer">
{content}
</a>
)
return <DrawerExternalLink href={url}>{content}</DrawerExternalLink>
}

const mapStateToProps = (state: any) => ({
neo4jVersion: getVersion(state)
})

export default connect<any, any, any, any>(mapStateToProps, null)(ManualLink)
export default connect(mapStateToProps)(ManualLink)
2 changes: 1 addition & 1 deletion src/browser/components/SavedScripts/SavedScriptsFolder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ interface SavedScriptsFolderProps {
forceEdit: boolean
onDoneEditing: () => void
selectedScriptIds: string[]
children: JSX.Element[]
children: React.ReactNode
}

function SavedScriptsFolder({
Expand Down
16 changes: 12 additions & 4 deletions src/browser/components/TabNavigation/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,14 @@ import {
StyledTopNav,
StyledBottomNav
} from './styled'
import { GUIDE_DRAWER_ID } from 'shared/modules/sidebar/sidebarDuck'

const Closing = 'CLOSING'
const Closed = 'CLOSED'
const Open = 'OPEN'
const Opening = 'OPENING'
export const LARGE_DRAWER_WIDTH = 500
export const STANDARD_DRAWER_WIDTH = 300

export interface NavItem {
name: string
Expand Down Expand Up @@ -169,17 +172,22 @@ class Navigation extends Component<NavigationProps, NavigationState> {
this.state.drawerContent
)

const drawerWidth =
this.props.openDrawer === GUIDE_DRAWER_ID
? LARGE_DRAWER_WIDTH
: STANDARD_DRAWER_WIDTH
const useFullWidth =
this.state.transitionState === Open ||
this.state.transitionState === Opening
const width = useFullWidth ? drawerWidth : 0
return (
<StyledSidebar>
<StyledTabsWrapper>
<StyledTopNav>{topNavItemsList}</StyledTopNav>
<StyledBottomNav>{bottomNavItemsList}</StyledBottomNav>
</StyledTabsWrapper>
<StyledDrawer
open={
this.state.transitionState === Open ||
this.state.transitionState === Opening
}
width={width}
ref={(ref: any) => {
if (ref) {
// Remove old listeners so we don't get multiple callbacks.
Expand Down
4 changes: 2 additions & 2 deletions src/browser/components/TabNavigation/styled.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ export const StyledSidebar = styled.div`
color: #fff;
`

export const StyledDrawer: any = styled.div`
export const StyledDrawer = styled.div<{ width: number }>`
flex: 0 0 auto;
background-color: #31333b;
overflow-x: hidden;
overflow-y: auto;
width: ${(props: any) => (props.open ? '300px' : '0px')};
width: ${props => props.width}px;
transition: 0.2s ease-out;
z-index: 1;
`
Expand Down
42 changes: 42 additions & 0 deletions src/browser/components/drawer/Drawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/

import styled from 'styled-components'
import linkIcon from 'icons/external-link.svg'

export const Drawer = styled.div`
width: 290px;
Expand All @@ -43,6 +44,9 @@ export const DrawerHeader = styled.h4`
export const DrawerToppedHeader = styled(DrawerHeader)`
padding-top: 8px;
`
export const DrawerSeparator = styled.div`
border-bottom: 1px solid #424650;
`

export const DrawerSubHeader = styled.h5`
color: ${props => props.theme.primaryHeaderText};
Expand Down Expand Up @@ -76,3 +80,41 @@ export const DrawerFooter = styled.div`
margin-bottom: 20px;
text-align: center;
`

export const DrawerExternalLink = styled.a.attrs({
target: '_blank',
rel: 'noreferrer'
})`
cursor: pointer;
text-decoration: none;
color: #68bdf4;

&:active {
text-decoration: none;
}

&:before {
display: inline-block;
content: ' ';
background-image: url("data:image/svg+xml;utf8,${linkIcon}");
height: 12px;
width: 12px;
margin-right: 7px;
}
`

export const DrawerBrowserCommand = styled.span.attrs({
className: 'remove-play-icon'
})`
background-color: #2a2c33;
border-radius: 2px;
padding: 3px;

color: #e36962;
font-family: Fira Code;

overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
cursor: pointer;
`
18 changes: 18 additions & 0 deletions src/browser/components/icons/Icons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import addCircle from 'icons/add-circle.svg'
import appWindowCode from 'icons/app-window-code.svg'
import arrowLeft from 'icons/arrow-left.svg'
import arrowRight from 'icons/arrow-right.svg'
import backArrow from 'icons/back-arrow.svg'
import buttonRefreshArrow from 'icons/button-refresh-arrow.svg'
import cannyFeedback from 'icons/canny-feedback.svg'
import cannyNotifications from 'icons/canny-notifications.svg'
Expand All @@ -39,6 +40,7 @@ import expand from 'icons/expand.svg'
import file from 'icons/file.svg'
import folderEmpty from 'icons/folder-empty.svg'
import help from 'icons/help.svg'
import monitorPlay from 'icons/monitor-play.svg'
import navigationMenuVertical from 'icons/navigation-menu-vertical.svg'
import neo4j from 'icons/neo-world.svg'
import newFolder from 'icons/folder-add.svg'
Expand Down Expand Up @@ -135,6 +137,17 @@ export const DatabaseIcon = (props: {
)
}

export const GuidesDrawerIcon = (props: { isOpen: boolean }): JSX.Element => (
<IconContainer
activeStyle={white}
inactiveStyle={inactive}
width={28}
isOpen={props.isOpen}
icon={monitorPlay}
title="Guides"
/>
)

interface SidebarIconProps {
isOpen: boolean
title: string
Expand Down Expand Up @@ -339,6 +352,7 @@ export const MinusIcon = (): JSX.Element => (
className="sl-minus-circle"
/>
)

export const RightArrowIcon = (): JSX.Element => (
<IconContainer
activeStyle={blue}
Expand Down Expand Up @@ -455,3 +469,7 @@ export const CannyFeedbackIcon = (): JSX.Element => (
export const CannyNotificationsIcon = (): JSX.Element => (
<IconContainer icon={cannyNotifications} />
)

export const BackIcon = ({ width }: { width: number }): JSX.Element => (
<IconContainer width={width} icon={backArrow} />
)
Loading