MCPcopy Create free account
hub / github.com/codename-co/stack / hexFromSlug

Function hexFromSlug

packages/website/src/components/Logo.tsx:16–24  ·  view source on GitHub ↗
(s?: string)

Source from the content-addressed store, hash-verified

14const stacks = getStacks("en");
15
16const hexFromSlug = (s?: string) => {
17 if (!s) return null;
18 let hash = 0;
19 for (let i = 0; i < s.length; i++) {
20 hash = s.charCodeAt(i) + ((hash << 5) - hash);
21 }
22 const hex = "#" + ("000000" + (hash & 0xffffff).toString(16)).slice(-6);
23 return hex;
24};
25
26export const logoFromIcon = ({ slug, icon }: LogoProps) => {
27 if (!slug && !icon) return null;

Callers 1

logoFromIconFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected