From d609a0ed3874408a09e65104dede61a7ddc7cea7 Mon Sep 17 00:00:00 2001 From: Tobias Drisch Date: Tue, 24 Oct 2023 16:16:06 +0200 Subject: [PATCH 1/4] fixed double appearances of demo buttons --- src/components/DemoContextProvider.js | 31 +++++++++++++++++++-------- src/components/StoryDetailView.js | 10 ++++----- 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/src/components/DemoContextProvider.js b/src/components/DemoContextProvider.js index 5a56d52..4e6ef14 100644 --- a/src/components/DemoContextProvider.js +++ b/src/components/DemoContextProvider.js @@ -65,6 +65,13 @@ const DemoContextProvider = ({ children }) => { /** * enrich storybook mc_meta.json data with thumbnail URL and demo URLs from stories.json */ + + /* +componentData.stories.push(_storyData.filter((el) => { +return (el.name === 'Catalogue Demo'); +})); +*/ + const applyStorybookDataToMcMeta = ({ componentData, storybookData, @@ -73,17 +80,23 @@ const DemoContextProvider = ({ children }) => { }) => { for (var storyId in storybookData.stories) { let _storyData = storybookData.stories[storyId]; + console.log(_storyData); let _compName = _storyData.kind.split("/"); if (typeof _compName[1] !== "undefined" && _compName[1] === compId) { - componentData.stories.push(_storyData); - componentData.url = url; - componentData.demos ||= []; - componentData.demos.push({ - name: _storyData.name === "Example Config" ? "demo" : _storyData.name, - url: url + "/iframe.html?id=" + _storyData.id + "&viewMode=story", - id: _storyData.id, - }); - componentData.thumbnail = url + "/thumbnails/" + _compName[1] + ".png"; + if ( + _storyData.name === "Catalogue Demo" || + _storyData.name === "Example Config" + ) { + componentData.url = url; + componentData.demos ||= []; + componentData.demos.push({ + name: "demo", + url: url + "/iframe.html?id=" + _storyData.id + "&viewMode=story", + id: _storyData.id, + }); + componentData.thumbnail = + url + "/thumbnails/" + _compName[1] + ".png"; + } } } return componentData; diff --git a/src/components/StoryDetailView.js b/src/components/StoryDetailView.js index e993286..6d0e313 100644 --- a/src/components/StoryDetailView.js +++ b/src/components/StoryDetailView.js @@ -105,6 +105,8 @@ function StoryDetailView(props) { fetchDescription(); }, [fetchDescription]); + console.log(componentData.demos); + return ( <> @@ -170,11 +172,7 @@ function StoryDetailView(props) { > -

Demos

- +

{componentData && @@ -184,7 +182,7 @@ function StoryDetailView(props) { item xs={6} style={{ marginTop: "16px", paddingTop: "0px" }} - key={demo.id ? demo.id : demo.name} + key={demo.name} >