Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
DartWelder committed Oct 2, 2019
1 parent 2216eb8 commit b863b93
Show file tree
Hide file tree
Showing 14 changed files with 1,235 additions and 765 deletions.
1,164 changes: 582 additions & 582 deletions config/webpack.config.js

Large diffs are not rendered by default.

412 changes: 278 additions & 134 deletions package-lock.json

Large diffs are not rendered by default.

118 changes: 112 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,73 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@babel/core": "7.6.0",
"@material-ui/core": "^4.5.0",
"@material-ui/icons": "^4.4.3",
"@svgr/webpack": "4.3.2",
"@types/jest": "^24.0.18",
"@types/node": "^12.7.8",
"@types/react": "^16.9.4",
"@types/react-dom": "^16.9.1",
"@typescript-eslint/eslint-plugin": "^2.2.0",
"@typescript-eslint/parser": "^2.2.0",
"babel-eslint": "10.0.3",
"babel-jest": "^24.9.0",
"babel-loader": "8.0.6",
"babel-plugin-named-asset-import": "^0.3.4",
"babel-preset-react-app": "^9.0.2",
"camelcase": "^5.2.0",
"case-sensitive-paths-webpack-plugin": "2.2.0",
"css-loader": "2.1.1",
"dotenv": "6.2.0",
"dotenv-expand": "5.1.0",
"eslint": "^6.1.0",
"eslint-config-react-app": "^5.0.2",
"eslint-loader": "3.0.0",
"eslint-plugin-flowtype": "3.13.0",
"eslint-plugin-import": "2.18.2",
"eslint-plugin-jsx-a11y": "6.2.3",
"eslint-plugin-react": "7.14.3",
"eslint-plugin-react-hooks": "^1.6.1",
"file-loader": "3.0.1",
"fs-extra": "7.0.1",
"html-webpack-plugin": "4.0.0-beta.5",
"identity-obj-proxy": "3.0.0",
"is-wsl": "^1.1.0",
"jest": "24.9.0",
"jest-environment-jsdom-fourteen": "0.1.0",
"jest-resolve": "24.9.0",
"jest-watch-typeahead": "0.4.0",
"mini-css-extract-plugin": "0.8.0",
"optimize-css-assets-webpack-plugin": "5.0.3",
"pnp-webpack-plugin": "1.5.0",
"postcss-flexbugs-fixes": "4.1.0",
"postcss-loader": "3.0.0",
"postcss-normalize": "7.0.1",
"postcss-preset-env": "6.7.0",
"postcss-safe-parser": "4.0.1",
"react": "^16.10.1",
"react-app-polyfill": "^1.0.3",
"react-dev-utils": "^9.0.4",
"react-dom": "^16.10.1",
"react-scripts": "3.1.2",
"typescript": "^3.6.3"
"resolve": "1.12.0",
"resolve-url-loader": "3.1.0",
"sass-loader": "7.2.0",
"semver": "6.3.0",
"style-loader": "1.0.0",
"terser-webpack-plugin": "1.4.1",
"ts-pnp": "1.1.4",
"typescript": "^3.6.3",
"url-loader": "2.1.0",
"webpack": "4.40.2",
"webpack-dev-server": "3.2.1",
"webpack-manifest-plugin": "2.0.4",
"workbox-webpack-plugin": "4.3.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
"start": "node scripts/start.js",
"build": "node scripts/build.js",
"test": "node scripts/test.js"
},
"eslintConfig": {
"extends": "react-app"
Expand All @@ -36,5 +89,58 @@
"devDependencies": {
"node-sass": "^4.12.0",
"sass-loader": "^8.0.0"
},
"jest": {
"roots": [
"<rootDir>/src"
],
"collectCoverageFrom": [
"src/**/*.{js,jsx,ts,tsx}",
"!src/**/*.d.ts"
],
"setupFiles": [
"react-app-polyfill/jsdom"
],
"setupFilesAfterEnv": [],
"testMatch": [
"<rootDir>/src/**/__tests__/**/*.{js,jsx,ts,tsx}",
"<rootDir>/src/**/*.{spec,test}.{js,jsx,ts,tsx}"
],
"testEnvironment": "jest-environment-jsdom-fourteen",
"transform": {
"^.+\\.(js|jsx|ts|tsx)$": "<rootDir>/node_modules/babel-jest",
"^.+\\.css$": "<rootDir>/config/jest/cssTransform.js",
"^(?!.*\\.(js|jsx|ts|tsx|css|json)$)": "<rootDir>/config/jest/fileTransform.js"
},
"transformIgnorePatterns": [
"[/\\\\]node_modules[/\\\\].+\\.(js|jsx|ts|tsx)$",
"^.+\\.module\\.(css|sass|scss)$"
],
"modulePaths": [],
"moduleNameMapper": {
"^react-native$": "react-native-web",
"^.+\\.module\\.(css|sass|scss)$": "identity-obj-proxy"
},
"moduleFileExtensions": [
"web.js",
"js",
"web.ts",
"ts",
"web.tsx",
"tsx",
"json",
"web.jsx",
"jsx",
"node"
],
"watchPlugins": [
"jest-watch-typeahead/filename",
"jest-watch-typeahead/testname"
]
},
"babel": {
"presets": [
"react-app"
]
}
}
18 changes: 9 additions & 9 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>

