-
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
4 changed files
with
93 additions
and
0 deletions.
There are no files selected for viewing
67 changes: 67 additions & 0 deletions
67
frontend/packages/volto-trepr-intranet/src/components/Blocks/Listing/IconListingTemplate.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,67 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { Container } from '@plone/components'; | ||
import { ConditionalLink, UniversalLink, Icon } from '@plone/volto/components'; | ||
import { flattenToAppURL } from '@plone/volto/helpers'; | ||
import { isInternalURL } from '@plone/volto/helpers/Url/Url'; | ||
import { getContentIcon } from '@plone/volto/helpers/Content/Content'; | ||
|
||
const IconListingTemplate = ({ | ||
headlineTag, | ||
items, | ||
linkTitle, | ||
linkHref, | ||
isEditMode, | ||
}) => { | ||
let link = null; | ||
let href = linkHref?.[0]?.['@id'] || ''; | ||
|
||
if (isInternalURL(href)) { | ||
link = ( | ||
<ConditionalLink to={flattenToAppURL(href)} condition={!isEditMode}> | ||
{linkTitle || href} | ||
</ConditionalLink> | ||
); | ||
} else if (href) { | ||
link = <UniversalLink href={href}>{linkTitle || href}</UniversalLink>; | ||
} | ||
|
||
const getTitleTag = (tag) => { | ||
const level = tag.slice(-1); | ||
if (/\d/.test(level)) { | ||
return `h${Number(level) + 1}`; | ||
} else { | ||
return 'h3'; | ||
} | ||
}; | ||
const TitleTag = headlineTag ? getTitleTag(headlineTag) : 'h3'; | ||
|
||
return ( | ||
<> | ||
<Container className="items icon-items"> | ||
{items.map((item) => { | ||
const iconName = getContentIcon(item.portal_type, true); | ||
return ( | ||
<div className="listing-item" key={item['@id']}> | ||
<ConditionalLink item={item} condition={!isEditMode}> | ||
<Icon name={iconName} size="64px" /> | ||
<div className="listing-body"> | ||
<TitleTag>{item.title ? item.title : item.id}</TitleTag> | ||
<p>{item.description}</p> | ||
</div> | ||
</ConditionalLink> | ||
</div> | ||
); | ||
})} | ||
</Container> | ||
|
||
{link && <div className="footer">{link}</div>} | ||
</> | ||
); | ||
}; | ||
IconListingTemplate.propTypes = { | ||
items: PropTypes.arrayOf(PropTypes.any).isRequired, | ||
linkMore: PropTypes.any, | ||
isEditMode: PropTypes.bool, | ||
}; | ||
export default IconListingTemplate; |
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
// This theme extends the volto-light-theme | ||
@import 'root'; | ||
@import 'components/block_listing'; |
13 changes: 13 additions & 0 deletions
13
frontend/packages/volto-trepr-intranet/src/theme/components/_block_listing.scss
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,13 @@ | ||
.block.listing.icon-template { | ||
.items { | ||
.listing-item { | ||
svg.icon { | ||
padding: $spacing-small; | ||
border-radius: 50%; | ||
margin-right: $spacing-small; | ||
background-color: lightblue; | ||
color: white; | ||
} | ||
} | ||
} | ||
} |