Skip to content

Refactor Codebase: Replace jQuery with Vue.js in Key Components #465

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
22 changes: 10 additions & 12 deletions src/components/DialogBox/Themes/ApplyThemes.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@
:id="theme"
:key="theme"
class="theme"
:class="
theme == selectedTheme ? 'selected set' : ''
"
:class="{
selected: theme === selectedTheme,
set: theme === selectedThemeRef
}"
>
<div
class="themeSel"
Expand Down Expand Up @@ -161,6 +162,7 @@ const customThemes = ref<((keyof typeof customThemesList)[]) | undefined>(undefi
const customThemesList: Themes = reactive({})
const selectedTheme = ref('default-theme')
const iscustomTheme = ref(false)
const selectedThemeRef = ref<string | null>(null)

onMounted(() => {
SimulatorState.dialogBox.theme_dialog = false
Expand Down Expand Up @@ -195,36 +197,32 @@ function changeCustomTheme(e: InputEvent) {

function applyTheme() {
if (iscustomTheme.value == false) {
if ($('.selected label').text()) {
if (selectedTheme.value) {
localStorage.removeItem('Custom Theme')
localStorage.setItem('theme', $('.selected label').text())
localStorage.setItem('theme', selectedTheme.value)
}
} else {
// update theme to Custom Theme
localStorage.setItem('theme', 'Custom Theme')
// add Custom theme to custom theme object
localStorage.setItem(
'Custom Theme',
JSON.stringify(themeOptions['Custom Theme'])
)
}
$('.set').removeClass('set')
$('.selected').addClass('set')
selectedThemeRef.value = selectedTheme.value
SimulatorState.dialogBox.theme_dialog = false
setTimeout(() => (iscustomTheme.value = false), 1000)
}

function applyCustomTheme() {
iscustomTheme.value = true
updateThemeForStyle(localStorage.getItem('theme'))
updateBG()
localStorage.setItem('theme', 'Custom Theme')
// add Custom theme to custom theme object
localStorage.setItem(
'Custom Theme',
JSON.stringify(themeOptions['Custom Theme'])
)
$('.set').removeClass('set')
$('.selected').addClass('set')
selectedThemeRef.value = selectedTheme.value
}

function receivedText(e: ProgressEvent<FileReader>) {
Expand Down