diff --git a/libraries/core-react/src/SideSheet/SideSheet.jsx b/libraries/core-react/src/SideSheet/SideSheet.jsx deleted file mode 100644 index abd595cc69..0000000000 --- a/libraries/core-react/src/SideSheet/SideSheet.jsx +++ /dev/null @@ -1,95 +0,0 @@ -// @ts-nocheck -import React, { forwardRef } from 'react' -import PropTypes from 'prop-types' -import styled from 'styled-components' -import { clear } from '@equinor/eds-icons' -import { spacingsTemplate } from '../_common/templates' -import { Typography } from '../Typography' -import { Button } from '../Button' -import { Icon } from '../Icon' -import { sidesheet as tokens } from './SideSheet.tokens' - -const icons = { - clear, -} - -Icon.add(icons) - -const { background, spacings, border } = tokens - -const StyledSideSheet = styled.div` - height: 100%; - position: absolute; - z-index: 1; - top: 0; - right: 0; - box-sizing: border-box; - border-left: ${border.left.width} solid ${border.left.color}; - background: ${background}; - width: ${({ width }) => width}; - - ${spacingsTemplate(spacings)}; -` - -const Header = styled.div` - display: flex; - flex-wrap: nowrap; - justify-content: space-between; - align-items: center; - padding-bottom: 24px; - padding-right: 10px; -` - -export const SideSheet = forwardRef(function EdsSideSheet( - { variant, title, children, className, open, onClose, ...rest }, - ref, -) { - const props = { - ...rest, - className, - ref, - width: tokens.width[variant], - } - - // Controller must set open={false} when pressing the close button - return ( - open && ( - -
- {title} - -
- {children} -
- ) - ) -}) - -SideSheet.displayName = 'eds-sidesheet' - -SideSheet.propTypes = { - // Title for Side Sheet - title: PropTypes.string, - // Variant controls width of Side Sheet - variant: PropTypes.oneOf(['small', 'medium', 'large', 'xlarge']), - // OnClick function (close) - onClose: PropTypes.func, - // Open / close Side Sheet: - open: PropTypes.bool, - // Any type of content - /** @ignore */ - children: PropTypes.node, - /** @ignore */ - className: PropTypes.string, -} - -SideSheet.defaultProps = { - variant: 'medium', - title: '', - className: '', - open: true, - onClose: undefined, - children: undefined, -} diff --git a/libraries/core-react/src/SideSheet/SideSheet.test.jsx b/libraries/core-react/src/SideSheet/SideSheet.test.tsx similarity index 97% rename from libraries/core-react/src/SideSheet/SideSheet.test.jsx rename to libraries/core-react/src/SideSheet/SideSheet.test.tsx index ff3302c0aa..d4c07f5bbc 100644 --- a/libraries/core-react/src/SideSheet/SideSheet.test.jsx +++ b/libraries/core-react/src/SideSheet/SideSheet.test.tsx @@ -1,4 +1,3 @@ -/* eslint-disable no-undef */ import React from 'react' import { render, cleanup } from '@testing-library/react' import '@testing-library/jest-dom' diff --git a/libraries/core-react/src/SideSheet/SideSheet.tokens.js b/libraries/core-react/src/SideSheet/SideSheet.tokens.ts similarity index 97% rename from libraries/core-react/src/SideSheet/SideSheet.tokens.js rename to libraries/core-react/src/SideSheet/SideSheet.tokens.ts index af45492457..30f26c42c3 100644 --- a/libraries/core-react/src/SideSheet/SideSheet.tokens.js +++ b/libraries/core-react/src/SideSheet/SideSheet.tokens.ts @@ -1,4 +1,3 @@ -// @ts-nocheck import { tokens } from '@equinor/eds-tokens' const { diff --git a/libraries/core-react/src/SideSheet/SideSheet.tsx b/libraries/core-react/src/SideSheet/SideSheet.tsx new file mode 100644 index 0000000000..90ae39c79f --- /dev/null +++ b/libraries/core-react/src/SideSheet/SideSheet.tsx @@ -0,0 +1,94 @@ +import React, { forwardRef } from 'react' +import PropTypes from 'prop-types' +import styled from 'styled-components' +import { clear } from '@equinor/eds-icons' +import { spacingsTemplate } from '../_common/templates' +import { Typography } from '../Typography' +import { Button } from '../Button' +import { Icon } from '../Icon' +import { sidesheet as tokens } from './SideSheet.tokens' + +const icons = { + clear, +} + +Icon.add(icons) + +const { background, spacings, border } = tokens + +type StyleProps = { + width: string +} + +type Props = { + /** Title for Side Sheet */ + title?: string + /** Variant controls width of Side Sheet */ + variant?: 'small' | 'medium' | 'large' | 'xlarge' + /** OnClick function (close) */ + onClose?: (Event) => void + /** Open / close Side Sheet */ + open?: boolean +} & React.HTMLAttributes + +const StyledSideSheet = styled.div` + height: 100%; + position: absolute; + z-index: 1; + top: 0; + right: 0; + box-sizing: border-box; + border-left: ${border.left.width} solid ${border.left.color}; + background: ${background}; + width: ${({ width }) => width}; + + ${spacingsTemplate(spacings)}; +` + +const Header = styled.div` + display: flex; + flex-wrap: nowrap; + justify-content: space-between; + align-items: center; + padding-bottom: 24px; + padding-right: 10px; +` + +export const SideSheet = forwardRef( + function EdsSideSheet( + { + variant = 'medium', + title = '', + children, + className = '', + open = true, + onClose, + ...rest + }, + ref, + ) { + const props = { + ...rest, + className, + ref, + width: tokens.width[variant], + } + + // Controller must set open={false} when pressing the close button + return ( + open && ( + +
+ {title} + +
+ {children} +
+ ) + ) + }, +) + +SideSheet.displayName = 'eds-sidesheet' diff --git a/libraries/core-react/src/SideSheet/index.js b/libraries/core-react/src/SideSheet/index.ts similarity index 72% rename from libraries/core-react/src/SideSheet/index.js rename to libraries/core-react/src/SideSheet/index.ts index 0d69a724ea..b2b4911a1d 100644 --- a/libraries/core-react/src/SideSheet/index.js +++ b/libraries/core-react/src/SideSheet/index.ts @@ -1,2 +1 @@ -// @ts-nocheck export { SideSheet } from './SideSheet'