Skip to content

Commit 3586655

Browse files
Support experimental features in CodeTabs
1 parent 43f4439 commit 3586655

File tree

5 files changed

+20
-4
lines changed

5 files changed

+20
-4
lines changed

src/components/CodeExample.res

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ module Toggle = {
157157
label: option<string>,
158158
lang: option<string>,
159159
code: string,
160+
experiments: option<string>,
160161
}
161162

162163
@react.component
@@ -243,7 +244,12 @@ module Toggle = {
243244
let playgroundLinkButton =
244245
tab->isReScript
245246
? <Next.Link
246-
href={`/try?code=${LzString.compressToEncodedURIComponent(tab.code)}}`}
247+
href={`/try?code=${LzString.compressToEncodedURIComponent(
248+
tab.code,
249+
)}&experiments=${switch tab.experiments {
250+
| Some(experiments) => experiments
251+
| None => ""
252+
}}`}
247253
target="_blank">
248254
// ICON Link to PLAYGROUND
249255
<Icon.ExternalLink

src/components/CodeExample.resi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ module Toggle: {
1313
label: option<string>,
1414
lang: option<string>,
1515
code: string,
16+
experiments: option<string>,
1617
}
1718

1819
@react.component

src/components/Markdown.res

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,11 @@ module CodeTab = {
287287
return element.props.metastring;
288288
}")
289289
@react.component
290-
let make = (~children: Mdx.MdxChildren.t, ~labels: array<string>=[]) => {
290+
let make = (
291+
~children: Mdx.MdxChildren.t,
292+
~labels: array<string>=[],
293+
~experiments: option<string>=?,
294+
) => {
291295
let mdxElements = switch Mdx.MdxChildren.classify(children) {
292296
| Array(mdxElements) => mdxElements
293297
| Element(el) => [el]
@@ -315,6 +319,7 @@ module CodeTab = {
315319
code,
316320
label,
317321
highlightedLines: Some(Code.parseNumericRangeMeta(metastring)),
322+
experiments,
318323
}
319324
Array.push(acc, tab)->ignore
320325

src/components/Markdown.resi

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,11 @@ module Code: {
9999

100100
module CodeTab: {
101101
@react.component
102-
let make: (~children: Mdx.MdxChildren.t, ~labels: array<string>=?) => React.element
102+
let make: (
103+
~children: Mdx.MdxChildren.t,
104+
~labels: array<string>=?,
105+
~experiments: string=?,
106+
) => React.element
103107
}
104108

105109
module Blockquote: {

src/components/MarkdownComponents.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ type t = {
2020
@as("UrlBox")
2121
urlBox?: React.componentLike<UrlBox.props<string, string, Mdx.MdxChildren.t>, React.element>,
2222
@as("CodeTab")
23-
codeTab?: CodeTab.props<Mdx.MdxChildren.t, array<string>> => React.element,
23+
codeTab?: CodeTab.props<Mdx.MdxChildren.t, array<string>, string> => React.element,
2424
/* Common markdown elements */
2525
p?: P.props<React.element> => React.element,
2626
li?: Li.props<React.element> => React.element,

0 commit comments

Comments
 (0)