Skip to content

Commit 1ef16f1

Browse files
author
Cathy Siller
committed
fix(hx-alert): exchange static attr with persist
1 parent a8bc8c5 commit 1ef16f1

File tree

7 files changed

+27
-23
lines changed

7 files changed

+27
-23
lines changed

docs/components/alerts/alert-demo.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@ if (document.getElementById('vue-alertDemo')) {
1414
data: {
1515
content: 'Nope! Nope! Nope! Nope! Nope!',
1616
cta: 'burn it',
17-
isStatic: false,
17+
isPersistent: false,
1818
status: 'spider',
1919
type: TYPES[0],
2020
types: TYPES,
2121
},
2222
methods: {
23-
onSubmit: function () {
24-
alert('The spider didn\'t see that coming!');
23+
onEvent: function (evt) {
24+
evt.preventDefault();
25+
alert(`Event: "${evt.type}"`);
2526
},
2627
},
2728
computed: {
@@ -51,7 +52,7 @@ if (document.getElementById('vue-alertDemo')) {
5152
<hx-alert
5253
${this.attrCta}
5354
${this.attrStatus}
54-
${this.isStatic ? 'static' : ''}
55+
${this.isPersistent ? 'persist' : ''}
5556
${this.attrType}
5657
>
5758
${this.content}

docs/components/alerts/index.html

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ <h2 id="basic-alert">Basic Alert</h2>
4040
<fieldset>
4141
<legend>Options</legend>
4242
<label>
43-
<input type="checkbox" v-model="isStatic">
44-
Static
43+
<input type="checkbox" v-model="isPersistent">
44+
Persist
4545
</label>
4646
</fieldset>
4747
</form>
@@ -50,10 +50,11 @@ <h2 id="basic-alert">Basic Alert</h2>
5050
<div>
5151
<hx-alert
5252
:cta="cta"
53-
:static="isStatic"
53+
:persist="isPersistent"
5454
:status="status"
5555
:type="type.value"
56-
@submit="onSubmit"
56+
@dismiss="onEvent"
57+
@submit="onEvent"
5758
>
5859
{% raw %}{{content}}{% endraw %}
5960
</hx-alert>

docs/components/toasts/index.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ <h2 id="basic-toast">Basic Toast</h2>
4141
<hx-toast
4242
:type="type.value"
4343
:cta="cta"
44-
@submit="onSubmit">
44+
@dismiss="onEvent"
45+
@submit="onEvent"
46+
>
4547
{% raw %}{{content}}{% endraw %}
4648
</hx-toast>
4749
</div>

docs/components/toasts/toast-demo.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ if (document.getElementById('vue-toastDemo')) {
1717
types: TYPES,
1818
},
1919
methods: {
20-
onSubmit: function () {
21-
alert('Unicorn pigeon puppy pop rainbows delight social pop!');
20+
onEvent: function (evt) {
21+
evt.preventDefault();
22+
alert(`Event: "${evt.type}"`);
2223
},
2324
},
2425
computed: {

docs/elements/hx-alert/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ <h2 id="methods">Methods</h2>
5757
If absent or blank, the CTA button will not be displayed.
5858
</dd>
5959

60-
<dt>static {Boolean} <i>(optional)</i></dt>
60+
<dt>persist {Boolean}</dt>
6161
<dd>
6262
When present, alert will not be dismissable.
6363
</dd>
@@ -88,7 +88,7 @@ <h2 id="methods">Methods</h2>
8888
Manipulates the <code>cta</code> attribute.
8989
</dd>
9090

91-
<dt>static {Boolean}</dt>
91+
<dt>persist {Boolean}</dt>
9292
<dd>
9393
When <code>true</code>, alert will not be dismissable.
9494
</dd>

src/helix-ui/elements/HXAlertElement.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export class HXAlertElement extends HXElement {
5050

5151
$onConnect () {
5252
this.$upgradeProperty('cta');
53-
this.$upgradeProperty('static');
53+
this.$upgradeProperty('persist');
5454
this.$upgradeProperty('status');
5555
this.$upgradeProperty('type');
5656

@@ -66,7 +66,6 @@ export class HXAlertElement extends HXElement {
6666
static get $observedAttributes () {
6767
return [
6868
'cta',
69-
'static',
7069
'status',
7170
'type',
7271
];
@@ -112,20 +111,20 @@ export class HXAlertElement extends HXElement {
112111
}
113112

114113
/**
115-
* Property reflecting the `static` HTML attribute, indicating whether the
114+
* Property reflecting the `persist` HTML attribute, indicating whether the
116115
* alert may be dismissed. If true, the dismiss button will not be shown.
117116
*
118117
* @default false
119118
* @type {Boolean}
120119
*/
121-
get static () {
122-
return this.hasAttribute('static');
120+
get persist () {
121+
return this.hasAttribute('persist');
123122
}
124-
set static (value) {
123+
set persist (value) {
125124
if (value) {
126-
this.setAttribute('static', ''); // boolean
125+
this.setAttribute('persist', '');
127126
} else {
128-
this.removeAttribute('static');
127+
this.removeAttribute('persist');
129128
}
130129
}
131130

@@ -169,7 +168,7 @@ export class HXAlertElement extends HXElement {
169168
* Dismiss the alert (removes element from the DOM).
170169
*/
171170
dismiss () {
172-
if (this.$emit('dismiss')) {
171+
if (!this.persist && this.$emit('dismiss')) {
173172
// only if event was not canceled by consumer
174173
this.remove();
175174
}

src/helix-ui/elements/HXAlertElement.less

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
}
5757
}
5858

59-
:host([static]) {
59+
:host([persist]) {
6060
#hxAlert {
6161
#hxDismiss {
6262
display: none;

0 commit comments

Comments
 (0)