Skip to content

Commit

Permalink
Typescript Integration - Phase 1 (#148)
Browse files Browse the repository at this point in the history
* TS integration working build

* add lint TS hook

* convert utils folder

* revert Helper transition due to error in build

* add lint staged and TS config

* update tsconfig add build types to build

* update git ignore

* replace storybook loader

* feedback fixes

* convert 1 story to TS and fix build

* add accordion component to TS

* fix rollup build

* config components Type declarations

* separate stories from ts build

* feedback fixes part 1

* feedback fixes part 2

* fix jest module resolver

* fix Media Queries type declaration

* update changelog

* v5.0.0-beta.0

* eslint auto fix files

* eslint fixes

* bump typescript version

* alert component typo and webpack reorg

* remove prettier for autogenerated files

* fix typo

* testing lintstaged

* testing lintstaged TS

* testing lintstaged JS

* Hard type mediaqueries type

* refactor cleanup

* retore svg indexes and prettier config

* add TS flags

* v7.0.0-beta.0

* update changelog

* remove rollup TS plugin

* update changelog v7 beta 1

* v7.0.0-beta.1

* update babel plugin

* update changelog

* v7.0.0-beta.2

* reorder TSC command in build

* udpate snapshot test

* emitDeclarationOnly flag

* udpate changelog

* v7.0.0-beta.3

* restore utils colors to original format

* update roll babel plugin

* revert rollplugin bable version

* update changelog

* v7.0.0-beta.4
  • Loading branch information
daigof authored Apr 20, 2020
1 parent 182843d commit 20911f8
Show file tree
Hide file tree
Showing 82 changed files with 4,445 additions and 5,797 deletions.
59 changes: 46 additions & 13 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,30 +1,63 @@
{
"extends": "curology",
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
},
"extends": [
"curology",
"plugin:@typescript-eslint/recommended"
],
"plugins": ["emotion"],
"globals": {
"document": false
},
"settings": {
"import/resolver": {
"webpack": {
"config": "./.storybook/webpack.config.js"
}
},
"import/extensions": [".js", ".md"]
},
"rules": {
"@typescript-eslint/camelcase": 0,
"@typescript-eslint/ban-ts-ignore": 0,
"react/state-in-constructor": 0,
"react/static-property-placement": 0,
"import/no-extraneous-dependencies": ["error", { "devDependencies": true }],
"react/jsx-filename-extension": [1, { "extensions": [".js", ".tsx"] }],
"import/extensions": [2, { "svg": "always" }]
},
"overrides": [
{
"files": ["test.js"],
"files": ["test.js", "test.ts", "test.tsx"],
"rules": {
"no-undef": "off",
"emotion/jsx-import": "error",
"emotion/no-vanilla": "error",
"emotion/import-from-emotion": "error",
"emotion/styled-import": "error"
}
}
],
"settings": {
"import/resolver": {
"webpack": {
"config": "./.storybook/webpack.config.js"
},
{
"files": ["**/style.js"],
"rules": {
"indent": "off"
}
},
"import/extensions": [".js", ".jsx", ".md"]
},
"rules": {
"import/no-extraneous-dependencies": ["error", { "devDependencies": true }]
}
{
"files": ["*.js"],
"rules": {
"@typescript-eslint/no-var-requires": 0,
"@typescript-eslint/explicit-function-return-type": 0
}
},
{
"files": ["*.tsx"],
"rules": {
"react/prop-types": 0
}
}
]
}
10 changes: 10 additions & 0 deletions .lintstagedrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = {
'!(style|styles|test).js': ['prettier --write', 'eslint --fix'],
'(style|styles|test).js': 'prettier --write',
'src/**/*.{ts,tsx}': [
'prettier --write',
'eslint --fix',
() => 'tsc -p tsconfig.json --noEmit --emitDeclarationOnly false',
],
'*.{md,json}': 'prettier --write',
};
6 changes: 6 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
src/svgs/deprecated/index.js
src/svgs/emojis/index.js
src/svgs/glyphs/index.js
src/svgs/icons/index.js
src/svgs/logos/index.js
src/svgs/navIcons/index.js
2 changes: 1 addition & 1 deletion .storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ addParameters({
},
});

