Skip to content

Commit

Permalink
Merge branch 'main' into ans_yarn_update
Browse files Browse the repository at this point in the history
  • Loading branch information
anselmbradford authored May 7, 2024
2 parents 0946eb7 + 3ea74cd commit df6f65c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/components/Headings/Heading.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import classnames from 'classnames';
import type { JSXElement } from '~/src/types/jsxElement';
import type { ReactNode } from 'react';

export type HeadingType =
| '1'
Expand All @@ -21,7 +21,7 @@ export const Heading = ({
children,
className,
...properties
}: HeadingProperties): JSXElement => {
}: HeadingProperties): ReactNode => {
let DynamicHeading: keyof JSX.IntrinsicElements;
const classes = [className];

Expand Down
3 changes: 2 additions & 1 deletion src/components/Paragraph/Paragraph.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import classnames from 'classnames';
import type { ReactNode } from 'react';

interface ParagraphProperties extends React.HTMLProps<HTMLParagraphElement> {
isLead?: boolean;
Expand All @@ -14,7 +15,7 @@ export function Paragraph({
isLead,
className,
...properties
}: ParagraphProperties): JSX.Element {
}: ParagraphProperties): ReactNode {
const cnames = [className];

if (isLead) cnames.push('lead-paragraph');
Expand Down
11 changes: 9 additions & 2 deletions src/components/TextIntroduction/TextIntroduction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ import List from '../List/List';
import ListItem from '../List/ListItem';
import { Paragraph } from '../Paragraph/Paragraph';

const renderDescription = (description: ReactNode | string): ReactNode => {
if (!description) return null;
if (typeof description === 'string')
return <Paragraph>{description}</Paragraph>;
return description;
};

interface TextIntroductionProperties extends React.HTMLProps<HTMLDivElement> {
// Page title
heading: string;
Expand Down Expand Up @@ -45,7 +52,7 @@ export const TextIntroduction = ({
>
<Heading type='1'>{heading}</Heading>
<Paragraph isLead>{subheading}</Paragraph>
{description ? <p>{description}</p> : null}
{renderDescription(description)}
{call2action}
</div>
);
Expand Down Expand Up @@ -84,7 +91,7 @@ export const TextIntroductionHeading = TextIntroduction.Heading;

TextIntroduction.Description = ({
children
}: TextIntroductionSubProperties): JSX.Element => <p>{children}</p>;
}: TextIntroductionSubProperties): ReactNode => renderDescription(children);

export const TextIntroductionDescription = TextIntroduction.Description;

Expand Down
1 change: 1 addition & 0 deletions src/stories/Introduction.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ In your `package.json`:
```

<Heading type='2'>Components - Verified vs Draft</Heading>

This library is still in it's early stages of developement, with lots of changes expected in the coming months. You will notice two subsections in the navigation sidebar: `Components (Verified)` and `Components (Draft)`.

`Verified` components have been thoroughly reviewed for consistency with their [Design System] counterparts and can be considered unlikely to change in the near future.
Expand Down

0 comments on commit df6f65c

Please sign in to comment.