Skip to content

Commit 4563e86

Browse files
authored
Merge pull request #100 from reason-association/build-schema-fixes
Add link to visualize build-schema correctly, based on rescript-compi…
2 parents aedadff + 0c9ca95 commit 4563e86

File tree

13 files changed

+1737
-22
lines changed

13 files changed

+1737
-22
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ node_modules/
1414
index_data/*.json
1515
!index_data/blog_authors.json
1616
!index_data/blog_posts.json
17+
!index_data/build-schema.json
1718

1819
yarn-error.log
1920

components/Docson.res

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
Docson is a tool to render a json schema via client side JS.
3+
4+
Here is a list of files needed by this component:
5+
- Build schema is found in index_data/build-schema.json
6+
- Templates for rendering the content can be found in public/static/docson/.
7+
- Styles can be found in styles/docson.css
8+
9+
Please note that this component cannot be rendered on SSR, so use it in conjunction with
10+
Next's dynamic import mechanism.
11+
12+
*/
13+
14+
%%raw(`import "../styles/docson.css";`)
15+
16+
type t
17+
18+
@module("docson") external docson: t = "default"
19+
20+
@set external setTemplateBaseUrl: (t, string) => unit = "templateBaseUrl"
21+
22+
@module("docson") @scope("default")
23+
external doc: (string, Js.Json.t, option<string>, string) => unit = "doc"
24+
25+
@module("../index_data/build-schema.json") external schema: Js.Json.t = "default"
26+
27+
@react.component
28+
let make = () => {
29+
let element = React.useRef(Js.Nullable.null)
30+
31+
React.useEffect0(() => {
32+
let segment = "https://raw.githubusercontent.com/rescript-lang/rescript-compiler/master/docs/docson/build-schema.json"
33+
switch element.current->Js.Nullable.toOption {
34+
| Some(_el) =>
35+
setTemplateBaseUrl(docson, "/static/docson")
36+
37+
// The api for docson is a little bit funky, so you need to check out the source to understand what it's doing
38+
// See: https://github.com/lbovet/docson/blob/master/src/index.js
39+
doc("docson-root", schema, None, segment)
40+
41+
| None => ()
42+
}
43+
None
44+
})
45+
<div ref={ReactDOMRe.Ref.domRef(element)} id="docson-root"> </div>
46+
}

components/Navigation.re

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ let make = (~fixed=true, ~overlayState: (bool, (bool => bool) => unit)) => {
471471
[||],
472472
);
473473

474-
let fixedNav = fixed ? "fixed z-20 top-0" : "";
474+
let fixedNav = fixed ? "fixed z-30 top-0" : "";
475475

476476
<nav
477477
ref={ReactDOMRe.Ref.domRef(outerRef)}
@@ -587,7 +587,7 @@ let make = (~fixed=true, ~overlayState: (bool, (bool => bool) => unit)) => {
587587
style={Style.make(~minWidth, ~top="4.5rem", ())}
588588
className={
589589
(isOverlayOpen ? "flex" : "hidden")
590-
++ " sm:hidden flex-col fixed top-0 left-0 h-full w-full z-20 sm:w-9/12 bg-gray-100 sm:h-auto sm:flex sm:relative sm:flex-row sm:justify-between"
590+
++ " sm:hidden flex-col fixed top-0 left-0 h-full w-full z-30 sm:w-9/12 bg-gray-100 sm:h-auto sm:flex sm:relative sm:flex-row sm:justify-between"
591591
}>
592592
<MobileNav route />
593593
</div>

0 commit comments

Comments
 (0)