diff --git a/src/Panel/Panel.spec.js b/src/Panel/Panel.spec.tsx
similarity index 83%
rename from src/Panel/Panel.spec.js
rename to src/Panel/Panel.spec.tsx
index 7d35a1f4..8f85f5f9 100644
--- a/src/Panel/Panel.spec.js
+++ b/src/Panel/Panel.spec.tsx
@@ -1,12 +1,11 @@
-import React from 'react';
import { render } from '@testing-library/react';
-import Panel from './Panel';
+import { Panel } from './Panel';
describe('', () => {
it('should render panel', () => {
const { container } = render();
- const panel = container.firstChild;
+ const panel = container.firstElementChild;
expect(panel).toBeInTheDocument();
});
@@ -15,7 +14,7 @@ describe('', () => {
const { container } = render(
);
- const panel = container.firstChild;
+ const panel = container.firstElementChild;
expect(panel).toHaveAttribute('style', 'background-color: papayawhip;');
});
@@ -34,7 +33,7 @@ describe('', () => {
it('should render custom props', () => {
const customProps = { title: 'panel' };
const { container } = render();
- const panel = container.firstChild;
+ const panel = container.firstElementChild;
expect(panel).toHaveAttribute('title', 'panel');
});
diff --git a/src/Panel/Panel.stories.js b/src/Panel/Panel.stories.tsx
similarity index 94%
rename from src/Panel/Panel.stories.js
rename to src/Panel/Panel.stories.tsx
index 47ed286c..460f4326 100644
--- a/src/Panel/Panel.stories.js
+++ b/src/Panel/Panel.stories.tsx
@@ -1,7 +1,6 @@
-import React from 'react';
-import styled from 'styled-components';
-
+import { ComponentMeta } from '@storybook/react';
import { Panel } from 'react95';
+import styled from 'styled-components';
const Wrapper = styled.div`
padding: 5rem;
@@ -22,7 +21,7 @@ export default {
title: 'Panel',
component: Panel,
decorators: [story => {story()}]
-};
+} as ComponentMeta;
export function Default() {
return (
diff --git a/src/Panel/Panel.js b/src/Panel/Panel.tsx
similarity index 56%
rename from src/Panel/Panel.js
rename to src/Panel/Panel.tsx
index e3cacf47..1c84bb07 100644
--- a/src/Panel/Panel.js
+++ b/src/Panel/Panel.tsx
@@ -1,4 +1,4 @@
-import React from 'react';
+import React, { forwardRef } from 'react';
import propTypes from 'prop-types';
import styled, { css } from 'styled-components';
import {
@@ -6,8 +6,16 @@ import {
createBoxStyles,
createWellBorderStyles
} from '../common';
+import { CommonStyledProps } from '../types';
-const createPanelStyles = (variant = 'default') => {
+type PanelProps = {
+ children?: React.ReactNode;
+ shadow?: boolean;
+ variant?: 'outside' | 'inside' | 'well';
+} & React.HTMLAttributes &
+ CommonStyledProps;
+
+const createPanelStyles = (variant: PanelProps['variant']) => {
switch (variant) {
case 'well':
return css`
@@ -24,17 +32,19 @@ const createPanelStyles = (variant = 'default') => {
}
};
-const StyledPanel = styled.div`
+const StyledPanel = styled.div>>`
position: relative;
font-size: 1rem;
${({ variant }) => createPanelStyles(variant)}
${createBoxStyles()}
`;
-const Panel = React.forwardRef(function Panel(props, ref) {
- const { children, variant, ...otherProps } = props;
+const Panel = forwardRef(function Panel(
+ { children, shadow = false, variant = 'outside', ...otherProps },
+ ref
+) {
return (
-
+
{children}
);
@@ -52,4 +62,4 @@ Panel.propTypes = {
shadow: propTypes.bool
};
-export default Panel;
+export { Panel, PanelProps };
diff --git a/src/index.ts b/src/index.ts
index 05595aef..1f30d80a 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -20,7 +20,7 @@ export { default as List } from './List/List';
export { default as ListItem } from './ListItem/ListItem';
export { default as LoadingIndicator } from './LoadingIndicator/LoadingIndicator';
export { default as NumberField } from './NumberField/NumberField';
-export { default as Panel } from './Panel/Panel';
+export * from './Panel/Panel';
export { default as Progress } from './Progress/Progress';
export { default as Radio } from './Radio/Radio';
export { default as Select } from './Select/Select';