diff --git a/.gitignore b/.gitignore index 57404005b31..86546b875a0 100644 --- a/.gitignore +++ b/.gitignore @@ -21,6 +21,7 @@ DerivedData *.ipa *.xcuserstate project.xcworkspace +.gradle # node.js # diff --git a/packages/markup/fixtures/link.json b/packages/markup/fixtures/link.json new file mode 100644 index 00000000000..abd7f1b382e --- /dev/null +++ b/packages/markup/fixtures/link.json @@ -0,0 +1,91 @@ +{ + "name": "paragraph", + "children": [ + { + "name": "text", + "children": [], + "attributes": { + "value": "Before they became one of the bestselling pop groups in history Abba had to deal with the complaints of a canned fish company that shared their name. Mercifully the " + } + }, + { + "name": "link", + "children": [ + { + "name": "text", + "children": [], + "attributes": { + "value": "firm" + } + } + ], + "attributes": { + "href": "https://www.thetimes.com/culture/music" + } + }, + { + "name": "text", + "children": [], + "attributes": { + "value": " relented and the band broke through in 1974 after winning the Eurovision Song Contest with " + } + }, + { + "name": "emphasis", + "children": [ + { + "name": "text", + "children": [], + "attributes": { + "value": "Waterloo" + } + } + ] + }, + { + "name": "text", + "children": [], + "attributes": { + "value": ". Comprising two married couples, the Swedish group scored more than a dozen No 1s across the world and have the second highest-selling album in Britain, the compilation " + } + }, + { + "name": "emphasis", + "children": [ + { + "name": "text", + "children": [], + "attributes": { + "value": "Gold" + } + } + ] + }, + { + "name": "text", + "children": [], + "attributes": { + "value": ". They split in 1982 after their marriages collapsed but reformed in 2021 for an album and holographic stage show called " + } + }, + { + "name": "emphasis", + "children": [ + { + "name": "text", + "children": [], + "attributes": { + "value": "Voyage" + } + } + ] + }, + { + "name": "text", + "children": [], + "attributes": { + "value": "." + } + } + ] +} diff --git a/packages/markup/markup.showcase.js b/packages/markup/markup.showcase.js index 6e0babdb0e1..6ce42ff9e4a 100644 --- a/packages/markup/markup.showcase.js +++ b/packages/markup/markup.showcase.js @@ -1,7 +1,7 @@ /* eslint-disable react/no-array-index-key */ /* eslint-env browser */ import React from "react"; -import { TcText, TcView } from "@times-components/utils"; +import { TcText, TcTextLink, TcView } from "@times-components/utils"; import { CenteredDecorator } from "@times-components/storybook"; import { fontsWithFallback } from "@times-components/ts-styleguide"; import renderTrees, { renderTree } from "@times-components/markup-forest"; @@ -13,6 +13,7 @@ const bio = require("./fixtures/bio.json"); const ratings = require("./fixtures/ratings.json"); const subscript = require("./fixtures/multiple-subscripts.json"); const superscript = require("./fixtures/multiple-superscripts.json"); +const link = [require("./fixtures/link.json")]; export default { children: [ @@ -33,18 +34,15 @@ export default { renderTree(mixture, { ...coreRenderers, block(key, attributes, renderedChildren) { - return { - element: {renderedChildren} - }; + return {renderedChildren}; }, link(key, attributes, renderedChildren) { - return { - element: ( - - {renderedChildren} - - ) - }; + const { href: url } = attributes; + return ( + + {renderedChildren} + + ); } }), name: "Mixture of tags", @@ -55,6 +53,11 @@ export default { name: "Biography", type: "story" }, + { + component: () => {renderTrees(link, coreRenderers)}, + name: "Link", + type: "story" + }, { component: () => {renderTrees(ratings, coreRenderers)}, name: "Ratings", @@ -78,20 +81,18 @@ export default { {renderTrees(multiParagraph, { ...coreRenderers, paragraph(key, attributes, children) { - return { - element: ( - - {children} - - ) - }; + return ( + + {children} + + ); } })} diff --git a/packages/markup/src/markup.js b/packages/markup/src/markup.js index 0a609a98f54..90c4dcf4ee2 100644 --- a/packages/markup/src/markup.js +++ b/packages/markup/src/markup.js @@ -31,6 +31,13 @@ export default { superscript(key, attributes, renderedChildren) { return {renderedChildren}; }, + link(key, attributes, renderedChildren) { + return ( + + {renderedChildren} + + ); + }, text(key, { value }) { return value; }