-
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.
Adds gradient utils and matches assets card to account card color (#246)
- Loading branch information
Showing
5 changed files
with
49 additions
and
24 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,31 @@ | ||
import { GRADIENTS } from "@/ui/colors"; | ||
|
||
export type GradientColors = keyof typeof GRADIENTS; | ||
|
||
const gradientColors = Object.keys(GRADIENTS) as Array<GradientColors>; | ||
|
||
/** | ||
* Creates a CSS linear gradient string based on the provided gradient color. | ||
*/ | ||
export function makeGradient(gradient: GradientColors, isShadow?: boolean) { | ||
const { from, to } = GRADIENTS[gradient]; | ||
return `linear-gradient(to right, ${ | ||
isShadow ? "white" : from | ||
} 0%, ${to} 100%)`; | ||
} | ||
|
||
/** | ||
* Determines a gradient color based on an address. | ||
*/ | ||
export function getAddressGradientColor(address: string) { | ||
const bigAddress = BigInt(`0x${address}`); | ||
const bigLength = BigInt(gradientColors.length); | ||
return gradientColors[Number(bigAddress % bigLength)]; | ||
} | ||
|
||
/** | ||
* Retrieves the gradient object for a given gradient color. | ||
*/ | ||
export function getGradientObject(gradient: GradientColors) { | ||
return GRADIENTS[gradient]; | ||
} |