From 462dc6cf29b4ebd1544aab2d4de73c5462699f3a Mon Sep 17 00:00:00 2001 From: Nicolas Merget <104347736+nmerget@users.noreply.github.com> Date: Mon, 5 Feb 2024 12:26:01 +0100 Subject: [PATCH] chore: removed examples from patternhub (#2175) --- showcases/patternhub/data/routes.ts | 4 - .../patternhub/scripts/generate-docs-mdx.js | 5 - .../patternhub/scripts/get-example-file.js | 180 ------------------ 3 files changed, 189 deletions(-) delete mode 100644 showcases/patternhub/scripts/get-example-file.js diff --git a/showcases/patternhub/data/routes.ts b/showcases/patternhub/data/routes.ts index 05825ab7218..b9a6be0f3b0 100644 --- a/showcases/patternhub/data/routes.ts +++ b/showcases/patternhub/data/routes.ts @@ -226,10 +226,6 @@ export const ROUTES: NavigationItem[] = [ label: 'Properties', path: `/components/${component.name}/properties` }, - { - label: 'Examples', - path: `/components/${component.name}/examples` - }, { label: 'How to use', path: `/components/${component.name}/how-to-use` diff --git a/showcases/patternhub/scripts/generate-docs-mdx.js b/showcases/patternhub/scripts/generate-docs-mdx.js index 602691aff7d..ee13c038ece 100644 --- a/showcases/patternhub/scripts/generate-docs-mdx.js +++ b/showcases/patternhub/scripts/generate-docs-mdx.js @@ -1,7 +1,6 @@ /* eslint-disable unicorn/prefer-top-level-await, no-await-in-loop */ import FS from 'node:fs'; -import getExampleFile from './get-example-file.js'; import getPropertiesFile from './get-properties-file.js'; import getHowToFile from './get-how-to-file.js'; import writeCodeFiles from './get-code-files.js'; @@ -28,10 +27,6 @@ const generateDocsMdx = async () => { `${componentPath}/properties.mdx`, getPropertiesFile(componentValue) ); - FS.writeFileSync( - `${componentPath}/examples.tsx`, - getExampleFile(componentName, componentValue) - ); const docsPath = `./../../packages/components/src/components/${componentName}/docs`; if (FS.existsSync(docsPath)) { diff --git a/showcases/patternhub/scripts/get-example-file.js b/showcases/patternhub/scripts/get-example-file.js deleted file mode 100644 index 19800a96400..00000000000 --- a/showcases/patternhub/scripts/get-example-file.js +++ /dev/null @@ -1,180 +0,0 @@ -import { getUnionElements } from './utils.js'; - -const getOption = (optionName, tsType) => { - if (tsType.name === 'boolean') { - return `${optionName}={true}`; - } - - if (tsType.name === 'Array') { - if (optionName === 'dataList') { - return `${optionName}={[{key:'test1', value:'Test1'},{key:'test2', value:'Test2'}]}`; - } - - if (optionName === 'initOpenIndex') { - return `${optionName}={[0,1]}`; - } - - if (tsType?.raw.includes('DBSelect')) { - return `${optionName}={[{"value":"Test1"},{"value":"Test2"}]}`; - } - - return `${optionName}={['test1','test2']}`; - } - - if ( - tsType.name === 'intersection' && - tsType.raw.includes('DBNavigationItemActionProps') - ) { - return `${optionName}={{"text":"Test", "icon":"edit"}}`; - } - - if (tsType.name === 'number') { - return `${optionName}={100}`; - } - - if (tsType.name === 'literal') { - return `${optionName}="${tsType.value?.replace(/'/g, '')}"`; - } - - if (tsType.name === 'union') { - const options = []; - getUnionElements(options, tsType.elements); - return `${optionName}="${(options[1] || options[0])?.replace( - /'/g, - '' - )}"`; - } - - if (tsType.name === 'COLOR') { - return `${optionName}="primary"`; - } - - if (tsType.name === 'signature' && tsType.raw.startsWith('(event')) { - return `${optionName}={(event) => console.log(event)}`; - } - - if (tsType.name === 'signature' && tsType.raw === '() => void') { - return `${optionName}={() => console.log("${optionName} triggered")}`; - } - - if ( - tsType.name === 'signature' && - tsType.raw.includes('boolean) => void') - ) { - return `${optionName}={(event) => console.log(event)}`; - } - - if ( - tsType.name === 'signature' && - tsType.raw.includes('openAccordionItemIds') - ) { - return `${optionName}={(openAccordionItemIds) => console.log(openAccordionItemIds)}`; - } - - if (tsType.name === 'signature' && tsType.type === 'object') { - return `${optionName}={{${tsType.signature?.properties?.map( - (property) => - `"${getOption(property.key, property.value) - .replace('=', '":') - .replace(/{/g, '') - .replace(/}/g, '')}` - )}}}`; - } - - if (optionName.toLowerCase().endsWith('src')) { - return `${optionName}="https://db-ui.github.io/images/db_logo.svg"`; - } - - if (optionName.toLowerCase().startsWith('slot')) { - return `${optionName}={