Skip to content

Commit

Permalink
feat(storefront): fix indentation | hj | #3315
Browse files Browse the repository at this point in the history
  • Loading branch information
henrijoss committed Jun 19, 2024
1 parent ec26f0d commit 36d25b3
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions packages/storefront/src/utils/getComponentMarkup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const getComponentExampleMarkup = (
};

const componentExampleMarkup: FrameworkMarkup = {
'vanilla-js': codeSamples['vanilla-js']?.replace(componentRegex, markup),
'vanilla-js': replaceWithIndentation(codeSamples['vanilla-js'], componentRegex, markup),
react: replaceWithIndentation(codeSamples['react'], componentRegexPascalCase, convertToReact(markup)),
angular: replaceWithIndentation(codeSamples['angular'], componentRegex, convertToAngular(markup)),
vue: replaceWithIndentation(codeSamples['vue'], componentRegexPascalCase, convertToVue(markup)),
Expand All @@ -50,19 +50,6 @@ export const getComponentExampleMarkup = (
return componentExampleMarkup;
};

// function extractSlots(markup: string) {
// const regex = /(<[^\/][\S\s]*?slot="([a-zA-Z-]+)"[\S\s]*?<\/.*?>)/g;
// const slots = {};
// let match;
//
// while ((match = regex.exec(markup)) !== null) {
// const [fullMatch, , slotName] = match;
// slots[slotName] = fullMatch;
// }
//
// return slots;
// }

export const getComponentMarkup = <T extends TagName>(component: T, props: ComponentProps, slots: ComponentSlots) => {
return `<${component}${getHTMLAttributes(props)}>
${slots
Expand All @@ -74,6 +61,9 @@ export const getComponentMarkup = <T extends TagName>(component: T, props: Compo

/**
* Get HTML attributes string from an object of properties.
*
* Only selectedValues which are not equal to the defaultValue will be returned.
* Prop of type 'Theme' will be excluded.
* @param props - The object containing the properties.
* @returns The HTML attributes string.
*/
Expand Down

0 comments on commit 36d25b3

Please sign in to comment.