<head>
<meta charset="utf-8" />
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<meta name="description" content="Web site created using create-react-app" />
<link rel="apple-touch-icon" href="logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
Expand All @@ -25,8 +23,9 @@
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
</head>
<body>
</head>

<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
Expand All @@ -39,5 +38,6 @@
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
</body>

</html>
22 changes: 0 additions & 22 deletions src/App.css

This file was deleted.

25 changes: 25 additions & 0 deletions src/App.sass
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.App
display: flex
align-items: center

.list
margin: 20px 20px
height: 500px
width: 300px
overflow: auto
background-color: #222
float: left
color: #ddd
list-style-type: none
svg
color: #777

.list::-webkit-scrollbar
width: 0

.item
margin: 5px

.left
margin-right: auto

10 changes: 8 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import React from 'react';
import './App.css';
import './App.sass';
import List from './components/List';

function App() {
return (
<div className="App">

<div className="left">
<List></List>
</div>
<div className="right">
<List></List>
</div>
</div>
);
}
Expand Down
30 changes: 30 additions & 0 deletions src/Items.class.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { IListItem, ItemFlagsEnum } from "./constants";

export class Items {
list: IListItem[];
constructor() {
this.list = this.createList(100);
}

createList = (num: Number): IListItem[] => {
let list = new Array<IListItem>();

for (let i = 1; i <= num; i++) {
list.push({
name: `Item${i}`,
flags: this.generateFlags()
});
}
return list;
}

generateFlags = (): ItemFlagsEnum[] => {
let flags = new Array<ItemFlagsEnum>();
Object.keys(ItemFlagsEnum).forEach((flag) => {
if (Math.random() <= 0.5) {
flags.push(flag as ItemFlagsEnum)
}
});
return flags;
}
}
44 changes: 44 additions & 0 deletions src/components/FlagIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import React, { Component } from 'react';
import {
Brightness5,
FlashOn,
LocalFlorist,
Favorite
} from '@material-ui/icons';
import { ItemFlagsEnum } from '../constants';

export default class FlagIcon extends Component<IFlagIconProps, IFlagIconState> {
constructor(props: IFlagIconProps) {
super(props);
this.state = {
icon: props.icon
};
}
render() {
let icon;
switch (this.state.icon) {
case 'flower':
icon = <LocalFlorist/>;
break;
case 'heart':
icon = <Favorite/>;
break;
case 'sun':
icon = <Brightness5/>;
break;
case 'flash':
icon = <FlashOn/>;
break;
}
return icon;
}
}

export interface IFlagIconState {
icon: string
}

export interface IFlagIconProps {
icon: ItemFlagsEnum
}

30 changes: 30 additions & 0 deletions src/components/List.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React, { Component } from 'react'
import ListItem from './ListItem';
import { Items } from '../Items.class';
import { IListItem } from '../constants';

export class List extends Component {
constructor(props: IListProps) {
super(props);
this.state = {

};
}

render() {
const items = new Items();
return (
<div className="list">
{
items.list.map((item: IListItem) => <ListItem item={item}/>)
}
</div>
)
}
}

export default List

export interface IListProps {
items: string[]
}
35 changes: 35 additions & 0 deletions src/components/ListItem.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import React, { Component } from 'react'
import { IListItem } from '../constants';
import FlagIcon from './FlagIcon';

export class ListItem extends Component<IListItemProps, IListItemState> {
constructor(props: IListItemProps) {
super(props);

this.state = {
item: props.item
};
}

render() {
return (
<div className="item">
{this.state.item.name}
{this.state.item.flags.map((flag) => (
<FlagIcon icon={flag} />
))}
</div>
)
}
}

export default ListItem

export interface IListItemState {
item: IListItem
}

export interface IListItemProps {
item: IListItem
}

Loading

0 comments on commit b863b93

Please sign in to comment.