Skip to content

Commit

Permalink
Display constructor parameter types in the web reference
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinstadler committed Apr 15, 2024
1 parent bf27111 commit a56b9e2
Showing 1 changed file with 30 additions and 29 deletions.
59 changes: 30 additions & 29 deletions src/templates/reference/class.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
import React from 'react';
import { graphql } from 'gatsby';
import { LocalizedLink as Link } from 'gatsby-theme-i18n';
import { getImage } from 'gatsby-plugin-image';
import { useLocalization } from 'gatsby-theme-i18n';
import { useIntl } from 'react-intl';
import { widont } from '../../utils/index.js';
import {graphql} from 'gatsby';
import {LocalizedLink as Link} from 'gatsby-theme-i18n';
import {getImage} from 'gatsby-plugin-image';
import {useLocalization} from 'gatsby-theme-i18n';
import {useIntl} from 'react-intl';
import {widont} from '../../utils/index.js';

import HeadMatter from '../../components/HeadMatter';

import Layout from '../../components/Layout';
import Content from '../../components/ContentWithSidebar';
import { SidebarTree } from '../../components/Sidebar';
import {SidebarTree} from '../../components/Sidebar';
import Section from '../../components/reference/Section';
import License from '../../components/reference/License';
import { CodeList, ExampleList } from '../../components/reference/ContentList';
import { ExampleItem } from '../../components/examples/ExamplesList';
import {CodeList, ExampleList} from '../../components/reference/ContentList';
import {ExampleItem} from '../../components/examples/ExamplesList';
import Breadcrumbs from '../../components/Breadcrumbs';

import { useHighlight, useTree, useSidebar, usePdes } from '../../hooks';
import {useHighlight, useTree, useSidebar, usePdes} from '../../hooks';
import {
usePreparedItems,
usePreparedExamples,
usePreparedList,
useInUseExamples,
useTrail
} from '../../hooks/reference';
import { referencePath } from '../../utils/paths';
import {referencePath} from '../../utils/paths';

import * as grid from '../../styles/grid.module.css';

const ClassRefTemplate = ({ data, pageContext }) => {
const { name, libraryName } = pageContext;
const ClassRefTemplate = ({data, pageContext}) => {
const {name, libraryName} = pageContext;
const entry = data?.json?.childJson;
const isProcessing = libraryName === 'processing';
const [showSidebar, setShowSidebar] = useSidebar('reference');

const { locale } = useLocalization();
const {locale} = useLocalization();
const intl = useIntl();
useHighlight();

Expand All @@ -59,8 +59,8 @@ const ClassRefTemplate = ({ data, pageContext }) => {
(entry?.name ?? data.en.childJson.name) +
' / ' +
(isProcessing
? intl.formatMessage({ id: 'reference' })
: intl.formatMessage({ id: 'libraries' }));
? intl.formatMessage({id: 'reference'})
: intl.formatMessage({id: 'libraries'}));

return (
<Layout withSidebar withBreadcrumbs>
Expand All @@ -72,56 +72,56 @@ const ClassRefTemplate = ({ data, pageContext }) => {

<div className={grid.grid}>
<SidebarTree
title={intl.formatMessage({ id: 'reference' })}
title={intl.formatMessage({id: 'reference'})}
tree={tree}
setShow={setShowSidebar}
show={showSidebar}
/>
{entry ? (
<Content sidebarOpen={showSidebar}>
<Breadcrumbs trail={trail} />
<Section title={intl.formatMessage({ id: 'className' })}>
<Section title={intl.formatMessage({id: 'className'})}>
<h3>{entry.name}</h3>
</Section>
<Section title={intl.formatMessage({ id: 'description' })}>
<Section title={intl.formatMessage({id: 'description'})}>
<p
dangerouslySetInnerHTML={{ __html: widont(entry.description) }}
dangerouslySetInnerHTML={{__html: widont(entry.description)}}
/>
</Section>
{examples && (
<Section
columns={false}
title={intl.formatMessage({ id: 'examples' })}>
title={intl.formatMessage({id: 'examples'})}>
<ExampleList examples={examples} />
</Section>
)}
{constructors && (
<Section title={intl.formatMessage({ id: 'constructors' })}>
<Section title={intl.formatMessage({id: 'constructors'})}>
<CodeList nameIsHtml items={constructors} />
</Section>
)}
{fields && (
<Section title={intl.formatMessage({ id: 'fields' })}>
<Section title={intl.formatMessage({id: 'fields'})}>
<CodeList nameIsHtml items={fields} />
</Section>
)}
{parameters && (
<Section title={intl.formatMessage({ id: 'parameters' })}>
<Section title={intl.formatMessage({id: 'parameters'})}>
<CodeList variant="parameters" items={parameters} />
</Section>
)}
{methods && (
<Section title={intl.formatMessage({ id: 'methods' })}>
<Section title={intl.formatMessage({id: 'methods'})}>
<CodeList descriptionIsHtml items={methods} />
</Section>
)}
{related && (
<Section title={intl.formatMessage({ id: 'related' })}>
<Section title={intl.formatMessage({id: 'related'})}>
<CodeList items={related} />
</Section>
)}
{inUseExamples && (
<Section title={intl.formatMessage({ id: 'inUse' })}>
<Section title={intl.formatMessage({id: 'inUse'})}>
<ul className={grid.grid}>
{inUseExamples.slice(0, 6).map((e, key) => (
<ExampleItem
Expand All @@ -137,10 +137,10 @@ const ClassRefTemplate = ({ data, pageContext }) => {
</Content>
) : (
<Content sidebarOpen={showSidebar}>
{intl.formatMessage({ id: 'notTranslated' })}
{intl.formatMessage({id: 'notTranslated'})}
<Link to={referencePath(name, libraryName)}>
{' '}
{intl.formatMessage({ id: 'englishPage' })}
{intl.formatMessage({id: 'englishPage'})}
</Link>
</Content>
)}
Expand Down Expand Up @@ -183,6 +183,7 @@ export const query = graphql`
parameters {
name
description
type
}
}
}
Expand Down

0 comments on commit a56b9e2

Please sign in to comment.