Skip to content

Commit 0f6fed2

Browse files
rockwellllexcid3
andauthored
Alert docs (excid3#137)
* Update README.md * Use `v3`'s default values * Update README.md * remove getters. rely on Values API. Co-authored-by: Chris Oliver <excid3@gmail.com>
1 parent 5e138ab commit 0f6fed2

File tree

2 files changed

+10
-21
lines changed

2 files changed

+10
-21
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,12 @@ Alerts are set up to slide into view from the top-right side of the
106106
screen. Clicking on the "X" button will cause the alert to slide back
107107
out of view and be removed from the DOM.
108108

109+
- `data-alert-dismiss-after-value` can be provided to make the alert dimiss after x miliseconds. Default is `undefined`.
110+
- `data-alert-show-delay-value` can be set to tell the alert to show itself after x miliseconds. Defaults to `200` miliseconds.
111+
- `data-alert-remove-delay-value` can be set to tell the alert to hide itself after x milisconds. Defaults to `1100` miliseconds.
112+
- `data-alert-show-class` is a set of all classes to apply on the alert when it's shown.
113+
- `data-alert-hide-class` is a set of all classes to apply on the alert when it's hidden.
114+
109115
### Dropdowns
110116

111117
![Dropdowns](https://d3vv6lp55qjaqc.cloudfront.net/items/3X1m1v1w2g1M3P0F2p2C/Screen%20Shot%202018-12-07%20at%201.23.52%20PM.png?X-CloudApp-Visitor-Id=bcd17e7039e393c836f30de901088b96&v=4c0ae15f)

src/alert.js

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,8 @@ import { Controller } from '@hotwired/stimulus'
3131
export default class extends Controller {
3232
static values = {
3333
dismissAfter: Number,
34-
showDelay: Number,
35-
removeDelay: Number
36-
34+
showDelay: { type: Number, default: 200 },
35+
removeDelay: { type: Number, default: 1100 }
3736
}
3837
static classes = ["show", "hide"]
3938

@@ -44,7 +43,7 @@ export default class extends Controller {
4443
connect() {
4544
setTimeout(() => {
4645
this.show()
47-
}, this.showAfter)
46+
}, this.showDelayValue)
4847

4948
// Auto dimiss if defined
5049
if (this.hasDismissAfterValue) {
@@ -59,7 +58,7 @@ export default class extends Controller {
5958

6059
setTimeout(() => {
6160
this.element.remove()
62-
}, this.removeAfter)
61+
}, this.removeDelayValue)
6362
}
6463

6564
show() {
@@ -71,20 +70,4 @@ export default class extends Controller {
7170
this.element.classList.add(...this.hideClasses)
7271
this.element.classList.remove(...this.showClasses)
7372
}
74-
75-
get removeAfter() {
76-
if (this.hasRemoveDelayValue) {
77-
return this.removeDelayValue
78-
} else {
79-
return 1100
80-
}
81-
}
82-
83-
get showAfter() {
84-
if (this.hasShowDelayValue) {
85-
return this.showDelayValue
86-
} else {
87-
return 200
88-
}
89-
}
9073
}

0 commit comments

Comments
 (0)