Skip to content

Commit

Permalink
remove duplicated code
Browse files Browse the repository at this point in the history
  • Loading branch information
ionlizarazu committed Jan 2, 2025
1 parent db48fde commit a1f98a9
Show file tree
Hide file tree
Showing 11 changed files with 5,176 additions and 1,141 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import React from 'react';
import { Button } from 'semantic-ui-react';
import { ConditionalLink } from '@plone/volto/components';

export const BannerFeaturedView = (props) => {
const { data, isEditMode } = props;
return (
<div
className="banner-top-main"
style={{
backgroundImage: `url(${data?.url}/@@images/image)`,
}}
>
<div className="banner-top-main-block-title">
{data.title && (
<h2>
<ConditionalLink
to={data?.href?.[0]?.['@id']}
condition={!isEditMode}
>
{data?.title}
</ConditionalLink>
</h2>
)}
{data.description && <h3>{data?.description} </h3>}
{data.hrefText && (
<Button
as="a"
size="large"
href={'' + data?.link?.[0]?.['@id']}
primary
>
{data.hrefText}
</Button>
)}
</div>
</div>
);
};

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
import { ConditionalLink } from '@plone/volto/components';
import { Button, GridRow, GridColumn, Grid } from 'semantic-ui-react';
import config from '@plone/volto/registry';
import { LEFT, RIGHT } from '../constants';
import { TextBlockView } from '@plone/volto-slate/blocks/Text';
import { DetachedTextBlockEditor } from '@plone/volto-slate/blocks/Text/DetachedTextBlockEditor';
import DefaultImageSVG from '@plone/volto/components/manage/Blocks/Listing/default-image.svg';

export const FeaturedBaseView = (props) => {
const { data, isEditMode, imagePosition, richText } = props;
let Image = config.getComponent('Image').component;
return (
<Grid divided="vertically">
<GridRow>
{imagePosition === LEFT && (
<GridColumn width="6">
{data?.url?.length > 0 ? (
<Image
item={{
'@id': data.url,
image_field: data.image_field,
image_scales: data.image_scales,
}}
alt={data.title}
sizes="50vw"
responsive={true}
/>
) : isEditMode ? (
<img
src={
config.getComponent({
name: 'DefaultImage',
dependencies: ['listing', 'summary'],
}).component || DefaultImageSVG
}
alt={''}
width="400"
height="300"
/>
) : (
''
)}
</GridColumn>
)}
<GridColumn width="6">
<div className="featured-block-item-content">
<div className="featured-block-item-content-title">
{data?.title && (
<h2>
<ConditionalLink
condition={!isEditMode}
to={data?.href?.[0]?.['@id']}
>
{data?.title}
</ConditionalLink>
</h2>
)}
</div>
<div className="featured-block-item-content-description">
{data?.description && <h3>{data.description} </h3>}
</div>
{richText && (
<div className="featured-block-item-content-value">
{isEditMode ? (
<DetachedTextBlockEditor {...props} />
) : (
<TextBlockView {...props} />
)}
</div>
)}
<div className="featured-block-item-content-link">
{data?.hrefText && (
<Button
as="a"
size="large"
href={!isEditMode ? data?.href?.[0]?.['@id'] : null}
primary
>
{data.hrefText}
</Button>
)}
</div>
</div>
</GridColumn>
{imagePosition === RIGHT && (
<GridColumn width="6">
{data?.url?.length > 0 ? (
<Image
item={{
'@id': data.url,
image_field: data.image_field,
image_scales: data.image_scales,
}}
alt={data.title}
sizes="50vw"
responsive={true}
/>
) : isEditMode ? (
<img
src={
config.getComponent({
name: 'DefaultImage',
dependencies: ['listing', 'summary'],
}).component || DefaultImageSVG
}
alt={''}
width="400"
height="300"
/>
) : (
''
)}
</GridColumn>
)}
</GridRow>
</Grid>
);
};
Original file line number Diff line number Diff line change
@@ -1,56 +1,5 @@
import ConditionalLink from '@plone/volto/components/manage/ConditionalLink/ConditionalLink';

