Skip to content

Commit

Permalink
remove proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
jantimon committed Dec 2, 2024
1 parent aa80605 commit ab2b3f9
Showing 1 changed file with 15 additions and 22 deletions.
37 changes: 15 additions & 22 deletions packages/next-yak/runtime/styled.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -257,28 +257,21 @@ type StyledLiteral<T> = <TCSSProps>(
* `;
* ```
*/
export const styled =
// The proxy adds the styled.div, styled.button, etc. syntax
new Proxy(
StyledFactory as typeof StyledFactory & {
[Tag in HtmlTags]: StyledLiteral<JSX.IntrinsicElements[Tag]> & {
attrs: <
TAttrsIn extends object = {},
TAttrsOut extends AttrsMerged<
JSX.IntrinsicElements[Tag],
TAttrsIn
> = AttrsMerged<JSX.IntrinsicElements[Tag], TAttrsIn>,
>(
attrs: Attrs<JSX.IntrinsicElements[Tag], TAttrsIn, TAttrsOut>,
) => StyledLiteral<Substitute<JSX.IntrinsicElements[Tag], TAttrsIn>>;
};
},
{
get(target, TagName: keyof JSX.IntrinsicElements) {
return target(TagName);
},
},
);
export const styled = StyledFactory as
// this type is wrong - but it will work correctly with compiled code
typeof StyledFactory & {
[Tag in HtmlTags]: StyledLiteral<JSX.IntrinsicElements[Tag]> & {
attrs: <
TAttrsIn extends object = {},
TAttrsOut extends AttrsMerged<
JSX.IntrinsicElements[Tag],
TAttrsIn
> = AttrsMerged<JSX.IntrinsicElements[Tag], TAttrsIn>,
>(
attrs: Attrs<JSX.IntrinsicElements[Tag], TAttrsIn, TAttrsOut>,
) => StyledLiteral<Substitute<JSX.IntrinsicElements[Tag], TAttrsIn>>;
};
};

/**
* Remove all entries that start with a $ sign
Expand Down

0 comments on commit ab2b3f9

Please sign in to comment.