-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2ae16ff
commit 5161db2
Showing
15 changed files
with
166 additions
and
35 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,28 @@ | ||
import { ClassNameValue, twMerge } from 'tailwind-merge'; | ||
|
||
export function variationName(name: string, value: string) { | ||
type VariationName = (name: string, value: string) => string; | ||
|
||
/** | ||
* Constructs a variation name by capitalizing the first letter of the value and appending it to the name. | ||
* | ||
* @example | ||
* // returns "colorRed" | ||
* variationName("color", "red"); | ||
*/ | ||
export const variationName: VariationName = (name: string, value: string) => { | ||
return `${name}${value.charAt(0).toUpperCase()}${value.slice(1)}`; | ||
} | ||
}; | ||
|
||
/** | ||
* A utility function that merges multiple class names into a single string. | ||
* | ||
* This function uses the `twMerge` function from the `twin.macro` library to merge the class names. | ||
* It accepts an array of class names, which can be strings, arrays of strings, or objects with class names as keys and boolean values. | ||
* | ||
* @example | ||
* // returns "text-red-500 bg-blue-500" | ||
* cn('text-red-500', 'bg-blue-500'); | ||
*/ | ||
export function cn(...inputs: ClassNameValue[]) { | ||
return twMerge(inputs); | ||
} |
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
15 changes: 14 additions & 1 deletion
15
packages/opub-ui/src/utils/hooks/use-isomorphic-layout-effect.ts
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 |
---|---|---|
@@ -1,6 +1,19 @@ | ||
'use client'; | ||
|
||
import { isServer } from '../target'; | ||
import { useEffect, useLayoutEffect } from 'react'; | ||
|
||
import { isServer } from '../target'; | ||
|
||
/** | ||
* A custom hook that uses `useLayoutEffect` on the client and `useEffect` on the server. | ||
* | ||
* This is useful for avoiding warnings about `useLayoutEffect` not working on the server, | ||
* while still getting the benefits of `useLayoutEffect` when running on the client. | ||
* | ||
* @example | ||
* // In a component... | ||
* useIsomorphicLayoutEffect(() => { | ||
* // Your effect here... | ||
* }); | ||
*/ | ||
export const useIsomorphicLayoutEffect = isServer ? useEffect : useLayoutEffect; |
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
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