1+ import * as React from 'react' ;
12import Slide , { SlideProps } from './slide/slide' ;
2- import { Box , FlexBox } from './layout-primitives' ;
3+ import { Box , FlexBox , Grid } from './layout-primitives' ;
4+ import CodePane , { CodePaneProps } from './code-pane' ;
35import { ComponentProps , Fragment , ReactNode } from 'react' ;
46import {
57 Heading ,
@@ -192,11 +194,110 @@ const Quote = ({
192194 </ Slide >
193195) ;
194196
197+ /**
198+ * Generic Codepane utility with optional Description text
199+ */
200+ const CodeLayout = ( {
201+ text,
202+ textProps,
203+ children,
204+ ...props
205+ } : CodePaneProps & {
206+ text ?: string | ReactNode ;
207+ textProps ?: ComponentProps < typeof Text > ;
208+ } ) => (
209+ < Box data-testid = "CodePane" >
210+ { text ? (
211+ < Text margin = { 8 } { ...textProps } >
212+ { text }
213+ </ Text >
214+ ) : null }
215+ < CodePane { ...props } > { children } </ CodePane >
216+ </ Box >
217+ ) ;
218+
219+ /**
220+ * single Code Pane with optional Title layout
221+ */
222+ const Code = ( {
223+ children,
224+ language,
225+ title,
226+ titleProps,
227+ codePaneProps,
228+ ...rest
229+ } : Omit < SlideProps , 'children' > & {
230+ children : string ;
231+ language : string ;
232+ title ?: string | ReactNode ;
233+ titleProps ?: ComponentProps < typeof Text > ;
234+ codePaneProps ?: CodePaneProps ;
235+ } ) => {
236+ return (
237+ < Slide { ...rest } >
238+ < Box display = "inline-block" style = { { overflow : 'scroll' } } >
239+ { title ? < Heading { ...titleProps } > { title } </ Heading > : null }
240+ < CodeLayout language = { language } { ...codePaneProps } >
241+ { children }
242+ </ CodeLayout >
243+ </ Box >
244+ </ Slide >
245+ ) ;
246+ } ;
247+
248+ /**
249+ * multiple Code Panes with optional Description, with optional Title layout
250+ */
251+ const MultiCodeLayout = ( {
252+ codeBlocks,
253+ title,
254+ titleProps,
255+ numColumns = 1 ,
256+ ...rest
257+ } : Omit < SlideProps , 'children' > & {
258+ codeBlocks : Array <
259+ Omit < CodePaneProps , 'children' > & {
260+ code : CodePaneProps [ 'children' ] ;
261+ description ?: string | ReactNode ;
262+ descriptionProps ?: ComponentProps < typeof Text > ;
263+ }
264+ > ;
265+ title ?: string | ReactNode ;
266+ titleProps ?: ComponentProps < typeof Text > ;
267+ numColumns ?: number ;
268+ } ) => {
269+ return (
270+ < Slide { ...rest } >
271+ < Box display = "inline-block" style = { { overflow : 'scroll' } } >
272+ { title ? < Heading { ...titleProps } > { title } </ Heading > : null }
273+ < Grid
274+ gridRowGap = { 1 }
275+ gridColumnGap = { 1 }
276+ gridTemplateColumns = { `repeat(${ numColumns } , minmax(100px, 1fr))` }
277+ maxWidth = "100%"
278+ >
279+ { codeBlocks . map (
280+ ( { description, descriptionProps, code, ...codePaneProps } , i ) => (
281+ < CodeLayout
282+ key = { i }
283+ text = { description }
284+ textProps = { descriptionProps }
285+ { ...codePaneProps }
286+ >
287+ { code }
288+ </ CodeLayout >
289+ )
290+ ) }
291+ </ Grid >
292+ </ Box >
293+ </ Slide >
294+ ) ;
295+ } ;
296+
195297/**
196298 * Layouts to consider:
197299 * - Image (left, right, full bleed?)
198300 * - Intro
199- * - Code Snippet (syntax highlighting)
200301 */
201302
202303export default {
@@ -207,5 +308,7 @@ export default {
207308 Section,
208309 BigFact,
209310 Quote,
210- Statement
311+ Statement,
312+ Code,
313+ MultiCodeLayout
211314} ;
0 commit comments