Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/cli/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
};

Expand Down
8 changes: 6 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -70,7 +74,7 @@ export const styled = <
}

componentProps.className = componentStyles.join(" ");
styledComponent.displayName = element.toString();
styledComponent.displayName = componentDisplayName(element);
return createElement(element, componentProps);
}
);
Expand Down
3 changes: 3 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();