Skip to content
This repository has been archived by the owner on Oct 4, 2022. It is now read-only.

Commit

Permalink
TypeScript, PNPM (#47)
Browse files Browse the repository at this point in the history
* Migrating to TypeScript

* PNPM Setup

* PNPM Config

* TypeScript Types

* PNPM Config for Docs

* Docs dev

* TypeScript

* TS Changes

* TypeScript Errors, Move to Beta
  • Loading branch information
Anmol Mahatpurkar authored Jan 8, 2020
1 parent 7faa2b8 commit 625aac7
Show file tree
Hide file tree
Showing 63 changed files with 19,776 additions and 18,319 deletions.
3 changes: 0 additions & 3 deletions .babelrc

This file was deleted.

22 changes: 17 additions & 5 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,33 +1,45 @@
{
"parser": "babel-eslint",
"plugins": ["react", "jsx-a11y", "import", "react-hooks"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
},
"plugins": ["@typescript-eslint", "react", "jsx-a11y", "import", "react-hooks"],
"extends": ["airbnb", "plugin:prettier/recommended", "prettier/react", "prettier/standard"],
"env": { "browser": true },
"rules": {
"@typescript-eslint/indent": ["warn", "tab", { "SwitchCase": 1 }],
"@typescript-eslint/no-explicit-any": "off",
"indent": ["warn", "tab", { "SwitchCase": 1 }],
"class-methods-use-this": "off",
"prettier/prettier": "error",
"no-underscore-dangle": "off",
"no-cond-assign": "off",
"no-plusplus": "off",
"no-tabs": "off",
"no-unused-vars": "off",
"eqeqeq": "warn",
"camelcase": "off",
"import/extensions": "off",
"import/no-extraneous-dependencies": "off",
"import/prefer-default-export": "off",
"react/destructuring-assignment": "off",
"react/jsx-props-no-spreading": "off",
"react/jsx-indent": ["error", "tab"],
"react/jsx-indent-props": ["error", "tab"],
"react/no-array-index-key": "warn",
"react/jsx-one-expression-per-line": "off",
"react/jsx-filename-extension": [1, { "extensions": [".jsx"] }],
"react/jsx-filename-extension": [1, { "extensions": [".jsx", ".tsx"] }],
"react/static-property-placement": "off",
"jsx-a11y/mouse-events-have-key-events": "off",
"jsx-a11y/media-has-caption": "off",
"jsx-a11y/anchor-is-valid": "off"
},
"settings": {
"import/extensions": [".js", ".jsx"],
"import/extensions": [".js", ".jsx", ".ts", ".tsx", ".json"],
"import/parsers": { "@typescript-eslint/parser": [".ts", ".tsx"] },
"import/resolver": {
"node": { "extensions": [".js", ".jsx"] }
"node": { "extensions": [".js", ".jsx", ".ts", ".tsx", ".json"] }
}
}
}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ yarn-error.log*

docs/.next/
docs/out/

pnpm-debug.log
3 changes: 2 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"semi": true,
"singleQuote": true,
"trailingComma": "all",
"jsxBracketSameLine": true,
"jsxBracketSameLine": false,
"arrowParens": "always",
"proseWrap": "preserve"
}
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
### Features

- 4.2.0-beta.0

- Refactored entire codebase to TypeScript.
- Switched from yarn to pnpm to manage package dependencies.
- Bundle Size reduced to 4 KB
- No change to the package API or features. Everything should work as before.

- 4.1.3

- Fixes #44 and #45
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2019 Cogo Freight Private Limited
Copyright (c) 2020 Cogo Freight Private Limited

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 0 additions & 4 deletions docs/.babelrc

This file was deleted.

43 changes: 0 additions & 43 deletions docs/common-util/code-panel/index.jsx

This file was deleted.

34 changes: 0 additions & 34 deletions docs/common-util/code-panel/styles.jsx

This file was deleted.

6 changes: 4 additions & 2 deletions docs/common-util/button/index.jsx → docs/common/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import styled from '@emotion/styled';
import colors from '../../util/colors';
import colors from '../util/colors';

export default styled.button`
const Button = styled.button`
background: #fff;
border-radius: 4px;
border: 1px solid ${colors.OUTLINE};
Expand Down Expand Up @@ -63,3 +63,5 @@ export default styled.button`
outline: none;
}
`;

