generated from eea/volto-addon-template
-
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
1 parent
2d33a65
commit 7515c72
Showing
4 changed files
with
67 additions
and
2 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
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 @@ | ||
/** | ||
* View toc block. | ||
* @module components/manage/Blocks/ToC/View | ||
*/ | ||
|
||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { map } from 'lodash'; | ||
import { Menu } from 'semantic-ui-react'; | ||
import { FormattedMessage, injectIntl } from 'react-intl'; | ||
import AnchorLink from 'react-anchor-link-smooth-scroll'; | ||
|
||
/** | ||
* View toc block class. | ||
* @class View | ||
* @extends Component | ||
*/ | ||
const View = ({ properties, data, tocEntries }) => { | ||
return ( | ||
<> | ||
{data.title && !data.hide_title ? ( | ||
<h2> | ||
{data.title || ( | ||
<FormattedMessage | ||
id="Table of Contents" | ||
defaultMessage="Table of Contents" | ||
/> | ||
)} | ||
</h2> | ||
) : ( | ||
'' | ||
)} | ||
<Menu> | ||
{map( | ||
tocEntries, | ||
([level, entry, id]) => | ||
entry && ( | ||
<Menu.Item key={id} className={`headline-${level}`}> | ||
<AnchorLink href={`#${id}`}>{entry}</AnchorLink> | ||
</Menu.Item> | ||
), | ||
)} | ||
</Menu> | ||
</> | ||
); | ||
}; | ||
|
||
/** | ||
* Property types. | ||
* @property {Object} propTypes Property types. | ||
* @static | ||
*/ | ||
View.propTypes = { | ||
properties: PropTypes.objectOf(PropTypes.any).isRequired, | ||
}; | ||
|
||
export default injectIntl(View); |
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