@elementor/editor-app-bar 0.9.7 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/index.d.mts +9 -218
  3. package/dist/index.d.ts +9 -218
  4. package/dist/index.js +169 -641
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +142 -619
  7. package/dist/index.mjs.map +1 -1
  8. package/package.json +4 -7
  9. package/src/extensions/documents-indicator/index.ts +1 -1
  10. package/src/extensions/documents-preview/index.ts +1 -1
  11. package/src/extensions/documents-save/components/__tests__/primary-action-menu.test.tsx +1 -1
  12. package/src/extensions/documents-save/components/primary-action-menu.tsx +2 -2
  13. package/src/extensions/documents-save/hooks/use-document-save-draft-props.ts +1 -1
  14. package/src/extensions/documents-save/hooks/use-document-save-template-props.ts +1 -1
  15. package/src/extensions/documents-save/index.ts +2 -1
  16. package/src/extensions/documents-save/locations.ts +3 -0
  17. package/src/extensions/elements/index.ts +1 -1
  18. package/src/extensions/finder/index.ts +1 -1
  19. package/src/extensions/help/index.ts +1 -1
  20. package/src/extensions/history/index.ts +1 -1
  21. package/src/extensions/keyboard-shortcuts/hooks/use-action-props.ts +1 -1
  22. package/src/extensions/keyboard-shortcuts/index.ts +1 -1
  23. package/src/extensions/site-settings/hooks/use-action-props.ts +1 -1
  24. package/src/extensions/site-settings/index.ts +1 -1
  25. package/src/extensions/structure/hooks/use-action-props.ts +1 -1
  26. package/src/extensions/structure/index.ts +1 -1
  27. package/src/extensions/theme-builder/hooks/use-action-props.ts +1 -1
  28. package/src/extensions/theme-builder/index.ts +1 -1
  29. package/src/extensions/user-preferences/hooks/use-action-props.ts +1 -1
  30. package/src/extensions/user-preferences/index.ts +1 -1
  31. package/src/extensions/wordpress/index.ts +1 -1
  32. package/src/index.ts +12 -9
  33. package/src/init.ts +1 -1
  34. package/src/components/__tests__/top-bar.test.tsx +0 -15
  35. package/src/components/actions/action.tsx +0 -33
  36. package/src/components/actions/link.tsx +0 -33
  37. package/src/components/actions/toggle-action.tsx +0 -35
  38. package/src/components/app-bar.tsx +0 -37
  39. package/src/components/locations/__tests__/locations-components.test.tsx +0 -37
  40. package/src/components/locations/__tests__/menus.test.tsx +0 -120
  41. package/src/components/locations/integrations-menu-location.tsx +0 -59
  42. package/src/components/locations/main-menu-location.tsx +0 -38
  43. package/src/components/locations/page-indication-location.tsx +0 -8
  44. package/src/components/locations/primary-action-location.tsx +0 -8
  45. package/src/components/locations/responsive-location.tsx +0 -8
  46. package/src/components/locations/tools-menu-location.tsx +0 -26
  47. package/src/components/locations/utilities-menu-location.tsx +0 -35
  48. package/src/components/ui/popover-menu-item.tsx +0 -44
  49. package/src/components/ui/popover-menu.tsx +0 -24
  50. package/src/components/ui/popover-sub-menu.tsx +0 -29
  51. package/src/components/ui/toolbar-logo.tsx +0 -84
  52. package/src/components/ui/toolbar-menu-item.tsx +0 -45
  53. package/src/components/ui/toolbar-menu-more.tsx +0 -29
  54. package/src/components/ui/toolbar-menu-toggle-item.tsx +0 -34
  55. package/src/components/ui/toolbar-menu.tsx +0 -15
  56. package/src/contexts/menu-context.tsx +0 -20
  57. package/src/locations/__tests__/menus.test.tsx +0 -212
  58. package/src/locations/index.ts +0 -29
  59. package/src/locations/menus.tsx +0 -129
  60. package/src/types.ts +0 -3
