Merged in feature/SW-3245-move-jsontohtml (pull request #2661)
Feature/SW-3245 move jsontohtml * wip * Move JsonToHtml -> design-system * Fix semantic issues within Stories * replace imports of 'storybook/react-vite' with 'storybook/nextjs-vite' * merge Approved-by: Anton Gunnarsson
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
import { IconByIconName } from "@scandic-hotels/design-system/Icons/IconByIconName"
|
||||
import { JsonToHtml } from "@scandic-hotels/design-system/JsonToHtml"
|
||||
|
||||
import JsonToHtml from "@/components/JsonToHtml"
|
||||
|
||||
import { renderOptions } from "./renderOptions"
|
||||
import { getUspIconName } from "./utils"
|
||||
|
||||
import styles from "./uspgrid.module.css"
|
||||
@@ -27,7 +25,6 @@ export default function UspGrid({ usp_grid }: UspGridProps) {
|
||||
<JsonToHtml
|
||||
embeds={usp.text.embedded_itemsConnection?.edges}
|
||||
nodes={usp.text.json.children}
|
||||
renderOptions={renderOptions}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
import Link from "@scandic-hotels/design-system/Link"
|
||||
|
||||
import type { EmbedByUid } from "@/types/transitionTypes/jsontohtml"
|
||||
import { RTEItemTypeEnum, RTETypeEnum } from "@/types/transitionTypes/rte/enums"
|
||||
import type { RTENext, RTENode } from "@/types/transitionTypes/rte/node"
|
||||
import type { RenderOptions } from "@/types/transitionTypes/rte/option"
|
||||
|
||||
export const renderOptions: RenderOptions = {
|
||||
[RTETypeEnum.reference]: (
|
||||
node: RTENode,
|
||||
embeds: EmbedByUid,
|
||||
next: RTENext,
|
||||
fullRenderOptions: RenderOptions
|
||||
) => {
|
||||
if ("attrs" in node) {
|
||||
const type = node.attrs.type
|
||||
if (type !== RTEItemTypeEnum.asset) {
|
||||
const href = node.attrs?.locale
|
||||
? `/${node.attrs.locale}${node.attrs.href}`
|
||||
: node.attrs.href
|
||||
|
||||
return (
|
||||
<Link href={href} key={node.uid} textDecoration="underline">
|
||||
{next(node.children, embeds, fullRenderOptions)}
|
||||
</Link>
|
||||
)
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user