-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optional Event Information and Simplified UI #29
base: main
Are you sure you want to change the base?
Changes from 9 commits
efdf29a
90e9cf0
6a64e8e
4158868
9b12fd1
cf1437d
61f3e6b
e37f8b3
d25cbd5
1e1d285
4359591
05085df
14c85f2
e1db8b3
c8d53f1
e8759d8
e43504d
b205a60
47f3285
45b4ee3
50b66a5
773ab13
56c64eb
631c08d
646269b
242acfc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,32 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { ConditionalLink } from '@plone/volto/components'; | ||
import { flattenToAppURL } from '@plone/volto/helpers'; | ||
import {ConditionalLink} from '@plone/volto/components'; | ||
import {flattenToAppURL} from '@plone/volto/helpers'; | ||
|
||
import DefaultImageSVG from '@plone/volto/components/manage/Blocks/Listing/default-image.svg'; | ||
import { isInternalURL } from '@plone/volto/helpers/Url/Url'; | ||
import { Grid, Image } from 'semantic-ui-react'; | ||
import {isInternalURL} from '@plone/volto/helpers/Url/Url'; | ||
import {Grid, Image} from 'semantic-ui-react'; | ||
import moment from 'moment'; | ||
import { useIntl } from 'react-intl'; | ||
import {useIntl} from 'react-intl'; | ||
|
||
const AdvancedListingBlockTemplate = ({ | ||
items, | ||
moreLinkText, | ||
moreLinkUrl, | ||
header, | ||
headerUrl, | ||
headerTag, | ||
isEditMode, | ||
imageSide, | ||
imageWidth, | ||
howManyColumns, | ||
effectiveDate, | ||
titleTag, | ||
showDescription, | ||
}) => { | ||
items, | ||
moreLinkText, | ||
moreLinkUrl, | ||
header, | ||
headerUrl, | ||
headerTag, | ||
isEditMode, | ||
imageSide, | ||
imageWidth, | ||
howManyColumns, | ||
effectiveDate, | ||
titleTag, | ||
showDescription, | ||
eventDate, | ||
eventLocation, | ||
eventTime | ||
}) => { | ||
let moreLink = null; | ||
let moreHref = moreLinkUrl?.[0]?.['@id'] || ''; | ||
if (isInternalURL(moreHref)) { | ||
|
@@ -46,16 +50,58 @@ const AdvancedListingBlockTemplate = ({ | |
} else if (headerHref) { | ||
moreLink = <a href={headerHref}>{moreLinkText || headerHref}</a>; | ||
} | ||
const getEventDate = (item) => { | ||
let start = '', | ||
end = ''; | ||
|
||
if (item.start) { | ||
const parsedDate = new Date(Date.parse(item.start)); | ||
start = `${parsedDate.toLocaleString('default', { | ||
month: 'short', | ||
})} ${parsedDate.getDate()}, ${parsedDate.getFullYear()}`; | ||
} | ||
|
||
if (item.end) { | ||
const parsedDate = new Date(Date.parse(item.end)); | ||
end = `${parsedDate.toLocaleString('default', { | ||
month: 'short', | ||
})} ${parsedDate.getDate()}, ${parsedDate.getFullYear()}`; | ||
} | ||
if (end == start) {return start} | ||
else {return start + ' - ' + end;}; | ||
}; | ||
const getEventTime = (item) => { | ||
let start = '', | ||
end = ''; | ||
|
||
if (item.start) { | ||
const parsedDate = new Date(Date.parse(item.start)); | ||
start = `${parsedDate.toLocaleString( | ||
'en-US', | ||
{hour: 'numeric', minute: 'numeric', hour12: true}, | ||
)}`; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be done in some generic way, not to be attached to en-US locale always. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. changed locales to 'default' instead of 'en-US' |
||
} | ||
|
||
if (item.end) { | ||
const parsedDate = new Date(Date.parse(item.end)); | ||
end = ` - ${parsedDate.toLocaleString('en-US', { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. idem. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. changed locales to default instead of 'en-US' |
||
hour: 'numeric', | ||
minute: 'numeric', | ||
hour12: true, | ||
})}`; | ||
} | ||
|
||
return start + end; | ||
}; | ||
const hasImage = imageSide !== null; | ||
const oneColumnElement = ['up', 'down', null].includes(imageSide); | ||
const columnSize = oneColumnElement ? 1 : 2; | ||
const imageGridWidth = oneColumnElement ? 12 : imageWidth ? imageWidth : 2; | ||
const contentGridWidth = oneColumnElement | ||
? 12 | ||
: hasImage | ||
? 12 - imageWidth | ||
: 12; | ||
? 12 - imageWidth | ||
: 12; | ||
const intl = useIntl(); | ||
const TitleTag = titleTag ? titleTag : 'h3'; | ||
const HeaderTag = headerTag ? headerTag : 'h3'; | ||
|
@@ -99,10 +145,15 @@ const AdvancedListingBlockTemplate = ({ | |
{item.title ? item.title : item.id} | ||
</ConditionalLink> | ||
</TitleTag> | ||
{eventDate|eventTime && <p class="event-when">{eventDate && <span className="start-date">{getEventDate(item)}</span>} | ||
{eventTime && eventDate && <span> | </span>} | ||
{eventTime && <span className="start-time">{getEventTime(item)}</span>}</p>||null} | ||
{eventLocation && <p>{item.location}</p>} | ||
{effectiveDate && <p>{moment(item.effective).format('L')}</p>} | ||
{showDescription && item.description && ( | ||
<p>{item.description}</p> | ||
)} | ||
|
||
</Grid.Column> | ||
{['right', 'down'].includes(imageSide) && ( | ||
<Grid.Column width={imageGridWidth}> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do not modify the CHANGELOG file please, we handle this auth auto-changelog. Group your commits with prefixes like: "feat: Optional Event Date", "fix: simplified field labels", etc.