refactor: move Checkmark, Avatar, Chip and Tooltip to twenty-ui (#4946)
Split from https://github.com/twentyhq/twenty/pull/4518 Part of #4766
This commit is contained in:
@ -0,0 +1,7 @@
|
||||
import { stringToHslColor } from '../stringToHslColor';
|
||||
|
||||
describe('stringToHslColor', () => {
|
||||
it('should return a color based on a string', () => {
|
||||
expect(stringToHslColor('red', 70, 90)).toBe('hsl(105, 70%, 90%)');
|
||||
});
|
||||
});
|
||||
@ -0,0 +1,13 @@
|
||||
export const stringToHslColor = (
|
||||
str: string,
|
||||
saturation: number,
|
||||
lightness: number,
|
||||
) => {
|
||||
let hash = 0;
|
||||
for (let i = 0; i < str.length; i++) {
|
||||
hash = str.charCodeAt(i) + ((hash << 5) - hash);
|
||||
}
|
||||
|
||||
const h = hash % 360;
|
||||
return 'hsl(' + h + ', ' + saturation + '%, ' + lightness + '%)';
|
||||
};
|
||||
@ -1 +1,3 @@
|
||||
export * from './color/utils/stringToHslColor';
|
||||
export * from './state/utils/createState';
|
||||
export * from './types/Nullable';
|
||||
|
||||
1
packages/twenty-ui/src/utilities/types/Nullable.ts
Normal file
1
packages/twenty-ui/src/utilities/types/Nullable.ts
Normal file
@ -0,0 +1 @@
|
||||
export type Nullable<T> = T | null | undefined;
|
||||
Reference in New Issue
Block a user