Skip to content

Commit

Permalink
fix: fix close prop
Browse files Browse the repository at this point in the history
  • Loading branch information
g-francesca committed Aug 5, 2024
1 parent b1af788 commit 729fd83
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 24 deletions.
2 changes: 1 addition & 1 deletion packages/ui-stencil-vue/lib/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export const OramaSearchResults = /*@__PURE__*/ defineContainer<JSX.OramaSearchR

export const OramaSlidingPanel = /*@__PURE__*/ defineContainer<JSX.OramaSlidingPanel>('orama-sliding-panel', undefined, [
'open',
'onClosed'
'closed'
]);


Expand Down
4 changes: 2 additions & 2 deletions packages/ui-stencil/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export namespace Components {
"sections": SearchResultBySection[];
}
interface OramaSlidingPanel {
"onClosed": () => void;
"closed": () => void;
"open": boolean;
}
interface OramaText {
Expand Down Expand Up @@ -447,7 +447,7 @@ declare namespace LocalJSX {
"sections"?: SearchResultBySection[];
}
interface OramaSlidingPanel {
"onClosed"?: () => void;
"closed"?: () => void;
"open"?: boolean;
}
interface OramaText {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, Prop, State, h, Element, Watch } from '@stencil/core'
import { Component, Prop, State, h, Element, Watch, Event } from '@stencil/core'
import '@phosphor-icons/webcomponents/dist/icons/PhX.mjs'

@Component({
Expand All @@ -9,20 +9,17 @@ import '@phosphor-icons/webcomponents/dist/icons/PhX.mjs'
export class SlideInPanel {
@Element() el: HTMLElement
@Prop() open = false
@Prop() onClosed: () => void
@Prop() closed: () => void
@State() isOpen: boolean = this.open

panelRef: HTMLElement
buttonRef: HTMLElement

@Watch('open')
openChanged() {
this.isOpen = this.open
}

closePanel() {
if (this.onClosed) {
this.onClosed()
if (this.closed) {
this.closed()
}
this.isOpen = false
}
Expand All @@ -32,7 +29,6 @@ export class SlideInPanel {
<div class={{ 'slide-container': true, 'slide-up': this.isOpen }}>
<div class="slide-container-header">
<button
ref={(el) => (this.buttonRef = el as HTMLElement)}
onClick={() => this.closePanel()}
aria-expanded={this.isOpen ? 'true' : 'false'}
aria-label="Close panel"
Expand All @@ -43,14 +39,7 @@ export class SlideInPanel {
<ph-x size="18" />
</button>
</div>
<div
id="panel"
role="region"
aria-hidden={!this.isOpen}
tabindex="-1"
ref={(el) => (this.panelRef = el as HTMLElement)}
class="slide-container-inner"
>
<div id="panel" role="region" aria-hidden={!this.isOpen} tabindex="-1" class="slide-container-inner">
<slot />
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

## Properties

| Property | Attribute | Description | Type | Default |
| ---------- | --------- | ----------- | ------------ | ----------- |
| `onClosed` | -- | | `() => void` | `undefined` |
| `open` | `open` | | `boolean` | `false` |
| Property | Attribute | Description | Type | Default |
| -------- | --------- | ----------- | ------------ | ----------- |
| `closed` | -- | | `() => void` | `undefined` |
| `open` | `open` | | `boolean` | `false` |


## Dependencies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ export class SearchBox {
{this.windowWidth > 1024 && (
<orama-sliding-panel
open={globalContext.currentTask === 'chat'}
onClose={() => {
closed={() => {
globalContext.currentTask = 'search'
}}
>
Expand Down

0 comments on commit 729fd83

Please sign in to comment.