-
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.
Showing
15 changed files
with
333 additions
and
135 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { CssBaseline, ThemeProvider } from "@material-ui/core"; | ||
import React from "react"; | ||
import { Provider } from "react-redux"; | ||
|
||
import { addedSection, SectionType } from "../../states/analysisSlice"; | ||
import store from "../../states/store"; | ||
import theme from "../../styles/theme"; | ||
import StructureView from "./structureView"; | ||
|
||
export default { | ||
title: "Views|StructureView", | ||
component: StructureView | ||
}; | ||
|
||
export const Default = () => { | ||
store.dispatch( | ||
addedSection({ | ||
type: SectionType.INTRO, | ||
startTime: 0, | ||
endTime: 1, | ||
id: "intro" | ||
}) | ||
); | ||
store.dispatch( | ||
addedSection({ | ||
type: SectionType.VERSE, | ||
startTime: 1, | ||
endTime: 2, | ||
id: "verse" | ||
}) | ||
); | ||
store.dispatch( | ||
addedSection({ | ||
type: SectionType.CHORUS, | ||
startTime: 2, | ||
endTime: 3, | ||
id: "chorus" | ||
}) | ||
); | ||
|
||
return ( | ||
<Provider store={store}> | ||
<ThemeProvider theme={theme}> | ||
<CssBaseline /> | ||
|
||
<StructureView></StructureView> | ||
</ThemeProvider> | ||
</Provider> | ||
); | ||
}; |
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,8 @@ | ||
import React from "react"; | ||
|
||
import TestEnvironment from "../../tests/TestEnvironment"; | ||
import StructureView from "./structureView"; | ||
|
||
it("renders without crashing", () => { | ||
TestEnvironment.smokeTest(<StructureView />); | ||
}); |
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,112 @@ | ||
import { | ||
IconButton, | ||
Table, | ||
TableBody, | ||
TableCell, | ||
TableHead, | ||
TableRow | ||
} from "@material-ui/core"; | ||
import AddIcon from "@material-ui/icons/Add"; | ||
import RemoveIcon from "@material-ui/icons/Remove"; | ||
import React, { Component } from "react"; | ||
import { connect } from "react-redux"; | ||
|
||
import { | ||
addedSection, | ||
removedSection, | ||
Section, | ||
SectionType, | ||
updatedSection | ||
} from "../../states/analysisSlice"; | ||
import { ApplicationState } from "../../states/store"; | ||
|
||
interface PropsFromState { | ||
readonly sections: Section[]; | ||
} | ||
|
||
interface PropsFromDispatch { | ||
addedSection: typeof addedSection; | ||
updatedSection: typeof updatedSection; | ||
removedSection: typeof removedSection; | ||
} | ||
|
||
type AllProps = PropsFromState & PropsFromDispatch; | ||
|
||
class StructureView extends Component<AllProps> { | ||
handleAddSection = (section: Section) => { | ||
this.props.addedSection(section); | ||
}; | ||
|
||
handleRemoveSection = (id: string) => { | ||
this.props.removedSection(id); | ||
}; | ||
|
||
render() { | ||
return ( | ||
<Table size="small"> | ||
<TableHead> | ||
<TableRow> | ||
<TableCell style={{ width: "10%" }}></TableCell> | ||
<TableCell style={{ width: "30%" }}>Section</TableCell> | ||
<TableCell style={{ width: "30%" }}>First Measure</TableCell> | ||
<TableCell style={{ width: "30%" }}>Last Measure</TableCell> | ||
</TableRow> | ||
</TableHead> | ||
<TableBody> | ||
{this.props.sections.map(section => ( | ||
<TableRow key={section.id}> | ||
<TableCell component="th" scope="row"> | ||
<IconButton | ||
onClick={() => this.handleRemoveSection(section.id!)} | ||
> | ||
<RemoveIcon></RemoveIcon> | ||
</IconButton> | ||
</TableCell> | ||
<TableCell>{section.type}</TableCell> | ||
<TableCell>{section.startTime}</TableCell> | ||
<TableCell>{section.endTime}</TableCell> | ||
</TableRow> | ||
))} | ||
<TableRow key="last"> | ||
<TableCell component="th" scope="row"> | ||
<IconButton | ||
onClick={() => { | ||
this.handleAddSection({ | ||
endTime: Math.random(), | ||
startTime: 34, | ||
type: SectionType.OUTRO, | ||
id: | ||
Math.random() | ||
.toString(36) | ||
.substring(2, 15) + | ||
Math.random() | ||
.toString(36) | ||
.substring(2, 15) | ||
}); | ||
}} | ||
> | ||
<AddIcon></AddIcon> | ||
</IconButton> | ||
</TableCell> | ||
<TableCell /> | ||
<TableCell /> | ||
<TableCell /> | ||
</TableRow> | ||
</TableBody> | ||
</Table> | ||
); | ||
} | ||
} | ||
|
||
const mapStateToProps = ({ analysis }: ApplicationState) => { | ||
return { | ||
sections: analysis.sections | ||
}; | ||
}; | ||
|
||
const mapDispatchToProps = { | ||
addedSection, | ||
updatedSection, | ||
removedSection | ||
}; | ||
export default connect(mapStateToProps, mapDispatchToProps)(StructureView); |
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