Skip to content
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

Open
wants to merge 26 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
efdf29a
Update AdvancedListingBlockTemplate.jsx
rnunez80 Oct 24, 2022
90e9cf0
Update advancedSchema.js
rnunez80 Oct 24, 2022
6a64e8e
Update messages.js
rnunez80 Oct 24, 2022
4158868
Update README.md
rnunez80 Oct 24, 2022
9b12fd1
Update CHANGELOG.md
rnunez80 Oct 24, 2022
cf1437d
Update CHANGELOG.md
rnunez80 Oct 24, 2022
61f3e6b
Add files via upload
rnunez80 Oct 24, 2022
e37f8b3
Update README.md
rnunez80 Oct 24, 2022
d25cbd5
Update advancedSchema.js
rnunez80 Oct 24, 2022
1e1d285
Update AdvancedListingBlockTemplate.jsx
rnunez80 Oct 26, 2022
4359591
Update CHANGELOG.md
rnunez80 Oct 26, 2022
05085df
Delete Screenshot 2022-10-24 at 12.28.49 PM.png
rnunez80 Oct 26, 2022
14c85f2
Add files via upload
rnunez80 Oct 26, 2022
e1db8b3
image styles
rnunez80 Nov 26, 2022
c8d53f1
added class to image and Image placeholder
rnunez80 Nov 29, 2022
e8759d8
background image listing
rnunez80 Nov 30, 2022
e43504d
corrected 'It looks like there is a mistake in the srcset attribute. …
rnunez80 Dec 3, 2022
b205a60
prin class
rnunez80 Dec 7, 2022
47f3285
listing working properly, carousel needs work
rnunez80 Dec 10, 2022
45b4ee3
slider working, needs more option and adjust width when editing
rnunez80 Dec 10, 2022
50b66a5
Slider working with options, styles needs refinement
rnunez80 Dec 12, 2022
773ab13
refined styles to make sure it display properly
rnunez80 Dec 13, 2022
56c64eb
pixel perfect
rnunez80 Dec 14, 2022
631c08d
event card added as option
rnunez80 Dec 14, 2022
646269b
limit number of lines in background item
rnunez80 Dec 14, 2022
242acfc
limit number of lines in background item
rnunez80 Dec 16, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,18 @@

All notable changes to this project will be documented in this file. Dates are displayed in UTC.

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

#### [0.10.1]

> 24 October 2022

- Optional Event Date (End dates shows if different from Start Date)
- Optional Event Time (Separator show if both date and time are selected)
- Optional Event Location
- Simplified Block side menu to reduce the number of collapsible accordions
- Simplified fields labels
- Move Heading information to the same location as default variants

Copy link
Member

@erral erral Oct 25, 2022

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.


#### [0.10.0](https://github.com/codesyntax/volto-listingadvanced-variation/compare/0.9.0...0.10.0)

Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,17 @@ Volto addon to add an additional variation to the default listing block with adv

This add-on adds a fully customizable variation to the default listing block. It adds the following features:

- Select the number of columns in which the content will be shown
- Select to show the image of the item or not
- Select the position of the image in the item card
- Select the size of the card (to build mosaic-like listings)
- An option to select to show the description
- An option to select to show the publication date
- Select the number of columns in which the content will be shown
- An option to select to show the event date
- An option to select to show the event time
- An option to select to show the event location

