Skip to content

Commit

Permalink
refactor(tags): Use Tag, TagsList from volto-eea-design-system
Browse files Browse the repository at this point in the history
  • Loading branch information
avoinea committed Mar 31, 2022
1 parent c39fd6b commit 0a239f9
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from 'react';
import cx from 'classnames';
import Tag from '@eeacms/volto-eea-design-system/ui/Tag/Tag';

export const TokenWidget = ({ value, children, className }) =>
value ? (
<span className={cx(className, 'token', 'widget')}>
{value.map((tag) => (
<Tag href={`http://search.apps.eea.europa.eu/?q=${tag}`} key={tag}>
{children ? children(tag) : tag}
</Tag>
))}
</span>
) : (
''
);
53 changes: 53 additions & 0 deletions src/customizations/volto/components/theme/Tags/Tags.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/**
* Tags component.
* @module components/theme/Tags/Tags
*/

import React from 'react';
import PropTypes from 'prop-types';
import TagList from '@eeacms/volto-eea-design-system/ui/TagList/TagList';
import Tag from '@eeacms/volto-eea-design-system/ui/Tag/Tag';
import { Container } from 'semantic-ui-react';

/**
* Tags component class.
* @function Tags
* @param {array} tags Array of tags.
* @returns {string} Markup of the component.
*/
const Tags = ({ tags }) =>
tags && tags.length > 0 ? (
<Container className="eea">
<TagList className="right">
<TagList.Content>
{tags.map((tag) => (
<Tag href={`http://search.apps.eea.europa.eu/?q=${tag}`} key={tag}>
{tag}
</Tag>
))}
</TagList.Content>
</TagList>
</Container>
) : (
''
);

/**
* Property types.
* @property {Object} propTypes Property types.
* @static
*/
Tags.propTypes = {
tags: PropTypes.arrayOf(PropTypes.string),
};

/**
* Default properties.
* @property {Object} defaultProps Default properties.
* @static
*/
Tags.defaultProps = {
tags: null,
};

export default Tags;

0 comments on commit 0a239f9

Please sign in to comment.