-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2216eb8
commit b863b93
Showing
14 changed files
with
1,235 additions
and
765 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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,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 | ||
|
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,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; | ||
} | ||
} |
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,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 | ||
} | ||
|
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,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[] | ||
} |
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,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 | ||
} | ||
|
Oops, something went wrong.