Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

♻️ Sidesheet story to Typescript #803

Merged
merged 4 commits into from
Oct 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
185 changes: 0 additions & 185 deletions apps/storybook-react/stories/SideSheet.stories.jsx

This file was deleted.

37 changes: 37 additions & 0 deletions apps/storybook-react/stories/SideSheet.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import React, { useState } from 'react'
import styled from 'styled-components'
import { SideSheet, SideSheetProps, Button } from '@equinor/eds-core-react'
import { Story, Meta } from '@storybook/react'

const Child = styled.div`
padding: 6px;
background-color: rgba(255, 146, 0, 0.15);
box-sizing: border-box;
border: 1px dashed #ff9200;
border-radius: 4px;
`

export default {
title: 'Components/SideSheet',
component: SideSheet,
argTypes: {
title: {
defaultValue: 'Title',
},
},
} as Meta

export const Default: Story<SideSheetProps> = (args) => {
const [toggle, setToggle] = useState(true)

return (
<div style={{ height: '400px' }}>
<Button variant="outlined" onClick={() => setToggle(!toggle)}>
Click me!
</Button>
<SideSheet {...args} open={toggle} onClose={() => setToggle(!toggle)}>
<Child>Children</Child>
</SideSheet>
</div>
)
}
11 changes: 5 additions & 6 deletions libraries/core-react/src/SideSheet/SideSheet.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, { forwardRef } from 'react'
import PropTypes from 'prop-types'
import React, { forwardRef, HTMLAttributes } from 'react'
import styled from 'styled-components'
import { clear } from '@equinor/eds-icons'
import { spacingsTemplate } from '../_common/templates'
Expand All @@ -20,7 +19,7 @@ type StyleProps = {
width: string
}

type Props = {
export type SideSheetProps = {
/** Title for Side Sheet */
title?: string
/** Variant controls width of Side Sheet */
Expand All @@ -29,7 +28,7 @@ type Props = {
onClose?: (Event) => void
/** Open / close Side Sheet */
open?: boolean
} & React.HTMLAttributes<HTMLDivElement>
} & HTMLAttributes<HTMLDivElement>

const StyledSideSheet = styled.div<StyleProps>`
height: 100%;
Expand All @@ -54,8 +53,8 @@ const Header = styled.div`
padding-right: 10px;
`

export const SideSheet = forwardRef<HTMLDivElement, Props>(
function EdsSideSheet(
export const SideSheet = forwardRef<HTMLDivElement, SideSheetProps>(
function SideSheet(
{
variant = 'medium',
title = '',
Expand Down
2 changes: 1 addition & 1 deletion libraries/core-react/src/SideSheet/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { SideSheet } from './SideSheet'
export * from './SideSheet'
4 changes: 2 additions & 2 deletions libraries/core-react/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ export * from './TopBar'
export { Dialog } from './Dialog'
export * from './Scrim'
export { TableOfContents } from './TableOfContents'
export { SideSheet } from './SideSheet'
export * from './Chip'
export * from './SideSheet'
export { Chip } from './Chip'
export * from './Avatar'
export * from './Search'
export { Slider } from './Slider'
Expand Down