@@ -1,33 +0,0 @@
1
- import * as React from 'react';
2
- import { useMenuContext } from '../../contexts/menu-context';
3
- import ToolbarMenuItem from '../ui/toolbar-menu-item';
4
- import PopoverMenuItem from '../ui/popover-menu-item';
5
- import { ElementType } from 'react';
6
-
7
- export type Props = {
8
- title: string;
9
- icon: ElementType;
10
- disabled?: boolean;
11
- visible?: boolean;
12
- onClick?: () => void;
13
- };
14
-
15
- export default function Action( { icon: Icon, title, visible = true, ...props }: Props ) {
16
- const { type } = useMenuContext();
17
-
18
- if ( ! visible ) {
19
- return null;
20
- }
21
-
22
- return type === 'toolbar' ? (
23
- <ToolbarMenuItem title={ title } { ...props }>
24
- <Icon />
25
- </ToolbarMenuItem>
26
- ) : (
27
- <PopoverMenuItem
28
- { ...props }
29
- text={ title }
30
- icon={ <Icon /> }
31
- />
32
- );
33
- }
@@ -1,33 +0,0 @@
1
- import * as React from 'react';
2
- import { useMenuContext } from '../../contexts/menu-context';
3
- import ToolbarMenuItem from '../ui/toolbar-menu-item';
4
- import PopoverMenuItem from '../ui/popover-menu-item';
5
- import { ElementType } from 'react';
6
-
7
- export type Props = {
8
- title: string;
9
- icon: ElementType;
10
- href?: string;
11
- visible?: boolean;
12
- target?: string;
13
- }
14
-
15
- export default function Link( { icon: Icon, title, visible = true, ...props }: Props ) {
16
- const { type } = useMenuContext();
17
-
18
- if ( ! visible ) {
19
- return null;
20
- }
21
-
22
- return type === 'toolbar' ? (
23
- <ToolbarMenuItem title={ title } { ...props }>
24
- <Icon />
25
- </ToolbarMenuItem>
26
- ) : (
27
- <PopoverMenuItem
28
- { ...props }
29
- text={ title }
30
- icon={ <Icon /> }
31
- />
32
- );
33
- }
@@ -1,35 +0,0 @@
1
- import * as React from 'react';
2
- import { useMenuContext } from '../../contexts/menu-context';
3
- import PopoverMenuItem from '../ui/popover-menu-item';
4
- import ToolbarMenuToggleItem from '../ui/toolbar-menu-toggle-item';
5
- import { ElementType } from 'react';
6
-
7
- export type Props = {
8
- title: string;
9
- icon: ElementType;
10
- selected?: boolean;
11
- disabled?: boolean;
12
- visible?: boolean;
13
- onClick?: () => void;
14
- value?: string;
15
- };
16
-
17
- export default function ToggleAction( { icon: Icon, title, value, visible = true, ...props }: Props ) {
18
- const { type } = useMenuContext();
19
-
20
- if ( ! visible ) {
21
- return null;
22
- }
23
-
24
- return type === 'toolbar' ? (
25
- <ToolbarMenuToggleItem value={ value || title } title={ title } { ...props }>
26
- <Icon />
27
- </ToolbarMenuToggleItem>
28
- ) : (
29
- <PopoverMenuItem
30
- { ...props }
31
- text={ title }
32
- icon={ <Icon /> }
33
- />
34
- );
35
- }
@@ -1,37 +0,0 @@
1
- import * as React from 'react';
2
- import { AppBar as BaseAppBar, Box, Divider, Grid, ThemeProvider } from '@elementor/ui';
3
- import MainMenuLocation from './locations/main-menu-location';
4
- import ToolsMenuLocation from './locations/tools-menu-location';
5
- import UtilitiesMenuLocation from './locations/utilities-menu-location';
6
- import PrimaryActionLocation from './locations/primary-action-location';
7
- import ToolbarMenu from './ui/toolbar-menu';
8
- import PageIndicationLocation from './locations/page-indication-location';
9
- import ResponsiveLocation from './locations/responsive-location';
10
-
11
- export default function AppBar() {
12
- return (
13
- <ThemeProvider colorScheme="dark">
14
- <BaseAppBar position="sticky">
15
- <Box display="grid" gridTemplateColumns="repeat(3, 1fr)">
16
- <Grid container>
17
- <MainMenuLocation />
18
- <ToolsMenuLocation />
19
- </Grid>
20
- <Grid container justifyContent="center">
21
- <ToolbarMenu spacing={ 1.5 }>
22
- <Divider orientation="vertical" />
23
- <PageIndicationLocation />
24
- <Divider orientation="vertical" />
25
- <ResponsiveLocation />
26
- <Divider orientation="vertical" />
27
- </ToolbarMenu>
28
- </Grid>
29
- <Grid container justifyContent="flex-end">
30
- <UtilitiesMenuLocation />
31
- <PrimaryActionLocation />
32
- </Grid>
33
- </Box>
34
- </BaseAppBar>
35
- </ThemeProvider>
36
- );
37
- }
@@ -1,37 +0,0 @@
1
- import * as React from 'react';
2
- import { render, screen } from '@testing-library/react';
3
- import ResponsiveLocation from '../responsive-location';
4
- import PrimaryActionLocation from '../primary-action-location';
5
- import PageIndicationLocation from '../page-indication-location';
6
- import { injectIntoPageIndication, injectIntoPrimaryAction, injectIntoResponsive } from '../../../locations';
7
-
8
- describe( '@elementor/editor-app-bar - Locations components', () => {
9
- it.each( [
10
- {
11
- name: 'page indication',
12
- component: PageIndicationLocation,
13
- inject: injectIntoPageIndication,
14
- },
15
- {
16
- name: 'responsive',
17
- component: ResponsiveLocation,
18
- inject: injectIntoResponsive,
19
- },
20
- {
21
- name: 'primary action',
22
- component: PrimaryActionLocation,
23
- inject: injectIntoPrimaryAction,
24
- },
25
- ] )( 'should inject into $name', ( { inject, component: Component } ) => {
26
- // Act.
27
- inject( {
28
- id: 'test',
29
- component: () => <span>test</span>,
30
- } );
31
-
32
- // Assert.
33
- render( <Component /> );
34
-
35
- expect( screen.getByText( 'test' ) ).toBeInTheDocument();
36
- } );
37
- } );
@@ -1,120 +0,0 @@
1
- import * as React from 'react';
2
- import { fireEvent, render, screen } from '@testing-library/react';
3
- import MainMenuLocation from '../main-menu-location';
4
- import ToolsMenuLocation from '../tools-menu-location';
5
- import UtilitiesMenuLocation from '../utilities-menu-location';
6
- import { integrationsMenu, mainMenu, toolsMenu, utilitiesMenu } from '../../../locations';
7
- import { createMockMenuAction, createMockMenuLink, createMockMenuToggleAction } from 'test-utils';
8
-
9
- describe( '@elementor/editor-app-bar - Menus components', () => {
10
- describe( 'Main menu', () => {
11
- it( 'should render ordered menu items in a popover', () => {
12
- // Arrange.
13
- mainMenu.registerAction( {
14
- ...createMockMenuAction(),
15
- id: 'test-action',
16
- } );
17
-
18
- mainMenu.registerToggleAction( {
19
- ...createMockMenuToggleAction(),
20
- id: 'test-toggle-action',
21
- } );
22
-
23
- mainMenu.registerLink( {
24
- ...createMockMenuLink(),
25
- group: 'exits',
26
- id: 'test-link',
27
- } );
28
-
29
- // Act.
30
- render( <MainMenuLocation /> );
31
-
32
- fireEvent.click( screen.getByRole( 'button' ) ); // Opens the popover menu
33
-
34
- // Assert.
35
- const menuItems = screen.getAllByRole( 'menuitem' );
36
-
37
- expect( menuItems ).toHaveLength( 3 );
38
-
39
- // Ensure the last one is the link, so the order is correct (`default`, then `exits`).
40
- expect( menuItems[ 2 ] ).toHaveAttribute( 'href', 'https://elementor.com' );
41
- } );
42
-
43
- it( 'should render the integrations menu inside the main menu if there are registered integrations', () => {
44
- // Arrange.
45
- integrationsMenu.registerAction( {
46
- ...createMockMenuAction(),
47
- } );
48
-
49
- // Act.
50
- render( <MainMenuLocation /> );
51
-
52
- fireEvent.click( screen.getByRole( 'button' ) ); // Opens the popover menu
53
-
54
- // Assert.
55
- expect( screen.getByText( 'Integrations' ) ).toBeInTheDocument();
56
-
57
- // Act.
58
- fireEvent.mouseOver( screen.getByText( 'Integrations' ) ); // Opens the integrations menu.
59
-
60
- // Assert.
61
- expect( screen.getByText( 'Test' ) ).toBeInTheDocument();
62
- } );
63
-
64
- it( 'should NOT render the integrations menu inside if there are no registered integrations', () => {
65
- // Act.
66
- render( <MainMenuLocation /> );
67
-
68
- fireEvent.click( screen.getByRole( 'button' ) ); // Opens the popover menu
69
-
70
- // Assert.
71
- expect( screen.queryByText( 'Integrations' ) ).not.toBeInTheDocument();
72
- } );
73
- } );
74
-
75
- describe.each( [
76
- {
77
- menuName: 'Tools',
78
- menu: toolsMenu,
79
- maxItems: 5,
80
- Component: ToolsMenuLocation,
81
- },
82
- {
83
- menuName: 'Utilities',
84
- menu: utilitiesMenu,
85
- maxItems: 3,
86
- Component: UtilitiesMenuLocation,
87
- },
88
- ] )( '$menuName menu', ( { maxItems, menu, Component } ) => {
89
- it( `should render ${ maxItems } menu items in a toolbar and the rest in a popover`, () => {
90
- // Arrange.
91
- const extraAfterMax = 2;
92
-
93
- for ( let i = 0; i < maxItems + extraAfterMax; i++ ) {
94
- menu.registerAction( {
95
- id: `test-${ i }`,
96
- props: {
97
- title: `Test ${ i }`,
98
- icon: () => <span>a</span>,
99
- },
100
- } );
101
- }
102
-
103
- // Act.
104
- render( <Component /> );
105
-
106
- // Assert.
107
- const toolbarButtons = screen.getAllByRole( 'button' );
108
- const popoverButton = toolbarButtons[ maxItems ];
109
-
110
- expect( toolbarButtons ).toHaveLength( maxItems + 1 ); // Including the popover button.
111
- expect( popoverButton ).toHaveAttribute( 'aria-label', 'More' );
112
-
113
- // Act.
114
- fireEvent.click( popoverButton );
115
-
116
- // Assert.
117
- expect( screen.getAllByRole( 'menuitem' ) ).toHaveLength( extraAfterMax );
118
- } );
119
- } );
120
- } );
@@ -1,59 +0,0 @@
1
- import * as React from 'react';
2
- import { integrationsMenu } from '../../locations';
3
- import {
4
- bindMenu,
5
- Divider,
6
- ListItemIcon,
7
- ListItemText,
8
- MenuItem,
9
- usePopupState,
10
- bindHover,
11
- bindFocus,
12
- withDirection,
13
- } from '@elementor/ui';
14
- import { __ } from '@wordpress/i18n';
15
- import { ChevronRightIcon, PlugIcon } from '@elementor/icons';
16
- import PopoverSubMenu from '../ui/popover-sub-menu';
17
-
18
- type Props = {
19
- parentPopupState: ReturnType<typeof usePopupState>;
20
- }
21
-
22
- const { useMenuItems } = integrationsMenu;
23
-
24
- const DirectionalChevronIcon = withDirection( ChevronRightIcon );
25
-
26
- export default function IntegrationsMenuLocation( { parentPopupState }: Props ) {
27
- const menuItems = useMenuItems();
28
-
29
- const popupState = usePopupState( {
30
- parentPopupState,
31
- variant: 'popover',
32
- popupId: 'elementor-v2-app-bar-integrations',
33
- } );
34
-
35
- if ( menuItems.default.length === 0 ) {
36
- return null;
37
- }
38
-
39
- return (
40
- <>
41
- <Divider />
42
- <MenuItem
43
- { ...bindHover( popupState ) }
44
- { ...bindFocus( popupState ) }
45
- >
46
- <ListItemIcon>
47
- <PlugIcon />
48
- </ListItemIcon>
49
- <ListItemText primary={ __( 'Integrations', 'elementor' ) } />
50
- <DirectionalChevronIcon />
51
- <PopoverSubMenu { ...bindMenu( popupState ) } onClick={ popupState.close }>
52
- { menuItems.default.map(
53
- ( { MenuItem: IntegrationsMenuItem, id } ) => <IntegrationsMenuItem key={ id } />
54
- ) }
55
- </PopoverSubMenu>
56
- </MenuItem>
57
- </>
58
- );
59
- }
@@ -1,38 +0,0 @@
1
- import * as React from 'react';
2
- import { usePopupState, bindMenu, bindTrigger, Stack, Divider } from '@elementor/ui';
3
- import { mainMenu } from '../../locations';
4
- import PopoverMenu from '../ui/popover-menu';
5
- import ToolbarLogo from '../ui/toolbar-logo';
6
- import IntegrationsMenuLocation from './integrations-menu-location';
7
-
8
- const { useMenuItems } = mainMenu;
9
-
10
- export default function MainMenuLocation() {
11
- const menuItems = useMenuItems();
12
-
13
- const popupState = usePopupState( {
14
- variant: 'popover',
15
- popupId: 'elementor-v2-app-bar-main-menu',
16
- } );
17
-
18
- return (
19
- <Stack sx={ { paddingInlineStart: 3 } } direction="row" alignItems="center">
20
- <ToolbarLogo
21
- { ...bindTrigger( popupState ) }
22
- selected={ popupState.isOpen }
23
- />
24
- <PopoverMenu
25
- onClick={ popupState.close }
26
- { ...bindMenu( popupState ) }
27
- marginThreshold={ 8 }
28
- >
29
- { menuItems.default.map( ( { MenuItem, id } ) => <MenuItem key={ id } /> ) }
30
-
31
- <IntegrationsMenuLocation key="integrations-location" parentPopupState={ popupState } />
32
-
33
- { menuItems.exits.length > 0 && <Divider /> }
34
- { menuItems.exits.map( ( { MenuItem, id } ) => <MenuItem key={ id } /> ) }
35
- </PopoverMenu>
36
- </Stack>
37
- );
38
- }
@@ -1,8 +0,0 @@
1
- import * as React from 'react';
2
- import { PageIndicationSlot } from '../../locations';
3
-
4
- export default function PageIndicationLocation() {
5
- return (
6
- <PageIndicationSlot />
7
- );
8
- }
@@ -1,8 +0,0 @@
1
- import * as React from 'react';
2
- import { PrimaryActionSlot } from '../../locations';
3
-
4
- export default function PrimaryActionLocation() {
5
- return (
6
- <PrimaryActionSlot />
7
- );
8
- }
@@ -1,8 +0,0 @@
1
- import * as React from 'react';
2
- import { ResponsiveSlot } from '../../locations';
3
-
4
- export default function ResponsiveLocation() {
5
- return (
6
- <ResponsiveSlot />
7
- );
8
- }
@@ -1,26 +0,0 @@
1
- import * as React from 'react';
2
- import { toolsMenu } from '../../locations';
3
- import ToolbarMenu from '../ui/toolbar-menu';
4
- import ToolbarMenuMore from '../ui/toolbar-menu-more';
5
-
6
- const MAX_TOOLBAR_ACTIONS = 5;
7
-
8
- const { useMenuItems } = toolsMenu;
9
-
10
- export default function ToolsMenuLocation() {
11
- const menuItems = useMenuItems();
12
-
13
- const toolbarMenuItems = menuItems.default.slice( 0, MAX_TOOLBAR_ACTIONS );
14
- const popoverMenuItems = menuItems.default.slice( MAX_TOOLBAR_ACTIONS );
15
-
16
- return (
17
- <ToolbarMenu>
18
- { toolbarMenuItems.map( ( { MenuItem, id } ) => <MenuItem key={ id } /> ) }
19
- { popoverMenuItems.length > 0 && (
20
- <ToolbarMenuMore id="elementor-editor-app-bar-tools-more">
21
- { popoverMenuItems.map( ( { MenuItem, id } ) => <MenuItem key={ id } /> ) }
22
- </ToolbarMenuMore>
23
- ) }
24
- </ToolbarMenu>
25
- );
26
- }
@@ -1,35 +0,0 @@
1
- import * as React from 'react';
2
- import { Fragment } from 'react';
3
- import ToolbarMenu from '../ui/toolbar-menu';
4
- import { utilitiesMenu } from '../../locations';
5
- import { Divider } from '@elementor/ui';
6
- import ToolbarMenuMore from '../ui/toolbar-menu-more';
7
-
8
- const MAX_TOOLBAR_ACTIONS = 3;
9
-
10
- const { useMenuItems } = utilitiesMenu;
11
-
12
- export default function UtilitiesMenuLocation() {
13
- const menuItems = useMenuItems();
14
-
15
- const toolbarMenuItems = menuItems.default.slice( 0, MAX_TOOLBAR_ACTIONS );
16
- const popoverMenuItems = menuItems.default.slice( MAX_TOOLBAR_ACTIONS );
17
-
18
- return (
19
- <ToolbarMenu>
20
- { toolbarMenuItems.map(
21
- ( { MenuItem, id }, index ) => (
22
- <Fragment key={ id }>
23
- { index === 0 && <Divider orientation="vertical" /> }
24
- <MenuItem />
25
- </Fragment>
26
- )
27
- ) }
28
- { popoverMenuItems.length > 0 && (
29
- <ToolbarMenuMore id="elementor-editor-app-bar-utilities-more">
30
- { popoverMenuItems.map( ( { MenuItem, id } ) => <MenuItem key={ id } /> ) }
31
- </ToolbarMenuMore>
32
- ) }
33
- </ToolbarMenu>
34
- );
35
- }
@@ -1,44 +0,0 @@
1
- import * as React from 'react';
2
- import {
3
- MenuItem,
4
- MenuItemProps,
5
- ListItemText,
6
- ListItemIcon,
7
- withDirection,
8
- } from '@elementor/ui';
9
- import { ArrowUpRightIcon } from '@elementor/icons';
10
-
11
- type ExtraProps = {
12
- href?: string;
13
- target?: string;
14
- text?: string;
15
- icon?: JSX.Element;
16
- }
17
-
18
- export type PopoverMenuItemProps = MenuItemProps & ExtraProps;
19
-
20
- const DirectionalArrowIcon = withDirection( ArrowUpRightIcon );
21
-
22
- export default function PopoverMenuItem( { text, icon, onClick, href, target, disabled, ...props }: PopoverMenuItemProps ) {
23
- const isExternalLink = href && target === '_blank';
24
-
25
- return (
26
- <MenuItem
27
- { ...props }
28
- disabled={ disabled }
29
- onClick={ onClick }
30
- component={ href ? 'a' : 'div' }
31
- href={ href }
32
- target={ target }
33
- sx={ {
34
- '&:hover': {
35
- color: 'text.primary', // Overriding global CSS from the editor.
36
- },
37
- } }
38
- >
39
- <ListItemIcon>{ icon }</ListItemIcon>
40
- <ListItemText primary={ text } />
41
- { isExternalLink && <DirectionalArrowIcon /> }
42
- </MenuItem>
43
- );
44
- }
@@ -1,24 +0,0 @@
1
- import * as React from 'react';
2
- import { Menu, MenuProps } from '@elementor/ui';
3
- import { MenuContextProvider } from '../../contexts/menu-context';
4
-
5
- export type PopoverMenuProps = MenuProps;
6
-
7
- export default function PopoverMenu( { children, ...props }: PopoverMenuProps ) {
8
- return (
9
- <MenuContextProvider type={ 'popover' }>
10
- <Menu
11
- PaperProps={ {
12
- sx: { mt: 1.5 },
13
- } }
14
- { ...props }
15
- MenuListProps={ {
16
- component: 'div',
17
- dense: true,
18
- } }
19
- >
20
- { children }
21
- </Menu>
22
- </MenuContextProvider>
23
- );
24
- }
@@ -1,29 +0,0 @@
1
- import * as React from 'react';
2
- import PopoverMenu, { PopoverMenuProps } from './popover-menu';
3
- import { useTheme } from '@elementor/ui';
4
-
5
- export default function PopoverSubMenu( { children, ...props }: PopoverMenuProps ) {
6
- const theme = useTheme();
7
- const isRTL = theme.direction === 'rtl';
8
-
9
- return (
10
- <PopoverMenu
11
- sx={ { pointerEvents: 'none' } }
12
- PaperProps={ {
13
- sx: {
14
- // This is a workaround to support RTL in PopoverMenu, since it doesn't support it yet.
15
- ...( isRTL
16
- ? { marginInlineEnd: -1 }
17
- : { marginInlineStart: 1 }
18
- ),
19
- pointerEvents: 'auto',
20
- },
21
- } }
22
- anchorOrigin={ { vertical: 'center', horizontal: isRTL ? 'left' : 'right' } }
23
- transformOrigin={ { vertical: 'center', horizontal: isRTL ? 'right' : 'left' } }
24
- { ...props }
25
- >
26
- { children }
27
- </PopoverMenu>
28
- );
29
- }
@@ -1,84 +0,0 @@
1
- import * as React from 'react';
2
- import { useState } from 'react';
3
- import { __ } from '@wordpress/i18n';
4
- import { ToggleButton, ToggleButtonProps, SvgIconProps, SvgIcon, styled } from '@elementor/ui';
5
-
6
- interface StyledElementorLogoProps extends SvgIconProps {
7
- showMenuIcon?: boolean;
8
- }
9
-
10
- type ToolbarLogoProps = Omit<ToggleButtonProps, 'value'>;
11
-
12
- const ElementorLogo = ( props: SvgIconProps ) => {
13
- return (
14
- <SvgIcon viewBox="0 0 32 32" { ...props }>
15
- <g>
16
- <circle cx="16" cy="16" r="16" />
17
- <path d="M11.7 9H9V22.3H11.7V9Z" />
18
- <path d="M22.4 9H9V11.7H22.4V9Z" />
19
- <path d="M22.4 14.4004H9V17.1004H22.4V14.4004Z" />
20
- <path d="M22.4 19.6992H9V22.3992H22.4V19.6992Z" />
21
- </g>
22
- </SvgIcon>
23
- );
24
- };
25
-
26
- const StyledToggleButton = styled( ToggleButton )( ( { theme } ) => ( {
27
- padding: 0,
28
- border: 0,
29
- color: theme.palette.text.primary,
30
- '&.MuiToggleButton-root:hover': {
31
- backgroundColor: 'initial',
32
- },
33
- '&.MuiToggleButton-root.Mui-selected': {
34
- backgroundColor: 'initial',
35
- },
36
- } ) );
37
-
38
- const StyledElementorLogo = styled( ElementorLogo, {
39
- shouldForwardProp: ( prop ) => prop !== 'showMenuIcon',
40
- } )<StyledElementorLogoProps>( ( { theme, showMenuIcon } ) => ( {
41
- '& path': {
42
- fill: theme.palette.background.default,
43
- transition: 'all 0.2s linear',
44
- transformOrigin: 'bottom left',
45
- '&:first-of-type': {
46
- transitionDelay: ! showMenuIcon && '0.2s',
47
- transform: showMenuIcon && 'translateY(-9px) scaleY(0)',
48
- },
49
- '&:not(:first-of-type)': {
50
- // Emotion automatically change 4 to -4 in RTL moode.
51
- transform: ! showMenuIcon && `translateX(${ theme.direction === 'rtl' ? '4' : '9' }px) scaleX(0.6)`,
52
- },
53
- '&:nth-of-type(2)': {
54
- transitionDelay: showMenuIcon ? '0' : '0.2s',
55
- },
56
- '&:nth-of-type(3)': {
57
- transitionDelay: '0.1s',
58
- },
59
- '&:nth-of-type(4)': {
60
- transitionDelay: showMenuIcon ? '0.2s' : '0',
61
- },
62
- },
63
- } ) );
64
-
65
- export default function ToolbarLogo( props: ToolbarLogoProps ) {
66
- const [ isHoverState, setIsHoverState ] = useState( false );
67
- const showMenuIcon = props.selected || isHoverState;
68
-
69
- return (
70
- <StyledToggleButton
71
- { ...props }
72
- value="selected"
73
- size="large"
74
- onMouseEnter={ () => setIsHoverState( true ) }
75
- onMouseLeave={ () => setIsHoverState( false ) }
76
- >
77
- <StyledElementorLogo
78
- fontSize="large"
79
- showMenuIcon={ showMenuIcon }
80
- titleAccess={ __( 'Elementor Logo', 'elementor' ) }
81
- />
82
- </StyledToggleButton>
83
- );
84
- }