import React from "react"; import Markdown from "react-markdown"; const headers = { js: "JS", android: "Android", ios: "iOS" }; type DocProps = { fieldSpec: { doc?: string values?: { [key: string]: { doc?: string } } "sdk-support"?: { [key: string]: typeof headers } docUrl?: string, docUrlLinkText?: string } }; export default class Doc extends React.Component { render () { const {fieldSpec} = this.props; const {doc, values, docUrl, docUrlLinkText} = fieldSpec; const sdkSupport = fieldSpec["sdk-support"]; const renderValues = ( !!values && // HACK: Currently we merge additional values into the style spec, so this is required // See !Array.isArray(values) ); const sdkSupportToJsx = (value: string) => { const supportValue = value.toLowerCase(); if (supportValue.startsWith("https://")) { return {"#" + supportValue.split("/").pop()}; } return value; }; return ( <> {doc &&
{children}, }}>{doc}
{renderValues &&
    {Object.entries(values).map(([key, value]) => { return (
  • {JSON.stringify(key)}
    {value.doc}
  • ); })}
}
} {sdkSupport &&
{Object.values(headers).map(header => { return ; })} {Object.entries(sdkSupport).map(([key, supportObj]) => { return ( {Object.keys(headers).map((k) => { if (Object.prototype.hasOwnProperty.call(supportObj, k)) { return ; } else { return ; } })} ); })}
{header}
{key}{sdkSupportToJsx(supportObj[k as keyof typeof headers])}no
} {docUrl && docUrlLinkText &&
{docUrlLinkText}
} ); } }