-
Notifications
You must be signed in to change notification settings - Fork 1
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
12 changed files
with
394 additions
and
36 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,40 @@ | ||
/** | ||
* Edit map block. | ||
* @module components/manage/Blocks/Maps/Edit | ||
*/ | ||
import React, { useState } from 'react'; | ||
import InlineForm from '@plone/volto/components/manage/Form/InlineForm'; | ||
import { SidebarPortal } from '@plone/volto/components'; | ||
import View from './View'; | ||
import getSchema from './schema'; | ||
|
||
const Edit = (props) => { | ||
const [state, setState] = useState({ | ||
schema: getSchema(props), | ||
}); | ||
|
||
const handleChangeBlock = (id, value) => { | ||
const { data } = props; | ||
props.onChangeBlock(props.block, { | ||
...data, | ||
[id]: value, | ||
}); | ||
}; | ||
|
||
return ( | ||
<div> | ||
<SidebarPortal selected={props.selected}> | ||
<InlineForm | ||
schema={state.schema} | ||
title={state.schema.title} | ||
onChangeField={handleChangeBlock} | ||
formData={props.data} | ||
block={props.block} | ||
/> | ||
</SidebarPortal> | ||
<View {...props} mode="edit" /> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Edit; |
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,145 @@ | ||
import React, { useState, useEffect } from 'react'; | ||
import { compose } from 'redux'; | ||
import { connect } from 'react-redux'; | ||
import Icon from '@plone/volto/components/theme/Icon/Icon'; | ||
import { Link } from 'react-router-dom'; | ||
import { getSparqlData } from '~/actions'; | ||
import { Image } from 'semantic-ui-react'; | ||
import moment from 'moment'; | ||
import cx from 'classnames'; | ||
import downSVG from '@plone/volto/icons/down.svg'; | ||
import upSVG from '@plone/volto/icons/up.svg'; | ||
import placeholderImage from './placeholder.png'; | ||
import './style.css'; | ||
|
||
const View = (props) => { | ||
const [activeItem, setActiveItem] = useState(1); | ||
const { page = '/', redirectPage = null, preview = false } = props.data || {}; | ||
const items = props.sparql_data[page]?.items || []; | ||
|
||
useEffect(() => { | ||
if (!props.sparql_data[page]) { | ||
props.getSparqlData(page); | ||
} | ||
/* eslint-disable-next-line */ | ||
}, []); | ||
|
||
const isVisible = (index) => { | ||
if (!preview) return true; | ||
if (activeItem === 0) { | ||
return index < 3; | ||
} else { | ||
return Math.abs(index - activeItem) < 2; | ||
} | ||
}; | ||
|
||
return ( | ||
<div className="articles-sparql"> | ||
{props.mode === 'edit' && !props.data.page ? ( | ||
<p>Select SPARQL data from sidebar</p> | ||
) : ( | ||
'' | ||
)} | ||
{props.mode === 'edit' && props.data.page && !items.length ? ( | ||
<p>There is no SPARQL data</p> | ||
) : ( | ||
'' | ||
)} | ||
{items.length ? ( | ||
<div className="grid-layout articles"> | ||
{items.map((item, index) => | ||
isVisible(index) ? ( | ||
<div | ||
className={cx( | ||
'row articles-row mb-1 sm-height-fit-content', | ||
index !== activeItem && preview ? 'can-be-half' : '', | ||
)} | ||
key={`sparql-row-${index}-${item.title}`} | ||
> | ||
<div className="column-4 sm-12 article hero pa-1"> | ||
<Image src={item.image || placeholderImage} /> | ||
</div> | ||
<div className="column-8 sm-12 article pa-1"> | ||
<div className="article-header"> | ||
<h3 className="mb-0">{item.title}</h3> | ||
</div> | ||
<div className="article-metadata mb-1"> | ||
<p className="info"> | ||
{moment(item.time).format('DD MMM YYYY')} | ||
</p> | ||
</div> | ||
<div className="article-description mb-1"> | ||
<p>{item.description}</p> | ||
</div> | ||
<div className="article-footer"> | ||
<a | ||
className="outline dark-blue display-inline-block" | ||
href={item.resource} | ||
target="_blank" | ||
rel="noreferrer" | ||
> | ||
READ ARTICLE | ||
</a> | ||
</div> | ||
</div> | ||
</div> | ||
) : ( | ||
'' | ||
), | ||
)} | ||
</div> | ||
) : ( | ||
'' | ||
)} | ||
{preview && redirectPage && items.length ? ( | ||
<Link | ||
className="solid dark-blue articles-redirect" | ||
as="a" | ||
to={redirectPage} | ||
title="READ MORE" | ||
> | ||
READ MORE | ||
</Link> | ||
) : ( | ||
'' | ||
)} | ||
{/* {items.length > 2 ? ( | ||
<div className="articles-slideshow"> | ||
{activeItem > 1 ? ( | ||
<Icon | ||
onClick={() => { | ||
setActiveItem(activeItem - 1); | ||
}} | ||
name={upSVG} | ||
size="24px" | ||
/> | ||
) : ( | ||
'' | ||
)} | ||
{activeItem < items.length - 1 ? ( | ||
<Icon | ||
onClick={() => { | ||
setActiveItem(activeItem + 1); | ||
}} | ||
name={downSVG} | ||
size="24px" | ||
/> | ||
) : ( | ||
'' | ||
)} | ||
</div> | ||
) : ( | ||
'' | ||
)} */} | ||
</div> | ||
); | ||
}; | ||
|
||
export default compose( | ||
connect( | ||
(state, props) => ({ | ||
sparql_data: state.sparql.items, | ||
}), | ||
{ getSparqlData }, | ||
), | ||
)(View); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,33 @@ | ||
export const getSchema = (props) => { | ||
return { | ||
title: 'Detailed Link', | ||
|
||
fieldsets: [ | ||
{ | ||
id: 'default', | ||
title: 'Default', | ||
fields: ['page', 'preview', 'redirectPage'], | ||
}, | ||
], | ||
|
||
properties: { | ||
page: { | ||
title: 'Page', | ||
widget: 'object_by_path', | ||
}, | ||
preview: { | ||
title: 'Preview', | ||
type: 'boolean', | ||
}, | ||
redirectPage: { | ||
title: 'Redirect page', | ||
widget: 'object_by_path', | ||
description: 'Applies if preview is selected', | ||
}, | ||
}, | ||
|
||
required: ['page'], | ||
}; | ||
}; | ||
|
||
export default getSchema; |
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,80 @@ | ||
.articles-sparql { | ||
position: relative; | ||
} | ||
|
||
.articles .articles-row { | ||
align-items: center; | ||
height: 250px; | ||
justify-content: center; | ||
} | ||
|
||
.articles .article { | ||
display: block; | ||
} | ||
|
||
.articles .articles-row.can-be-half:last-child { | ||
-webkit-mask-image: -webkit-gradient(linear, left top, | ||
left bottom, from(rgba(0,0,0,1)), to(rgba(0,0,0,0))); | ||
} | ||
.articles .articles-row.can-be-half:last-child .article { | ||
height: 50%; | ||
overflow: hidden; | ||
-webkit-mask-image: -webkit-gradient(linear, left top, | ||
left bottom, from(rgba(0,0,0,1)), to(rgba(0,0,0,0))); | ||
} | ||
|
||
.articles .article.hero img { | ||
border-radius: 2em; | ||
} | ||
|
||
.articles .article-header, | ||
.articles .article-description { | ||
display: block; | ||
position: relative; | ||
} | ||
|
||
.articles .article-header h3 { | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
display: -webkit-box; | ||
-webkit-box-orient: vertical; | ||
-webkit-line-clamp: 1; | ||
line-height: 1.5em; | ||
max-height: 1.5em; | ||
} | ||
|
||
.articles .article-description p { | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
display: -webkit-box; | ||
-webkit-box-orient: vertical; | ||
-webkit-line-clamp: 3; | ||
line-height: 1.5em; | ||
max-height: 4.5em; | ||
} | ||
|
||
.articles-slideshow { | ||
position: absolute; | ||
display: flex; | ||
flex-direction: column; | ||
top: 50%; | ||
right: 1em; | ||
transform: translateY(-50%); | ||
} | ||
|
||
.articles-slideshow .icon { | ||
cursor: pointer; | ||
} | ||
|
||
.articles-redirect { | ||
position: absolute; | ||
bottom: 7em; | ||
left: 50%; | ||
transform: translateX(-50%); | ||
} | ||
|
||
@media (min-width: 500px) and (max-width: 768px) { | ||
.sm-height-fit-content { | ||
height: fit-content !important; | ||
} | ||
} |
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
Oops, something went wrong.