const req = require.context('../stories', true, /.js$/);
const req = require.context('../stories', true, /.(ts|tsx|js)$/);
function loadStories() {
req.keys().forEach(req);
}
Expand Down
53 changes: 33 additions & 20 deletions .storybook/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,41 +23,54 @@ function removeDefaultStorybookSvgRule(config) {
module.exports = webpackSettings => {
// ESLint fix for `Resolve error: Cannot destructure property" `config` of 'undefined' or 'null'` in /stories/**/index.js files.
if (!webpackSettings) return {};
const { config } = webpackSettings;

removeDefaultStorybookSvgRule(config);
const { config } = webpackSettings;

config.resolve = {
modules: [path.resolve(__dirname, '..'), 'node_modules'],
extensions: ['.js', '.jsx', '.md'],
extensions: ['.js', '.md', '.ts', '.tsx'],
};

const customRules = [
{
test: /\.svg$/,
use: [
{ loader: 'babel-loader', options: require('../babel.config.js') },
{
loader: '@svgr/webpack',
options: {
template: transformTemplateForUtilLocation(UTIL_LOCATION),
expandProps: false,
babel: false,
},
// SVG Rule
removeDefaultStorybookSvgRule(config);

config.module.rules.push({
test: /\.svg$/,
use: [
{ loader: 'babel-loader', options: require('../babel.config.js') },
{
loader: '@svgr/webpack',
options: {
template: transformTemplateForUtilLocation(UTIL_LOCATION),
expandProps: false,
babel: false,
},
],
},
];
},
],
});

customRules.forEach(rule => config.module.rules.push(rule));
// Typescript Rule
config.module.rules.push({
test: /\.(ts|tsx)$/,
use: [
{
loader: require.resolve('babel-loader'),
options: {
presets: ['@babel/preset-typescript'],
},
},
],
});

// Storybook Index Loader Rule
config.module.rules.push({
test: /index\.js?$/,
test: /index\.(ts|tsx|js)?$/,
loaders: [require.resolve('@storybook/source-loader')],
include: path.resolve(__dirname, '../stories'),
enforce: 'pre',
});

// CircularDependencyPlugin
config.plugins.push(
new CircularDependencyPlugin({
exclude: /node_modules/,
Expand Down
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
# CHANGELOG

# v7.0.0-beta.4

- [Internal] Convert Project to Typescript: Refactor TS files

# v7.0.0-beta.3

- [Internal] Convert Project to Typescript: update TSC declaration build config

# v7.0.0-beta.2

- [Internal] Convert Project to Typescript: update TS babel plugin

# v7.0.0-beta.1

- [Internal] Convert Project to Typescript: transpile TS files with Babel for Rollup build

# v7.0.0-beta.0

- [Internal] Convert Project to Typescript Updated ([#148](https://github.com/PocketDerm/radiance-ui/pull/148))

# v6.4.1

- Added CheckPlusIcon and CheckMinusIcon ([#220](https://github.com/curology/radiance-ui/pull/220))
Expand Down Expand Up @@ -52,6 +72,11 @@

- Added Callout and Indicator new components ([#202](https://github.com/curology/radiance-ui/pull/202))

# v5.0-beta

- [Internal] Convert Project to Typescript ([#148](https://github.com/PocketDerm/radiance-ui/pull/148))
- [Feature] Publish Generated Types declarations

# v4.2.22

- Updated border width on OptionButton ([#197](https://github.com/curology/radiance-ui/pull/197))
Expand Down
10 changes: 3 additions & 7 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
module.exports = {
presets: [
'@babel/env',
'@babel/react',
'@emotion/babel-preset-css-prop',
],
presets: ['@babel/env', '@babel/react', '@emotion/babel-preset-css-prop'],
plugins: [
'@babel/plugin-proposal-export-namespace-from',
'@babel/plugin-proposal-export-default-from',
['@babel/plugin-proposal-class-properties', { 'loose': true }],
['@babel/plugin-transform-parameters', { 'loose': true }],
['@babel/plugin-proposal-class-properties', { loose: true }],
['@babel/plugin-transform-parameters', { loose: true }],
],
};
2 changes: 1 addition & 1 deletion docs/accordion.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ The accordion style renders thumbnail images into the right hand side of the acc

- **3+ images:** Renders thumbnail of first image and a counter of additional images

Upon opening of the accordion, the thumbnail images should disapear from the title bar because they'll then be visible in the `content` container.
Upon opening of the accordion, the thumbnail images should disappear from the title bar because they'll then be visible in the `content` container.

```jsx
import { Accordion } from 'radiance-ui';
Expand Down
2 changes: 1 addition & 1 deletion docs/alert.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { Fragment } from 'react';
import { Alert } from 'radiance-ui';

<Alert.Container>
<Alert content="Default Alert: it will dissapear after 3 seconds" />
<Alert content="Default Alert: it will disappear after 3 seconds" />
<Alert
content={
<Fragment>
Expand Down
51 changes: 31 additions & 20 deletions docs/button/button.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ import { CheckmarkIcon } from 'radiance-ui/lib/icons';
Full Width Loading
</Button>
</Button.Container>
</React.Fragment>
</React.Fragment>;
```

## With Color
Expand All @@ -76,13 +76,25 @@ import { COLORS } from 'radiance-ui/lib/constants';
<React.Fragment>
<Button.Container>
<Button buttonColor={COLORS.statusRed}>Primary Button</Button>
<Button buttonColor={COLORS.statusRed} buttonType="secondary">Secondary Button</Button>
<Button buttonColor={COLORS.statusRed} buttonType="tertiary">Tertiary Button</Button>
<Button buttonColor={COLORS.statusRed} buttonType="quaternary">Quaternary Button</Button>
<Button buttonColor={COLORS.statusRed} disabled>Disabled Button</Button>
<Button buttonColor={COLORS.statusRed} isFullWidth>Full Width Button</Button>
<Button buttonColor={COLORS.statusRed} buttonType="secondary">
Secondary Button
</Button>
<Button buttonColor={COLORS.statusRed} buttonType="tertiary">
Tertiary Button
</Button>
<Button buttonColor={COLORS.statusRed} buttonType="quaternary">
Quaternary Button
</Button>
<Button buttonColor={COLORS.statusRed} disabled>
Disabled Button
</Button>
<Button buttonColor={COLORS.statusRed} isFullWidth>
Full Width Button
</Button>

<Button buttonColor={COLORS.statusRed} isLoading>Primary Loading</Button>
<Button buttonColor={COLORS.statusRed} isLoading>
Primary Loading
</Button>
<Button buttonColor={COLORS.statusRed} isLoading buttonType="secondary">
Secondary Loading
</Button>
Expand All @@ -96,25 +108,24 @@ import { COLORS } from 'radiance-ui/lib/constants';
Full Width Loading
</Button>
</Button.Container>
</React.Fragment>
</React.Fragment>;
```


<!-- STORY -->

### Proptypes

| prop | propType | required | default | description |
| ----------- | -------- | -------- | -------- | ------------------------------------------------------------------------------------------------------------------------------ |
| buttonType | string | no | primary | Determines the button's main style theme. Must be one of `primary`, `secondary`, `tertiary`, `quaternary`. |
| buttonColor | string | no | primary | Determines the color of the button . Must be one of the predefined colors (e.g. `primary`, `statusRed`, `statusGreen`, etc). |
| children | node | yes | - | node to be rendered inside the button. Recommended to be the button text |
| disabled | bool | no | false | when disabled, click listener will not be called and the UI will look disabled |
| icon | node | no | null | icon to render in the button. Recommended to use one of Radiance's icons |
| isLoading | bool | no | false | renders loading state and prevents click listener from being called |
| onClick | func | no | () => {} | callback function called on click of the button |
| textColor | string | no | '' | color (as a string) that will override existing text, icon, and loading colors for the button (except when disabled is true) |
| isFullWidth | bool | no | false | adjusts the default button styles so that the button takes the full width of the container. Intended for mobile-use only. |
| prop | propType | required | default | description |
| ----------- | -------- | -------- | -------- | ---------------------------------------------------------------------------------------------------------------------------- |
| buttonType | string | no | primary | Determines the button's main style theme. Must be one of `primary`, `secondary`, `tertiary`, `quaternary`. |
| buttonColor | string | no | primary | Determines the color of the button . Must be one of the predefined colors (e.g. `primary`, `statusRed`, `statusGreen`, etc). |
| children | node | yes | - | node to be rendered inside the button. Recommended to be the button text |
| disabled | bool | no | false | when disabled, click listener will not be called and the UI will look disabled |
| icon | node | no | null | icon to render in the button. Recommended to use one of Radiance's icons |
| isLoading | bool | no | false | renders loading state and prevents click listener from being called |
| onClick | func | no | () => {} | callback function called on click of the button |
| textColor | string | no | '' | color (as a string) that will override existing text, icon, and loading colors for the button (except when disabled is true) |
| isFullWidth | bool | no | false | adjusts the default button styles so that the button takes the full width of the container. Intended for mobile-use only. |

### Notes

Expand Down
Loading

0 comments on commit 20911f8

Please sign in to comment.