-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2fd5f4b
commit fbcb9fa
Showing
7 changed files
with
64 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from './base-elements/action-base-element.js'; | ||
export * from './base-elements/button-base-element.js'; | ||
export * from './base-elements/link-base-element.js'; | ||
export * from './base-elements/overlay-base-element.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { LitElement } from 'lit'; | ||
|
||
import { EventEmitter } from '../eventing/event-emitter.js'; | ||
import type { SbbOpenedClosedState } from '../interfaces.js'; | ||
|
||
/** Base class for overlay components. */ | ||
export abstract class SbbOverlayBaseElement extends LitElement { | ||
public static readonly events = { | ||
willOpen: 'willOpen', | ||
didOpen: 'didOpen', | ||
willClose: 'willClose', | ||
didClose: 'didClose', | ||
} as const; | ||
|
||
/** The state of the component. */ | ||
protected set state(state: SbbOpenedClosedState) { | ||
this.setAttribute('data-state', state); | ||
} | ||
protected get state(): SbbOpenedClosedState { | ||
return this.getAttribute('data-state') as SbbOpenedClosedState; | ||
} | ||
|
||
/** Emits whenever the component starts the opening transition. */ | ||
protected willOpen: EventEmitter = new EventEmitter(this, SbbOverlayBaseElement.events.willOpen); | ||
|
||
/** Emits whenever the component is opened. */ | ||
protected didOpen: EventEmitter = new EventEmitter(this, SbbOverlayBaseElement.events.didOpen); | ||
|
||
/** Emits whenever the component begins the closing transition. */ | ||
protected willClose: EventEmitter = new EventEmitter( | ||
this, | ||
SbbOverlayBaseElement.events.willClose, | ||
); | ||
|
||
/** Emits whenever the component is closed. */ | ||
protected didClose: EventEmitter = new EventEmitter(this, SbbOverlayBaseElement.events.didClose); | ||
|
||
/** Opens the component. */ | ||
public abstract open(): void; | ||
/** Closes the component. */ | ||
public abstract close(): void; | ||
|
||
public override connectedCallback(): void { | ||
super.connectedCallback(); | ||
this.state ||= 'closed'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters