From 69a93a39da4817e66cdd865cfe57872a8331c998 Mon Sep 17 00:00:00 2001 From: George Gloyens Date: Tue, 2 Apr 2024 16:15:21 +0100 Subject: [PATCH 1/3] Modify regex to match h1-h6 tags --- src/cli/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cli/utils.ts b/src/cli/utils.ts index 37d5566..fc0a134 100644 --- a/src/cli/utils.ts +++ b/src/cli/utils.ts @@ -24,7 +24,7 @@ export const extractStyles = (path: string) => { : fs.readFileSync(path).toString(); return fileContent.match( - /([a-zA-Z_]*)(?:[.]{1})([a-zA-Z_]+[\w\-_]*)(?:[\s\.\,\{\>#\:]{0})/gim + /(h[1-6]|[a-zA-Z_]*)(?:[.]{1})([a-zA-Z_]+[\w\-_]*)(?:[\s\.\,\{\>#\:]{0})/gim ); }; From eea8bd0c7259c75a73b75f177eedab3dc40e16b9 Mon Sep 17 00:00:00 2001 From: Numa Schmeder Date: Thu, 19 Sep 2024 10:00:31 +0200 Subject: [PATCH 2/3] SSR fix --- src/index.ts | 8 ++++++-- src/utils.ts | 3 +++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index 9b64e77..3264358 100755 --- a/src/index.ts +++ b/src/index.ts @@ -6,7 +6,11 @@ import { PolymorphicComponent, variantsType, } from "./type"; -import { findMatchingCompoundVariants, flattenCss } from "./utils"; +import { + componentDisplayName, + findMatchingCompoundVariants, + flattenCss, +} from "./utils"; export { CSSComponentConfig, CSS, VariantProps } from "./type"; @@ -70,7 +74,7 @@ export const styled = < } componentProps.className = componentStyles.join(" "); - styledComponent.displayName = element.toString(); + styledComponent.displayName = componentDisplayName(element); return createElement(element, componentProps); } ); diff --git a/src/utils.ts b/src/utils.ts index d0b1eb5..8101b88 100755 --- a/src/utils.ts +++ b/src/utils.ts @@ -16,3 +16,6 @@ export const findMatchingCompoundVariants = ( export const flattenCss = (css: CSS) => Array.isArray(css) ? css.join(" ") : css; + +export const componentDisplayName = (component: any) => + typeof window == undefined ? component.displayName : component.toString(); From 8c7f9e7a392b29dae2a688f2665b3b8cd717f011 Mon Sep 17 00:00:00 2001 From: Numa Schmeder Date: Thu, 19 Sep 2024 12:06:01 +0200 Subject: [PATCH 3/3] missing quotation marks --- src/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils.ts b/src/utils.ts index 8101b88..2643fb6 100755 --- a/src/utils.ts +++ b/src/utils.ts @@ -18,4 +18,4 @@ export const flattenCss = (css: CSS) => Array.isArray(css) ? css.join(" ") : css; export const componentDisplayName = (component: any) => - typeof window == undefined ? component.displayName : component.toString(); + typeof window == "undefined" ? component.displayName : component.toString();