![volto-listingadvanced-variation block details](https://github.com/rnunez80/volto-listingadvanced-variation/blob/main/Screenshot%202022-10-24%20at%2012.28.49%20PM.png?raw=true)

Installation:

Expand Down
Binary file added Screenshot 2022-10-24 at 12.28.49 PM.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
93 changes: 72 additions & 21 deletions src/AdvancedListingBlockTemplate.jsx
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)) {
Expand All @@ -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},
)}`;
Copy link
Member

@erral erral Oct 25, 2022

Choose a reason for hiding this comment

The 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.

Copy link
Author

Choose a reason for hiding this comment

The 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', {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idem.

Copy link
Author

Choose a reason for hiding this comment

The 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';
Expand Down Expand Up @@ -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}>
Expand Down
92 changes: 30 additions & 62 deletions src/advancedSchema.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import messages from './messages';

export const advancedSchema = (props) => {
const { intl, schema, formData } = props;
const imageWidth = ['right', 'left'].includes(formData.imageSide)
? ['imageWidth']
: [];
const {intl, schema, formData} = props;
// const imageWidth = ['right', 'left'].includes(formData.imageSide)
// ? ['imageWidth']
// : [];
const headingChoices = [
['h2', 'H2'],
['h3', 'H3'],
Expand All @@ -13,45 +13,21 @@ export const advancedSchema = (props) => {
return {
...schema,
fieldsets: [
...schema.fieldsets,
// {
// id: 'default',
// title: 'Default',
// fields: ['variation', 'headline', 'headlineTag'],
// },
// {
// id: 'querystring',
// title: intl.formatMessage(messages.querystring),
// fields: ['querystring'],
// },
{
id: 'default',
title: 'Default',
fields: ['variation'],
},
{
id: 'querystring',
title: intl.formatMessage(messages.querystring),
fields: ['querystring'],
},
{
id: 'header',
title: intl.formatMessage(messages.headerConfiguration),
fields: ['header', 'headerUrl', 'headerTag'],
},
{
id: 'columns',
title: intl.formatMessage(messages.columnsConfiguration),
fields: ['howManyColumns'],
},
{
id: 'image',
title: intl.formatMessage(messages.imageConfiguration),
fields: ['imageSide', ...imageWidth],
},
{
id: 'title',
title: intl.formatMessage(messages.titleConfiguration),
fields: ['titleTag'],
},
{
id: 'description',
title: intl.formatMessage(messages.descriptionConfiguration),
fields: ['showDescription'],
},
{
id: 'date',
title: intl.formatMessage(messages.dateConfiguration),
fields: ['effectiveDate'],
id: 'display',
title: intl.formatMessage(messages.itemDisplayOptions),
fields: ['howManyColumns', 'imageSide', 'imageWidth', 'titleTag', 'showDescription', 'effectiveDate', 'eventDate', 'eventTime', 'eventLocation'],
},
{
id: 'moreLink',
Expand All @@ -61,22 +37,6 @@ export const advancedSchema = (props) => {
],
properties: {
...schema.properties,
header: {
title: intl.formatMessage(messages.header),
description: intl.formatMessage(messages.headerDescription),
},
headerUrl: {
title: intl.formatMessage(messages.headerUrl),
description: intl.formatMessage(messages.headerUrlDescription),
widget: 'object_browser',
mode: 'link',
allowExternals: true,
},
headerTag: {
title: intl.formatMessage(messages.headerTag),
description: intl.formatMessage(messages.headerTagDescription),
choices: [['h1', 'H1'], ...headingChoices],
},
howManyColumns: {
title: intl.formatMessage(messages.columnsCount),
choices: [
Expand All @@ -99,7 +59,6 @@ export const advancedSchema = (props) => {
},
imageSide: {
title: intl.formatMessage(messages.imagePosition),
description: intl.formatMessage(messages.imagePositionDescription),
choices: [
[null, 'No image'],
['up', 'up'],
Expand All @@ -110,18 +69,27 @@ export const advancedSchema = (props) => {
},
titleTag: {
title: intl.formatMessage(messages.titleTag),
description: intl.formatMessage(messages.titleTagDescription),
choices: headingChoices,
},
showDescription: {
title: intl.formatMessage(messages.descriptionTitle),
description: intl.formatMessage(messages.descriptionDescription),
type: 'boolean',
default: true,
},
effectiveDate: {
title: intl.formatMessage(messages.date),
description: intl.formatMessage(messages.dateDescription),
type: 'boolean',
},
eventDate: {
title: intl.formatMessage(messages.eventDate),
type: 'boolean',
},
eventTime: {
title: intl.formatMessage(messages.eventTime),
type: 'boolean',
},
eventLocation: {
title: intl.formatMessage(messages.eventLocation),
type: 'boolean',
},
moreLinkText: {
Expand Down
Loading