Skip to content
This repository was archived by the owner on Aug 13, 2023. It is now read-only.

Commit d060eec

Browse files
author
HarryVerhoef
authored
Merge pull request #4500 from bbc/add-topic-tag-onclick
Forward onClick to anchor in TopicTag
2 parents 72b0137 + 51d4e8f commit d060eec

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

packages/components/psammead-topic-tags/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
| Version | Description |
44
|---------|-------------|
5+
| 0.1.0-alpha.9 | [PR#4500](https://github.com/bbc/psammead/pull/4500) Forward onClick to anchor on TopicTag |
56
| 0.1.0-alpha.8 | [PR#4497](https://github.com/bbc/psammead/pull/4497) Bump psammead-styles |
67
| 0.1.0-alpha.7 | [PR#4496](https://github.com/bbc/psammead/pull/4496) Forward ref in TopicTag and check single child type |
78
| 0.1.0-alpha.6 | [PR#4486](https://github.com/bbc/psammead/pull/4486) upgrade minor/patch dependencies |

packages/components/psammead-topic-tags/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@bbc/psammead-topic-tags",
3-
"version": "0.1.0-alpha.8",
3+
"version": "0.1.0-alpha.9",
44
"main": "dist/index.js",
55
"module": "esm/index.js",
66
"sideEffects": false,

packages/components/psammead-topic-tags/src/index.jsx

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { forwardRef } from 'react';
2-
import { string, shape, node } from 'prop-types';
2+
import { string, shape, node, func } from 'prop-types';
33
import styled from '@emotion/styled';
44
import { C_LUNAR, C_EBON, C_METAL } from '@bbc/psammead-styles/colours';
55
import {
@@ -57,8 +57,8 @@ const SingleTopicTagItem = styled.div`
5757
}
5858
`;
5959

60-
export const TopicTag = forwardRef(({ name, link }, ref) => (
61-
<a href={link} ref={ref}>
60+
export const TopicTag = forwardRef(({ name, link, onClick }, ref) => (
61+
<a href={link} onClick={onClick} ref={ref}>
6262
{name}
6363
</a>
6464
));
@@ -100,8 +100,11 @@ export const TopicTags = ({ children, script, service }) => {
100100
TopicTag.propTypes = {
101101
name: string.isRequired,
102102
link: string.isRequired,
103+
onClick: func,
103104
};
104105

106+
TopicTag.defaultProps = { onClick: null };
107+
105108
TopicTags.propTypes = {
106109
children: node,
107110
script: shape(scriptPropType).isRequired,

0 commit comments

Comments
 (0)