diff --git a/ui/blocks/src/EditPage/EditPage.tsx b/ui/blocks/src/EditPage/EditPage.tsx index 976929f9f..8b8b81a3b 100644 --- a/ui/blocks/src/EditPage/EditPage.tsx +++ b/ui/blocks/src/EditPage/EditPage.tsx @@ -12,7 +12,7 @@ import { useStoryContext } from '../context'; * In order for this to work, you need to set up the `repository` field in `package.json`. */ export const EditPage: FC = () => { - const { storyPackage } = useStoryContext({ id: '.', name }); + const { storyPackage } = useStoryContext({ id: '.' }); return storyPackage && storyPackage.repository && storyPackage.repository.browse ? ( diff --git a/ui/blocks/src/PackageVersion/PackageVersion.tsx b/ui/blocks/src/PackageVersion/PackageVersion.tsx new file mode 100644 index 000000000..1a3817987 --- /dev/null +++ b/ui/blocks/src/PackageVersion/PackageVersion.tsx @@ -0,0 +1,17 @@ +/** @jsx jsx */ +/* eslint react/jsx-key: 0 */ +import { jsx } from 'theme-ui'; +import { FC } from 'react'; +import { Tag } from '@component-controls/components'; +import { useComponentsContext } from '../context'; + +/** + * Display a label with the component's package version. + * extracted from package.json + */ +export const PackageVersion: FC = () => { + const { componentPackage } = useComponentsContext({ of: '.' }); + return componentPackage && componentPackage.version ? ( + {`${componentPackage.name}: ${componentPackage.version}`} + ) : null; +}; diff --git a/ui/blocks/src/PackageVersion/index.ts b/ui/blocks/src/PackageVersion/index.ts new file mode 100644 index 000000000..e7c81aca2 --- /dev/null +++ b/ui/blocks/src/PackageVersion/index.ts @@ -0,0 +1 @@ +export * from './PackageVersion'; diff --git a/ui/blocks/src/index.ts b/ui/blocks/src/index.ts index 5a441dffe..02ead0fc3 100644 --- a/ui/blocks/src/index.ts +++ b/ui/blocks/src/index.ts @@ -4,6 +4,7 @@ export * from './ComponentSource'; export * from './ControlsTable'; export * from './Description'; export * from './EditPage'; +export * from './PackageVersion'; export * from './PageContainer'; export * from './Playground'; export * from './PropsTable'; diff --git a/ui/components/src/Subtitle/Subtitle.tsx b/ui/components/src/Subtitle/Subtitle.tsx index 2faa97770..d5f292cb5 100644 --- a/ui/components/src/Subtitle/Subtitle.tsx +++ b/ui/components/src/Subtitle/Subtitle.tsx @@ -23,7 +23,12 @@ export const Subtitle: FC = ({ as = 'h3', ...rest }) => ( - + {children} ); diff --git a/ui/components/src/Title/Title.tsx b/ui/components/src/Title/Title.tsx index 27bdf84b8..3deba0170 100644 --- a/ui/components/src/Title/Title.tsx +++ b/ui/components/src/Title/Title.tsx @@ -1,5 +1,5 @@ /** @jsx jsx */ -import { jsx } from 'theme-ui'; +import { jsx, SxStyleProp } from 'theme-ui'; import { FC } from 'react'; import { Heading, HeadingProps } from 'theme-ui'; @@ -8,16 +8,21 @@ interface TitleOwnProps { * text to be displayed in the component. */ children?: string; + /** + * theme-ui styling object + */ + sxStyle?: SxStyleProp; } export type TitleProps = TitleOwnProps & Omit; -export const Title: FC = ({ children, ...rest }) => ( +export const Title: FC = ({ children, sxStyle, ...rest }) => ( diff --git a/ui/pages/src/ClassicPage/ClassicPage.tsx b/ui/pages/src/ClassicPage/ClassicPage.tsx index 678e06b3a..490819a81 100644 --- a/ui/pages/src/ClassicPage/ClassicPage.tsx +++ b/ui/pages/src/ClassicPage/ClassicPage.tsx @@ -1,4 +1,6 @@ -import React, { FC } from 'react'; +/** @jsx jsx */ +import { jsx, Box } from 'theme-ui'; +import { FC } from 'react'; import { EditPage, Title, @@ -9,14 +11,21 @@ import { Description, ComponentSource, PropsTable, + PackageVersion, } from '@component-controls/blocks'; export const ClassicPage: FC = () => { return ( - <> +
- + <Title sxStyle={{ paddingBottom: 0 }} /> <Subtitle /> + <PackageVersion /> + <Box + sx={{ + paddingBottom: 4, + }} + /> <Description /> <ComponentSource id="." title="Component" /> <Playground openTab="source" title="."> @@ -24,6 +33,6 @@ export const ClassicPage: FC = () => { </Playground> <PropsTable of="." title="Properties" /> <Stories dark={true} /> - </> + </div> ); };