Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript Integration - Phase 1 #148

Merged
merged 58 commits into from
Apr 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
55c720f
TS integration working build
daigof Oct 30, 2019
c5b1705
add lint TS hook
daigof Oct 30, 2019
4ab75f8
Merge branch 'master' into typescript-integration
daigof Oct 30, 2019
bfe125b
convert utils folder
daigof Oct 31, 2019
a34ac99
revert Helper transition due to error in build
daigof Oct 31, 2019
13beb60
Merge branch 'master' into typescript-integration
daigof Dec 23, 2019
9b3d36f
add lint staged and TS config
daigof Dec 23, 2019
c0e6b2f
update tsconfig add build types to build
daigof Dec 26, 2019
78cbf58
update git ignore
daigof Dec 26, 2019
2b1db3b
replace storybook loader
daigof Dec 26, 2019
351ae1c
feedback fixes
daigof Dec 27, 2019
4a06868
convert 1 story to TS and fix build
daigof Dec 30, 2019
0e8e0dd
add accordion component to TS
daigof Dec 30, 2019
1aec6ab
fix rollup build
daigof Dec 31, 2019
747bec2
config components Type declarations
daigof Dec 31, 2019
44b4b30
separate stories from ts build
daigof Dec 31, 2019
e328fbf
feedback fixes part 1
daigof Jan 2, 2020
fc46c68
feedback fixes part 2
daigof Jan 2, 2020
f2a0954
fix jest module resolver
daigof Jan 2, 2020
a9d5e3e
fix Media Queries type declaration
daigof Jan 3, 2020
8cf8520
update changelog
daigof Jan 10, 2020
1160c7a
v5.0.0-beta.0
daigof Jan 10, 2020
6fd5214
Merge branch 'master' into typescript-integration
daigof Apr 8, 2020
406b2fe
eslint auto fix files
daigof Apr 8, 2020
b05aa28
eslint fixes
daigof Apr 8, 2020
37542b6
bump typescript version
daigof Apr 9, 2020
5ff06d1
Merge branch 'master' into typescript-integration
daigof Apr 9, 2020
e7e3183
alert component typo and webpack reorg
daigof Apr 9, 2020
f15daac
remove prettier for autogenerated files
daigof Apr 9, 2020
425355c
fix typo
daigof Apr 9, 2020
df29122
Merge branch 'master' into typescript-integration
daigof Apr 9, 2020
07adf0f
testing lintstaged
daigof Apr 13, 2020
37fec5f
testing lintstaged TS
daigof Apr 13, 2020
a2b46a3
testing lintstaged JS
daigof Apr 13, 2020
60846e6
Hard type mediaqueries type
daigof Apr 13, 2020
2363eed
refactor cleanup
daigof Apr 13, 2020
55b219b
retore svg indexes and prettier config
daigof Apr 13, 2020
2fa0c78
add TS flags
daigof Apr 13, 2020
b6512db
v7.0.0-beta.0
daigof Apr 13, 2020
0ed16eb
update changelog
daigof Apr 13, 2020
da6217a
remove rollup TS plugin
daigof Apr 15, 2020
5bbcc16
update changelog v7 beta 1
daigof Apr 15, 2020
d0e9475
v7.0.0-beta.1
daigof Apr 15, 2020
838abc6
update babel plugin
daigof Apr 15, 2020
7cbb67c
update changelog
daigof Apr 15, 2020
416a484
v7.0.0-beta.2
daigof Apr 15, 2020
f484506
Merge branch 'master' into typescript-integration
daigof Apr 16, 2020
dfaf795
reorder TSC command in build
daigof Apr 16, 2020
37e2fa8
udpate snapshot test
daigof Apr 16, 2020
08d9145
emitDeclarationOnly flag
daigof Apr 16, 2020
b7a2af9
udpate changelog
daigof Apr 16, 2020
903c7fb
v7.0.0-beta.3
daigof Apr 16, 2020
533b138
Merge branch 'master' into typescript-integration
daigof Apr 17, 2020
fc1f154
restore utils colors to original format
daigof Apr 17, 2020
3b5e5e7
update roll babel plugin
daigof Apr 17, 2020
7b12832
revert rollplugin bable version
daigof Apr 17, 2020
a9f3365
update changelog
daigof Apr 17, 2020
6d27969
v7.0.0-beta.4
daigof Apr 17, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
daigof marked this conversation as resolved.
Show resolved Hide resolved
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'],
daigof marked this conversation as resolved.
Show resolved Hide resolved
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