From b709eb8acd1759b7a50599a40834253281118ced Mon Sep 17 00:00:00 2001 From: Wenche Tollevsen Date: Fri, 28 Aug 2020 09:59:26 +0200 Subject: [PATCH] Typescript support for Divider (#520) * First try for typescript support for Divider * In the middle of using proptables from ts components in the storybook * Lot's of lot's of tweeks to make prop tables in storybook working. This commit is kind of a proof of concept * Remove classname, key and ref from props table * Removed debug env * Removed configuration of typescript in storybook main * Remove old testing stuffs * Remove old rollup typescript plugin * Delete copy'n pasted babel typescript transpiler, we use rollup plugin instead * Remove testing stuffs --- libraries/core-react/rollup.config.js | 12 ++++-------- libraries/core-react/src/Divider/Divider.test.tsx | 6 ++++-- libraries/core-react/src/Divider/Divider.tokens.ts | 1 - libraries/core-react/src/Divider/Divider.tsx | 2 +- libraries/core-react/src/Divider/index.ts | 1 - 5 files changed, 9 insertions(+), 13 deletions(-) diff --git a/libraries/core-react/rollup.config.js b/libraries/core-react/rollup.config.js index a6be436910..560dfa8c49 100644 --- a/libraries/core-react/rollup.config.js +++ b/libraries/core-react/rollup.config.js @@ -4,7 +4,8 @@ import commonjs from '@rollup/plugin-commonjs' import json from '@rollup/plugin-json' import babel from '@rollup/plugin-babel' import polyfill from 'rollup-plugin-polyfill' -import typescript from 'rollup-plugin-typescript2' +import typescript from '@rollup/plugin-typescript' + import pkg from './package.json' const peerDeps = Object.keys(pkg.peerDependencies || {}) @@ -28,13 +29,8 @@ export default [ }, plugins: [ json(), - resolve({ extensions: ['.jsx', '.js'] }), - typescript({ - tsconfig: 'tsconfig.json', - typescript: require('typescript'), - include: ['*.ts+(|x)', '**/*.ts+(|x)', '*.js+(|x)', '**/*.js+(|x)'], - exclude: ['node_modules/**'], - }), + resolve({ extensions }), + typescript(), babel({ exclude: 'node_modules/**', babelHelpers: 'bundled', diff --git a/libraries/core-react/src/Divider/Divider.test.tsx b/libraries/core-react/src/Divider/Divider.test.tsx index abf5f6ebfa..bb319d09aa 100644 --- a/libraries/core-react/src/Divider/Divider.test.tsx +++ b/libraries/core-react/src/Divider/Divider.test.tsx @@ -29,7 +29,7 @@ describe('Divider', () => { expect(container.firstChild).toHaveStyleRule('margin-top', spacingMedium) }) it('Sets backgroundColor to light according to color prop', () => { - const { container } = render() + const { container } = render() expect(container.firstChild).toHaveStyleRule('background-color', light) }) it('Sets backgroundColor to lighter according to color prop', () => { @@ -41,7 +41,9 @@ describe('Divider', () => { expect(container.firstChild).toHaveStyleRule('margin-top', spacingSmall) }) it('Can extend the css for the component', () => { - const { container } = render() + const { container } = render( + , + ) expect(container.firstChild).toHaveStyleRule('position', 'relative') expect(container.firstChild).toHaveStyleRule('margin-top', spacingSmall) }) diff --git a/libraries/core-react/src/Divider/Divider.tokens.ts b/libraries/core-react/src/Divider/Divider.tokens.ts index 23e2649f85..4fbcfd5c25 100644 --- a/libraries/core-react/src/Divider/Divider.tokens.ts +++ b/libraries/core-react/src/Divider/Divider.tokens.ts @@ -1,4 +1,3 @@ -// @ts-nocheck import { tokens } from '@equinor/eds-tokens' const { diff --git a/libraries/core-react/src/Divider/Divider.tsx b/libraries/core-react/src/Divider/Divider.tsx index c6055508b7..855385b550 100644 --- a/libraries/core-react/src/Divider/Divider.tsx +++ b/libraries/core-react/src/Divider/Divider.tsx @@ -21,7 +21,7 @@ type Props = { /** Color variants @default medium */ color?: 'lighter' | 'light' | 'medium' - /** Vertical spacings + /** Vertical spacings @default medium */ variant?: 'small' | 'medium' className?: string diff --git a/libraries/core-react/src/Divider/index.ts b/libraries/core-react/src/Divider/index.ts index 271b490a2a..465ccc7fdb 100644 --- a/libraries/core-react/src/Divider/index.ts +++ b/libraries/core-react/src/Divider/index.ts @@ -1,2 +1 @@ -// @ts-nocheck export { Divider } from './Divider'