-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(typescript): refactor to use Babel
Resolves #114
- Loading branch information
Showing
48 changed files
with
972 additions
and
526 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
const { resolve } = require('path'); | ||
|
||
module.exports = { | ||
stories: ['../src/**/*.stories.(tsx|mdx)'], | ||
addons: [ | ||
{ | ||
name: '@storybook/preset-typescript', | ||
options: { | ||
forkTsCheckerWebpackPluginOptions: { | ||
colors: false, // disables built-in colors in logger messages | ||
}, | ||
include: [resolve('../src')], | ||
}, | ||
}, | ||
{ | ||
name: '@storybook/addon-docs', | ||
options: { | ||
configureJSX: true, | ||
}, | ||
}, | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"name": "example-ts-react", | ||
"version": "0.1.0", | ||
"private": true, | ||
"scripts": { | ||
"build": "exit 0;", | ||
"build-storybook": "build-storybook", | ||
"storybook": "start-storybook" | ||
}, | ||
"dependencies": { | ||
"@babel/core": "^7.8.7", | ||
"@storybook/addon-docs": "^5.3.14", | ||
"@storybook/preset-typescript": "*", | ||
"@storybook/react": "^5.3.17", | ||
"@types/react": "^16.9.23", | ||
"@types/react-dom": "^16.9.5", | ||
"babel-loader": "^8.0.6", | ||
"react": "^16.13.0", | ||
"react-dom": "^16.13.0", | ||
"typescript": "^3.8.3" | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
examples/ts-react/src/components/Button/Button.stories.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { Meta, Preview, Story, Props } from '@storybook/addon-docs/blocks'; | ||
import Button from './Button'; | ||
|
||
<Meta title='MDX|Button' component={Button} /> | ||
|
||
# Button | ||
|
||
With `MDX` we can define a story for `Button` right in the middle of our | ||
markdown documentation. | ||
|
||
<Preview> | ||
<Story name='Button'> | ||
<form> | ||
<Button>Example</Button> | ||
</form> | ||
</Story> | ||
</Preview> | ||
|
||
## Props | ||
|
||
<Props of={Button} /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import React, { FC } from 'react'; | ||
import Button from './Button'; | ||
|
||
// eslint-disable-next-line import/no-default-export | ||
export default { title: 'Button', component: Button }; | ||
|
||
export const Default: FC = () => <Button variant='small'>Example</Button>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* eslint-disable react/prop-types, react/button-has-type */ | ||
import React, { FC, ReactNode } from 'react'; | ||
|
||
interface ButtonProps { | ||
/** | ||
* The content of the button. | ||
*/ | ||
children: ReactNode; | ||
/** | ||
* Sets the button size. | ||
*/ | ||
variant: 'small' | 'large'; | ||
/** | ||
* Disables the button. | ||
*/ | ||
disabled?: boolean; | ||
} | ||
|
||
// NOTE: Right now FC<Props> is not working. | ||
const Button: FC<ButtonProps> = ({ | ||
children, | ||
disabled, | ||
variant, | ||
}: ButtonProps) => ( | ||
<button disabled={disabled}> | ||
{children} {variant} | ||
</button> | ||
); | ||
|
||
// eslint-disable-next-line import/no-default-export | ||
export default Button; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es5", | ||
"lib": ["dom", "dom.iterable", "esnext"], | ||
"skipLibCheck": true, | ||
"esModuleInterop": true, | ||
"strict": true, | ||
"module": "esnext", | ||
"moduleResolution": "node", | ||
"noEmit": true, | ||
"jsx": "react" | ||
}, | ||
"include": ["src", ".storybook/*"] | ||
} |
11 changes: 9 additions & 2 deletions
11
...ages/preset-typescript/.storybook/main.ts → examples/ts-vue/.storybook/main.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import Vue from 'vue'; | ||
|
||
import Button from '../src/components/Button/Button.vue'; | ||
|
||
Vue.component('my-button', Button); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"name": "example-ts-vue", | ||
"version": "0.1.0", | ||
"private": true, | ||
"scripts": { | ||
"build": "exit 0;", | ||
"build-storybook": "build-storybook", | ||
"storybook": "start-storybook" | ||
}, | ||
"dependencies": { | ||
"@babel/core": "^7.8.7", | ||
"@storybook/addon-docs": "^5.3.14", | ||
"@storybook/preset-typescript": "*", | ||
"@storybook/vue": "^5.3.14", | ||
"babel-loader": "^8.0.6", | ||
"babel-preset-vue": "^2.0.2", | ||
"typescript": "^3.8.3", | ||
"vue": "^2.6.11", | ||
"vue-loader": "^15.9.0", | ||
"vue-template-compiler": "^2.6.11" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { Meta, Preview, Story, Props } from '@storybook/addon-docs/blocks'; | ||
import Button from './Button.vue'; | ||
|
||
<Meta title='MDX|Button' component={Button} /> | ||
|
||
# Button | ||
|
||
With `MDX` we can define a story for `Button` right in the middle of our | ||
markdown documentation. | ||
|
||
<Preview> | ||
<Story name='Button'> | ||
{{ | ||
template: '<my-button>Example</my-button>', | ||
}} | ||
</Story> | ||
</Preview> | ||
|
||
## Props | ||
|
||
<Props of={Button} /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import Button from './Button.vue'; | ||
|
||
// eslint-disable-next-line import/no-default-export | ||
export default { title: 'Button', component: Button }; | ||
|
||
export const Default = (): object => ({ | ||
components: { Button }, | ||
template: '<my-button>Example</my-button>', | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<template> | ||
<button class="button" @click="onClick" @dblclick="onDoubleClick"> | ||
<slot />! | ||
</button> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import Vue from 'vue'; | ||
export default Vue.extend({ | ||
name: 'Button', | ||
methods: { | ||
onClick($event: Event) { | ||
/** | ||
* Emitted when the button is clicked. | ||
* @event click | ||
* @type {Event} | ||
*/ | ||
this.$emit('click', $event); | ||
}, | ||
onDoubleClick($event: Event) { | ||
/** | ||
* Emitted when the button is double clicked. | ||
* @event doubleClick | ||
* @type {Event} | ||
*/ | ||
this.$emit('double-click', $event); | ||
}, | ||
}, | ||
props: { | ||
/** | ||
* The button's color. | ||
*/ | ||
color: { | ||
type: String, | ||
default: '#333', | ||
}, | ||
}, | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
declare module '*.vue' { | ||
import Vue from 'vue'; | ||
|
||
// eslint-disable-next-line import/no-default-export | ||
export default Vue; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es5", | ||
"lib": ["dom", "dom.iterable", "esnext"], | ||
"skipLibCheck": true, | ||
"esModuleInterop": true, | ||
"strict": true, | ||
"module": "esnext", | ||
"moduleResolution": "node", | ||
"noEmit": true | ||
}, | ||
"include": ["src", ".storybook/*"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
module.exports = { | ||
cacheDirectory: '.cache/jest', | ||
clearMocks: true, | ||
roots: ['<rootDir>/packages'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.