-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
21 changed files
with
34,896 additions
and
27 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 @@ | ||
.DS_Store | ||
.*project | ||
.settings/ | ||
.vscode | ||
|
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
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
Empty file.
76 changes: 76 additions & 0 deletions
76
packages/volto-accordion-block/src/components/AccordionEdit.jsx
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,76 @@ | ||
import cx from 'classnames'; | ||
import React from 'react'; | ||
import { Icon } from '@plone/volto/components'; | ||
import { injectIntl } from 'react-intl'; | ||
|
||
import rightSVG from '@plone/volto/icons/right-key.svg'; | ||
|
||
const AccordionEdit = (props) => { | ||
const { | ||
children, | ||
handleTitleChange, | ||
handleTitleClick, | ||
panel, | ||
data, | ||
index, | ||
uid, | ||
} = props; | ||
const [activeIndex, setActiveIndex] = React.useState([0]); | ||
const isActive = activeIndex.includes(index); | ||
|
||
const handleClick = (e, itemProps) => { | ||
e.stopPropagation(); | ||
const { index } = itemProps; | ||
if (data.non_exclusive) { | ||
const newIndex = | ||
activeIndex.indexOf(index) === -1 | ||
? [...activeIndex, index] | ||
: activeIndex.filter((item) => item !== index); | ||
|
||
setActiveIndex(newIndex); | ||
} else { | ||
const newIndex = | ||
activeIndex.indexOf(index) === -1 | ||
? [index] | ||
: activeIndex.filter((item) => item !== index); | ||
|
||
setActiveIndex(newIndex); | ||
} | ||
}; | ||
|
||
React.useEffect(() => { | ||
return data.collapsed && setActiveIndex([]); | ||
}, [data.collapsed]); | ||
|
||
return ( | ||
<div className={'accordion-item'}> | ||
<div | ||
className={cx('accordion-title')} | ||
onClick={(e) => handleClick(e, { index })} | ||
role="button" | ||
tabIndex={0} | ||
aria-expanded={isActive} | ||
> | ||
<input | ||
placeholder="Enter title here..." | ||
value={panel?.title} | ||
onClick={(e) => { | ||
handleTitleClick(); | ||
e.stopPropagation(); | ||
}} | ||
onChange={(e) => handleTitleChange(e, [uid, panel])} | ||
/> | ||
<Icon | ||
className={cx(isActive ? 'open' : '')} | ||
name={rightSVG} | ||
size="20px" | ||
/> | ||
</div> | ||
<div className={cx('content-wrapper', isActive ? 'open' : '')}> | ||
<div className="accordion-content">{children}</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default injectIntl(AccordionEdit); |
57 changes: 57 additions & 0 deletions
57
packages/volto-accordion-block/src/components/AccordionFilter.jsx
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,57 @@ | ||
import React from 'react'; | ||
import { Accordion, Input } from 'semantic-ui-react'; | ||
import { defineMessages, useIntl } from 'react-intl'; | ||
import { Icon } from './util'; | ||
|
||
const messages = defineMessages({ | ||
placeholder: { | ||
id: 'Type to filter...', | ||
defaultMessage: 'Type to filter...', | ||
}, | ||
}); | ||
|
||
const AccordionFilter = ({ | ||
config, | ||
data, | ||
filterValue, | ||
handleFilteredValueChange, | ||
}) => { | ||
const intl = useIntl(); | ||
const { titleIcons } = config; | ||
const iconOnRight = data.right_arrows; | ||
const iconPosition = iconOnRight ? 'rightPosition' : 'leftPosition'; | ||
return ( | ||
<Accordion | ||
className={`styled ${ | ||
data.styles ? data.styles.theme : config?.defaults?.theme | ||
}`} | ||
> | ||
<Accordion.Title | ||
className={ | ||
'accordion-title filter ' + | ||
(data.right_arrows ? 'align-arrow-right' : 'align-arrow-left') | ||
} | ||
> | ||
<Icon | ||
name={ | ||
filterValue === '' | ||
? titleIcons.unfiltered[iconPosition] | ||
: titleIcons.filtered[iconPosition] | ||
} | ||
options={titleIcons} | ||
onClick={() => handleFilteredValueChange('')} | ||
/> | ||
<Input | ||
fluid | ||
className="input-accordion-title" | ||
transparent | ||
placeholder={intl.formatMessage(messages.placeholder)} | ||
value={filterValue} | ||
onChange={(e) => handleFilteredValueChange(e.target.value)} | ||
/> | ||
</Accordion.Title> | ||
</Accordion> | ||
); | ||
}; | ||
|
||
export default AccordionFilter; |
Oops, something went wrong.