Skip to content

Commit 352b754

Browse files
committed
Add carousel
1 parent 050fe68 commit 352b754

File tree

8 files changed

+322
-38
lines changed

8 files changed

+322
-38
lines changed

src/browser/components/TabNavigation/styled.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export const StyledDrawer: any = styled.div`
3333
background-color: #31333b;
3434
overflow-x: hidden;
3535
overflow-y: auto;
36-
width: ${(props: any) => (props.open ? '300px' : '0px')};
36+
width: ${(props: any) => (props.open ? 'auto' : '0px')};
3737
transition: 0.2s ease-out;
3838
z-index: 1;
3939
`
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import React from 'react'
2+
import { DrawerBrowserCommand } from 'browser-components/drawer'
3+
import Slide from 'browser/modules/Carousel/Slide'
4+
5+
const title = 'all guides'
6+
const slides = [
7+
<Slide key="first">
8+
use the dropdown to pick a guide
9+
<br />
10+
You can also access Browser guides by running
11+
<DrawerBrowserCommand> :play {'<guide_name>'} </DrawerBrowserCommand>
12+
in the main editor
13+
</Slide>
14+
]
15+
16+
export default { title, slides }

src/browser/documentation/guides/movie-graph.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import React from 'react'
2222
import ManualLink from 'browser-components/ManualLink'
2323
import Slide from '../../modules/Carousel/Slide'
24-
import TextCommand from 'browser/modules/DecoratedText/TextCommand'
2524

2625
const title = 'Movie Graph'
2726
const category = 'graphExamples'

src/browser/documentation/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ import helpHelp from './dynamic/help'
8989
import helpPlay from './dynamic/play'
9090

9191
// Carousels
92+
import allGuides from './guides/allGuides'
9293
import guideConcepts from './guides/concepts'
9394
import guideCypher from './guides/cypher'
9495
import guideIntro from './guides/intro'
@@ -128,6 +129,7 @@ export type GuideChapter =
128129
| 'typography'
129130
| 'unfound'
130131
| 'writeCode'
132+
| 'allGuides'
131133

132134
type DocItem = {
133135
title: string
@@ -297,6 +299,7 @@ const docs: AllDocumentation = {
297299
play: {
298300
title: 'Guides & Examples',
299301
chapters: {
302+
allGuides: allGuides,
300303
concepts: guideConcepts,
301304
cypher: guideCypher,
302305
iconography: guideIconography,

src/browser/modules/Carousel/Carousel.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,9 @@ export default function Carousel({
4545
withDirectives,
4646
originFrameId,
4747
initialSlide = 1,
48-
slides = []
49-
}: any) {
48+
slides = [],
49+
showSideButtons
50+
}: any): JSX.Element {
5051
const [visibleSlide, setVisibleSlide] = useState(() => {
5152
if (initialSlide <= slides.length) {
5253
return initialSlide - 1
@@ -110,7 +111,7 @@ export default function Carousel({
110111
onKeyUp={(e: any) => onKeyDown(e)}
111112
tabIndex="0"
112113
>
113-
{visibleSlide > 0 && (
114+
{showSideButtons && visibleSlide > 0 && (
114115
<CarouselButton
115116
className="previous-slide rounded"
116117
data-testid="previousSlide"
@@ -163,7 +164,7 @@ export default function Carousel({
163164
getSlide(visibleSlide)
164165
)}
165166
</SlideContainer>
166-
{visibleSlide < slides.length - 1 && (
167+
{showSideButtons && visibleSlide < slides.length - 1 && (
167168
<CarouselButton
168169
className="next-slide rounded"
169170
data-testid="nextSlide"

src/browser/modules/Docs/Docs.tsx

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,31 @@ import Slide from '../Carousel/Slide'
2626
import MdxSlide from './MDX/MdxSlide'
2727
import { splitMdxSlides } from './MDX/splitMdx'
2828

29+
type DocsProps = {
30+
slides?: JSX.Element[] | null
31+
content?: JSX.Element | null
32+
html?: string
33+
mdx?: string
34+
initialSlide?: number
35+
onSlide?: Function
36+
lastUpdate?: number
37+
originFrameId?: string
38+
withDirectives?: true
39+
showSideButtons?: boolean
40+
}
41+
2942
export default function Docs({
3043
slides,
3144
content,
3245
html,
3346
mdx,
34-
withDirectives,
3547
initialSlide,
3648
onSlide,
3749
originFrameId,
38-
lastUpdate
39-
}: any) {
50+
withDirectives = true,
51+
lastUpdate,
52+
showSideButtons = true
53+
}: DocsProps): JSX.Element | null {
4054
const [stateSlides, setStateSlides] = useState<JSX.Element[]>([])
4155

4256
useEffect(() => {
@@ -68,15 +82,13 @@ export default function Docs({
6882
return
6983
}
7084

71-
if (withDirectives) {
72-
slide = <Directives originFrameId={originFrameId} content={slide} />
73-
}
85+
slide = <Directives originFrameId={originFrameId} content={slide} />
7486
setStateSlides([slide])
7587

7688
if (onSlide) {
7789
onSlide({ hasPrev: false, hasNext: false, slideIndex: 0 })
7890
}
79-
}, [slides, content, html, withDirectives, lastUpdate])
91+
}, [slides, content, html, lastUpdate])
8092

8193
if (stateSlides.length > 1) {
8294
return (
@@ -86,6 +98,7 @@ export default function Docs({
8698
initialSlide={initialSlide}
8799
withDirectives={withDirectives}
88100
originFrameId={originFrameId}
101+
showSideButtons={showSideButtons}
89102
/>
90103
)
91104
} else if (stateSlides.length) {

0 commit comments

Comments
 (0)