Skip to content

Commit

Permalink
refactor(api): change show-popover to open to be consistent with othe…
Browse files Browse the repository at this point in the history
…r components

BREAKING CHANGE:

To migrate the code follow the example below:

Before:
show-popover=true

Now:
open=true
  • Loading branch information
jyounce committed Apr 25, 2019
1 parent 9fa3c4a commit e2be615
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
20 changes: 10 additions & 10 deletions src/client/scripts/rb-popover.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
this.rb.events.add(window, 'click touchstart', this._windowClickToggle, {
capture: true // so event fires first
});
if (this.showPopover) this.triggerUpdate();
if (this.open) this.triggerUpdate();
}

/* Properties
Expand All @@ -64,12 +64,12 @@
kind: Object.assign({}, props.string, {
default: 'default'
}),
open: Object.assign({}, props.boolean, {
deserialize: Converter.boolean
}),
position: Object.assign({}, props.string, {
default: 'right'
}),
showPopover: Object.assign({}, props.boolean, {
deserialize: Converter.boolean
}),
iconBurst: Object.assign({}, props.boolean, {
deserialize: Converter.valueless
}),
Expand Down Expand Up @@ -156,7 +156,7 @@
}
rendered() { // :void
super.rendered && super.rendered();
if (!this.showPopover) return;
if (!this.open) return;
if (!this.rb.view.isReady) return;
this._setPosition();
}
Expand Down Expand Up @@ -193,20 +193,20 @@
/* Event Handlers
*****************/
_clickToggle(evt) { // :void
this.showPopover = !this.showPopover;
this.open = !this.open;
}
_hoverToggle(evt) { // :void
if (!this.hover) return;
if (this.showPopover) return;
this.showPopover = true;
if (this.open) return;
this.open = true;
}
_windowClickToggle(evt) { // :void
if (this.pin) return;
if (!this.showPopover) return;
if (!this.open) return;
const path = evt.composedPath();
if (path.includes(this.rb.elms.popover)) return;
if (path.includes(this.rb.elms.trigger)) return;
this.showPopover = false;
this.open = false;
}

/* Template
Expand Down
2 changes: 1 addition & 1 deletion src/client/views/rb-popover.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<div
style="${View.styleMap(state.coords.popover)}"
class="popover ${View.classMap({
hidden: !props.showPopover || !this.rb.view.isReady
hidden: !props.open || !this.rb.view.isReady
})}">
<em class="pointer" style="${View.styleMap(state.coords.pointer)}"></em>
${props.caption ? html`<h3 class="caption">${props.caption}</h3>` : null}
Expand Down

0 comments on commit e2be615

Please sign in to comment.