@elementor/editor-editing-panel 0.13.0 → 0.14.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.
@@ -1,25 +1,45 @@
1
1
  import * as React from 'react';
2
- import { useId } from 'react';
3
- import { Accordion, AccordionSummary, AccordionDetails, AccordionSummaryText, Stack } from '@elementor/ui';
2
+ import { useState } from 'react';
3
+ import { ChevronDownIcon } from '@elementor/icons';
4
+ import { Button, Collapse, Stack, styled } from '@elementor/ui';
5
+ import { __ } from '@wordpress/i18n';
4
6
 
5
- export type CollapsibleSectionProps = React.PropsWithChildren< {
6
- title: React.ReactNode;
7
+ type CollapsibleSectionProps = React.PropsWithChildren< {
8
+ defaultOpen?: boolean;
7
9
  } >;
8
10
 
9
- export const CollapsibleSection = ( { title, children }: CollapsibleSectionProps ) => {
10
- const uid = useId();
11
- const labelId = `label-${ uid }`;
12
- const contentId = `content-${ uid }`;
11
+ export const CollapsibleSection = ( { children, defaultOpen = false }: CollapsibleSectionProps ) => {
12
+ const [ open, setOpen ] = useState( defaultOpen );
13
+
14
+ const handleToggle = () => {
15
+ setOpen( ( prevOpen ) => ! prevOpen );
16
+ };
13
17
 
14
- // TODO: Change to collapsible list item
15
18
  return (
16
- <Accordion disableGutters defaultExpanded>
17
- <AccordionSummary aria-controls={ contentId } id={ labelId }>
18
- <AccordionSummaryText primaryTypographyProps={ { variant: 'caption' } }>{ title }</AccordionSummaryText>
19
- </AccordionSummary>
20
- <AccordionDetails id={ contentId } aria-labelledby={ labelId }>
21
- <Stack gap={ 2.5 }>{ children }</Stack>
22
- </AccordionDetails>
23
- </Accordion>
19
+ <Stack sx={ { py: 0.5 } }>
20
+ <Button
21
+ fullWidth
22
+ size="small"
23
+ color="secondary"
24
+ variant="outlined"
25
+ onClick={ handleToggle }
26
+ endIcon={ <ChevronIcon open={ open } /> }
27
+ >
28
+ { open ? __( 'Show less', 'elementor' ) : __( 'Show more', 'elementor' ) }
29
+ </Button>
30
+ <Collapse in={ open } timeout="auto">
31
+ { children }
32
+ </Collapse>
33
+ </Stack>
24
34
  );
25
35
  };
36
+
37
+ // TODO: Replace this with future Rotate component that will be implemented in elementor-ui
38
+ const ChevronIcon = styled( ChevronDownIcon, {
39
+ shouldForwardProp: ( prop ) => prop !== 'open',
40
+ } )< { open: boolean } >( ( { theme, open } ) => ( {
41
+ transform: open ? 'rotate(180deg)' : 'rotate(0)',
42
+ transition: theme.transitions.create( 'transform', {
43
+ duration: theme.transitions.duration.standard,
44
+ } ),
45
+ } ) );
@@ -4,7 +4,7 @@ import { SettingsControl } from '../controls/settings-control';
4
4
  import { useElementContext } from '../contexts/element-context';
5
5
  import useElementType from '../hooks/use-element-type';
6
6
  import type { Control } from '../types';
7
- import { CollapsibleSection } from './collapsible-section';
7
+ import { AccordionSection } from './accordion-section';
8
8
  import { getControlByType } from '../controls/get-control-by-type';
9
9
 
10
10
  export const SettingsTab = () => {
@@ -25,7 +25,7 @@ export const SettingsTab = () => {
25
25
 
26
26
  if ( type === 'section' ) {
27
27
  return (
28
- <CollapsibleSection key={ type + '.' + index } title={ value.label }>
28
+ <AccordionSection key={ type + '.' + index } title={ value.label }>
29
29
  { value.items?.map( ( item ) => {
30
30
  if ( item.type === 'control' ) {
31
31
  return <Control key={ item.value.bind } control={ item.value } />;
@@ -34,7 +34,7 @@ export const SettingsTab = () => {
34
34
  // TODO: Handle 2nd level sections
35
35
  return null;
36
36
  } ) }
37
- </CollapsibleSection>
37
+ </AccordionSection>
38
38
  );
39
39
  }
40
40
 
@@ -1,28 +1,33 @@
1
1
  import * as React from 'react';
2
- import { CollapsibleSection } from '../../components/collapsible-section';
2
+ import { AccordionSection } from '../accordion-section';
3
3
  import { StyleControl, StyleControlProps } from '../../controls/style-control';
4
+ import { CollapsibleSection } from '../collapsible-section';
4
5
  import { SizeControl, Unit } from '../../controls/control-types/size-control';
5
6
  import { Stack } from '@elementor/ui';
6
7
  import { __ } from '@wordpress/i18n';
7
8
 
8
9
  export const SizeSection = () => {
9
10
  return (
10
- <CollapsibleSection title={ __( 'Size', 'elementor' ) }>
11
+ <AccordionSection title={ __( 'Size', 'elementor' ) }>
11
12
  <Stack gap={ 1.5 }>
12
13
  <Stack direction="row" gap={ 2 }>
13
14
  <Control bind="width" label={ __( 'Width', 'elementor' ) } />
14
15
  <Control bind="height" label={ __( 'Height', 'elementor' ) } />
15
16
  </Stack>
16
- <Stack direction="row" gap={ 2 }>
17
- <Control bind="minWidth" label={ __( 'Min. Width', 'elementor' ) } />
18
- <Control bind="minHeight" label={ __( 'Min. Height', 'elementor' ) } />
19
- </Stack>
20
- <Stack direction="row" gap={ 2 }>
21
- <Control bind="maxWidth" label={ __( 'Max. Width', 'elementor' ) } />
22
- <Control bind="maxHeight" label={ __( 'Max. Height', 'elementor' ) } />
23
- </Stack>
17
+ <CollapsibleSection>
18
+ <Stack gap={ 1.5 } sx={ { pt: 1.5 } }>
19
+ <Stack direction="row" gap={ 2 }>
20
+ <Control bind="minWidth" label={ __( 'Min. Width', 'elementor' ) } />
21
+ <Control bind="minHeight" label={ __( 'Min. Height', 'elementor' ) } />
22
+ </Stack>
23
+ <Stack direction="row" gap={ 2 }>
24
+ <Control bind="maxWidth" label={ __( 'Max. Width', 'elementor' ) } />
25
+ <Control bind="maxHeight" label={ __( 'Max. Height', 'elementor' ) } />
26
+ </Stack>
27
+ </Stack>
28
+ </CollapsibleSection>
24
29
  </Stack>
25
- </CollapsibleSection>
30
+ </AccordionSection>
26
31
  );
27
32
  };
28
33
 
@@ -1,15 +1,15 @@
1
1
  import * as React from 'react';
2
- import { CollapsibleSection } from '../collapsible-section';
2
+ import { AccordionSection } from '../accordion-section';
3
3
  import { Stack } from '@elementor/ui';
4
4
  import { TextStyleControl } from '../../controls/control-types/text-style-control';
5
5
  import { __ } from '@wordpress/i18n';
6
6
 
7
7
  export const TypographySection = () => {
8
8
  return (
9
- <CollapsibleSection title={ __( 'Typography', 'elementor' ) }>
9
+ <AccordionSection title={ __( 'Typography', 'elementor' ) }>
10
10
  <Stack gap={ 1.5 }>
11
11
  <TextStyleControl />
12
12
  </Stack>
13
- </CollapsibleSection>
13
+ </AccordionSection>
14
14
  );
15
15
  };