Skip to content

Commit

Permalink
feat(dropdown): export part for styles
Browse files Browse the repository at this point in the history
Export button,anchor, dropdown & dropdown-content parts to allow
complex styling from outside of shadow DOM.
  • Loading branch information
megheaiulian committed Mar 18, 2022
1 parent f834442 commit 02362c0
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/cosmoz-dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ const preventDefault = e => e.preventDefault(),
</button>
</div>
${ active && html`
<cosmoz-dropdown-content id="dropdown" part="dropdown" .anchor=${ anchor } .placement=${ placement } .render=${ render }>
<cosmoz-dropdown-content
id="dropdown" part="dropdown" exportparts="content: dropdown-content"
.anchor=${ anchor } .placement=${ placement } .render=${ render }
>
<slot></slot>
</cosmoz-dropdown-content>` || [] }
`;
Expand All @@ -86,6 +89,7 @@ const preventDefault = e => e.preventDefault(),
margin: 0;
width: 100%;
}
::slotted(:not(slot):hover) {
background: var(--cosmoz-dropdown-menu-hover-color, var(--cosmoz-selection-color, rgba(58, 145, 226, 0.1)));
}
Expand All @@ -98,7 +102,9 @@ const preventDefault = e => e.preventDefault(),
<slot></slot>
`,
Menu = host => html`
<cosmoz-dropdown .placement=${ host.placement }>
<cosmoz-dropdown .placement=${ host.placement }
part="dropdown"
exportparts=${ ['anchor', 'button', 'dropdown'].map(p => `${ p }: dropdown-${ p }`).concat(['dropdown-content']).join(', ') }>
<slot name="button" slot="button"></slot>
<cosmoz-dropdown-list><slot></slot></cosmoz-dropdown-list>
</cosmoz-dropdown>`;
Expand Down

0 comments on commit 02362c0

Please # to comment.