import { Button, GridRow, GridColumn, Grid } from 'semantic-ui-react';
import config from '@plone/volto/registry';
import { FeaturedBaseView } from './FeaturedBaseView';
import { LEFT } from '../constants';
export const FeaturedViewImageLeft = (props) => {
const { data } = props;
let Image = config.getComponent('Image').component;
return (
<Grid divided="vertically">
<GridRow>
<GridColumn width="6">
{data?.url?.length > 0 && (
<Image
item={{
'@id': data.url,
image_field: data.image_field,
image_scales: data.image_scales,
}}
alt=""
sizes="50vw"
responsive={true}
/>
)}
</GridColumn>
<GridColumn width="6">
<div className="featured-block-item-content">
<div className="featured-block-item-content-title">
{data?.title && (
<h2>
<ConditionalLink to={data?.href?.[0]?.['@id']}>
{data?.title}
</ConditionalLink>
</h2>
)}
</div>
<div className="featured-block-item-content-description">
{data?.description && <h3>{data.description} </h3>}
</div>
<div className="featured-block-item-content-link">
{data?.hrefText && (
<Button
as="a"
size="large"
href={'' + data?.href?.[0]?.['@id']}
primary
>
{data.hrefText}
</Button>
)}
</div>
</div>
</GridColumn>
</GridRow>
</Grid>
);
return <FeaturedBaseView {...props} imagePosition={LEFT} />;
};
Original file line number Diff line number Diff line change
@@ -1,67 +1,5 @@
import { TextBlockView } from '@plone/volto-slate/blocks/Text';
import { DetachedTextBlockEditor } from '@plone/volto-slate/blocks/Text/DetachedTextBlockEditor';
import ConditionalLink from '@plone/volto/components/manage/ConditionalLink/ConditionalLink';
import config from '@plone/volto/registry';
import { Button, Grid, GridColumn, GridRow } from 'semantic-ui-react';
import { FeaturedBaseView } from './FeaturedBaseView';
import { LEFT } from '../constants';
export const FeaturedViewImageLeftRichText = (props) => {
const { data, isEditMode } = props;
let Image = config.getComponent('Image').component;
return (
<Grid divided="vertically">
<GridRow>
<GridColumn width="6">
{data?.url?.length > 0 && (
<Image
item={{
'@id': data.url,
image_field: data.image_field,
image_scales: data.image_scales,
}}
alt=""
sizes="50vw"
responsive={true}
/>
)}
</GridColumn>
<GridColumn width="6">
<div className="featured-block-item-content">
{data?.title && (
<div className="featured-block-item-content-title">
<h2>
<ConditionalLink to={data?.href?.[0]?.['@id']}>
{data?.title}
</ConditionalLink>
</h2>
</div>
)}
{data?.description && (
<div className="featured-block-item-content-description">
{data?.description && <h3>{data.description} </h3>}
</div>
)}
<div className="featured-block-item-content-value">
{isEditMode ? (
<DetachedTextBlockEditor {...props} />
) : (
<TextBlockView {...props} />
)}
</div>

{data?.hrefText && (
<div className="featured-block-item-content-link">
<Button
as="a"
size="large"
href={'' + data?.href?.[0]?.['@id']}
primary
>
{data.hrefText}
</Button>
</div>
)}
</div>
</GridColumn>
</GridRow>
</Grid>
);
return <FeaturedBaseView {...props} imagePosition={LEFT} richText={true} />
};
Original file line number Diff line number Diff line change
@@ -1,55 +1,5 @@
import ConditionalLink from '@plone/volto/components/manage/ConditionalLink/ConditionalLink';
import config from '@plone/volto/registry';
import { Button, Grid, GridColumn, GridRow } from 'semantic-ui-react';
import { FeaturedBaseView } from './FeaturedBaseView';
import { RIGHT } from '../constants';
export const FeaturedViewImageRight = (props) => {
const { data } = props;
let Image = config.getComponent('Image').component;
return (
<Grid divided="vertically">
<GridRow>
<GridColumn width="6">
<div className="featured-block-item-content">
<div className="featured-block-item-content-title">
{data?.title && (
<h2>
<ConditionalLink to={data?.href?.[0]?.['@id']}>
{data?.title}
</ConditionalLink>
</h2>
)}
</div>
<div className="featured-block-item-content-description">
{data?.description && <h3>{data.description} </h3>}
</div>
<div className="featured-block-item-content-link">
{data?.hrefText && (
<Button
as="a"
size="large"
href={'' + data?.href?.[0]?.['@id']}
primary
>
{data.hrefText}
</Button>
)}
</div>
</div>
</GridColumn>
<GridColumn width="6">
{data?.url?.length > 0 && (
<Image
item={{
'@id': data.url,
image_field: data.image_field,
image_scales: data.image_scales,
}}
alt=""
sizes="50vw"
responsive={true}
/>
)}
</GridColumn>
</GridRow>
</Grid>
);
return <FeaturedBaseView {...props} imagePosition={RIGHT} />
};
Loading

0 comments on commit a1f98a9

Please sign in to comment.