Skip to content

Commit 4ed5503

Browse files
♻️ 💸 Tech Debt Refactor – Converting the Product Tour into a (super cool) Reusable Component (tinacms#2672)
* moving the product tour page into a re-usable component * wiring up the new component and removing old code * completing card grid work in another branch * removing console logs and other cleanup * checking for ref unmount to avoid errors on redirect with scroll behaviour * fixing an issue where the initial rendering height for the image was above the content window * lockfile * rectifying weird scroll behaviour and also pointer event illusions
1 parent eb08996 commit 4ed5503

File tree

10 files changed

+680
-462
lines changed

10 files changed

+680
-462
lines changed

components/tinaMarkdownComponents/docAndBlogComponents.tsx

+19-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { CardGrid } from 'components/blocks/CardGrid';
22
import RecipeBlock from 'components/blocks/Recipe';
33
import { GraphQLQueryResponseTabs } from 'components/ui/GraphQLQueryResponseTabs';
4+
import dynamic from 'next/dynamic';
45
import Image from 'next/image';
56
import { useState } from 'react';
67
import { BiRightArrowAlt } from 'react-icons/bi';
@@ -10,6 +11,12 @@ import { Components, TinaMarkdown } from 'tinacms/dist/rich-text';
1011
import { getDocId } from 'utils/docs/getDocIds';
1112
import { WarningCallout } from 'utils/shortcodes';
1213
import { Prism } from '../styles/Prism';
14+
const ScrollBasedShowcase = dynamic(
15+
() => import('./templateComponents/scrollBasedShowcase'),
16+
{
17+
ssr: false,
18+
}
19+
);
1320

1421
export const docAndBlogComponents: Components<{
1522
Iframe: { iframeSrc: string; height: string };
@@ -47,6 +54,14 @@ export const docAndBlogComponents: Components<{
4754
codeLineEnd?: number;
4855
}[];
4956
};
57+
scrollBasedShowcase: {
58+
showcaseItems: {
59+
image: string;
60+
title: string;
61+
useAsSubsection: boolean;
62+
content: string;
63+
}[];
64+
};
5065
cardGrid: {
5166
cards: {
5267
title: string;
@@ -56,6 +71,9 @@ export const docAndBlogComponents: Components<{
5671
}[];
5772
};
5873
}> = {
74+
scrollBasedShowcase: (props) => {
75+
return <ScrollBasedShowcase showcaseItems={props.showcaseItems} />;
76+
},
5977
cardGrid: (props) => {
6078
return <CardGrid props={props} />;
6179
},
@@ -356,7 +374,7 @@ export const docAndBlogComponents: Components<{
356374
function FormatHeaders({ children, level }) {
357375
const HeadingTag = `h${level}` as any;
358376
const id = getDocId(
359-
children.props.content.map((content) => content.text).join('')
377+
children.props?.content.map((content) => content.text).join('') ?? children
360378
);
361379

362380
const currentUrl =
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import { Template } from 'tinacms';
2+
3+
const ScrollBasedShowcase: Template = {
4+
label: 'Scroll Based Showcase',
5+
name: 'scrollBasedShowcase',
6+
fields: [
7+
{
8+
type: 'object',
9+
label: 'Showcase Items',
10+
name: 'showcaseItems',
11+
list: true,
12+
ui: {
13+
defaultItem: {
14+
title: 'Title',
15+
image: '/img/placeholder.png',
16+
content: {
17+
type: 'root',
18+
children: [
19+
{
20+
type: 'p',
21+
children: [
22+
{
23+
type: 'text',
24+
text: 'Default Text. Edit me!',
25+
},
26+
],
27+
},
28+
],
29+
},
30+
useAsSubsection: false,
31+
},
32+
itemProps: (item) => {
33+
return {
34+
label: item.title,
35+
};
36+
},
37+
},
38+
fields: [
39+
{
40+
type: 'image',
41+
label: 'Image',
42+
name: 'image',
43+
},
44+
{
45+
type: 'string',
46+
label: 'Title',
47+
name: 'title',
48+
},
49+
{
50+
type: 'boolean',
51+
label: 'Use as Subsection',
52+
name: 'useAsSubsection',
53+
},
54+
{
55+
type: 'rich-text',
56+
label: 'Content',
57+
name: 'content',
58+
},
59+
],
60+
},
61+
],
62+
};
63+
64+
export default ScrollBasedShowcase;

0 commit comments

Comments
 (0)