improve color gradient

This commit is contained in:
marlon-erler
2024-07-21 23:37:54 +02:00
parent e2c01138bb
commit 876e03abc7
3 changed files with 58 additions and 7 deletions
+1 -1
View File
@@ -100,7 +100,7 @@ main {
120deg, 120deg,
hsl(var(--hue), 100%, var(--gradient-luma-1)), hsl(var(--hue), 100%, var(--gradient-luma-1)),
hsla(var(--hue), 100%, var(--gradient-luma-2), 50%) ); hsla(var(--hue), 100%, var(--gradient-luma-2), 90%) );
--surface-hover: hsl(var(--hue), 100%, var(--hover-luma)); --surface-hover: hsl(var(--hue), 100%, var(--hover-luma));
--surface-active: hsl(var(--hue), 100%, var(--active-luma)); --surface-active: hsl(var(--hue), 100%, var(--active-luma));
--text-normal: hsl(var(--hue), 100%, var(--text-luma)); --text-normal: hsl(var(--hue), 100%, var(--text-luma));
+58 -7
View File
@@ -361,7 +361,8 @@
readStringifiable = (pathComponents) => { readStringifiable = (pathComponents) => {
const valueString = this.read(pathComponents); const valueString = this.read(pathComponents);
if (!valueString) return null; if (!valueString) return null;
return parse(valueString); const object = parseValidObject(valueString);
return object;
}; };
// init // init
constructor() { constructor() {
@@ -431,12 +432,14 @@
"last-used-page" "last-used-page"
], ],
chatColor: (id) => [DATA_VERSION, "chat", id, "color"], chatColor: (id) => [DATA_VERSION, "chat", id, "color"],
chatMessages: (id) => [DATA_VERSION, "chat", id, "messages"] chatMessages: (id) => [DATA_VERSION, "chat", id, "messages"],
chatFiles: [DATA_VERSION, "chat", "files"]
}; };
// src/Model/fileModel.ts // src/Model/fileModel.ts
var FileModel = class { var FileModel = class _FileModel {
chatModel; chatModel;
storageModel;
// handler // handler
handleStringifiedFile = (stringifiedFile) => { handleStringifiedFile = (stringifiedFile) => {
const file = parseValidObject(stringifiedFile); const file = parseValidObject(stringifiedFile);
@@ -446,11 +449,58 @@
addFile = (file) => { addFile = (file) => {
this.chatModel.sendMessage("", file); this.chatModel.sendMessage("", file);
}; };
// init // storage
constructor(chatModel) { storeFile = (file) => {
this.chatModel = chatModel; for (const fileContent of file.contentVersions) {
this.storeFileContent(file, fileContent);
} }
}; };
storeFileContent = (file, fileContent) => {
const fileContentName = _FileModel.getFileContentName(fileContent);
const fileContentPath = _FileModel.getFileContentPath(
file,
fileContentName
);
const stringifiedContent = stringify(fileContent);
this.storageModel.write(fileContentPath, stringifiedContent);
};
listFileIds = () => {
return this.storageModel.list(storageKeys.chatFiles);
};
listFileContents = (file) => {
const filePath = _FileModel.getFilePath(file.id);
return this.storageModel.list(filePath);
};
getFile = (fileId) => {
const filePath = _FileModel.getFilePath(fileId);
const fileOrNull = this.storageModel.readStringifiable(filePath);
return fileOrNull;
};
getLatestFileContentName = (fileContentNames) => {
return fileContentNames[fileContentNames.length - 1];
};
getFileContent = (file, fileContentName) => {
const filePath = _FileModel.getFileContentPath(file, fileContentName);
const fileContentOrNull = this.storageModel.readStringifiable(filePath);
return fileContentOrNull;
};
// init
constructor(chatModel, storageModel2) {
this.chatModel = chatModel;
this.storageModel = storageModel2;
}
// utility
static getFilePath = (fileId) => {
return [...storageKeys.chatFiles, fileId];
};
static getFileContentName = (fileContent) => {
return fileContent.creationDate + fileContent.id;
};
static getFileContentPath = (file, fileContentName) => {
const filePath = _FileModel.getFilePath(file.id);
return [...filePath, fileContentName];
};
};
// src/Model/Utility/crypto.ts // src/Model/Utility/crypto.ts
var IV_SIZE = 12; var IV_SIZE = 12;
@@ -702,11 +752,12 @@
this.loadColor(); this.loadColor();
this.subscribe(); this.subscribe();
connectionModel2.setMessageSentHandler(this.handleMessageSent); connectionModel2.setMessageSentHandler(this.handleMessageSent);
this.fileModel = new FileModel(this); this.fileModel = new FileModel(this, this.storageModel);
} }
// utility // utility
static generateChatInfo = (primaryChannel) => { static generateChatInfo = (primaryChannel) => {
return { return {
dataVersion: "v2",
primaryChannel, primaryChannel,
secondaryChannels: [], secondaryChannels: [],
encryptionKey: "", encryptionKey: "",
+1 -1
View File
@@ -28,7 +28,7 @@
--surface: linear-gradient( --surface: linear-gradient(
120deg, 120deg,
hsl(var(--hue), 100%, var(--gradient-luma-1)), hsl(var(--hue), 100%, var(--gradient-luma-1)),
hsla(var(--hue), 100%, var(--gradient-luma-2), 50%) hsla(var(--hue), 100%, var(--gradient-luma-2), 90%)
); );
--surface-hover: hsl(var(--hue), 100%, var(--hover-luma)); --surface-hover: hsl(var(--hue), 100%, var(--hover-luma));
--surface-active: hsl(var(--hue), 100%, var(--active-luma)); --surface-active: hsl(var(--hue), 100%, var(--active-luma));