@@ -3,7 +3,7 @@ open ReactNative;
33
44type pageData = {
55 id: string ,
6- title: option ( string ) ,
6+ title: string ,
77 wip: option (bool ),
88 body: string ,
99 modulesIndex: array (string ),
@@ -35,7 +35,18 @@ let styles =
3535 ~borderRadius= 4 .,
3636 () ,
3737 ),
38- "editLinkText" : style(~color= color(Consts . Colors . accent), () ),
38+ "editLinkText" :
39+ style(~color= color(Consts . Colors . accent), ~alignItems= ` center , () ),
40+ "officialDocLink" :
41+ style(
42+ ~display= ` flex ,
43+ ~flexDirection= ` row ,
44+ ~fontSize= 14 .,
45+ ~fontWeight= `_300 ,
46+ ~alignItems= ` center ,
47+ ~color= color(Consts . Colors . accent),
48+ () ,
49+ ),
3950 "wip" :
4051 style(
4152 ~borderWidth= 1 .,
@@ -56,15 +67,40 @@ let make = (~pageData) => {
5667 if (pageData. wip-> Option . getWithDefault(false )) {
5768 Js . log3("@todo" , pageData. title, "docs is still WIP" );
5869 };
70+ let officialDocHref =
71+ if (pageData. id
72+ |> Js . String . startsWith("apis/" )
73+ || pageData. id
74+ |> Js . String . startsWith("components/" )) {
75+ Some (
76+ "http://facebook.github.io/react-native/docs/"
77+ ++ pageData. title-> Js . String . toLocaleLowerCase
78+ ++ "/" ,
79+ );
80+ } else {
81+ None ;
82+ };
5983 let editHref =
6084 "https://github.com/reasonml-community/bs-react-native/blob/master/bs-react-native-next/src/"
6185 ++ pageData. id
6286 ++ ".md" ;
6387 <SpacedView style= styles##container vertical= SpacedView . L >
6488 <View style= styles##title>
65- <Text style= styles##titleText>
66- {pageData. title-> Option . getWithDefault(pageData. id)-> React . string}
67- </Text >
89+ <View >
90+ <Text style= styles##titleText> pageData.title-> React . string </Text >
91+ {officialDocHref
92+ -> Option . map(officialDocHref =>
93+ <TextLink style= styles##officialDocLink href= officialDocHref>
94+ <SVGExternalLink
95+ width= {14 .-> ReactFromSvg . Size . pt}
96+ height= {14 .-> ReactFromSvg . Size . pt}
97+ fill= Consts . Colors . accent
98+ />
99+ {| Official documentation |} -> React . string
100+ </TextLink >
101+ )
102+ -> Option . getWithDefault(React . null)}
103+ </View >
68104 <SpacedView
69105 vertical= SpacedView . XS horizontal= SpacedView . XS style= styles##editLink>
70106 <TextLink style= styles##editLinkText href= editHref>
0 commit comments