1f8204ef0SBartosz Kaszubowskiimport { APIDataType } from '~/components/plugins/api/APIDataType';
2299f02f2SBartosz Kaszubowskiimport { ConstantDefinitionData } from '~/components/plugins/api/APIDataTypes';
325b16883SBartosz Kaszubowskiimport { APISectionDeprecationNote } from '~/components/plugins/api/APISectionDeprecationNote';
4b3bd70ceSTomasz Sapetaimport { APISectionPlatformTags } from '~/components/plugins/api/APISectionPlatformTags';
56a5c065cSBartosz Kaszubowskiimport {
66a5c065cSBartosz Kaszubowski  CommentTextBlock,
7c4c6b9d1SBartosz Kaszubowski  getTagNamesList,
812abeb84SBartosz Kaszubowski  STYLE_APIBOX_NO_SPACING,
96a5c065cSBartosz Kaszubowski  STYLES_APIBOX,
10a16a3d18SBartosz Kaszubowski  H3Code,
116a5c065cSBartosz Kaszubowski} from '~/components/plugins/api/APISectionUtils';
12*3324c13cSBartosz Kaszubowskiimport { H2, BOLD, P, MONOSPACE } from '~/ui/components/Text';
13299f02f2SBartosz Kaszubowski
14299f02f2SBartosz Kaszubowskiexport type APISectionConstantsProps = {
15299f02f2SBartosz Kaszubowski  data: ConstantDefinitionData[];
16299f02f2SBartosz Kaszubowski  apiName?: string;
17299f02f2SBartosz Kaszubowski};
18299f02f2SBartosz Kaszubowski
19299f02f2SBartosz Kaszubowskiconst renderConstant = (
20464d48dfSBartosz Kaszubowski  { name, comment, type }: ConstantDefinitionData,
21299f02f2SBartosz Kaszubowski  apiName?: string
22299f02f2SBartosz Kaszubowski): JSX.Element => (
236a5c065cSBartosz Kaszubowski  <div key={`constant-definition-${name}`} css={STYLES_APIBOX}>
2425b16883SBartosz Kaszubowski    <APISectionDeprecationNote comment={comment} />
25d9bd5b6cSBartosz Kaszubowski    <APISectionPlatformTags comment={comment} prefix="Only for:" />
26c4c6b9d1SBartosz Kaszubowski    <H3Code tags={getTagNamesList(comment)}>
27*3324c13cSBartosz Kaszubowski      <MONOSPACE weight="medium">
28299f02f2SBartosz Kaszubowski        {apiName ? `${apiName}.` : ''}
29299f02f2SBartosz Kaszubowski        {name}
30*3324c13cSBartosz Kaszubowski      </MONOSPACE>
31299f02f2SBartosz Kaszubowski    </H3Code>
32f31f564bSBartosz Kaszubowski    {type && (
33464d48dfSBartosz Kaszubowski      <P>
3412abeb84SBartosz Kaszubowski        <BOLD>Type:</BOLD> <APIDataType typeDefinition={type} />
35464d48dfSBartosz Kaszubowski      </P>
36f31f564bSBartosz Kaszubowski    )}
3712abeb84SBartosz Kaszubowski    {comment && (
3812abeb84SBartosz Kaszubowski      <div css={STYLE_APIBOX_NO_SPACING}>
3912abeb84SBartosz Kaszubowski        <CommentTextBlock comment={comment} includePlatforms={false} beforeContent={<br />} />
4012abeb84SBartosz Kaszubowski      </div>
4112abeb84SBartosz Kaszubowski    )}
42299f02f2SBartosz Kaszubowski  </div>
43299f02f2SBartosz Kaszubowski);
44299f02f2SBartosz Kaszubowski
45558a63feSBartosz Kaszubowskiconst APISectionConstants = ({ data, apiName }: APISectionConstantsProps) =>
46299f02f2SBartosz Kaszubowski  data?.length ? (
47299f02f2SBartosz Kaszubowski    <>
48299f02f2SBartosz Kaszubowski      <H2 key="constants-header">Constants</H2>
49299f02f2SBartosz Kaszubowski      {data.map(constant => renderConstant(constant, apiName))}
50299f02f2SBartosz Kaszubowski    </>
51299f02f2SBartosz Kaszubowski  ) : null;
52299f02f2SBartosz Kaszubowski
53299f02f2SBartosz Kaszubowskiexport default APISectionConstants;
54