Skip to content

Commit 2771a46

Browse files
committed
Ability to remove samples
1 parent 18c62c8 commit 2771a46

File tree

5 files changed

+81
-25
lines changed

5 files changed

+81
-25
lines changed

src/component/Pad/LayerA.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { connect } from 'react-redux'
44

55
/* App imports */
66
import { MidiMap } from 'util/const'
7-
import { updatePadIntProperty, updatePadSensitivity } from 'redux/actions'
7+
import { updatePadIntProperty, updatePadProperty, updatePadSensitivity } from 'redux/actions'
88

99
/* Component imports */
1010
import SamplePlayerComponent from 'component/SamplePlayer'
@@ -21,7 +21,7 @@ const PadLayerAComponent = (props) => {
2121
let padName = MidiMap[pad.padType][0]
2222

2323
return (
24-
<div className="">
24+
<div className="PadLayer">
2525
<div className="level">
2626
<div className="level-left">
2727
<div className="level-item">
@@ -40,7 +40,9 @@ const PadLayerAComponent = (props) => {
4040
<SamplePlayerComponent sampleFile={props.padSampleFile}>
4141
<SampleComponent
4242
draggable={false}
43+
removable={true}
4344
fileName={pad.fileName}
45+
removeSample={() => {props.removePadSample(null)}}
4446
/>
4547
</SamplePlayerComponent>
4648
</div>
@@ -155,8 +157,8 @@ const mapDispatchToProps = (dispatch, ownProps) => {
155157
updatePadIntProperty: (property, value) => {
156158
dispatch(updatePadIntProperty(ownProps.padId, property, value));
157159
},
158-
updatePadStringProperty: (property, value) => {
159-
dispatch(updatePadIntProperty(ownProps.padId, property, value));
160+
removePadSample: (value) => {
161+
dispatch(updatePadProperty(ownProps.padId, 'fileName', null));
160162
},
161163
updatePadSensitivity: (value) => {
162164
dispatch(updatePadSensitivity(ownProps.padId, value));

src/component/Pad/LayerB.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import React from 'react';
33
import { connect } from 'react-redux'
44

55
/* App imports */
6-
import { updatePadIntProperty } from 'redux/actions'
6+
import { updatePadIntProperty, updatePadProperty } from 'redux/actions'
77

88
/* Component imports */
99
import SamplePlayerComponent from 'component/SamplePlayer'
@@ -14,7 +14,7 @@ const PadLayerBComponent = (props) => {
1414
let pad = props.pad;
1515

1616
return (
17-
<div className="level layerB">
17+
<div className="level PadLayer layerB">
1818
<div className="level-left">
1919
<div className="level-item">
2020
<span className="is-size-7 padName has-background-white-ter">
@@ -26,7 +26,9 @@ const PadLayerBComponent = (props) => {
2626
<SamplePlayerComponent sampleFile={props.sampleFile}>
2727
<SampleComponent
2828
draggable={false}
29+
removable={true}
2930
fileName={pad.fileNameB}
31+
removeSample={() => {props.removePadSample(null)}}
3032
/>
3133
</SamplePlayerComponent>
3234
</div>
@@ -58,7 +60,10 @@ const mapDispatchToProps = (dispatch, ownProps) => {
5860
return {
5961
updatePadIntProperty: (property, value) => {
6062
dispatch(updatePadIntProperty(ownProps.padId, property, value));
61-
}
63+
},
64+
removePadSample: (value) => {
65+
dispatch(updatePadProperty(ownProps.padId, 'fileNameB', null));
66+
},
6267
}
6368
}
6469

src/component/Sample.js

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,31 @@ const SampleComponent = (props) => {
2727
}
2828

2929
return (
30-
<div ref={drag}>
31-
<a href="#" className="panel-block sample" onClick={(e) => {if(hasSample) {props.playSample()}}}>
32-
<span className="panel-icon">
33-
<i className={"glyphicon " + ((props.playingSample) ? "glyphicon-stop" : "glyphicon-play")} aria-hidden="true" />
34-
</span>
35-
<span className={((props.playingSample) ? "has-text-primary" : "")}>
36-
{ hasSample &&
37-
<div dangerouslySetInnerHTML={{ __html: displayName }} />
38-
}
39-
{ !hasSample &&
40-
<span>&lt;Empty&gt;</span>
41-
}
42-
</span>
43-
</a>
30+
<div className="sampleContainer">
31+
32+
<div ref={drag} className="dragContainer">
33+
<a href="#" className="panel-block sample" onClick={(e) => {if(hasSample) {props.playSample()}}}>
34+
<span className="panel-icon">
35+
<i className={"glyphicon " + ((props.playingSample) ? "glyphicon-stop" : "glyphicon-play")} aria-hidden="true" />
36+
</span>
37+
<span className={((props.playingSample) ? "has-text-primary" : "")}>
38+
{ hasSample &&
39+
<div dangerouslySetInnerHTML={{ __html: displayName }} />
40+
}
41+
{ !hasSample &&
42+
<span>&lt;Empty&gt;</span>
43+
}
44+
</span>
45+
</a>
46+
</div>
47+
48+
<div className="removeSample">
49+
{ hasSample && props.removable &&
50+
<a href="#" onClick={props.removeSample}>
51+
<i className="glyphicon glyphicon-trash" aria-hidden="true" />
52+
</a>
53+
}
54+
</div>
4455
</div>
4556
);
4657
}

src/css/Pad.css

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,22 @@
1-
.Pad .panel-block.sample {
1+
.Pad .sampleContainer .dragContainer {
2+
display: inline-block; }
3+
4+
.Pad .sampleContainer .panel-block.sample {
25
border-radius: 6px;
36
padding: .2em .5em; }
47

8+
.Pad .sampleContainer .removeSample {
9+
display: none;
10+
margin-left: .2em; }
11+
12+
.Pad .PadLayer .level-left {
13+
padding-right: 2em; }
14+
15+
.Pad .PadLayer .level-left:hover {
16+
padding-right: .8em; }
17+
.Pad .PadLayer .level-left:hover .removeSample {
18+
display: inline-block; }
19+
520
.Pad .level {
621
margin-bottom: 0 !important; }
722

src/css/Pad.scss

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,31 @@
11
.Pad {
2-
.panel-block.sample {
3-
border-radius: 6px;
4-
padding: .2em .5em;
2+
3+
.sampleContainer {
4+
.dragContainer {
5+
display: inline-block;
6+
}
7+
8+
.panel-block.sample {
9+
border-radius: 6px;
10+
padding: .2em .5em;
11+
}
12+
13+
.removeSample {
14+
display: none;
15+
margin-left: .2em;
16+
}
517
}
18+
19+
.PadLayer .level-left{
20+
padding-right: 2em;
21+
}
22+
.PadLayer .level-left:hover {
23+
padding-right: .8em;
24+
.removeSample {
25+
display: inline-block;
26+
}
27+
}
28+
629
.level {
730
margin-bottom:0 !important;
831
}

0 commit comments

Comments
 (0)