-
Notifications
You must be signed in to change notification settings - Fork 1
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
62436b8
commit e36c5ce
Showing
4 changed files
with
30 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
export function generateGradient(name: string): string { | ||
const colors = [ | ||
'red', | ||
'orange', | ||
'yellow', | ||
'green', | ||
'blue', | ||
'purple' | ||
]; // Define an array of colors for the gradient | ||
|
||
const hue = name.split('').reduce((acc, char) => acc + char.charCodeAt(0), 0) % colors.length; // Generate hue based on character codes of name | ||
const startColor = colors[hue]; // Use the hue to select a starting color for the gradient | ||
const endColor = colors[(hue + 1) % colors.length]; // Use the next color in the array as the ending color for the gradient | ||
|
||
return `linear-gradient(to right, ${startColor}, ${endColor})`; | ||
} |