Skip to content

Commit 6a4b4f4

Browse files
committed
🐛 fix for duration label & 🔔 add notification off effect
1 parent 9091b8b commit 6a4b4f4

File tree

2 files changed

+26
-19
lines changed

2 files changed

+26
-19
lines changed

src/NotificationCalc.js

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -113,21 +113,6 @@ class NotificationCalc extends React.Component {
113113
);
114114
};
115115

116-
durationFormater = val => {
117-
switch (val) {
118-
case 255:
119-
return "Forever";
120-
case 1:
121-
return "1 second";
122-
default:
123-
if (val > 59) {
124-
return `${Math.floor(val / 60)}${val % 60} seconds`;
125-
} else {
126-
return `${val} seconds`;
127-
}
128-
}
129-
};
130-
131116
setValue = key => (e, v) => {
132117
this.props.onChange(
133118
key,
@@ -184,7 +169,12 @@ class NotificationCalc extends React.Component {
184169
</Tooltip>
185170
</div>
186171
<Typography gutterBottom>Color</Typography>
187-
<div className={this.props.classes.colorHelper} />
172+
<div
173+
className={this.props.classes.colorHelper}
174+
style={{
175+
filter: this.props.effect === "0" ? "grayscale(75%)" : undefined
176+
}}
177+
/>
188178
<Slider
189179
defaultValue={1}
190180
aria-labelledby="discrete-slider"
@@ -194,6 +184,7 @@ class NotificationCalc extends React.Component {
194184
max={255}
195185
value={this.props.color}
196186
onChange={this.setValue("color")}
187+
disabled={this.props.effect === "0"}
197188
/>
198189

199190
<Typography gutterBottom>Brightness Level</Typography>
@@ -208,6 +199,7 @@ class NotificationCalc extends React.Component {
208199
min={0}
209200
max={10}
210201
onChange={this.setValue("level")}
202+
disabled={this.props.effect === "0"}
211203
/>
212204
</Grid>
213205
<Grid item>
@@ -229,6 +221,7 @@ class NotificationCalc extends React.Component {
229221
max={255}
230222
onChange={this.setValue("duration")}
231223
ValueLabelComponent={ValueLabelTooltip}
224+
disabled={this.props.effect === "0"}
232225
/>
233226
</Grid>
234227
<Grid item>
@@ -238,7 +231,7 @@ class NotificationCalc extends React.Component {
238231
<FormControl fullWidth={true} margin="normal">
239232
<InputLabel>Effect</InputLabel>
240233
<Select value={this.props.effect} onChange={this.setValue("effect")}>
241-
{/* <MenuItem value="0">Off</MenuItem> */}
234+
<MenuItem value="0">Off (Notification Cleared)</MenuItem>
242235
<MenuItem
243236
value={
244237
this.props.type === "dimmer"

src/ValueLabelTooltip.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,22 @@ const durationFormater = val => {
99
case 1:
1010
return "1 second";
1111
default:
12-
if (val > 59) {
13-
return `${Math.floor(val / 60)} minutes ${val % 60} seconds`;
12+
if (val >= 60 && val < 120) {
13+
let minutes = val === 60 ? 1 : val - 60;
14+
return `${minutes} minute${minutes <= 1 ? "" : "s"}`;
15+
} else if (val >= 120) {
16+
let hours = val === 120 ? 1 : val - 120;
17+
let days = Math.floor(hours / 24);
18+
if (days > 0) {
19+
hours = hours % 24;
20+
}
21+
if (days === 0) {
22+
return `${hours} hour${hours === 1 ? "" : "s"}`;
23+
} else {
24+
return `${days} day${days === 1 ? "" : "s"} ${hours} hour${
25+
hours === 1 ? "" : "s"
26+
}`;
27+
}
1428
} else {
1529
return `${val} seconds`;
1630
}

0 commit comments

Comments
 (0)