-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.ts
More file actions
66 lines (56 loc) · 2.94 KB
/
Copy pathutils.ts
File metadata and controls
66 lines (56 loc) · 2.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import { NoteColor } from './types';
export const generateId = (): string => {
return Date.now().toString(36) + Math.random().toString(36).substring(2);
};
export const formatDate = (timestamp: number): string => {
const date = new Date(timestamp);
const now = new Date();
const diff = now.getTime() - timestamp;
// Less than 24 hours
if (diff < 24 * 60 * 60 * 1000 && date.getDate() === now.getDate()) {
return date.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
}
// Current year
if (date.getFullYear() === now.getFullYear()) {
return date.toLocaleDateString([], { month: 'short', day: 'numeric' });
}
return date.toLocaleDateString([], { year: 'numeric', month: 'short', day: 'numeric' });
};
export const getNoteColorClasses = (color: NoteColor, isDark: boolean): string => {
// Enhanced Material You Colors with better contrast and vibrancy
const colors: Record<NoteColor, { light: string; dark: string; border: string }> = {
default: {
light: 'bg-white',
dark: 'bg-[#1e1f21]',
border: isDark ? 'border-gray-700' : 'border-gray-200'
},
red: { light: 'bg-[#ffdad6]', dark: 'bg-[#93000a]', border: 'border-transparent' },
orange: { light: 'bg-[#ffdbcc]', dark: 'bg-[#5c1900]', border: 'border-transparent' },
yellow: { light: 'bg-[#ffeea1]', dark: 'bg-[#574500]', border: 'border-transparent' },
green: { light: 'bg-[#bcefa0]', dark: 'bg-[#185200]', border: 'border-transparent' },
cyan: { light: 'bg-[#bce9ff]', dark: 'bg-[#004e6f]', border: 'border-transparent' },
blue: { light: 'bg-[#d7e3ff]', dark: 'bg-[#00468c]', border: 'border-transparent' },
purple: { light: 'bg-[#e9ddff]', dark: 'bg-[#4d2d89]', border: 'border-transparent' },
pink: { light: 'bg-[#ffd9e3]', dark: 'bg-[#630b32]', border: 'border-transparent' },
brown: { light: 'bg-[#f0dbd4]', dark: 'bg-[#562214]', border: 'border-transparent' },
gray: { light: 'bg-[#e3e2e6]', dark: 'bg-[#444746]', border: 'border-transparent' },
};
const theme = colors[color];
const borderClass = color === 'default' ? 'border' : 'border-transparent';
return `${isDark ? theme.dark : theme.light} ${isDark ? theme.border : borderClass}`;
};
// Deterministically generate a shape class based on the Note ID
export const getNoteShape = (id: string, isPinned: boolean): string => {
if (isPinned) return 'rounded-3xl'; // Pinned notes are standard for emphasis
const shapes = [
'rounded-3xl', // Standard
'rounded-tl-xl rounded-tr-[3rem] rounded-bl-[3rem] rounded-br-xl', // Leaf Right
'rounded-tl-[3rem] rounded-tr-xl rounded-bl-xl rounded-br-[3rem]', // Leaf Left
'rounded-t-[2.5rem] rounded-b-xl', // Arch
'rounded-b-[2.5rem] rounded-t-xl', // Inverse Arch
'rounded-[2rem]', // Extra Soft
];
// Use the sum of char codes to pick a consistent shape for the same ID
const sum = id.split('').reduce((acc, char) => acc + char.charCodeAt(0), 0);
return shapes[sum % shapes.length];
};