From 6c38ba29e8735145afb4551abbba1789632465b1 Mon Sep 17 00:00:00 2001 From: hobbes7878 Date: Fri, 18 Apr 2025 18:54:39 +0100 Subject: [PATCH] cleanup --- src/components/Headline/Headline.svelte | 2 +- src/components/InfoBox/InfoBox.svelte | 2 +- src/docs/utils/css-to-js/index.d.ts | 3 +- src/docs/utils/{parseCss.js => parseCss.ts} | 7 ++-- src/docs/utils/withParams.js | 46 --------------------- 5 files changed, 7 insertions(+), 53 deletions(-) rename src/docs/utils/{parseCss.js => parseCss.ts} (90%) delete mode 100644 src/docs/utils/withParams.js diff --git a/src/components/Headline/Headline.svelte b/src/components/Headline/Headline.svelte index 73e45097..447f5b78 100644 --- a/src/components/Headline/Headline.svelte +++ b/src/components/Headline/Headline.svelte @@ -108,7 +108,7 @@ {/if} {#if typeof hed === 'string'}

- +

{:else if hed} diff --git a/src/components/InfoBox/InfoBox.svelte b/src/components/InfoBox/InfoBox.svelte index 1aa5d1fe..d3479636 100644 --- a/src/components/InfoBox/InfoBox.svelte +++ b/src/components/InfoBox/InfoBox.svelte @@ -83,7 +83,7 @@ {:else}
- +
{/if} diff --git a/src/docs/utils/css-to-js/index.d.ts b/src/docs/utils/css-to-js/index.d.ts index 6f1f4a47..9f5673f5 100644 --- a/src/docs/utils/css-to-js/index.d.ts +++ b/src/docs/utils/css-to-js/index.d.ts @@ -1 +1,2 @@ -export function convert(input: any, ...args: any[]): any; +// eslint-disable-next-line @typescript-eslint/no-explicit-any +export function convert(input: any, ...args: any[]): Record; diff --git a/src/docs/utils/parseCss.js b/src/docs/utils/parseCss.ts similarity index 90% rename from src/docs/utils/parseCss.js rename to src/docs/utils/parseCss.ts index e65de5e8..2451462a 100644 --- a/src/docs/utils/parseCss.js +++ b/src/docs/utils/parseCss.ts @@ -16,9 +16,8 @@ export const cssStringToTableArray = (cssString = '', withInclude = false) => { )};`; }) .join('\n'); - return withInclude ? - [className, className, properties] - : [className, properties]; + if (withInclude) return [className, className, properties]; + return [className, properties]; }); }; @@ -35,7 +34,7 @@ export const extractCssColourVariables = (cssString = '') => { const cssVariables = [...cssString.matchAll(variableRegexp)].map( ([_, g1, g2]) => [g2, g1] ); - const colours = {}; + const colours: Record = {}; for (const variable of cssVariables) { const [colour, css] = variable; if (colours[colour]) { diff --git a/src/docs/utils/withParams.js b/src/docs/utils/withParams.js deleted file mode 100644 index d92af00a..00000000 --- a/src/docs/utils/withParams.js +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Use custom source code in the "Show code" pull down. - * @param {object} source Source code object, where key is the language of the source code and value is the code string. - * @param {object} otherOptions Other props object options, allowing chaining with other methods like withStoryDocs - * @returns props object including parameters - */ -export const withSource = (source, otherOptions = {}) => { - const language = Object.keys(source)[0]; - const code = source[language]; - const docs = { - ...otherOptions?.parameters?.docs, - source: { code, language }, - }; - const parameters = { docs }; - return { parameters }; -}; - -/** - * Add custom documentation to a story. - * @param {string} storyDocs Markdown string of docs - * @param {object} otherOptions Other props object options, allowing chaining with other methods like withSource - * @returns props object including parameters - */ -export const withStoryDocs = (storyDocs, otherOptions = {}) => { - const docs = { - ...otherOptions?.parameters?.docs, - description: { story: storyDocs }, - }; - const parameters = { docs }; - return { parameters }; -}; - -/** - * Add custom documentation to the top of the component docs page. - * @param {string} componentDocs Markdown string of docs - * @param {object} otherOptions Other props object options, allowing chaining with other methods like withSource - * @returns props object including parameters - */ -export const withComponentDocs = (componentDocs, otherOptions = {}) => { - const docs = { - ...otherOptions?.parameters?.docs, - description: { component: componentDocs }, - }; - const parameters = { docs }; - return { parameters }; -};