/** * ### References: * * - https://components.publishing.service.gov.uk/component-guide/document_list * - https://github.com/alphagov/static/blob/077649737c43d3937f745df0b3adade9df3717dc/app/views/govuk_component/docs/metadata.yml * - https://github.com/alphagov/static/blob/077649737c43d3937f745df0b3adade9df3717dc/app/views/govuk_component/metadata.raw.html.erb */ import * as React from 'react'; import styled from 'styled-components'; import UnorderedList from '@govuk-react/unordered-list'; import { NTA_LIGHT } from '@govuk-react/constants'; import { spacing } from '@govuk-react/lib'; const StyledContainer = styled('div')({ fontFamily: NTA_LIGHT }, spacing.withWhiteSpace()); const StyledDefinition = styled('li')({ fontSize: '24px', fontWeight: 700, lineHeight: 1.25, '> a': { textDecoration: 'none', }, }); const StyledParagraph = styled('p')({ marginBottom: 0, }); /** * An ordered list of documents including a document type, when updated and a link. * * - https://govuk-react.github.io/govuk-react/?path=/docs/document-footer-metadata * - https://components.publishing.service.gov.uk/component-guide/document_list */ export const DocumentFooterMetadata: React.FC = ({ from = undefined, partOf = undefined, other = undefined, ...props }: DocumentFooterMetadataProps) => { const fromData = ( {from && (
From: {from && from.map((child, i) => ( /* eslint-disable react/no-array-index-key */ {child} /* eslint-enable react/no-array-index-key */ ))}
)}
); const partOfData = ( {partOf && (
Part of: {Array.isArray(partOf) && React.Children.map(partOf, (child, i) => {child})}
)}
); const otherData = ( {other && other.map((item) => (
{item.title}: {item.content}
))}
); return ( {fromData} {partOfData} {otherData} ); }; DocumentFooterMetadata.displayName = 'DocumentFooterMetadata'; export interface DocumentFooterMetadataProps extends React.HTMLAttributes { /** * Array of JSX nodes to render underneath the `from:` title */ from?: React.ReactNode[]; /** * Array of JSX nodes to render underneath the `part of:` title */ partOf?: React.ReactNode[]; /* eslint-disable max-len */ /** * Array of Objects for any additional items, each object should contain an `id`, `title` and `content` property */ /* eslint-enable max-len */ other?: { id?: number; title?: string; content?: React.ReactNode; }[]; } export default DocumentFooterMetadata;