diff options
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/db/schema.sql | 8 | ||||
-rw-r--r-- | src/lib/utils.ts | 8 |
2 files changed, 16 insertions, 0 deletions
diff --git a/src/lib/db/schema.sql b/src/lib/db/schema.sql index 8d1b288..4506619 100644 --- a/src/lib/db/schema.sql +++ b/src/lib/db/schema.sql @@ -57,6 +57,14 @@ CREATE INDEX IF NOT EXISTS idx_words_pos ON senses(pos); CREATE INDEX IF NOT EXISTS idx_senses_parent ON senses(parent_id); +CREATE TABLE IF NOT EXISTS bookmarks( + word_id INTEGER PRIMARY KEY, + notes TEXT, + created INTEGER NOT NULL, + FOREIGN KEY (word_id) REFERENCES expressions(id) +); +CREATE INDEX IF NOT EXISTS idx_bookmarks ON bookmarks(word_id); + -- Categories table (for noun and verb categories) CREATE TABLE IF NOT EXISTS categories ( diff --git a/src/lib/utils.ts b/src/lib/utils.ts index d3fdf9c..9bc74b8 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -49,3 +49,11 @@ export function handlePromise<T>( if (settlement.status === "fulfilled") return settlement.value; else return `${settlement.reason}`; } + +export function getRandomHexColor() { + // Generate a random number and convert it to a hexadecimal string + const randomColor = Math.floor(Math.random() * 16777215).toString(16); + + // Ensure the color code is always 6 digits by padding with zeros if needed + return "#" + randomColor.padStart(6, "0"); +} |