export default Button;
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ const CodeBlock = ({ children, className: langClass, theme }) => {
const language = langClass.replace(/language-/, '');
return (
<Highlight {...defaultProps} code={children} language={language} theme={themes[theme]}>
{({
className, style, tokens, getLineProps, getTokenProps,
}) => (
{({ className, style, tokens, getLineProps, getTokenProps }) => (
<pre
className={className}
style={{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';

const SvgComponent = props => (
const CodeIcon = (props) => (
<svg
width={20}
height={20}
Expand All @@ -14,4 +14,4 @@ const SvgComponent = props => (
</svg>
);

export default SvgComponent;
export default CodeIcon;
57 changes: 57 additions & 0 deletions docs/common/CodePanel.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import React, { useState } from 'react';
import PropTypes from 'prop-types';

import styled from '@emotion/styled';

import { H3 } from './Headers';
import CodeBlock from './CodeBlock';
import CodeIcon from './CodeIcon';

const CodePanel = ({ heading, code, children }) => {
const [isOpen, setIsOpen] = useState(false);

return (
<Container>
<Row>
<H3>{heading}</H3>
{code && <CodeIcon onClick={() => setIsOpen((prev) => !prev)} />}
</Row>
{isOpen && <CodeParent>{code}</CodeParent>}
{children}
</Container>
);
};

const Container = styled.div`
width: 100%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
padding: 30px 30px;
`;

const Row = styled.div`
display: flex;
align-items: center;
`;

const CodeParent = styled.div`
margin: 20px 0px;
display: flex;
justify-content: center;
`;

CodePanel.Block = CodeBlock;

CodePanel.propTypes = {
heading: PropTypes.string.isRequired,
children: PropTypes.node.isRequired,
code: PropTypes.node,
};

CodePanel.defaultProps = {
code: '',
};

export default CodePanel;
8 changes: 5 additions & 3 deletions docs/common-util/hgroup.jsx → docs/common/HGroup.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import styled from '@emotion/styled';

export default styled.div`
const HGroup = styled.div`
display: flex;
flex: ${({ flex }) => (flex || 1)} !important;
flex: ${({ flex }) => flex || 1} !important;
& > * {
flex: 1;
margin: 0px ${({ spacing }) => (spacing || '5px')};
margin: 0px ${({ spacing }) => spacing || '5px'};
&:first-child {
margin-left: 0px;
Expand All @@ -17,3 +17,5 @@ export default styled.div`
}
}
`;

export default HGroup;
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';

const SvgComponent = props => (
const HeartIcon = (props) => (
<svg width={15} height={15} style={{ margin: '0px 5px' }} viewBox="0 0 50 50" {...props}>
<path
d="M24.85 10.126c2.018-4.783 6.628-8.125 11.99-8.125 7.223 0 12.425 6.179 13.079 13.543 0 0 .353 1.828-.424 5.119-1.058 4.482-3.545 8.464-6.898 11.503L24.85 48 7.402 32.165c-3.353-3.038-5.84-7.021-6.898-11.503-.777-3.291-.424-5.119-.424-5.119C.734 8.179 5.936 2 13.159 2c5.363 0 9.673 3.343 11.691 8.126z"
Expand All @@ -9,4 +9,4 @@ const SvgComponent = props => (
</svg>
);

export default SvgComponent;
export default HeartIcon;
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import styled from '@emotion/styled';

export default styled.p`
const Paragraph = styled.p`
color: #404040;
margin: 2px 0px;
padding: 0px;
font-size: 14px;
text-align: center;
`;

export default Paragraph;
4 changes: 3 additions & 1 deletion docs/common-util/tag/index.jsx → docs/common/Tag.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import styled from '@emotion/styled';

export default styled.div`
const Tag = styled.div`
color: #fff;
text-align: center;
border-radius: 5px;
Expand All @@ -13,3 +13,5 @@ export default styled.div`
font-size: 14px;
}
`;

export default Tag;
8 changes: 5 additions & 3 deletions docs/common-util/vgroup.jsx → docs/common/VGroup.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import styled from '@emotion/styled';

export default styled.div`
flex: ${({ flex }) => (flex || 1)} !important;
const VGroup = styled.div`
flex: ${({ flex }) => flex || 1} !important;
& > * {
flex: 1;
margin: ${({ spacing }) => (spacing || '10px')} 0px;
margin: ${({ spacing }) => spacing || '10px'} 0px;
&:first-child {
margin-top: 0px;
Expand All @@ -16,3 +16,5 @@ export default styled.div`
}
}
`;

export default VGroup;
File renamed without changes.
24 changes: 24 additions & 0 deletions docs/components/Home/AllOptions.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React from 'react';
import styled from '@emotion/styled';

import CodePanel from '../../common/CodePanel';

const AllOptions = () => (
<CodePanel heading="All Options for Customization">
<Section>Table</Section>
</CodePanel>
);

const Section = styled.section`
display: flex;
justify-content: center;
flex-wrap: wrap;
margin-top: 20px;
& > * {
margin: 10px 15px;
width: 150px;
}
`;

export default AllOptions;
12 changes: 0 additions & 12 deletions docs/components/Home/AllOptions/index.jsx

This file was deleted.

Loading

0 comments on commit 625aac7

Please sign in to comment.