From 296c70e02277e22b00de2a061cf272105c7706e0 Mon Sep 17 00:00:00 2001 From: atanasster Date: Sat, 30 May 2020 01:50:08 -0400 Subject: [PATCH] feat: add Header component --- .../src/components/Header.tsx | 14 ++--- .../src/Header/Header.stories.tsx | 20 ++++++++ ui/app-components/src/Header/Header.tsx | 51 +++++++++++++++++++ ui/app-components/src/Header/index.ts | 1 + ui/app-components/src/index.ts | 1 + 5 files changed, 81 insertions(+), 6 deletions(-) create mode 100644 ui/app-components/src/Header/Header.stories.tsx create mode 100644 ui/app-components/src/Header/Header.tsx create mode 100644 ui/app-components/src/Header/index.ts diff --git a/integrations/gatsby-theme-stories/src/components/Header.tsx b/integrations/gatsby-theme-stories/src/components/Header.tsx index f8f183705..f29ea286c 100644 --- a/integrations/gatsby-theme-stories/src/components/Header.tsx +++ b/integrations/gatsby-theme-stories/src/components/Header.tsx @@ -2,7 +2,11 @@ import { FC, useContext } from 'react'; import { jsx } from 'theme-ui'; import { Flex } from '@theme-ui/components'; -import { ColorMode, SidebarContext } from '@component-controls/app-components'; +import { + ColorMode, + SidebarContext, + Header as AppHeader, +} from '@component-controls/app-components'; interface HeaderProps { title?: string; @@ -11,7 +15,7 @@ export const Header: FC = ({ children }) => { const { SidebarToggle } = useContext(SidebarContext); return ( -
+ = ({ children }) => { a: { color: `secondary`, ':hover': { color: `accent` } }, flexFlow: `wrap`, }} - > - link - + > -
+ ); }; diff --git a/ui/app-components/src/Header/Header.stories.tsx b/ui/app-components/src/Header/Header.stories.tsx new file mode 100644 index 000000000..770ed44e3 --- /dev/null +++ b/ui/app-components/src/Header/Header.stories.tsx @@ -0,0 +1,20 @@ +import React from 'react'; +import { Header, HeaderProps } from '.'; + +export default { + title: 'App components/Header', + component: Header, +}; + +export const overview = ({ position }: HeaderProps) => ( +
header
+); + +overview.story = { + controls: { + position: { + type: 'options', + options: ['fixed', 'absolute', 'sticky', 'static', 'relative'], + }, + }, +}; diff --git a/ui/app-components/src/Header/Header.tsx b/ui/app-components/src/Header/Header.tsx new file mode 100644 index 000000000..0bb5827d6 --- /dev/null +++ b/ui/app-components/src/Header/Header.tsx @@ -0,0 +1,51 @@ +/** @jsx jsx */ +import { FC } from 'react'; +import { jsx, Box, BoxProps, Theme } from 'theme-ui'; + +export interface HeaderProps { + /** Position property for the header element */ + position?: 'fixed' | 'absolute' | 'sticky' | 'static' | 'relative'; + + /** z-index for the header */ + zIndex?: number; +} + +/** + * A page header component + */ +export const Header: FC = ({ + children, + zIndex, + position, + ...rest +}) => ( + `0 1px 3px 1px ${t.colors?.shadow}`, + }} + {...rest} + > + {children} + +); + +Header.defaultProps = { + position: 'relative', + zIndex: 10, +}; diff --git a/ui/app-components/src/Header/index.ts b/ui/app-components/src/Header/index.ts new file mode 100644 index 000000000..266dec8a1 --- /dev/null +++ b/ui/app-components/src/Header/index.ts @@ -0,0 +1 @@ +export * from './Header'; diff --git a/ui/app-components/src/index.ts b/ui/app-components/src/index.ts index 2f5f7ba4a..d270e8f70 100644 --- a/ui/app-components/src/index.ts +++ b/ui/app-components/src/index.ts @@ -1,4 +1,5 @@ export * from './ColorMode'; +export * from './Header'; export * from './Keyboard'; export * from './Navmenu'; export * from './Sidebar';