Skip to content

Commit

Permalink
feat: added class and style props
Browse files Browse the repository at this point in the history
  • Loading branch information
wysher committed May 9, 2020
1 parent 153aaa4 commit cfefc80
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ To get it work component requires two slots:
| isOpen | Boolean | isOpen state | false |
| position | String | `top-left`<br />`top-center`<br />`top-right`<br />`bottom-left`<br />`bottom-center`<br />`bottom-right`<br />`left-top`<br />`left-center`<br />`left-bottom`<br />`right-top`<br />`right-center`<br />`right-bottom`<br /><br />Uses default position when wrong position was passed | `bottom-right` |
| zIndex | Number | value of z-index for overlay and portaled content | 1 |
| class | string | global class name | '' |
| style | string | style string which will be added at the end of component style attribute | '' |
| closeOnClickOutside | Boolean | if true click outside will close overlay | false |
| closeOnScroll | Boolean | if true scrolling outside content will close overlay | false |
| updateOnScroll | Boolean | if true scrolling will update content position | false |
Expand Down
1 change: 1 addition & 0 deletions src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
<Overlay
position={selectedPosition}
onWindowKeyDown={handleKeyDown}
closeOnClickOutside
on:toggle={handleToggle}
closeOnScroll
{isOpen}>
Expand Down
12 changes: 6 additions & 6 deletions src/components/Overlay.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
export let closeOnClickOutside = false;
export let zIndex = 1;
export let onWindowKeyDown = () => {};
export let style = '';
$: className = $$restProps['class'] || '';
let currentPosition = null;
let parent;
Expand Down Expand Up @@ -142,7 +145,7 @@
on:mousedown={handleWindowClick}
on:keydown={handleWindowKeyDown} />

<div class="overlay" style={`z-index:${zIndex};`}>
<div class={`overlay ${className}`} style={`z-index:${zIndex}; ${style}`}>
<div bind:this={parent}>
<slot name="parent" {toggle} isOpen={openedState} {open} {close} />
</div>
Expand All @@ -159,13 +162,10 @@
</div>

<style>
div {
display: inline-block;
box-sizing: border-box;
}
.overlay {
position: relative;
display: inline-block;
box-sizing: border-box;
}
.content-wrapper {
Expand Down

0 comments on commit cfefc80

Please sign in to comment.