Skip to content

Commit

Permalink
fix(material): show editor full width when there are no options
Browse files Browse the repository at this point in the history
  • Loading branch information
tpluscode committed Oct 25, 2020
1 parent 942f153 commit 7253387
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/seven-jobs-shop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hydrofoil/shaperone-wc-material": patch
---

Full width editors when there are not side controls
20 changes: 19 additions & 1 deletion packages/wc-material/elements/mwc-item-lite.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LitElement, html, css, customElement } from 'lit-element'
import { LitElement, html, css, customElement, PropertyValues, query, property } from 'lit-element'

@customElement('mwc-item-lite')
export class MwcItemLite extends LitElement {
Expand All @@ -13,6 +13,10 @@ export class MwcItemLite extends LitElement {
color: var(--mdc-theme-text-primary-on-background, rgba(0, 0, 0, 0.87));
}
:host([no-options]) #options {
display: none;
}
#main {
display: flex;
flex: 1;
Expand All @@ -34,9 +38,23 @@ slot[name=options]::slotted(mwc-icon) {
}`
}

@property({ type: Boolean, reflect: true, attribute: 'no-options' })
noOptions = true

@query('slot[name=options]')
optionsSlot: HTMLSlotElement | undefined

render() {
return html`
<div id="main"><slot></slot></div>
<div id="options"><slot name="options"></slot></div>`
}

protected firstUpdated(_changedProperties: PropertyValues) {
super.firstUpdated(_changedProperties)

this.optionsSlot?.addEventListener('slotchange', (e: any) => {
this.noOptions = !e.target.assignedElements().length
})
}
}

0 comments on commit 7253387

Please sign in to comment.