Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
avoinea committed May 31, 2022
1 parent 63b55e1 commit 7f8d80b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
[![Duplicated Lines (%)](https://sonarqube.eea.europa.eu/api/project_badges/measure?project=volto-call-to-action-block-develop&metric=duplicated_lines_density)](https://sonarqube.eea.europa.eu/dashboard?id=volto-call-to-action-block-develop)


[Volto](https://github.com/plone/volto) add-on
[Volto](https://github.com/plone/volto) Call to Action Block

## Features

Demo GIF
![Call to Action](https://github.com/eea/volto-call-to-action-block/raw/develop/docs/call-to-action.gif)

## Getting started

Expand Down
Binary file added docs/call-to-action.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 6 additions & 6 deletions src/components/Schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ const messages = defineMessages({
id: 'Call to Action',
defaultMessage: 'Call to Action',
},
Text: {
id: 'Text',
defaultMessage: 'Text',
Label: {
id: 'Label',
defaultMessage: 'Label',
},
Link: {
id: 'Link',
Expand Down Expand Up @@ -45,7 +45,7 @@ const messages = defineMessages({
id: 'Inverted',
defaultMessage: 'Inverted',
},
DefaultText: {
DefaultLabel: {
id: 'Click here',
defaultMessage: 'Click here',
},
Expand Down Expand Up @@ -84,8 +84,8 @@ export const EditSchema = ({ intl }) => ({

properties: {
text: {
title: intl.formatMessage(messages.Text),
default: intl.formatMessage(messages.DefaultText),
title: intl.formatMessage(messages.Label),
default: intl.formatMessage(messages.DefaultLabel),
},
href: {
title: intl.formatMessage(messages.Link),
Expand Down
10 changes: 7 additions & 3 deletions src/components/View.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React from 'react';
import { Icon } from 'semantic-ui-react';
import cx from 'classnames';
import { flattenToAppURL } from '@plone/volto/helpers';
import { Link } from 'react-router-dom';
import { flattenToAppURL, isInternalURL } from '@plone/volto/helpers';

const View = ({ data, isEditMode }) => {
const [hasLink, setHasLink] = React.useState(false);
Expand All @@ -21,9 +22,11 @@ const View = ({ data, isEditMode }) => {
}
}, [isEditMode, data.href]);

const As = hasLink && isInternalURL(data.href[0]['@id']) ? Link : 'a';

return (
<div className={cx('block button align', data.styles?.align)}>
<a
<As
className={cx(
data.styles?.theme !== 'link' ? 'ui button' : '',
data.styles?.inverted ? 'inverted' : '',
Expand All @@ -35,12 +38,13 @@ const View = ({ data, isEditMode }) => {
data.styles?.theme,
)}
href={hasLink ? flattenToAppURL(data.href[0]['@id']) : null}
to={hasLink ? flattenToAppURL(data.href[0]['@id']) : null}
title={hasLink ? data.href[0]['title'] : ''}
target={data.target}
>
{data.styles?.icon && <Icon className={data.styles?.icon} />}
{data.text}
</a>
</As>
</div>
);
};
Expand Down

0 comments on commit 7f8d80b

Please sign in to comment.