Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: add useOpenClose controller #11309

Draft
wants to merge 4 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
refactor: add useOpenClose controller
  • Loading branch information
jcfranco committed Jan 15, 2025
commit 83c8d3753f69b94feb21a430b15985ef6f8bff7a
14 changes: 14 additions & 0 deletions packages/calcite-components/src/controllers/useOpenClose
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { makeGenericController } from "@arcgis/components-controllers";
import { onToggleOpenCloseComponent, OpenCloseComponent } from "../utils/openCloseComponent";

export interface UseOpenClose {
afterToggle: () => void;
}

export const useOpenClose = makeGenericController<UseOpenClose, OpenCloseComponent>((component, controller) => {
return {
afterToggle: () => {
onToggleOpenCloseComponent(component);
},
};
});
5 changes: 1 addition & 4 deletions packages/calcite-components/src/utils/openCloseComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ import { whenTransitionDone } from "./dom";
* All implementations of this interface must handle the following events: `beforeOpen`, `open`, `beforeClose`, `close`.
*/
export interface OpenCloseComponent {
/** The host element. */
readonly el: HTMLElement;

/**
* Specifies property on which active transition is watched for.
*
Expand All @@ -18,7 +15,7 @@ export interface OpenCloseComponent {
openProp?: string;

/** Specifies the name of CSS transition property. */
transitionProp?: KebabCase<Extract<keyof CSSStyleDeclaration, string>>;
transitionProp: KebabCase<Extract<keyof CSSStyleDeclaration, string>>;

/** Specifies element that the transition is allowed to emit on. */
transitionEl: HTMLElement;
Expand Down
Loading