Skip to content

Commit

Permalink
Added stories for scrollable
Browse files Browse the repository at this point in the history
  • Loading branch information
matheusps committed Oct 16, 2019
1 parent eab58bc commit d23285f
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 11 deletions.
25 changes: 15 additions & 10 deletions src/components/Heading.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
import React, { FC } from 'react'
import styled from 'styled-components'

type HLevel = 1 | 2 | 3 | 4 | 5 | 6

interface Props {
level: HLevel
style: any //Find correct extension
}

const H1 = styled.h1`
font-size: 4rem;
font-weight: 400;
Expand Down Expand Up @@ -57,9 +50,21 @@ const getComponent = (level: HLevel) => {
}
}

const Heading: FC<Props> = ({ level, children, ...rest }) => {
const H = getComponent(level)
return <H {...rest}>{children}</H>
const Heading: FC<HeadingProps> = ({ level = 1, ...props }) => {
const Component = getComponent(level)
//@ts-ignore
return <Component {...props} />
}

type HLevel = 1 | 2 | 3 | 4 | 5 | 6

type NativeHeadingType = React.DetailedHTMLProps<
React.HTMLAttributes<HTMLHeadingElement>,
HTMLHeadingElement
>

type HeadingProps = NativeHeadingType & {
level?: HLevel
}

export { Heading }
File renamed without changes.
61 changes: 61 additions & 0 deletions src/components/Scrollable/scrollable.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import React from 'react'
import Scrollable from './index'
import { AdaptProvider, Heading, Box, Paragraph } from '..'

export default {
title: 'Scrollable',
decorators: [storyFn => <AdaptProvider>{storyFn()}</AdaptProvider>],
}

export const yAxis = () => (
<Scrollable axis="y" width="300px" height="200px">
<Heading level={6}>Start Scrolling</Heading>
<Box>
<Paragraph>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo consequat. Duis aute irure dolor in reprehenderit in voluptate
velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint
occaecat cupidatat non proident, sunt in culpa qui officia deserunt
mollit anim id est laborum.
</Paragraph>
</Box>
</Scrollable>
)

export const xAxis = () => (
<Scrollable axis="x" width="300px" height="200px">
<Heading level={6}>Start Scrolling</Heading>
<Box width="600px" height="1px" style={{ backgroundColor: 'black' }} />
<Box>
<Paragraph>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo consequat. Duis aute irure dolor in reprehenderit in voluptate
velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint
occaecat cupidatat non proident, sunt in culpa qui officia deserunt
mollit anim id est laborum.
</Paragraph>
</Box>
</Scrollable>
)

export const xyAxis = () => (
<Scrollable axis="xy" width="300px" height="200px">
<Heading level={6}>Start Scrolling</Heading>
<Box width="600px" height="1px" style={{ backgroundColor: 'black' }} />
<Box>
<Paragraph>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo consequat. Duis aute irure dolor in reprehenderit in voluptate
velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint
occaecat cupidatat non proident, sunt in culpa qui officia deserunt
mollit anim id est laborum.
</Paragraph>
</Box>
</Scrollable>
)
2 changes: 1 addition & 1 deletion src/components/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Box from './Box'
import Clickable from './Clickable'
import Flexible from './core/Flexible'
import Scrollable from './core/Scrollable'
import Scrollable from './Scrollable'

import AdaptProvider from './AdaptProvider'

Expand Down

0 comments on commit d23285f

Please sign in to comment.