-
-
Notifications
You must be signed in to change notification settings - Fork 480
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
7d6039e
commit a632593
Showing
11 changed files
with
198 additions
and
6 deletions.
There are no files selected for viewing
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,20 @@ | ||
.container { | ||
font: var(--main-font); | ||
white-space: nowrap; | ||
} | ||
|
||
.select { | ||
border: 1px solid #aaa; | ||
border-radius: 4px; | ||
display: block; | ||
flex: 1; | ||
width: 100%; | ||
color: #7f7f7f; | ||
height: 27px; | ||
} | ||
|
||
.label { | ||
font-size: 11px; | ||
font-weight: bold; | ||
margin-bottom: 7px; | ||
} |
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,64 @@ | ||
import PureComponent from '../lib/PureComponent'; | ||
import DropdownOption from './DropdownOption'; | ||
|
||
import s from './Dropdown.css'; | ||
import {store} from '../store'; | ||
|
||
const DEFAULT_DROPDOWN_SELECTION = 'Select an entrypoint'; | ||
|
||
export default class Dropdown extends PureComponent { | ||
|
||
constructor(props) { | ||
super(props); | ||
this.state = { | ||
selectedOption: DEFAULT_DROPDOWN_SELECTION | ||
}; | ||
} | ||
|
||
render() { | ||
const {label, options} = this.props; | ||
|
||
return ( | ||
<div className={s.container}> | ||
<div className={s.label}> | ||
{label}: | ||
</div> | ||
<div> | ||
<select className={s.select} name={label} id={label} onChange={this.handleSelection}> | ||
<DropdownOption value={DEFAULT_DROPDOWN_SELECTION}/> | ||
{options.map(option => | ||
<DropdownOption value={option}/> | ||
)} | ||
</select> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
handleSelection = (event) => { | ||
const selected = event.target.value; | ||
|
||
if (selected === DEFAULT_DROPDOWN_SELECTION) { | ||
store.selectedChunks = store.allChunks; | ||
return; | ||
} | ||
|
||
this.setState({selectedOption: selected}, () => { | ||
store.selectedChunks = []; | ||
for (const chunk of store.allChunks) { | ||
if (store.entrypointsToChunksMap[this.state.selectedOption].has(chunk.label)) { | ||
store.selectedChunks.push(chunk); | ||
} | ||
} | ||
}); | ||
|
||
// this.setState({selectedOption: selected}, () => { | ||
// store.selectedChunks = []; | ||
// for (const chunk of store.allChunks) { | ||
// if (chunk.label in store.entrypointsToChunksMap[this.state.selectedOption]) { | ||
// store.selectedChunks.push(chunk); | ||
// } | ||
// } | ||
// }); | ||
} | ||
} |
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,11 @@ | ||
import {Component} from 'preact'; | ||
|
||
export default class DropdownOption extends Component { | ||
render() { | ||
const {value} = this.props; | ||
|
||
return ( | ||
<option value={value}>{value}</option> | ||
); | ||
} | ||
} |
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 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 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 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