-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ignore falsy units for css variables
- Loading branch information
Showing
6 changed files
with
59 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/** | ||
* Internal helper called by transformed code - Do not use directly | ||
* | ||
* Takes a function and a css unit and returns the result of the function concatenated with the unit | ||
* | ||
* ```tsx | ||
* import { styled } from "next-yak"; | ||
* | ||
* const Button = styled.button<{ $width?: boolean }>` | ||
* width: ${({ $width }) => $width}px; | ||
* `; | ||
* ``` | ||
* | ||
* Which will be transformed to: | ||
* ```tsx | ||
* import { styled } from "next-yak/internals"; | ||
* | ||
* const Button = styled.button<{ $width?: boolean }>( | ||
* "button", { | ||
* width: unitPostFix({ $width }) => $width, "px") | ||
* }); | ||
*/ | ||
export const unitPostFix = (arg: unknown, unit: string) => { | ||
switch (typeof arg) { | ||
case "function": | ||
return (props: any) => unitPostFix(arg(props), unit); | ||
case "number": | ||
case "string": | ||
return `${arg}${unit}`; | ||
// Ignore falsy values | ||
default: | ||
return undefined | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.