0.15.4 • Published 5 months ago

@elementor/editor-panels v0.15.4

Weekly downloads
-
License
GPL-3.0-or-later
Repository
github
Last release
5 months ago

Editor Panels

!WARNING This package is under development and not ready for production use.

Usage

Creating panel contains 3 steps:

  1. Creating the panel component
// components/my-panel.tsx
import { Panel, PanelHeader, PanelHeaderTitle, PanelBody } from '@elementor/editor-panels';

export default function MyPanel() {
	return (
		<Panel>
			<PanelHeader>
				<PanelHeaderTitle>{ /* Panel title */ }</PanelHeaderTitle>
			</PanelHeader>
			<PanelBody>
				{ /* Here should be all the content of the panel */ }
			</PanelBody>
		</Panel>
	);
}
  1. Creating an instance of the panel
// panel.ts
import { createPanel } from '@elementor/editor-panels';
import MyPanel from './components/my-panel';

export const {
	panel,
	usePanelStatus,
	usePanelActions,
} = createPanel( {
	id: 'my-panel',
	component: MyPanel
} );
  1. Registering the panel
// init.ts
import { registerPanel } from '@elementor/editor-panels';
import { panel } from './panel';

function init() {
	registerPanel( panel );
}
// index.ts
import init from './init';

init();

Using panel actions and state

To change or read the state of a panel (open/close), you can use 2 hooks that are being returned from the createPanel() function. Let's assume that we have a button that should open the panel when clicked, and close it when clicked again.

// components/my-panel-button.tsx
import { usePanelStatus, usePanelActions } from '../panel';

export default function MyPanelButton() {
	const { isOpen, isBlocked } = usePanelStatus();
	const { open, close } = usePanelActions();

	return (
		<button onClick={ isOpen ? close : open } disabled={ isBlocked }>
			{ isOpen ? 'Close panel' : 'Open panel' }
		</button>
	);
}
0.15.4

5 months ago

0.11.0

8 months ago

0.11.1

8 months ago

0.13.0

7 months ago

0.13.1

7 months ago

0.15.0

6 months ago

0.15.1

6 months ago

0.15.2

5 months ago

0.15.3

5 months ago

0.9.0

11 months ago

0.10.1

11 months ago

0.12.0

8 months ago

0.10.2

10 months ago

0.12.1

7 months ago

0.10.3

9 months ago

0.14.0

7 months ago

0.12.2

7 months ago

0.10.4

9 months ago

0.14.1

6 months ago

0.10.5

9 months ago

0.10.0

11 months ago

0.8.0

1 year ago

0.4.17

1 year ago

0.4.15

1 year ago

0.4.16

1 year ago

0.4.13

1 year ago

0.4.14

1 year ago

0.5.0

1 year ago

0.7.0

1 year ago

0.6.1

1 year ago

0.6.0

1 year ago

0.4.12

1 year ago

0.4.11

1 year ago

0.4.10

2 years ago

0.4.9

2 years ago

0.4.8

2 years ago

0.4.7

2 years ago

0.4.6

2 years ago

0.3.0

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.4.5

2 years ago

0.4.4

2 years ago

0.4.1

2 years ago

0.1.4

2 years ago

0.4.0

2 years ago

0.1.3

2 years ago

0.4.3

2 years ago

0.1.6

2 years ago

0.4.2

2 years ago

0.1.5

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago