Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/Custom/Layouts/Toggles.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ import CardToggle from '@/components/Cards/Toggle.vue'
import IconThinkingProcess from '@/components/Icons/ThinkingProcess.vue'

// One toggle controls everything
const hideThinkingState = useToggleStorage(hideThinkingItem, '--displayThinkingProcess')
const hideThinkingState = useToggleStorage(hideThinkingItem, 'dsx-toggle-thinking-process')
</script>
43 changes: 25 additions & 18 deletions composables/useToggleStorage.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,43 @@
import { ref, watch } from 'vue'

export function useToggleStorage(storageItem, cssVar) {
export function useToggleStorage(storageItem, attributeName) {
const state = ref(false)
let initialized = false

// Initialize state from storage immediately
// Initialize state from storage
const initializeState = async () => {
try {
const val = await storageItem.getValue()
state.value = Boolean(val)
} catch (error) {
console.warn('Failed to load storage value:', error)
} finally {
initialized = true
}
}

// Fire and forget initialization
initializeState()

// Reactive sync: state → CSS + storage
watch(
state,
async (val) => {
const display = val ? 'none' : 'block'
document.documentElement.style.setProperty(cssVar, display)

try {
await storageItem.setValue(val)
} catch (error) {
console.warn('Failed to save storage value:', error)
}
},
{ immediate: true } // Apply initial state to CSS
)
watch(state, async (val, oldVal) => {
// Skip until initialization finishes
if (!initialized) return

// Only update if value actually changed
if (val === oldVal) return

const root = document.documentElement
if (val) {
if (!root.hasAttribute(attributeName)) root.setAttribute(attributeName, '')
} else {
if (root.hasAttribute(attributeName)) root.removeAttribute(attributeName)
}

try {
await storageItem.setValue(val)
} catch (error) {
console.warn('Failed to save storage value:', error)
}
})

return state
}
2 changes: 0 additions & 2 deletions styles/abstract/_root.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

--ds-font-family: var(--fontFamily) !important; // override DS font-family

--displayThinkingProcess: none;

/* ? --- Custom Widths --- */
--defaultWidthChats: 800px;
// --defaultWidthChats: var(--message-list-max-width);
Expand Down
Empty file.
Empty file.
5 changes: 5 additions & 0 deletions styles/customs/_custom-toggles.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
html[dsx-toggle-thinking-process] {
.ds-think-content {
display: none !important;
}
}
12 changes: 12 additions & 0 deletions styles/customs/utils/_hideToggles.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Define your toggle states in a map for scalability
$toggle-states: (
"thinking-process",
"user-accent",
);

// Mixin to generate all toggle styles
@mixin toggleStyles($state, $styles) {
html[dsx-toggle-#{$state}] & {
@content;
}
}
27 changes: 4 additions & 23 deletions styles/elements/_right--main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,14 @@
/* Thinking process texts */
.ds-think-content {
--thinking-p-left: 13px; // this is from ds deafult
display: var(--displayThinkingProcess) !important;
color: var(--c-subtext-2) !important;
transition: font-size 0.15s ease-in-out,
line-height 0.15s ease-in-out;

// @include toggleStyles('thinking-process', ()) {
// display: none !important;
// }

&:not(:empty) {
@extend .fadeIn;
}
Expand All @@ -143,28 +146,6 @@
line-height: calc((var(--lineHeight) / 16) * 0.85) !important;
}
}

// /* Thinking process texts */
// .e1675d8b {
// --thinking-p-left: 13px; // this is from ds deafult
// display: var(--displayThinkingProcess) !important;

// &:not(:empty) {
// @extend .fadeIn;
// }

// color: var(--c-subtext-2) !important;
// // font-size: calc(calc((var(--fontSize) / 16) * 1rem) * 0.75) !important;
// // line-height: calc((var(--lineHeight) / 16) * 0.5) !important;
// transition: font-size 0.15s ease-in-out,
// line-height 0.15s ease-in-out;

// /* Thinking border on the left */
// ._9ecc93a {
// border-color: currentColor !important;
// opacity: 0.6;
// }
// }
}

/* Shirmer animation on "Thought" txt while thinking */
Expand Down
2 changes: 2 additions & 0 deletions styles/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

@import 'global/_base';
@import 'global/_scrollbars';
@import 'customs/utils/_hideToggles';
@import 'customs/_custom-toggles';

@import 'components/_skeleton';
@import 'components/_icons';
Expand Down
9 changes: 7 additions & 2 deletions utils/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,13 @@ export const THEMES = {
OLED: 'oled',
}

export function getAllStorageItems() {
storage.snapshot('local').then((res) => console.table(res))
export async function getAllStorageItems() {
try {
const res = await storage.snapshot('local')
console.table(res)
} catch (e) {
console.warn('Failed to snapshot storage:', e)
}
}

export const themeItem = storage.defineItem('local:theme', {
Expand Down