${renderSmallCardOption({
- name: 'Chat Custom Width',
+ name: 'Chats Width',
inputId: 'gpth-full-width-custom',
inputType: 'range',
inputValue: FW_DEFAULTS.w_chat_gpt,
@@ -42,7 +44,7 @@ let assetsHtmlCode = `
unit: '%',
})}
${renderSmallCardOption({
- name: 'Prompt Field Width',
+ name: 'Message Width',
inputId: 'gpth-textarea-width-custom',
inputType: 'range',
inputValue: FW_DEFAULTS.w_prompt_textarea,
@@ -69,7 +71,7 @@ function whenFullWidth() {
chat_user_edit_icon_top: FW_OPTIONS.chat_user_edit_icon_top,
chat_user_edit_icon_transform: FW_OPTIONS.chat_user_edit_icon_transform,
})
- setInputCheckedValue('gpth-full-width', true)
+ // setInputCheckedValue('gpth-full-width', true)
}
function whenDefaultWidth() {
applySettings({
@@ -86,7 +88,7 @@ function whenDefaultWidth() {
chat_user_edit_icon_top: FW_DEFAULTS.chat_user_edit_icon_top,
chat_user_edit_icon_transform: FW_DEFAULTS.chat_user_edit_icon_transform,
})
- setInputCheckedValue('gpth-full-width', false)
+ // setInputCheckedValue('gpth-full-width', false)
}
function toggleChatFullWidth(e) {
if (e.target.checked) {
@@ -107,6 +109,16 @@ function setInputCheckedValue(inputSelector, isChecked) {
inputEl.checked = isChecked
}
+function setInputFieldValue(inputSelector, inputVal) {
+ const inputEl = document.querySelector(`.gpth-settings #${inputSelector}`)
+
+ inputEl.value = inputVal
+}
+function setRangeOutput(inputSelector, inputVal) {
+ const outputRangeEl = document.querySelector(`.gpth-settings #range-output-${inputSelector}`)
+
+ outputRangeEl.textContent = inputVal
+}
// Function to save settings to Chrome Storage
async function saveSettings(settings) {
try {
@@ -121,14 +133,21 @@ async function loadSettings() {
applySettings(settings)
// Set the checked attribute based on the saved settings
- setInputCheckedValue('gpth-full-width', settings.w_chat_gpt === '100%')
+ // setInputCheckedValue('gpth-full-width', settings.w_chat_gpt === '100%')
+ setRangeOutput('gpth-full-width-custom', removePercent(settings.w_chat_gpt))
+ setInputFieldValue('gpth-full-width-custom', removePercent(settings.w_chat_gpt))
+
+ setRangeOutput('gpth-textarea-width-custom', removePercent(settings.w_prompt_textarea))
+ setInputFieldValue('gpth-textarea-width-custom', removePercent(settings.w_prompt_textarea))
} catch (error) {
console.error('Failed to load settings:', error)
}
}
function handleChatCustomWidth(e) {
- console.log('handleChatCustomWidth()', e.target.value)
+ console.log('handleChatCustomWidth()', e.target.id)
+ setRangeOutput('gpth-full-width-custom', e.target.value)
+ setInputFieldValue('gpth-full-width-custom', e.target.value)
if (e.target.value === '100') {
whenFullWidth()
@@ -141,19 +160,35 @@ function handleChatCustomWidth(e) {
saveSettings({
w_chat_gpt: `${e.target.value}%`,
})
- setInputCheckedValue('gpth-full-width', false)
+
+ // setInputCheckedValue('gpth-full-width', false)
+}
+function handleTextareaCustomWidth(e) {
+ console.log('handleChatCustomWidth()', e.target.id)
+ setRangeOutput('gpth-textarea-width-custom', e.target.value)
+ setInputFieldValue('gpth-textarea-width-custom', e.target.value)
+
+ applySettings({
+ w_prompt_textarea: `${e.target.value}%`,
+ })
+ saveSettings({
+ w_prompt_textarea: `${e.target.value}%`,
+ })
+ // setInputCheckedValue('gpth-full-width', false)
}
function handleAssetsListeners() {
- console.log('handleAssetsListeners() called')
+ // console.log('handleAssetsListeners() called')
const selectors = {
chatFullWidth: document.querySelector('.gpth-settings #gpth-full-width'),
chatCustomWidth: document.querySelector('.gpth-settings #gpth-full-width-custom'),
+ textareaCustomWidth: document.querySelector('.gpth-settings #gpth-textarea-width-custom'),
}
- selectors.chatFullWidth.addEventListener('change', toggleChatFullWidth)
+ // selectors.chatFullWidth.addEventListener('change', toggleChatFullWidth)
selectors.chatCustomWidth.addEventListener('change', handleChatCustomWidth)
+ selectors.textareaCustomWidth.addEventListener('change', handleTextareaCustomWidth)
}
// Load settings on page load
diff --git a/src/sass/abstract/_vars.scss b/src/sass/abstract/_vars.scss
index 33fdbe6..ca0c95b 100644
--- a/src/sass/abstract/_vars.scss
+++ b/src/sass/abstract/_vars.scss
@@ -18,7 +18,8 @@
// --max-w-chat-bubble: 48rem;
--w_chat_user: initial;
--w_chat_gpt: 48rem;
- --w_prompt_textarea: var(--w_chat_gpt);
+ // --w_prompt_textarea: var(--w_chat_gpt);
+ --w_prompt_textarea: initial;
/* ? --- Border-radius --- */
--br: 1rem;
diff --git a/src/sass/elements/_chats-textarea-max-width.scss b/src/sass/elements/_chats-textarea-max-width.scss
index 35c3ffa..bbd6cc5 100644
--- a/src/sass/elements/_chats-textarea-max-width.scss
+++ b/src/sass/elements/_chats-textarea-max-width.scss
@@ -8,6 +8,10 @@ main:has(#prompt-textarea) {
// .mx-auto.flex.flex-1.text-base {
// max-width: var(--w_prompt_textarea) !important;
// }
+ /* Only textarea wrapper */
+ .mx-auto.flex.flex-1.text-base:has(>form) {
+ max-width: var(--w_prompt_textarea) !important;
+ }
}
// [class*='xl:max-w-[48rem]'] {
diff --git a/src/sass/gpthemes/gpth-index.scss b/src/sass/gpthemes/gpth-index.scss
index 42d42ac..5b8bc89 100644
--- a/src/sass/gpthemes/gpth-index.scss
+++ b/src/sass/gpthemes/gpth-index.scss
@@ -9,6 +9,7 @@
@import 'theme-manager/sections/_header';
@import 'theme-manager/sections/_main';
@import 'theme-manager/sections/_header';
+@import 'theme-manager/layouts/_gpth-assets';
@import '_gpth-floating-btn';
@import '_gpth-settings';
\ No newline at end of file
diff --git a/src/sass/gpthemes/theme-manager/components/_cards.scss b/src/sass/gpthemes/theme-manager/components/_cards.scss
index acde4f6..916eba2 100644
--- a/src/sass/gpthemes/theme-manager/components/_cards.scss
+++ b/src/sass/gpthemes/theme-manager/components/_cards.scss
@@ -273,7 +273,7 @@
/* _________________ RANGE CARDS _________________ */
&--range {
label {
- height: 5rem;
+ // height: 5.5rem;
// padding: 0.3rem;
background-color: var(--c-surface-2);
}
@@ -281,6 +281,7 @@
input {
width: 85% !important;
margin: 0 auto;
+ align-self: flex-end;
}
.card__unit {
@@ -299,13 +300,14 @@
}
.card__output {
+ --output-size: 2.5rem;
+ // width: var(--output-size);
+ // height: var(--output-size);
aspect-ratio: 1 / 1;
background-color: hsla(var(--accent-hsl) / 0.2);
color: var(--c-accent);
font-size: 0.8em;
line-height: 1;
- // border-radius: 50vw;
- // padding: 0.3rem;
}
}
diff --git a/src/sass/gpthemes/theme-manager/layouts/_gpth-assets.scss b/src/sass/gpthemes/theme-manager/layouts/_gpth-assets.scss
new file mode 100644
index 0000000..b0a0770
--- /dev/null
+++ b/src/sass/gpthemes/theme-manager/layouts/_gpth-assets.scss
@@ -0,0 +1,7 @@
+.gpth-assets {
+ &__custom-width {
+ display: grid;
+ grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
+ gap: 1rem 0.5rem;
+ }
+}
\ No newline at end of file
From 5f96c15d56d9123dd52f54896922c4aeed2bc082 Mon Sep 17 00:00:00 2001
From: itsmartashub <44645238+itsmartashub@users.noreply.github.com>
Date: Fri, 14 Jun 2024 21:51:23 +0200
Subject: [PATCH 12/27] feat(chat-full-width): Bring back toggle full-width
mode for all chats
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- Bring back the option to toggle full-width mode for all chats
- Note: This requires additional fixes and calculations, especially with custom widths. Reset buttons will also be implemented to restore default options.
Changes summary:
- Reintroduced the option to toggle full-width mode for all chats:
- Provides users with the ability to enable or disable full-width mode for all chat bubbles.
- ❗ TODO: Additional fixes and calculations are required, especially when considering custom widths.
- ❗ TODO: Reset buttons will be implemented to allow users to easily restore default options.
---
src/js/app/mainAssets.js | 38 ++++++++++++++++++++++++++------------
1 file changed, 26 insertions(+), 12 deletions(-)
diff --git a/src/js/app/mainAssets.js b/src/js/app/mainAssets.js
index 60a4a79..3d793eb 100644
--- a/src/js/app/mainAssets.js
+++ b/src/js/app/mainAssets.js
@@ -2,7 +2,7 @@ import browser from 'webextension-polyfill'
import { renderSwitchOption, renderSmallCardOption } from './components/renderSwitch'
import { icon_full_width } from './components/icons'
-const removePercent = (str) => str.replace('%', '') // /%/g
+const removePercentAndRem = (str) => str.replace(/%|rem/g, '') // /%/g
const FW_DEFAULTS = {
w_chat_user: 'initial',
@@ -32,7 +32,7 @@ const FW_OPTIONS = {
let assetsHtmlCode = `
-
+
${renderSmallCardOption({
name: 'Chats Width',
inputId: 'gpth-full-width-custom',
@@ -54,6 +54,16 @@ let assetsHtmlCode = `
unit: '%',
})}
+
+
+ ${renderSwitchOption({
+ inputId: 'gpth-full-width',
+ isChecked: false,
+ icon: icon_full_width,
+ textTitle: 'Chat Full Width',
+ textSubtitle: "Expand chats to screen's edge for wider conversation view",
+ })}
+
`
function whenFullWidth() {
@@ -71,7 +81,9 @@ function whenFullWidth() {
chat_user_edit_icon_top: FW_OPTIONS.chat_user_edit_icon_top,
chat_user_edit_icon_transform: FW_OPTIONS.chat_user_edit_icon_transform,
})
- // setInputCheckedValue('gpth-full-width', true)
+ setInputCheckedValue('gpth-full-width', true)
+ setRangeOutput('gpth-full-width-custom', removePercentAndRem(FW_OPTIONS.w_chat_gpt))
+ setInputFieldValue('gpth-full-width-custom', removePercentAndRem(FW_OPTIONS.w_chat_gpt))
}
function whenDefaultWidth() {
applySettings({
@@ -88,7 +100,9 @@ function whenDefaultWidth() {
chat_user_edit_icon_top: FW_DEFAULTS.chat_user_edit_icon_top,
chat_user_edit_icon_transform: FW_DEFAULTS.chat_user_edit_icon_transform,
})
- // setInputCheckedValue('gpth-full-width', false)
+ setInputCheckedValue('gpth-full-width', false)
+ setRangeOutput('gpth-full-width-custom', removePercentAndRem(FW_DEFAULTS.w_chat_gpt))
+ setInputFieldValue('gpth-full-width-custom', removePercentAndRem(FW_DEFAULTS.w_chat_gpt))
}
function toggleChatFullWidth(e) {
if (e.target.checked) {
@@ -133,12 +147,12 @@ async function loadSettings() {
applySettings(settings)
// Set the checked attribute based on the saved settings
- // setInputCheckedValue('gpth-full-width', settings.w_chat_gpt === '100%')
- setRangeOutput('gpth-full-width-custom', removePercent(settings.w_chat_gpt))
- setInputFieldValue('gpth-full-width-custom', removePercent(settings.w_chat_gpt))
+ setInputCheckedValue('gpth-full-width', settings.w_chat_gpt === '100%')
+ setRangeOutput('gpth-full-width-custom', removePercentAndRem(settings.w_chat_gpt))
+ setInputFieldValue('gpth-full-width-custom', removePercentAndRem(settings.w_chat_gpt))
- setRangeOutput('gpth-textarea-width-custom', removePercent(settings.w_prompt_textarea))
- setInputFieldValue('gpth-textarea-width-custom', removePercent(settings.w_prompt_textarea))
+ setRangeOutput('gpth-textarea-width-custom', removePercentAndRem(settings.w_prompt_textarea))
+ setInputFieldValue('gpth-textarea-width-custom', removePercentAndRem(settings.w_prompt_textarea))
} catch (error) {
console.error('Failed to load settings:', error)
}
@@ -161,7 +175,7 @@ function handleChatCustomWidth(e) {
w_chat_gpt: `${e.target.value}%`,
})
- // setInputCheckedValue('gpth-full-width', false)
+ setInputCheckedValue('gpth-full-width', false)
}
function handleTextareaCustomWidth(e) {
console.log('handleChatCustomWidth()', e.target.id)
@@ -174,7 +188,7 @@ function handleTextareaCustomWidth(e) {
saveSettings({
w_prompt_textarea: `${e.target.value}%`,
})
- // setInputCheckedValue('gpth-full-width', false)
+ setInputCheckedValue('gpth-full-width', false)
}
function handleAssetsListeners() {
@@ -186,7 +200,7 @@ function handleAssetsListeners() {
textareaCustomWidth: document.querySelector('.gpth-settings #gpth-textarea-width-custom'),
}
- // selectors.chatFullWidth.addEventListener('change', toggleChatFullWidth)
+ selectors.chatFullWidth.addEventListener('change', toggleChatFullWidth)
selectors.chatCustomWidth.addEventListener('change', handleChatCustomWidth)
selectors.textareaCustomWidth.addEventListener('change', handleTextareaCustomWidth)
}
From 0626032c0625b2043bbb88272b922fc6e82854bd Mon Sep 17 00:00:00 2001
From: itsmartashub <44645238+itsmartashub@users.noreply.github.com>
Date: Wed, 19 Jun 2024 14:27:50 +0200
Subject: [PATCH 13/27] feat(textarea-sync): Enhance width customization
options
- Implement "Sync Textarea with Chat Width" logic to synchronize prompt textarea width with chat bubbles
- Add "Reset All Widths" buttons to easily restore default width settings for chat bubbles and prompt textarea
Changes summary:
- Enhanced width customization options:
- Introduced the ability to synchronize the prompt textarea width with the width of chat bubbles, providing a consistent user experience.
- Added "Reset All Widths" buttons to allow users to conveniently restore the default width settings for both chat bubbles and the prompt textarea.
---
src/js/app/components/renderButtons.js | 7 ++
src/js/app/components/renderFonts.js | 8 --
src/js/app/mainAssets.js | 110 ++++++++++++++++--
src/js/app/mainFonts.js | 1 +
src/sass/elements/_right--main.scss | 3 +-
.../theme-manager/components/_switch.scss | 2 +-
6 files changed, 112 insertions(+), 19 deletions(-)
create mode 100644 src/js/app/components/renderButtons.js
diff --git a/src/js/app/components/renderButtons.js b/src/js/app/components/renderButtons.js
new file mode 100644
index 0000000..7d2b74e
--- /dev/null
+++ b/src/js/app/components/renderButtons.js
@@ -0,0 +1,7 @@
+export function renderButton({ name, className, id, content, disabled = false }) {
+ return `
+
+ `
+}
diff --git a/src/js/app/components/renderFonts.js b/src/js/app/components/renderFonts.js
index 16eea1b..89209cb 100644
--- a/src/js/app/components/renderFonts.js
+++ b/src/js/app/components/renderFonts.js
@@ -91,11 +91,3 @@ export function renderFontBigCard({
// return cardHtml
// }
-
-export function renderButton({ name, className, id, content, disabled = false }) {
- return `
-
- `
-}
diff --git a/src/js/app/mainAssets.js b/src/js/app/mainAssets.js
index 3d793eb..17ea0d6 100644
--- a/src/js/app/mainAssets.js
+++ b/src/js/app/mainAssets.js
@@ -1,9 +1,13 @@
import browser from 'webextension-polyfill'
import { renderSwitchOption, renderSmallCardOption } from './components/renderSwitch'
import { icon_full_width } from './components/icons'
+import { renderButton } from './components/renderButtons'
const removePercentAndRem = (str) => str.replace(/%|rem/g, '') // /%/g
+// Example keys to remove
+// Get the keys from FW_DEFAULTS object
+
const FW_DEFAULTS = {
w_chat_user: 'initial',
w_chat_gpt: '48rem',
@@ -11,6 +15,7 @@ const FW_DEFAULTS = {
chat_user_edit_icon_right: '100%',
chat_user_edit_icon_top: '0',
chat_user_edit_icon_transform: 'unset',
+ isTextareaSync: false,
}
const FW_OPTIONS = {
w_chat_user: '100%',
@@ -21,14 +26,8 @@ const FW_OPTIONS = {
chat_user_edit_icon_transform: 'translateY(-1.25rem)',
}
-// ${renderSwitchOption({
-// inputId: 'gpth-full-width',
-// isChecked: false,
-// icon: icon_full_width,
-// textTitle: 'Chat Full Width',
-// // textSubtitle: 'Maximize the chat layout and prompt field to fill the screen',
-// textSubtitle: "Expand chat and prompt field to screen's edge for wider conversation view",
-// })}
+const keysToRemove = Object.keys(FW_DEFAULTS)
+
let assetsHtmlCode = `
@@ -63,7 +62,18 @@ let assetsHtmlCode = `
textTitle: 'Chat Full Width',
textSubtitle: "Expand chats to screen's edge for wider conversation view",
})}
+ ${renderSwitchOption({
+ inputId: 'gpth-sync-textarea-chat-width',
+ isChecked: false,
+ icon: icon_full_width,
+ textTitle: 'Sync Width',
+ textSubtitle: 'Adjust prompt field to match the chat width for a more streamlined and consistent view',
+ })}
+
+
`
function whenFullWidth() {
@@ -111,10 +121,43 @@ function toggleChatFullWidth(e) {
whenDefaultWidth()
}
}
+function toggleSyncTextareaWithChatWidth(e) {
+ console.log('toggleSyncTextareaWithChatWidth()', e.target.id)
+
+ if (e.target.checked) {
+ const wChatGpt = removePercentAndRem(
+ getComputedStyle(document.documentElement).getPropertyValue('--w_chat_gpt')
+ )
+
+ applySettings({
+ w_prompt_textarea: 'var(--w_chat_gpt)',
+ })
+ saveSettings({
+ w_prompt_textarea: wChatGpt,
+ isTextareaSync: true,
+ })
+ setRangeOutput('gpth-textarea-width-custom', wChatGpt)
+ setInputFieldValue('gpth-textarea-width-custom', wChatGpt)
+ setInputCheckedValue('gpth-sync-textarea-chat-width', true)
+ } else {
+ applySettings({
+ w_prompt_textarea: FW_DEFAULTS.w_prompt_textarea,
+ })
+ saveSettings({
+ w_prompt_textarea: FW_DEFAULTS.w_prompt_textarea,
+ isTextareaSync: false,
+ })
+ setRangeOutput('gpth-textarea-width-custom', removePercentAndRem(FW_DEFAULTS.w_prompt_textarea))
+ setInputFieldValue('gpth-textarea-width-custom', removePercentAndRem(FW_DEFAULTS.w_prompt_textarea))
+ setInputCheckedValue('gpth-sync-textarea-chat-width', false)
+ }
+
+ // setRangeOutput('gpth-textarea-width-custom', removePercentAndRem(FW_DEFAULTS.w_chat_gpt))
+ // setInputFieldValue('gpth-textarea-width-custom', removePercentAndRem(FW_DEFAULTS.w_chat_gpt))
+}
function applySettings(settings) {
Object.entries(settings).forEach(([key, value]) => {
document.documentElement.style.setProperty(`--${key}`, value)
-
// console.log(key, getComputedStyle(document.documentElement).getPropertyValue(`--${key}`))
})
}
@@ -148,16 +191,37 @@ async function loadSettings() {
applySettings(settings)
// Set the checked attribute based on the saved settings
setInputCheckedValue('gpth-full-width', settings.w_chat_gpt === '100%')
+ // Textarea sync
+ // setInputCheckedValue('gpth-sync-textarea-chat-width', settings.w_chat_gpt === settings.w_prompt_textarea)
+ setInputCheckedValue('gpth-sync-textarea-chat-width', settings.isTextareaSync)
+
setRangeOutput('gpth-full-width-custom', removePercentAndRem(settings.w_chat_gpt))
setInputFieldValue('gpth-full-width-custom', removePercentAndRem(settings.w_chat_gpt))
setRangeOutput('gpth-textarea-width-custom', removePercentAndRem(settings.w_prompt_textarea))
setInputFieldValue('gpth-textarea-width-custom', removePercentAndRem(settings.w_prompt_textarea))
+
+ // setRangeOutput('gpth-textarea-width-custom', removePercentAndRem(settings.w_prompt_textarea))
+ // setInputFieldValue('gpth-textarea-width-custom', removePercentAndRem(settings.w_prompt_textarea))
} catch (error) {
console.error('Failed to load settings:', error)
}
}
+// Function to reset fonts to default
+function resetWidths() {
+ applySettings(FW_DEFAULTS)
+ saveSettings(FW_DEFAULTS)
+
+ setInputCheckedValue('gpth-full-width', false)
+ setInputCheckedValue('gpth-sync-textarea-chat-width', FW_DEFAULTS.isTextareaSync)
+
+ setInputFieldValue('gpth-full-width-custom', removePercentAndRem(FW_DEFAULTS.w_chat_gpt))
+ setRangeOutput('gpth-textarea-width-custom', removePercentAndRem(FW_DEFAULTS.w_prompt_textarea))
+
+ // removeSpecificStorageItems(keysToRemove)
+}
+
function handleChatCustomWidth(e) {
console.log('handleChatCustomWidth()', e.target.id)
setRangeOutput('gpth-full-width-custom', e.target.value)
@@ -196,19 +260,47 @@ function handleAssetsListeners() {
const selectors = {
chatFullWidth: document.querySelector('.gpth-settings #gpth-full-width'),
+ syncTextareaWithChats: document.querySelector('.gpth-settings #gpth-sync-textarea-chat-width'),
chatCustomWidth: document.querySelector('.gpth-settings #gpth-full-width-custom'),
textareaCustomWidth: document.querySelector('.gpth-settings #gpth-textarea-width-custom'),
+ btnReset: document.querySelector('.gpth-settings #resetWidths'),
}
selectors.chatFullWidth.addEventListener('change', toggleChatFullWidth)
+ selectors.syncTextareaWithChats.addEventListener('change', toggleSyncTextareaWithChatWidth)
selectors.chatCustomWidth.addEventListener('change', handleChatCustomWidth)
selectors.textareaCustomWidth.addEventListener('change', handleTextareaCustomWidth)
+ selectors.btnReset.addEventListener('click', resetWidths)
}
// Load settings on page load
function init() {
console.log('initAssets() called')
loadSettings()
+
+ getAllStorageItems()
+}
+
+// Function to get all storage items
+async function getAllStorageItems() {
+ try {
+ // Get all items from the local storage
+ const items = await browser.storage.sync.get(null)
+ console.log(items)
+ return items
+ } catch (error) {
+ console.error('Error getting storage items:', error)
+ }
+}
+// Function to remove specific named items from sync storage
+async function removeSpecificStorageItems(keys) {
+ try {
+ // Remove the items by keys from the sync storage
+ await browser.storage.sync.remove(keys)
+ console.log('Specified items removed from sync storage:', keys)
+ } catch (error) {
+ console.error('Error removing storage items:', error)
+ }
}
export { assetsHtmlCode, handleAssetsListeners, init }
diff --git a/src/js/app/mainFonts.js b/src/js/app/mainFonts.js
index ab02749..01933cf 100644
--- a/src/js/app/mainFonts.js
+++ b/src/js/app/mainFonts.js
@@ -1,6 +1,7 @@
// main.js
import browser from 'webextension-polyfill'
import { renderFontSmallCard, renderFontBigCard, renderButton } from './components/renderFonts'
+import { renderButton } from './components/renderButtons'
// Constants
const DEFAULTS = {
diff --git a/src/sass/elements/_right--main.scss b/src/sass/elements/_right--main.scss
index 40853ef..e57e3cf 100644
--- a/src/sass/elements/_right--main.scss
+++ b/src/sass/elements/_right--main.scss
@@ -423,7 +423,8 @@ main {
[data-testid^='conversation-turn-'] .mx-auto.flex.flex-1.text-base,
[data-testid^='conversation-turn-']:has([data-message-author-role='user']) [class*='bg-[#f4f4f4]'],
- &:has(#prompt-textarea) [class*='lg:max-w-[40rem]'] {
+ &:has(#prompt-textarea) [class*='lg:max-w-[40rem]'],
+ &:has(#prompt-textarea) .px-3.text-base.m-auto .mx-auto.flex.flex-1.text-base:has(>form) {
transition: 0.3s ease-in-out;
}
}
\ No newline at end of file
diff --git a/src/sass/gpthemes/theme-manager/components/_switch.scss b/src/sass/gpthemes/theme-manager/components/_switch.scss
index f1b686b..30f9689 100644
--- a/src/sass/gpthemes/theme-manager/components/_switch.scss
+++ b/src/sass/gpthemes/theme-manager/components/_switch.scss
@@ -2,7 +2,7 @@
display: flex;
align-items: center;
justify-content: space-between;
- margin-bottom: 2rem;
+ margin-bottom: 0.5rem;
cursor: pointer;
font-size: 1rem;
gap: 0.8rem;
From 6885de2473cd99c71a6a75552589bbb3a44ad153 Mon Sep 17 00:00:00 2001
From: itsmartashub <44645238+itsmartashub@users.noreply.github.com>
Date: Thu, 11 Jul 2024 16:37:38 +0200
Subject: [PATCH 14/27] refactor: Overhaul width customization
- Refactor and fix issues related to custom chat bubble and prompt textarea widths
- Implement proper synchronization between chat bubble width and prompt textarea width
- Fix issues with locking the textarea width to chat widths
Changes summary:
- Overhauled the width customization logic:
- Refactored and fixed issues related to custom chat bubble and prompt textarea widths.
- Implemented proper synchronization between chat bubble width and prompt textarea width, ensuring a consistent user experience.
- Addressed and resolved issues with locking the textarea width to chat widths.
---
src/js/app/floatingBtn.js | 3 +-
src/js/app/mainAssets.js | 167 ++++++++++++--------
src/js/app/mainAssetsUpgrade.js | 266 ++++++++++++++++++++++++++++++++
src/js/content.js | 3 +-
4 files changed, 370 insertions(+), 69 deletions(-)
create mode 100644 src/js/app/mainAssetsUpgrade.js
diff --git a/src/js/app/floatingBtn.js b/src/js/app/floatingBtn.js
index c27ddb5..cf51610 100644
--- a/src/js/app/floatingBtn.js
+++ b/src/js/app/floatingBtn.js
@@ -6,7 +6,8 @@ import { hexToHSL } from '../utils/hexToHSL'
// import { fontHtmlCode, addFontsEventHandlers } from './customFonts'
import { fontHtmlCode, handleFontsListeners } from './mainFonts'
-import { assetsHtmlCode, handleAssetsListeners } from './mainAssets'
+// import { assetsHtmlCode, handleAssetsListeners } from './mainAssets'
+import { assetsHtmlCode, handleAssetsListeners } from './mainAssetsUpgrade.js'
// console.log(fontHtmlCode)
// let isOptionsShown = false
diff --git a/src/js/app/mainAssets.js b/src/js/app/mainAssets.js
index 17ea0d6..c2f4442 100644
--- a/src/js/app/mainAssets.js
+++ b/src/js/app/mainAssets.js
@@ -3,7 +3,7 @@ import { renderSwitchOption, renderSmallCardOption } from './components/renderSw
import { icon_full_width } from './components/icons'
import { renderButton } from './components/renderButtons'
-const removePercentAndRem = (str) => str.replace(/%|rem/g, '') // /%/g
+const removePercentAndRem = (str) => str?.replace(/%|rem/g, '') // /%/g
// Example keys to remove
// Get the keys from FW_DEFAULTS object
@@ -15,17 +15,18 @@ const FW_DEFAULTS = {
chat_user_edit_icon_right: '100%',
chat_user_edit_icon_top: '0',
chat_user_edit_icon_transform: 'unset',
- isTextareaSync: false,
}
const FW_OPTIONS = {
w_chat_user: '100%',
w_chat_gpt: '100%',
- w_prompt_textarea: '100%',
chat_user_edit_icon_right: 'calc(0% + 2rem)',
chat_user_edit_icon_top: '100%',
chat_user_edit_icon_transform: 'translateY(-1.25rem)',
}
+// let isTextareaSync = false
+// let isFullWidth = false
+
const keysToRemove = Object.keys(FW_DEFAULTS)
let assetsHtmlCode = `
@@ -76,43 +77,72 @@ let assetsHtmlCode = `
`
+
+// let isTextareaSync = document.querySelector('.gpth-settings #gpth-sync-textarea-chat-width').checked ? true : false
+// let isFullWidth = document.querySelector('.gpth-settings #gpth-full-width').checked ? true : false
+
function whenFullWidth() {
- applySettings({
- w_chat_user: FW_OPTIONS.w_chat_user,
- w_chat_gpt: FW_OPTIONS.w_chat_gpt,
- chat_user_edit_icon_right: FW_OPTIONS.chat_user_edit_icon_right,
- chat_user_edit_icon_top: FW_OPTIONS.chat_user_edit_icon_top,
- chat_user_edit_icon_transform: FW_OPTIONS.chat_user_edit_icon_transform,
- })
- saveSettings({
- w_chat_user: FW_OPTIONS.w_chat_user,
- w_chat_gpt: FW_OPTIONS.w_chat_gpt,
- chat_user_edit_icon_right: FW_OPTIONS.chat_user_edit_icon_right,
- chat_user_edit_icon_top: FW_OPTIONS.chat_user_edit_icon_top,
- chat_user_edit_icon_transform: FW_OPTIONS.chat_user_edit_icon_transform,
- })
- setInputCheckedValue('gpth-full-width', true)
- setRangeOutput('gpth-full-width-custom', removePercentAndRem(FW_OPTIONS.w_chat_gpt))
- setInputFieldValue('gpth-full-width-custom', removePercentAndRem(FW_OPTIONS.w_chat_gpt))
+ // isFullWidth = true
+ // const customTextareaValue = document.querySelector('#gpth-textarea-width-custom').value
+ const textareaCSSVar = getComputedStyle(document.documentElement).getPropertyValue('--w_prompt_textarea')
+
+ // let isTextareaSync = FW_OPTIONS.w_chat_gpt === textareaCSSVar
+
+ // console.log({ textareaCSSVar, isTextareaSync })
+ console.log('whenFullWidth', textareaCSSVar)
+
+ let fwOptions = {
+ ...FW_OPTIONS,
+ w_prompt_textarea: textareaCSSVar,
+ }
+
+ applySettings(fwOptions)
+ saveSettings(fwOptions)
+ // saveSettings({ ...fwOptions, isFullWidth, isTextareaSync })
+
+ setInputCheckedValue('gpth-sync-textarea-chat-width', FW_OPTIONS.w_chat_gpt === textareaCSSVar)
+ setInputFieldValue('gpth-textarea-width-custom', removePercentAndRem(fwOptions.w_prompt_textarea))
+ setRangeOutput('gpth-textarea-width-custom', removePercentAndRem(fwOptions.w_prompt_textarea))
+
+ setInputCheckedValue('gpth-full-width', fwOptions.w_chat_gpt === '100%')
+ setInputFieldValue('gpth-full-width-custom', removePercentAndRem(fwOptions.w_chat_gpt))
+ setRangeOutput('gpth-full-width-custom', removePercentAndRem(fwOptions.w_chat_gpt))
}
function whenDefaultWidth() {
- applySettings({
- w_chat_user: FW_DEFAULTS.w_chat_user,
- w_chat_gpt: FW_DEFAULTS.w_chat_gpt,
- chat_user_edit_icon_right: FW_DEFAULTS.chat_user_edit_icon_right,
- chat_user_edit_icon_top: FW_DEFAULTS.chat_user_edit_icon_top,
- chat_user_edit_icon_transform: FW_DEFAULTS.chat_user_edit_icon_transform,
- })
- saveSettings({
- w_chat_user: FW_DEFAULTS.w_chat_user,
- w_chat_gpt: FW_DEFAULTS.w_chat_gpt,
- chat_user_edit_icon_right: FW_DEFAULTS.chat_user_edit_icon_right,
- chat_user_edit_icon_top: FW_DEFAULTS.chat_user_edit_icon_top,
- chat_user_edit_icon_transform: FW_DEFAULTS.chat_user_edit_icon_transform,
- })
- setInputCheckedValue('gpth-full-width', false)
- setRangeOutput('gpth-full-width-custom', removePercentAndRem(FW_DEFAULTS.w_chat_gpt))
- setInputFieldValue('gpth-full-width-custom', removePercentAndRem(FW_DEFAULTS.w_chat_gpt))
+ // isFullWidth = false
+ // const customTextareaValue = document.querySelector('#gpth-textarea-width-custom').value
+ const textareaCSSVar = getComputedStyle(document.documentElement).getPropertyValue('--w_prompt_textarea')
+ console.log('whenDefaultWidth', textareaCSSVar)
+
+ // console.log('whenDefaultWidth', { textareaCSSVar }, FW_DEFAULTS.w_chat_gpt)
+
+ // let isTextareaSync = FW_DEFAULTS.w_chat_gpt === textareaCSSVar
+
+ // console.log({ textareaCSSVar, isTextareaSync })
+
+ let dwOptions = {
+ w_chat_user: 'initial',
+ w_chat_gpt: '48rem',
+ w_prompt_textarea: textareaCSSVar,
+ // w_prompt_textarea:
+ // FW_DEFAULTS.w_chat_gpt === `${customTextareaValue}%` ? FW_DEFAULTS.w_chat_gpt : `${customTextareaValue}%`,
+ chat_user_edit_icon_right: '100%',
+ chat_user_edit_icon_top: '0',
+ chat_user_edit_icon_transform: 'unset',
+ }
+
+ applySettings(dwOptions)
+ saveSettings(dwOptions)
+ // saveSettings({ ...dwOptions, isFullWidth, isTextareaSync })
+
+ setInputCheckedValue('gpth-sync-textarea-chat-width', dwOptions.w_chat_gpt === dwOptions.w_prompt_textarea)
+ // setInputCheckedValue('gpth-sync-textarea-chat-width', dwOptions.w_chat_gpt === '100%')
+ setInputFieldValue('gpth-textarea-width-custom', removePercentAndRem(dwOptions.w_prompt_textarea))
+ setRangeOutput('gpth-textarea-width-custom', removePercentAndRem(dwOptions.w_prompt_textarea))
+
+ setInputCheckedValue('gpth-full-width', dwOptions.w_chat_gpt === '100%')
+ setRangeOutput('gpth-full-width-custom', removePercentAndRem(dwOptions.w_chat_gpt))
+ setInputFieldValue('gpth-full-width-custom', removePercentAndRem(dwOptions.w_chat_gpt))
}
function toggleChatFullWidth(e) {
if (e.target.checked) {
@@ -122,40 +152,35 @@ function toggleChatFullWidth(e) {
}
}
function toggleSyncTextareaWithChatWidth(e) {
- console.log('toggleSyncTextareaWithChatWidth()', e.target.id)
+ isTextareaSync = e.target.checked
if (e.target.checked) {
- const wChatGpt = removePercentAndRem(
- getComputedStyle(document.documentElement).getPropertyValue('--w_chat_gpt')
- )
+ const wChatGpt = getComputedStyle(document.documentElement).getPropertyValue('--w_chat_gpt')
applySettings({
w_prompt_textarea: 'var(--w_chat_gpt)',
})
saveSettings({
w_prompt_textarea: wChatGpt,
- isTextareaSync: true,
})
- setRangeOutput('gpth-textarea-width-custom', wChatGpt)
- setInputFieldValue('gpth-textarea-width-custom', wChatGpt)
- setInputCheckedValue('gpth-sync-textarea-chat-width', true)
+ setInputFieldValue('gpth-textarea-width-custom', removePercentAndRem(wChatGpt))
+ setRangeOutput('gpth-textarea-width-custom', removePercentAndRem(wChatGpt))
} else {
applySettings({
w_prompt_textarea: FW_DEFAULTS.w_prompt_textarea,
})
saveSettings({
w_prompt_textarea: FW_DEFAULTS.w_prompt_textarea,
- isTextareaSync: false,
})
setRangeOutput('gpth-textarea-width-custom', removePercentAndRem(FW_DEFAULTS.w_prompt_textarea))
setInputFieldValue('gpth-textarea-width-custom', removePercentAndRem(FW_DEFAULTS.w_prompt_textarea))
- setInputCheckedValue('gpth-sync-textarea-chat-width', false)
}
- // setRangeOutput('gpth-textarea-width-custom', removePercentAndRem(FW_DEFAULTS.w_chat_gpt))
- // setInputFieldValue('gpth-textarea-width-custom', removePercentAndRem(FW_DEFAULTS.w_chat_gpt))
+ setInputCheckedValue('gpth-sync-textarea-chat-width', isTextareaSync)
}
function applySettings(settings) {
+ console.log('applySettings', settings)
+
Object.entries(settings).forEach(([key, value]) => {
document.documentElement.style.setProperty(`--${key}`, value)
// console.log(key, getComputedStyle(document.documentElement).getPropertyValue(`--${key}`))
@@ -178,6 +203,8 @@ function setRangeOutput(inputSelector, inputVal) {
}
// Function to save settings to Chrome Storage
async function saveSettings(settings) {
+ console.log('saveSettings', settings)
+
try {
await browser.storage.sync.set(settings)
} catch (error) {
@@ -186,23 +213,25 @@ async function saveSettings(settings) {
}
async function loadSettings() {
try {
+ // const settings = await browser.storage.sync.get(Object.keys({ ...FW_DEFAULTS, isFullWidth, isTextareaSync }))
const settings = await browser.storage.sync.get(Object.keys(FW_DEFAULTS))
+ console.log('loadSettings', settings)
+
+ // const { isTextareaSync, isFullWidth, ...rest } = settings
+
+ // isTextareaSync = settings.isTextareaSync
+ // isFullWidth = settings.isFullWidth
applySettings(settings)
// Set the checked attribute based on the saved settings
+ // setInputCheckedValue('gpth-full-width', isFullWidth)
setInputCheckedValue('gpth-full-width', settings.w_chat_gpt === '100%')
- // Textarea sync
- // setInputCheckedValue('gpth-sync-textarea-chat-width', settings.w_chat_gpt === settings.w_prompt_textarea)
- setInputCheckedValue('gpth-sync-textarea-chat-width', settings.isTextareaSync)
-
- setRangeOutput('gpth-full-width-custom', removePercentAndRem(settings.w_chat_gpt))
setInputFieldValue('gpth-full-width-custom', removePercentAndRem(settings.w_chat_gpt))
+ setRangeOutput('gpth-full-width-custom', removePercentAndRem(settings.w_chat_gpt))
- setRangeOutput('gpth-textarea-width-custom', removePercentAndRem(settings.w_prompt_textarea))
+ setInputCheckedValue('gpth-sync-textarea-chat-width', settings.w_chat_gpt === settings.w_prompt_textarea)
setInputFieldValue('gpth-textarea-width-custom', removePercentAndRem(settings.w_prompt_textarea))
-
- // setRangeOutput('gpth-textarea-width-custom', removePercentAndRem(settings.w_prompt_textarea))
- // setInputFieldValue('gpth-textarea-width-custom', removePercentAndRem(settings.w_prompt_textarea))
+ setRangeOutput('gpth-textarea-width-custom', removePercentAndRem(settings.w_prompt_textarea))
} catch (error) {
console.error('Failed to load settings:', error)
}
@@ -210,16 +239,18 @@ async function loadSettings() {
// Function to reset fonts to default
function resetWidths() {
- applySettings(FW_DEFAULTS)
- saveSettings(FW_DEFAULTS)
+ whenDefaultWidth()
- setInputCheckedValue('gpth-full-width', false)
- setInputCheckedValue('gpth-sync-textarea-chat-width', FW_DEFAULTS.isTextareaSync)
+ // applySettings(FW_DEFAULTS)
+ // saveSettings({ ...FW_DEFAULTS, isFullWidth, isTextareaSync })
- setInputFieldValue('gpth-full-width-custom', removePercentAndRem(FW_DEFAULTS.w_chat_gpt))
- setRangeOutput('gpth-textarea-width-custom', removePercentAndRem(FW_DEFAULTS.w_prompt_textarea))
+ // setRangeOutput('gpth-textarea-width-custom', removePercentAndRem(FW_DEFAULTS.w_prompt_textarea))
+ // setInputFieldValue('gpth-textarea-width-custom', FW_DEFAULTS.w_prompt_textarea)
+ // setInputCheckedValue('gpth-sync-textarea-chat-width', isTextareaSync)
- // removeSpecificStorageItems(keysToRemove)
+ // setRangeOutput('gpth-full-width-custom', removePercentAndRem(FW_DEFAULTS.w_chat_gpt))
+ // setInputFieldValue('gpth-full-width-custom', removePercentAndRem(FW_DEFAULTS.w_chat_gpt))
+ // setInputCheckedValue('gpth-full-width', FW_DEFAULTS.isFullWidth)
}
function handleChatCustomWidth(e) {
@@ -242,7 +273,6 @@ function handleChatCustomWidth(e) {
setInputCheckedValue('gpth-full-width', false)
}
function handleTextareaCustomWidth(e) {
- console.log('handleChatCustomWidth()', e.target.id)
setRangeOutput('gpth-textarea-width-custom', e.target.value)
setInputFieldValue('gpth-textarea-width-custom', e.target.value)
@@ -252,7 +282,9 @@ function handleTextareaCustomWidth(e) {
saveSettings({
w_prompt_textarea: `${e.target.value}%`,
})
+ // setInputCheckedValue('gpth-full-width', false)
setInputCheckedValue('gpth-full-width', false)
+ setInputCheckedValue('gpth-sync-textarea-chat-width', false)
}
function handleAssetsListeners() {
@@ -275,10 +307,11 @@ function handleAssetsListeners() {
// Load settings on page load
function init() {
- console.log('initAssets() called')
loadSettings()
getAllStorageItems()
+
+ // removeSpecificStorageItems([...keysToRemove, 'isFullWidth', 'isTextareaSync'])
}
// Function to get all storage items
diff --git a/src/js/app/mainAssetsUpgrade.js b/src/js/app/mainAssetsUpgrade.js
new file mode 100644
index 0000000..40e540f
--- /dev/null
+++ b/src/js/app/mainAssetsUpgrade.js
@@ -0,0 +1,266 @@
+import browser from 'webextension-polyfill'
+import { renderSwitchOption, renderSmallCardOption } from './components/renderSwitch'
+import { icon_full_width } from './components/icons'
+import { renderButton } from './components/renderButtons'
+
+const removePercentAndRem = (str) => str?.replace(/%|rem/g, '')
+
+const FW_DEFAULTS = {
+ w_chat_user: 'initial',
+ w_chat_gpt: '48rem',
+ w_prompt_textarea: '48rem',
+ chat_user_edit_icon_right: '100%',
+ chat_user_edit_icon_top: '0',
+ chat_user_edit_icon_transform: 'unset',
+}
+
+const FW_OPTIONS = {
+ w_chat_user: '100%',
+ w_chat_gpt: '100%',
+ chat_user_edit_icon_right: 'calc(0% + 2rem)',
+ chat_user_edit_icon_top: '100%',
+ chat_user_edit_icon_transform: 'translateY(-1.25rem)',
+}
+
+let currentSettings = { ...FW_DEFAULTS }
+let isSyncEnabled = false
+
+const keysToRemove = Object.keys(FW_DEFAULTS)
+
+let assetsHtmlCode = `
+
+
+ ${renderSmallCardOption({
+ name: 'Chats Width',
+ inputId: 'gpth-full-width-custom',
+ inputType: 'range',
+ inputValue: removePercentAndRem(FW_DEFAULTS.w_chat_gpt),
+ inputPlaceholder: '100%',
+ min: 0,
+ max: 100,
+ unit: '%',
+ })}
+ ${renderSmallCardOption({
+ name: 'Message Width',
+ inputId: 'gpth-textarea-width-custom',
+ inputType: 'range',
+ inputValue: removePercentAndRem(FW_DEFAULTS.w_prompt_textarea),
+ inputPlaceholder: '100%',
+ min: 0,
+ max: 100,
+ unit: '%',
+ })}
+
+
+
+ ${renderSwitchOption({
+ inputId: 'gpth-full-width',
+ isChecked: false,
+ icon: icon_full_width,
+ textTitle: 'Chat Full Width',
+ textSubtitle: "Expand chats to screen's edge for wider conversation view",
+ })}
+ ${renderSwitchOption({
+ inputId: 'gpth-sync-textarea-chat-width',
+ isChecked: false,
+ icon: icon_full_width,
+ textTitle: 'Sync Width',
+ textSubtitle: 'Adjust prompt field to match the chat width for a more streamlined and consistent view',
+ })}
+
+
+
+
+`
+
+function applySettings(settings) {
+ Object.entries(settings).forEach(([key, value]) => {
+ document.documentElement.style.setProperty(`--${key}`, value)
+ })
+}
+
+function setInputCheckedValue(inputSelector, isChecked) {
+ const inputEl = document.querySelector(`.gpth-settings #${inputSelector}`)
+ if (inputEl) inputEl.checked = isChecked
+}
+
+// Add this helper function
+function ensureValidPercentage(value) {
+ const numValue = parseInt(value, 10)
+ if (isNaN(numValue) || numValue < 0) return '0'
+ if (numValue > 100) return '100'
+ return numValue.toString()
+}
+function setRangeOutput(inputSelector, inputVal) {
+ const outputRangeEl = document.querySelector(`.gpth-settings #range-output-${inputSelector}`)
+ if (outputRangeEl) {
+ outputRangeEl.textContent = ensureValidPercentage(inputVal)
+ }
+}
+function setInputFieldValue(inputSelector, inputVal) {
+ const inputEl = document.querySelector(`.gpth-settings #${inputSelector}`)
+ if (inputEl) {
+ inputEl.value = ensureValidPercentage(inputVal)
+ }
+}
+
+async function saveSettings(settings) {
+ try {
+ await browser.storage.sync.set(settings)
+ } catch (error) {
+ console.error('Failed to save settings:', error)
+ }
+}
+
+async function loadSettings() {
+ try {
+ const settings = await browser.storage.sync.get(null)
+ currentSettings = { ...FW_DEFAULTS, ...settings }
+ isSyncEnabled = currentSettings.w_chat_gpt === currentSettings.w_prompt_textarea
+
+ applySettings(currentSettings)
+ updateUI(currentSettings)
+ } catch (error) {
+ console.error('Failed to load settings:', error)
+ }
+}
+
+function updateUI(settings) {
+ const isFullWidth = settings.w_chat_gpt === '100%'
+
+ setInputCheckedValue('gpth-full-width', isFullWidth)
+ setInputFieldValue('gpth-full-width-custom', removePercentAndRem(settings.w_chat_gpt))
+ setRangeOutput('gpth-full-width-custom', removePercentAndRem(settings.w_chat_gpt))
+
+ setInputCheckedValue('gpth-sync-textarea-chat-width', isSyncEnabled)
+ setInputFieldValue('gpth-textarea-width-custom', removePercentAndRem(settings.w_prompt_textarea))
+ setRangeOutput('gpth-textarea-width-custom', removePercentAndRem(settings.w_prompt_textarea))
+
+ // Disable textarea width slider when sync is enabled
+ const textareaWidthSlider = document.querySelector('#gpth-textarea-width-custom')
+ if (textareaWidthSlider) {
+ textareaWidthSlider.disabled = isSyncEnabled
+ }
+}
+
+function toggleChatFullWidth(e) {
+ const isFullWidth = e.target.checked
+ if (isFullWidth) {
+ currentSettings.w_chat_gpt = '100%'
+ if (isSyncEnabled) {
+ currentSettings.w_prompt_textarea = '100%'
+ }
+ } else {
+ currentSettings.w_chat_gpt = FW_DEFAULTS.w_chat_gpt
+ if (isSyncEnabled) {
+ currentSettings.w_prompt_textarea = FW_DEFAULTS.w_chat_gpt
+ }
+ }
+
+ applySettings(currentSettings)
+ saveSettings(currentSettings)
+ updateUI(currentSettings)
+}
+
+function toggleSyncTextareaWithChatWidth(e) {
+ isSyncEnabled = e.target.checked
+ if (isSyncEnabled) {
+ currentSettings.w_prompt_textarea = currentSettings.w_chat_gpt
+ }
+ applySettings(currentSettings)
+ saveSettings(currentSettings)
+ updateUI(currentSettings)
+}
+
+function handleChatCustomWidth(e) {
+ const value = `${e.target.value}%`
+ currentSettings.w_chat_gpt = value
+
+ if (isSyncEnabled) {
+ currentSettings.w_prompt_textarea = value
+ }
+
+ // Uncheck full width if it's not 100%
+ if (e.target.value !== '100') {
+ setInputCheckedValue('gpth-full-width', false)
+ }
+
+ applySettings(currentSettings)
+ saveSettings(currentSettings)
+ updateUI(currentSettings)
+}
+
+function handleTextareaCustomWidth(e) {
+ const value = `${e.target.value}%`
+ currentSettings.w_prompt_textarea = value
+
+ // If user manually changes textarea width, disable sync
+ if (isSyncEnabled && value !== currentSettings.w_chat_gpt) {
+ isSyncEnabled = false
+ setInputCheckedValue('gpth-sync-textarea-chat-width', false)
+ }
+
+ applySettings(currentSettings)
+ saveSettings(currentSettings)
+ updateUI(currentSettings)
+}
+
+function resetWidths() {
+ currentSettings = { ...FW_DEFAULTS }
+ isSyncEnabled = false
+ applySettings(currentSettings)
+ saveSettings(currentSettings)
+ updateUI(currentSettings)
+}
+
+function handleAssetsListeners() {
+ const selectors = {
+ chatFullWidth: document.querySelector('.gpth-settings #gpth-full-width'),
+ syncTextareaWithChats: document.querySelector('.gpth-settings #gpth-sync-textarea-chat-width'),
+ chatCustomWidth: document.querySelector('.gpth-settings #gpth-full-width-custom'),
+ textareaCustomWidth: document.querySelector('.gpth-settings #gpth-textarea-width-custom'),
+ btnReset: document.querySelector('.gpth-settings #resetWidths'),
+ }
+
+ selectors.chatFullWidth?.addEventListener('change', toggleChatFullWidth)
+ selectors.syncTextareaWithChats?.addEventListener('change', toggleSyncTextareaWithChatWidth)
+ selectors.chatCustomWidth?.addEventListener('input', handleChatCustomWidth)
+ selectors.textareaCustomWidth?.addEventListener('input', handleTextareaCustomWidth)
+ selectors.btnReset?.addEventListener('click', resetWidths)
+}
+
+// Load settings on page load
+function init() {
+ // removeSpecificStorageItems(keysToRemove)
+ loadSettings()
+
+ getAllStorageItems()
+ // removeSpecificStorageItems([...keysToRemove, 'isFullWidth', 'isTextareaSync'])
+}
+
+// Function to get all storage items
+async function getAllStorageItems() {
+ try {
+ // Get all items from the local storage
+ const items = await browser.storage.sync.get(null)
+ console.log(items)
+ return items
+ } catch (error) {
+ console.error('Error getting storage items:', error)
+ }
+}
+
+// Function to remove specific named items from sync storage
+async function removeSpecificStorageItems(keys) {
+ try {
+ // Remove the items by keys from the sync storage
+ await browser.storage.sync.remove(keys)
+ console.log('Specified items removed from sync storage:', keys)
+ } catch (error) {
+ console.error('Error removing storage items:', error)
+ }
+}
+
+export { assetsHtmlCode, handleAssetsListeners, init }
diff --git a/src/js/content.js b/src/js/content.js
index 226ddf2..8f9a4df 100644
--- a/src/js/content.js
+++ b/src/js/content.js
@@ -1,5 +1,6 @@
import './app/floatingBtn'
import './app/mainFonts'
-import { init as initAssets } from './app/mainAssets'
+// import { init as initAssets } from './app/mainAssets'
+import { init as initAssets } from './app/mainAssetsUpgrade'
initAssets()
From 2a9cdeb30549bb5ea9f63e11016c801978c39d68 Mon Sep 17 00:00:00 2001
From: itsmartashub <44645238+itsmartashub@users.noreply.github.com>
Date: Thu, 11 Jul 2024 17:43:23 +0200
Subject: [PATCH 15/27] fix(chat-custom-width): Correct user chat bubble width
and edit icon
- Fix user chat bubble width behavior to match GPT chat bubbles
- Ensure the edit icon is visible and accessible for user chat bubbles
Changes summary:
- Corrected the width behavior of user chat bubbles to match the width of GPT chat bubbles, ensuring a consistent user experience.
- Ensured the edit icon for user chat bubbles is visible and accessible, providing users with the ability to edit their messages.
---
src/js/app/mainAssetsUpgrade.js | 62 ++++++++++++++++++++++++---------
1 file changed, 45 insertions(+), 17 deletions(-)
diff --git a/src/js/app/mainAssetsUpgrade.js b/src/js/app/mainAssetsUpgrade.js
index 40e540f..1ff1fd7 100644
--- a/src/js/app/mainAssetsUpgrade.js
+++ b/src/js/app/mainAssetsUpgrade.js
@@ -1,3 +1,5 @@
+/* const keysToRemove = Object.keys(FW_DEFsAULTS) // ? DEV ONLY var - Get the keys from FW_DEFAULTS object */
+
import browser from 'webextension-polyfill'
import { renderSwitchOption, renderSmallCardOption } from './components/renderSwitch'
import { icon_full_width } from './components/icons'
@@ -6,7 +8,8 @@ import { renderButton } from './components/renderButtons'
const removePercentAndRem = (str) => str?.replace(/%|rem/g, '')
const FW_DEFAULTS = {
- w_chat_user: 'initial',
+ // w_chat_user: 'initial',
+ w_chat_user: '70%',
w_chat_gpt: '48rem',
w_prompt_textarea: '48rem',
chat_user_edit_icon_right: '100%',
@@ -25,7 +28,7 @@ const FW_OPTIONS = {
let currentSettings = { ...FW_DEFAULTS }
let isSyncEnabled = false
-const keysToRemove = Object.keys(FW_DEFAULTS)
+const keysToRemove = Object.keys(FW_DEFAULTS) // ? DEV ONLY var - Get the keys from FW_DEFAULTS object
let assetsHtmlCode = `
@@ -86,19 +89,20 @@ function setInputCheckedValue(inputSelector, isChecked) {
if (inputEl) inputEl.checked = isChecked
}
-// Add this helper function
function ensureValidPercentage(value) {
const numValue = parseInt(value, 10)
if (isNaN(numValue) || numValue < 0) return '0'
if (numValue > 100) return '100'
return numValue.toString()
}
+
function setRangeOutput(inputSelector, inputVal) {
const outputRangeEl = document.querySelector(`.gpth-settings #range-output-${inputSelector}`)
if (outputRangeEl) {
outputRangeEl.textContent = ensureValidPercentage(inputVal)
}
}
+
function setInputFieldValue(inputSelector, inputVal) {
const inputEl = document.querySelector(`.gpth-settings #${inputSelector}`)
if (inputEl) {
@@ -106,14 +110,25 @@ function setInputFieldValue(inputSelector, inputVal) {
}
}
+const debounce = (func, delay) => {
+ let timeoutId
+ return (...args) => {
+ clearTimeout(timeoutId)
+ timeoutId = setTimeout(() => func(...args), delay)
+ }
+}
+
async function saveSettings(settings) {
try {
await browser.storage.sync.set(settings)
} catch (error) {
console.error('Failed to save settings:', error)
+ // TODO: Show user-friendly error message
}
}
+const debouncedSaveSettings = debounce(saveSettings, 300)
+
async function loadSettings() {
try {
const settings = await browser.storage.sync.get(null)
@@ -124,6 +139,7 @@ async function loadSettings() {
updateUI(currentSettings)
} catch (error) {
console.error('Failed to load settings:', error)
+ // TODO: Show user-friendly error message
}
}
@@ -138,29 +154,46 @@ function updateUI(settings) {
setInputFieldValue('gpth-textarea-width-custom', removePercentAndRem(settings.w_prompt_textarea))
setRangeOutput('gpth-textarea-width-custom', removePercentAndRem(settings.w_prompt_textarea))
- // Disable textarea width slider when sync is enabled
const textareaWidthSlider = document.querySelector('#gpth-textarea-width-custom')
if (textareaWidthSlider) {
textareaWidthSlider.disabled = isSyncEnabled
}
+ updateEditIconPosition(settings.w_chat_gpt)
+}
+
+function updateEditIconPosition(chatWidth) {
+ const chatWidthValue = parseInt(removePercentAndRem(chatWidth))
+ if (chatWidthValue > 48) {
+ // Assuming 48rem is the default width
+ currentSettings.chat_user_edit_icon_right = FW_OPTIONS.chat_user_edit_icon_right
+ currentSettings.chat_user_edit_icon_top = FW_OPTIONS.chat_user_edit_icon_top
+ currentSettings.chat_user_edit_icon_transform = FW_OPTIONS.chat_user_edit_icon_transform
+ } else {
+ currentSettings.chat_user_edit_icon_right = FW_DEFAULTS.chat_user_edit_icon_right
+ currentSettings.chat_user_edit_icon_top = FW_DEFAULTS.chat_user_edit_icon_top
+ currentSettings.chat_user_edit_icon_transform = FW_DEFAULTS.chat_user_edit_icon_transform
+ }
+ applySettings(currentSettings)
}
function toggleChatFullWidth(e) {
const isFullWidth = e.target.checked
if (isFullWidth) {
currentSettings.w_chat_gpt = '100%'
+ currentSettings.w_chat_user = '100%'
if (isSyncEnabled) {
currentSettings.w_prompt_textarea = '100%'
}
} else {
currentSettings.w_chat_gpt = FW_DEFAULTS.w_chat_gpt
+ currentSettings.w_chat_user = FW_DEFAULTS.w_chat_user
if (isSyncEnabled) {
currentSettings.w_prompt_textarea = FW_DEFAULTS.w_chat_gpt
}
}
applySettings(currentSettings)
- saveSettings(currentSettings)
+ debouncedSaveSettings(currentSettings)
updateUI(currentSettings)
}
@@ -170,25 +203,25 @@ function toggleSyncTextareaWithChatWidth(e) {
currentSettings.w_prompt_textarea = currentSettings.w_chat_gpt
}
applySettings(currentSettings)
- saveSettings(currentSettings)
+ debouncedSaveSettings(currentSettings)
updateUI(currentSettings)
}
function handleChatCustomWidth(e) {
const value = `${e.target.value}%`
currentSettings.w_chat_gpt = value
+ currentSettings.w_chat_user = value
if (isSyncEnabled) {
currentSettings.w_prompt_textarea = value
}
- // Uncheck full width if it's not 100%
if (e.target.value !== '100') {
setInputCheckedValue('gpth-full-width', false)
}
applySettings(currentSettings)
- saveSettings(currentSettings)
+ debouncedSaveSettings(currentSettings)
updateUI(currentSettings)
}
@@ -196,14 +229,13 @@ function handleTextareaCustomWidth(e) {
const value = `${e.target.value}%`
currentSettings.w_prompt_textarea = value
- // If user manually changes textarea width, disable sync
if (isSyncEnabled && value !== currentSettings.w_chat_gpt) {
isSyncEnabled = false
setInputCheckedValue('gpth-sync-textarea-chat-width', false)
}
applySettings(currentSettings)
- saveSettings(currentSettings)
+ debouncedSaveSettings(currentSettings)
updateUI(currentSettings)
}
@@ -211,7 +243,7 @@ function resetWidths() {
currentSettings = { ...FW_DEFAULTS }
isSyncEnabled = false
applySettings(currentSettings)
- saveSettings(currentSettings)
+ debouncedSaveSettings(currentSettings)
updateUI(currentSettings)
}
@@ -231,19 +263,15 @@ function handleAssetsListeners() {
selectors.btnReset?.addEventListener('click', resetWidths)
}
-// Load settings on page load
function init() {
// removeSpecificStorageItems(keysToRemove)
loadSettings()
-
getAllStorageItems()
- // removeSpecificStorageItems([...keysToRemove, 'isFullWidth', 'isTextareaSync'])
}
-// Function to get all storage items
+// ? =============== DEV ONLY fn ===============
async function getAllStorageItems() {
try {
- // Get all items from the local storage
const items = await browser.storage.sync.get(null)
console.log(items)
return items
@@ -251,7 +279,7 @@ async function getAllStorageItems() {
console.error('Error getting storage items:', error)
}
}
-
+// ? =============== DEV ONLY fn ===============
// Function to remove specific named items from sync storage
async function removeSpecificStorageItems(keys) {
try {
From 7a08d29698c138aa67e9e6901b674f39fd5d1aaf Mon Sep 17 00:00:00 2001
From: itsmartashub <44645238+itsmartashub@users.noreply.github.com>
Date: Thu, 11 Jul 2024 19:47:11 +0200
Subject: [PATCH 16/27] refactor(chat-custom-width): Apply `DRY` principle
- Apply the DRY (Don't Repeat Yourself) principle by eliminating code duplication and improving code reusability
Changes summary:
- Applied the DRY (Don't Repeat Yourself) principle:
- Eliminated code duplication to improve maintainability and reduce redundancy.
- Improved code reusability by extracting common functionality into reusable functions or components.
---
src/js/app/mainAssetsUpgrade.js | 177 +++++++++++++-------------------
1 file changed, 74 insertions(+), 103 deletions(-)
diff --git a/src/js/app/mainAssetsUpgrade.js b/src/js/app/mainAssetsUpgrade.js
index 1ff1fd7..06f9646 100644
--- a/src/js/app/mainAssetsUpgrade.js
+++ b/src/js/app/mainAssetsUpgrade.js
@@ -16,7 +16,6 @@ const FW_DEFAULTS = {
chat_user_edit_icon_top: '0',
chat_user_edit_icon_transform: 'unset',
}
-
const FW_OPTIONS = {
w_chat_user: '100%',
w_chat_gpt: '100%',
@@ -78,36 +77,19 @@ let assetsHtmlCode = `
`
-function applySettings(settings) {
+const applySettings = (settings) => {
Object.entries(settings).forEach(([key, value]) => {
document.documentElement.style.setProperty(`--${key}`, value)
})
}
-function setInputCheckedValue(inputSelector, isChecked) {
- const inputEl = document.querySelector(`.gpth-settings #${inputSelector}`)
- if (inputEl) inputEl.checked = isChecked
+const setElementProperty = (selector, property, value) => {
+ const element = document.querySelector(selector)
+ if (element) element[property] = value
}
-
-function ensureValidPercentage(value) {
+const ensureValidPercentage = (value) => {
const numValue = parseInt(value, 10)
- if (isNaN(numValue) || numValue < 0) return '0'
- if (numValue > 100) return '100'
- return numValue.toString()
-}
-
-function setRangeOutput(inputSelector, inputVal) {
- const outputRangeEl = document.querySelector(`.gpth-settings #range-output-${inputSelector}`)
- if (outputRangeEl) {
- outputRangeEl.textContent = ensureValidPercentage(inputVal)
- }
-}
-
-function setInputFieldValue(inputSelector, inputVal) {
- const inputEl = document.querySelector(`.gpth-settings #${inputSelector}`)
- if (inputEl) {
- inputEl.value = ensureValidPercentage(inputVal)
- }
+ return isNaN(numValue) ? '0' : Math.max(0, Math.min(100, numValue)).toString()
}
const debounce = (func, delay) => {
@@ -118,7 +100,7 @@ const debounce = (func, delay) => {
}
}
-async function saveSettings(settings) {
+const saveSettings = async (settings) => {
try {
await browser.storage.sync.set(settings)
} catch (error) {
@@ -129,7 +111,7 @@ async function saveSettings(settings) {
const debouncedSaveSettings = debounce(saveSettings, 300)
-async function loadSettings() {
+const loadSettings = async () => {
try {
const settings = await browser.storage.sync.get(null)
currentSettings = { ...FW_DEFAULTS, ...settings }
@@ -143,61 +125,63 @@ async function loadSettings() {
}
}
-function updateUI(settings) {
+const updateUI = (settings) => {
const isFullWidth = settings.w_chat_gpt === '100%'
- setInputCheckedValue('gpth-full-width', isFullWidth)
- setInputFieldValue('gpth-full-width-custom', removePercentAndRem(settings.w_chat_gpt))
- setRangeOutput('gpth-full-width-custom', removePercentAndRem(settings.w_chat_gpt))
-
- setInputCheckedValue('gpth-sync-textarea-chat-width', isSyncEnabled)
- setInputFieldValue('gpth-textarea-width-custom', removePercentAndRem(settings.w_prompt_textarea))
- setRangeOutput('gpth-textarea-width-custom', removePercentAndRem(settings.w_prompt_textarea))
+ setElementProperty('.gpth-settings #gpth-full-width', 'checked', isFullWidth)
+ setElementProperty('.gpth-settings #gpth-full-width-custom', 'value', removePercentAndRem(settings.w_chat_gpt))
+ setElementProperty(
+ '.gpth-settings #range-output-gpth-full-width-custom',
+ 'textContent',
+ removePercentAndRem(settings.w_chat_gpt)
+ )
+
+ setElementProperty('.gpth-settings #gpth-sync-textarea-chat-width', 'checked', isSyncEnabled)
+ setElementProperty(
+ '.gpth-settings #gpth-textarea-width-custom',
+ 'value',
+ removePercentAndRem(settings.w_prompt_textarea)
+ )
+ setElementProperty(
+ '.gpth-settings #range-output-gpth-textarea-width-custom',
+ 'textContent',
+ removePercentAndRem(settings.w_prompt_textarea)
+ )
+
+ setElementProperty('.gpth-settings #gpth-textarea-width-custom', 'disabled', isSyncEnabled)
- const textareaWidthSlider = document.querySelector('#gpth-textarea-width-custom')
- if (textareaWidthSlider) {
- textareaWidthSlider.disabled = isSyncEnabled
- }
updateEditIconPosition(settings.w_chat_gpt)
}
-function updateEditIconPosition(chatWidth) {
+const updateEditIconPosition = (chatWidth) => {
const chatWidthValue = parseInt(removePercentAndRem(chatWidth))
- if (chatWidthValue > 48) {
- // Assuming 48rem is the default width
- currentSettings.chat_user_edit_icon_right = FW_OPTIONS.chat_user_edit_icon_right
- currentSettings.chat_user_edit_icon_top = FW_OPTIONS.chat_user_edit_icon_top
- currentSettings.chat_user_edit_icon_transform = FW_OPTIONS.chat_user_edit_icon_transform
- } else {
- currentSettings.chat_user_edit_icon_right = FW_DEFAULTS.chat_user_edit_icon_right
- currentSettings.chat_user_edit_icon_top = FW_DEFAULTS.chat_user_edit_icon_top
- currentSettings.chat_user_edit_icon_transform = FW_DEFAULTS.chat_user_edit_icon_transform
- }
+ const iconSettings = chatWidthValue > 48 ? FW_OPTIONS : FW_DEFAULTS
+
+ Object.assign(currentSettings, {
+ chat_user_edit_icon_right: iconSettings.chat_user_edit_icon_right,
+ chat_user_edit_icon_top: iconSettings.chat_user_edit_icon_top,
+ chat_user_edit_icon_transform: iconSettings.chat_user_edit_icon_transform,
+ })
+
applySettings(currentSettings)
}
-function toggleChatFullWidth(e) {
+const toggleChatFullWidth = (e) => {
const isFullWidth = e.target.checked
- if (isFullWidth) {
- currentSettings.w_chat_gpt = '100%'
- currentSettings.w_chat_user = '100%'
- if (isSyncEnabled) {
- currentSettings.w_prompt_textarea = '100%'
- }
- } else {
- currentSettings.w_chat_gpt = FW_DEFAULTS.w_chat_gpt
- currentSettings.w_chat_user = FW_DEFAULTS.w_chat_user
- if (isSyncEnabled) {
- currentSettings.w_prompt_textarea = FW_DEFAULTS.w_chat_gpt
- }
- }
+ const width = isFullWidth ? '100%' : FW_DEFAULTS.w_chat_gpt
+
+ Object.assign(currentSettings, {
+ w_chat_gpt: width,
+ w_chat_user: width,
+ w_prompt_textarea: isSyncEnabled ? width : currentSettings.w_prompt_textarea,
+ })
applySettings(currentSettings)
debouncedSaveSettings(currentSettings)
updateUI(currentSettings)
}
-function toggleSyncTextareaWithChatWidth(e) {
+const toggleSyncTextareaWithChatWidth = (e) => {
isSyncEnabled = e.target.checked
if (isSyncEnabled) {
currentSettings.w_prompt_textarea = currentSettings.w_chat_gpt
@@ -207,31 +191,20 @@ function toggleSyncTextareaWithChatWidth(e) {
updateUI(currentSettings)
}
-function handleChatCustomWidth(e) {
- const value = `${e.target.value}%`
- currentSettings.w_chat_gpt = value
- currentSettings.w_chat_user = value
-
- if (isSyncEnabled) {
- currentSettings.w_prompt_textarea = value
- }
-
- if (e.target.value !== '100') {
- setInputCheckedValue('gpth-full-width', false)
- }
-
- applySettings(currentSettings)
- debouncedSaveSettings(currentSettings)
- updateUI(currentSettings)
-}
-
-function handleTextareaCustomWidth(e) {
- const value = `${e.target.value}%`
- currentSettings.w_prompt_textarea = value
+// function handleChatCustomWidth(e) {
+const handleWidthChange = (key, e) => {
+ const value = `${ensureValidPercentage(e.target.value)}%`
+ currentSettings[key] = value
- if (isSyncEnabled && value !== currentSettings.w_chat_gpt) {
+ if (key === 'w_chat_gpt') {
+ currentSettings.w_chat_user = value
+ if (isSyncEnabled) {
+ currentSettings.w_prompt_textarea = value
+ }
+ setElementProperty('.gpth-settings #gpth-full-width', 'checked', e.target.value === '100')
+ } else if (key === 'w_prompt_textarea' && isSyncEnabled && value !== currentSettings.w_chat_gpt) {
isSyncEnabled = false
- setInputCheckedValue('gpth-sync-textarea-chat-width', false)
+ setElementProperty('.gpth-settings #gpth-sync-textarea-chat-width', 'checked', false)
}
applySettings(currentSettings)
@@ -239,7 +212,7 @@ function handleTextareaCustomWidth(e) {
updateUI(currentSettings)
}
-function resetWidths() {
+const resetWidths = () => {
currentSettings = { ...FW_DEFAULTS }
isSyncEnabled = false
applySettings(currentSettings)
@@ -247,23 +220,21 @@ function resetWidths() {
updateUI(currentSettings)
}
-function handleAssetsListeners() {
- const selectors = {
- chatFullWidth: document.querySelector('.gpth-settings #gpth-full-width'),
- syncTextareaWithChats: document.querySelector('.gpth-settings #gpth-sync-textarea-chat-width'),
- chatCustomWidth: document.querySelector('.gpth-settings #gpth-full-width-custom'),
- textareaCustomWidth: document.querySelector('.gpth-settings #gpth-textarea-width-custom'),
- btnReset: document.querySelector('.gpth-settings #resetWidths'),
- }
-
- selectors.chatFullWidth?.addEventListener('change', toggleChatFullWidth)
- selectors.syncTextareaWithChats?.addEventListener('change', toggleSyncTextareaWithChatWidth)
- selectors.chatCustomWidth?.addEventListener('input', handleChatCustomWidth)
- selectors.textareaCustomWidth?.addEventListener('input', handleTextareaCustomWidth)
- selectors.btnReset?.addEventListener('click', resetWidths)
+const handleAssetsListeners = () => {
+ document.querySelector('.gpth-settings #gpth-full-width')?.addEventListener('change', toggleChatFullWidth)
+ document
+ .querySelector('.gpth-settings #gpth-sync-textarea-chat-width')
+ ?.addEventListener('change', toggleSyncTextareaWithChatWidth)
+ document
+ .querySelector('.gpth-settings #gpth-full-width-custom')
+ ?.addEventListener('input', (e) => handleWidthChange('w_chat_gpt', e))
+ document
+ .querySelector('.gpth-settings #gpth-textarea-width-custom')
+ ?.addEventListener('input', (e) => handleWidthChange('w_prompt_textarea', e))
+ document.querySelector('.gpth-settings #resetWidths')?.addEventListener('click', resetWidths)
}
-function init() {
+const init = () => {
// removeSpecificStorageItems(keysToRemove)
loadSettings()
getAllStorageItems()
From fcb9b81b50cde65f056162108107b23658652e87 Mon Sep 17 00:00:00 2001
From: itsmartashub <44645238+itsmartashub@users.noreply.github.com>
Date: Thu, 11 Jul 2024 21:00:11 +0200
Subject: [PATCH 17/27] feat(textarea-sync/lock-indicator): Add lock icon
indicator
- Add a lock icon indicator on the textarea message sync switch to show when it is locked to chat widths
- The lock icon dynamically appears based on the state of the textarea sync switch
Changes summary:
- Added a visual indicator for the textarea message sync switch:
- A lock icon is displayed when the textarea width is locked to chat widths, providing a clear indication of the current synchronization state.
- The lock icon dynamically appears or disappears based on the state of the textarea sync switch, offering users a straightforward way to understand the synchronization behavior.
---
src/js/app/components/icons.js | 4 +-
src/js/app/components/renderSwitch.js | 9 +++-
src/js/app/mainAssetsUpgrade.js | 12 ++++-
.../theme-manager/components/_cards.scss | 47 +++++++++++++++++++
.../theme-manager/components/_range.scss | 4 +-
.../theme-manager/components/_switch.scss | 2 +-
6 files changed, 72 insertions(+), 6 deletions(-)
diff --git a/src/js/app/components/icons.js b/src/js/app/components/icons.js
index 93c3a76..3ae185d 100644
--- a/src/js/app/components/icons.js
+++ b/src/js/app/components/icons.js
@@ -12,4 +12,6 @@ const icon_palette = `