-
Notifications
You must be signed in to change notification settings - Fork 0
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
c34e023
commit deff06d
Showing
6 changed files
with
76 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,17 @@ | ||
import { getPastelColorFromName } from 'utils/colorUtils'; | ||
import { getBrandColorFromName } from 'utils/colorUtils'; | ||
|
||
export default function Avatar({ name }: { name: string }) { | ||
const backgroundColor = getPastelColorFromName(name); | ||
const backgroundColor = getBrandColorFromName(name).split(" ").join(""); | ||
const firstLetter = name.charAt(0).toUpperCase(); | ||
|
||
console.log("Avatar: ", name, firstLetter, backgroundColor); | ||
|
||
return ( | ||
<div | ||
className={`flex items-center justify-center w-12 h-12 rounded-full bg-${backgroundColor} text-white`} | ||
className="text-3xl flex items-center justify-center w-12 h-12 rounded-full text-white" | ||
style={{ backgroundColor: backgroundColor }} | ||
> | ||
{firstLetter} | ||
</div> | ||
) | ||
} | ||
); | ||
} |
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,3 +1,13 @@ | ||
@tailwind base; | ||
@tailwind components; | ||
@tailwind utilities; | ||
|
||
/* Custom utility for animation-play-state */ | ||
@layer utilities { | ||
.animation-paused { | ||
animation-play-state: paused; | ||
} | ||
.hover\:animation-paused:hover { | ||
animation-play-state: paused; | ||
} | ||
} |
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,16 +1,35 @@ | ||
// Utility function that returns an array of your brand colors | ||
const brandColors = [ | ||
'hsl(24,96%,90%)', // primary 100 | ||
'hsl(24,96%,70%)', // primary 300 | ||
'hsl(24,96%,50%)', // primary 500 (Base: #F36301) | ||
'hsl(24,96%,40%)', // primary 700 | ||
'hsl(24,96%,25%)', // primary 900 | ||
'hsl(74,25%,85%)', // accent 100 | ||
'hsl(74,25%,50%)', // accent 300 | ||
'hsl(74,25%,35%)', // accent 500 (Base: #525938) | ||
'hsl(74,25%,30%)', // accent 700 | ||
'hsl(74,25%,15%)', // accent 900 | ||
'hsl(0,0%,95%)', // neutral 100 | ||
'hsl(0,0%,80%)', // neutral 300 | ||
'hsl(0,0%,50%)', // neutral 500 | ||
'hsl(0,0%,30%)', // neutral 700 | ||
'hsl(0, 0%, 10%)', // neutral 900 | ||
]; | ||
|
||
// Updated stringToHue function | ||
export function stringToHue(str) { | ||
let hash = 0; | ||
for (let i = 0; i < str.length; i++) { | ||
// Generate a hash code from the string | ||
hash = str.charCodeAt(i) + ((hash << 5) - hash); | ||
} | ||
// Convert hash code to a hue value between 0 and 359 | ||
return Math.abs(hash % 360); | ||
// Convert hash code to an index of the brand color array | ||
return Math.abs(hash % brandColors.length); | ||
} | ||
|
||
export function getPastelColorFromName(name) { | ||
const hue = stringToHue(name); | ||
const saturation = 70; // Pastel saturation | ||
const lightness = 85; // Pastel lightness | ||
return `hsl(${hue}, ${saturation}%, ${lightness}%)`; | ||
} | ||
// Updated getBrandColorFromName function | ||
export function getBrandColorFromName(name) { | ||
const colorIndex = stringToHue(name); | ||
return brandColors[colorIndex]; // Return a color from the brand color array | ||
} |