diff --git a/images/icons/code.svg b/images/icons/code.svg new file mode 100644 index 00000000..ea83092e --- /dev/null +++ b/images/icons/code.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/plop-templates/pattern-library-page.hbs b/plop-templates/pattern-library-page.hbs index 6265ce7c..441fdbee 100644 --- a/plop-templates/pattern-library-page.hbs +++ b/plop-templates/pattern-library-page.hbs @@ -9,7 +9,7 @@ export default function {{name}}Page() { intro={

{{name}} is a {{category}} component

} > - + diff --git a/src/components/icons/Code.tsx b/src/components/icons/Code.tsx new file mode 100644 index 00000000..d42037d5 --- /dev/null +++ b/src/components/icons/Code.tsx @@ -0,0 +1,23 @@ +// This file was auto-generated using scripts/generate-icons.js +import type { JSX } from 'preact'; + +export type CodeIconProps = JSX.SVGAttributes; + +/** + * Icon generated from code.svg + */ +export default function CodeIcon(props: CodeIconProps) { + return ( + + ); +} diff --git a/src/components/icons/index.ts b/src/components/icons/index.ts index 818fc660..366b4c99 100644 --- a/src/components/icons/index.ts +++ b/src/components/icons/index.ts @@ -21,6 +21,7 @@ export { default as CheckIcon } from './Check'; export { default as CheckboxIcon } from './Checkbox'; export { default as CheckboxCheckedIcon } from './CheckboxChecked'; export { default as CheckboxOutlineIcon } from './CheckboxOutline'; +export { default as CodeIcon } from './Code'; export { default as CollapseIcon } from './Collapse'; export { default as ContrastIcon } from './Contrast'; export { default as CopyIcon } from './Copy'; diff --git a/src/pattern-library/components/Library.tsx b/src/pattern-library/components/Library.tsx index 9d5320eb..e697089e 100644 --- a/src/pattern-library/components/Library.tsx +++ b/src/pattern-library/components/Library.tsx @@ -4,7 +4,7 @@ import type { ComponentChildren, JSX } from 'preact'; import { useMemo, useState } from 'preact/hooks'; import { Link as RouteLink } from 'wouter-preact'; -import { Link as UILink, Scroll, ScrollContainer } from '../../'; +import { CodeIcon, Link as UILink, Scroll, ScrollContainer } from '../../'; import { jsxToHTML } from '../util/jsx-to-string'; /** @@ -17,7 +17,7 @@ import { jsxToHTML } from '../util/jsx-to-string'; *

Any content you want on the page.

* * - * + * *

The `Elephant` component is used to render information about elephant * personalities.

* @@ -48,19 +48,22 @@ export type LibraryPageProps = { */ function Page({ children, intro, title }: LibraryPageProps) { return ( -
+
+ +
+ {intro && ( +
+ {intro} +
+ )} + {children}
- {intro && ( -
- {intro} -
- )} -
{children}
); } @@ -78,16 +81,14 @@ export type LibrarySectionProps = { */ function Section({ children, id, intro, title }: LibrarySectionProps) { return ( -
-

+
+

{title}

{intro && ( -
- {intro} -
+
{intro}
)} -
{children}
+
{children}
); } @@ -95,7 +96,7 @@ function Section({ children, id, intro, title }: LibrarySectionProps) { export type LibraryPatternProps = { children?: ComponentChildren; id?: string; - title: string; + title?: string; }; /** @@ -103,11 +104,13 @@ export type LibraryPatternProps = { */ function Pattern({ children, id, title }: LibraryPatternProps) { return ( -
-

- {title} -

-
{children}
+
+ {title && ( +

+ {title} +

+ )} +
{children}
); } @@ -124,43 +127,20 @@ export type LibraryExampleProps = { */ function Example({ children, id, title }: LibraryExampleProps) { return ( -
+
{title && ( -

+

{title}

)} -
{children}
+
{children}
); } -type DemoButtonProps = { - children: ComponentChildren; - onClick: () => void; - pressed: boolean; -}; -/** - * Render a button to swap between demo and source views in a Demo - */ -function DemoButton({ children, onClick, pressed }: DemoButtonProps) { - return ( - - ); -} - export type LibraryDemoProps = { children: ComponentChildren; /** Extra CSS classes for the demo content's immediate parent container */ @@ -202,33 +182,45 @@ function Demo({ ); }); return ( -
-
-
-
{title}
+
+
+
+
+ {title} +
{withSource && ( - <> - setVisibleTab('demo')} - pressed={visibleTab === 'demo'} - > - Demo - - setVisibleTab('source')} - pressed={visibleTab === 'source'} - > - Source - - + )}
-
+
{visibleTab === 'demo' && ( -
+
jsxToHTML(content), [content]); return ( -
+
{children}

; + return ( +

+ {children} +

+ ); } /** @@ -35,7 +39,7 @@ function NavSection({ }) { return (
-

{title}

+

{title}

{children}
); @@ -46,7 +50,7 @@ function NavSection({ */ function NavList({ children }: { children: ComponentChildren }) { return ( -
    {children}
+
    {children}
); } @@ -158,7 +162,7 @@ export default function PlaygroundApp({ >; return ( -
+
diff --git a/src/pattern-library/components/patterns/ColorsPage.tsx b/src/pattern-library/components/patterns/ColorsPage.tsx index 4502b01a..3d6f30fb 100644 --- a/src/pattern-library/components/patterns/ColorsPage.tsx +++ b/src/pattern-library/components/patterns/ColorsPage.tsx @@ -71,11 +71,13 @@ export default function ColorsPage() { return ( -
{brandExamples}
+
+ {brandExamples} +
-
{greyExamples}
+
{greyExamples}
@@ -83,15 +85,21 @@ export default function ColorsPage() { These slightly blue greys may be used sparingly to help with differentiation and clarity within interfaces.

-
{slateExamples}
+
+ {slateExamples} +
-
{stateExamples}
+
+ {stateExamples} +
-
{focusExamples}
+
+ {focusExamples} +
); diff --git a/src/pattern-library/components/patterns/data/AspectRatioPage.tsx b/src/pattern-library/components/patterns/data/AspectRatioPage.tsx index 404fd0c9..e7caa57a 100644 --- a/src/pattern-library/components/patterns/data/AspectRatioPage.tsx +++ b/src/pattern-library/components/patterns/data/AspectRatioPage.tsx @@ -13,7 +13,7 @@ export default function AspectRatioPage() { } > - + - + diff --git a/src/pattern-library/components/patterns/data/IconsPage.tsx b/src/pattern-library/components/patterns/data/IconsPage.tsx index 5975f9c7..7266d812 100644 --- a/src/pattern-library/components/patterns/data/IconsPage.tsx +++ b/src/pattern-library/components/patterns/data/IconsPage.tsx @@ -11,7 +11,7 @@ export default function IconsPage() { } > - + @@ -21,7 +21,7 @@ export default function IconsPage() { -
+
{(Object.keys(Icons) as Array).map(iconName => { const IconComponent = Icons[iconName]; return ( diff --git a/src/pattern-library/components/patterns/data/ScrollBoxPage.tsx b/src/pattern-library/components/patterns/data/ScrollBoxPage.tsx index dc18543c..f04b9c0c 100644 --- a/src/pattern-library/components/patterns/data/ScrollBoxPage.tsx +++ b/src/pattern-library/components/patterns/data/ScrollBoxPage.tsx @@ -28,7 +28,7 @@ export default function ScrollBoxPage() {

} > - + @@ -110,7 +110,7 @@ export default function ScrollBoxPage() {

} > - + @@ -166,7 +166,7 @@ export default function ScrollBoxPage() {

} > - + @@ -201,7 +201,7 @@ export default function ScrollBoxPage() { } > - + diff --git a/src/pattern-library/components/patterns/data/TablePage.tsx b/src/pattern-library/components/patterns/data/TablePage.tsx index c6b5b683..44d282fe 100644 --- a/src/pattern-library/components/patterns/data/TablePage.tsx +++ b/src/pattern-library/components/patterns/data/TablePage.tsx @@ -21,7 +21,7 @@ export default function TablePage() { } > - + } > - +

diff --git a/src/pattern-library/components/patterns/feedback/DialogPage.tsx b/src/pattern-library/components/patterns/feedback/DialogPage.tsx index d442e9f2..2f5b4c6d 100644 --- a/src/pattern-library/components/patterns/feedback/DialogPage.tsx +++ b/src/pattern-library/components/patterns/feedback/DialogPage.tsx @@ -181,7 +181,7 @@ export default function DialogPage() {

- +
- + diff --git a/src/pattern-library/components/patterns/feedback/ModalPage.tsx b/src/pattern-library/components/patterns/feedback/ModalPage.tsx index b4818e78..a1f485c5 100644 --- a/src/pattern-library/components/patterns/feedback/ModalPage.tsx +++ b/src/pattern-library/components/patterns/feedback/ModalPage.tsx @@ -122,7 +122,7 @@ export default function ModalPage() { - + } > - + @@ -77,7 +77,7 @@ export default function SpinnerPage() {

} > - + diff --git a/src/pattern-library/components/patterns/input/ButtonPage.tsx b/src/pattern-library/components/patterns/input/ButtonPage.tsx index 3e35ab7c..81949701 100644 --- a/src/pattern-library/components/patterns/input/ButtonPage.tsx +++ b/src/pattern-library/components/patterns/input/ButtonPage.tsx @@ -29,7 +29,7 @@ export default function ButtonPage() {

} > - + @@ -135,7 +135,7 @@ export default function ButtonPage() {

} > - + @@ -314,7 +314,7 @@ export default function ButtonPage() { } > - + diff --git a/src/pattern-library/components/patterns/input/CheckboxPage.tsx b/src/pattern-library/components/patterns/input/CheckboxPage.tsx index f103a9be..fb81f539 100644 --- a/src/pattern-library/components/patterns/input/CheckboxPage.tsx +++ b/src/pattern-library/components/patterns/input/CheckboxPage.tsx @@ -19,7 +19,7 @@ export default function CheckboxPage() {

} > - + diff --git a/src/pattern-library/components/patterns/input/InputGroupPage.tsx b/src/pattern-library/components/patterns/input/InputGroupPage.tsx index cabb2269..5e95e88e 100644 --- a/src/pattern-library/components/patterns/input/InputGroupPage.tsx +++ b/src/pattern-library/components/patterns/input/InputGroupPage.tsx @@ -21,7 +21,7 @@ export default function InputGroupPage() {

} > - + } > - + diff --git a/src/pattern-library/components/patterns/input/SelectPage.tsx b/src/pattern-library/components/patterns/input/SelectPage.tsx index fad3f92a..483b2d80 100644 --- a/src/pattern-library/components/patterns/input/SelectPage.tsx +++ b/src/pattern-library/components/patterns/input/SelectPage.tsx @@ -42,7 +42,7 @@ export default function SelectPage() {

} > - + diff --git a/src/pattern-library/components/patterns/layout/CardPage.tsx b/src/pattern-library/components/patterns/layout/CardPage.tsx index 172eda90..8897ab52 100644 --- a/src/pattern-library/components/patterns/layout/CardPage.tsx +++ b/src/pattern-library/components/patterns/layout/CardPage.tsx @@ -29,7 +29,7 @@ export default function CardPage() {

} > - + @@ -121,7 +121,7 @@ export default function CardPage() {

} > - + @@ -207,7 +207,7 @@ export default function CardPage() {

} > - + } > - + } > - + } > - + diff --git a/src/pattern-library/components/patterns/layout/PanelPage.tsx b/src/pattern-library/components/patterns/layout/PanelPage.tsx index 9f6a8135..262c37fc 100644 --- a/src/pattern-library/components/patterns/layout/PanelPage.tsx +++ b/src/pattern-library/components/patterns/layout/PanelPage.tsx @@ -23,7 +23,7 @@ export default function PanelPage() {

} > - +

diff --git a/src/pattern-library/components/patterns/navigation/LinkButtonPage.tsx b/src/pattern-library/components/patterns/navigation/LinkButtonPage.tsx index cd72fb84..09f45226 100644 --- a/src/pattern-library/components/patterns/navigation/LinkButtonPage.tsx +++ b/src/pattern-library/components/patterns/navigation/LinkButtonPage.tsx @@ -20,7 +20,7 @@ export default function LinkButtonPage() {

} > - + diff --git a/src/pattern-library/components/patterns/navigation/LinkPage.tsx b/src/pattern-library/components/patterns/navigation/LinkPage.tsx index 06fe53f6..4b961aae 100644 --- a/src/pattern-library/components/patterns/navigation/LinkPage.tsx +++ b/src/pattern-library/components/patterns/navigation/LinkPage.tsx @@ -21,7 +21,7 @@ export default function LinkPage() {

} > - + @@ -108,7 +108,7 @@ export default function LinkPage() { } > - + diff --git a/src/pattern-library/components/patterns/navigation/PointerButtonPage.tsx b/src/pattern-library/components/patterns/navigation/PointerButtonPage.tsx index ae772416..db381e5a 100644 --- a/src/pattern-library/components/patterns/navigation/PointerButtonPage.tsx +++ b/src/pattern-library/components/patterns/navigation/PointerButtonPage.tsx @@ -30,7 +30,7 @@ export default function PointerButtonPage() {

} > - + } > - + @@ -255,7 +255,7 @@ export default function TabPage() { TabList is a new component.

- +

diff --git a/styles/library.scss b/styles/library.scss index 26e540ea..bc95e989 100644 --- a/styles/library.scss +++ b/styles/library.scss @@ -10,12 +10,16 @@ } :where(code):not(:where([class~='unstyled-text'] *)) { - @apply p-1 bg-slate-0 rounded-sm mx-0.5; + @apply p-1 bg-stone-100 rounded-sm mx-0.5; font-size: 0.85em; } + :where(p):not(:where([class~='unstyled-text'] *)) { + @apply my-4; + } + :where(ul):not(:where([class~='unstyled-text'] *)) { - @apply list-disc list-outside ml-8 space-y-2; + @apply list-disc list-outside ml-8 space-y-2 my-4; } :where(ol):not(:where([class~='unstyled-text'] *)) {