Skip to content

Commit

Permalink
Merge branch 'main' into project-ts
Browse files Browse the repository at this point in the history
  • Loading branch information
niladrix719 authored Jul 30, 2024
2 parents ede5dd5 + 5f66af1 commit f89cdea
Show file tree
Hide file tree
Showing 91 changed files with 2,321 additions and 5,643 deletions.
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"@tiptap/starter-kit": "^2.0.3",
"@tiptap/vue-3": "^2.0.3",
"bootstrap": "^4.6.1",
"canvas-to-svg": "^1.0.3",
"codemirror": "^5.65.1",
"codemirror-editor-vue3": "^2.1.7",
"dom-to-image": "^2.6.0",
Expand Down
6 changes: 3 additions & 3 deletions src/components/DialogBox/CombinationalAnalysis.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
import { stripTags } from '#/simulator/src/utils'
import { useState } from '#/store/SimulatorStore/state'
import messageBox from '@/MessageBox/messageBox.vue'
import { ref } from '@vue/reactivity'
import { onMounted, onUpdated } from '@vue/runtime-core'
import { ref } from 'vue'
import { onMounted, onUpdated } from 'vue'
/* imports from combinationalAnalysis.js */
import Node from '#/simulator/src/node'
Expand Down Expand Up @@ -199,7 +199,7 @@ function createLogicTable() {
SimulatorState.dialogBox.combinationalanalysis_dialog = false
output.value = []
solveBooleanFunction(booleanInputVariables, booleanExpression)
if (output != null) {
if (output.value != null) {
createBooleanPrompt(booleanInputVariables, booleanExpression)
}
} else if (
Expand Down
2 changes: 1 addition & 1 deletion src/components/DialogBox/ExportVerilog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
</template>

<script lang="ts" setup>
import { onMounted, ref } from '@vue/runtime-core'
import { onMounted, ref } from 'vue'
import { useState } from '#/store/SimulatorStore/state'
const SimulatorState = useState()
import Codemirror from 'codemirror-editor-vue3'
Expand Down
30 changes: 19 additions & 11 deletions src/components/DialogBox/OpenOffline.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@
type="radio"
name="projectId"
:value="projectId"
v-model="selectedProjectId"
/>
{{ projectName }}<span></span>
<i
class="fa fa-trash deleteOfflineProject"
@click="deleteOfflineProject(projectId)"
@click="deleteOfflineProject(projectId.toString())"
></i>
</label>
<p v-if="JSON.stringify(projectList) == '{}'">
Expand Down Expand Up @@ -64,32 +65,39 @@
<script lang="ts" setup>
import load from '#/simulator/src/data/load'
import { useState } from '#/store/SimulatorStore/state'
import { onMounted, onUpdated, ref, toRaw } from '@vue/runtime-core'
import { onMounted, onUpdated, ref, reactive } from '@vue/runtime-core'
const SimulatorState = useState()
const projectList = ref({})
const projectList: {
[key: string]: string
} = reactive({})
const selectedProjectId = ref<string | null>(null)
onMounted(() => {
SimulatorState.dialogBox.open_project_dialog = false
})
onUpdated(() => {
var data = localStorage.getItem('projectList')
projectList.value = JSON.parse(localStorage.getItem('projectList')) || {}
const data = localStorage.getItem('projectList')
projectList.value = data ? JSON.parse(data) : {}
})
function deleteOfflineProject(id) {
function deleteOfflineProject(id: string) {
localStorage.removeItem(id)
const temp = JSON.parse(localStorage.getItem('projectList')) || {}
const data = localStorage.getItem('projectList')
const temp = data ? JSON.parse(data) : {}
delete temp[id]
projectList.value = temp
localStorage.setItem('projectList', JSON.stringify(temp))
}
function openProjectOffline() {
SimulatorState.dialogBox.open_project_dialog = false
let ele = $('input[name=projectId]:checked')
if (!ele.val()) return
load(JSON.parse(localStorage.getItem(ele.val())))
window.projectId = ele.val()
if (!selectedProjectId.value) return
const projectData = localStorage.getItem(selectedProjectId.value)
if (projectData) {
load(JSON.parse(projectData))
window.projectId = selectedProjectId.value
}
}
function OpenImportProjectDialog() {
Expand Down
101 changes: 56 additions & 45 deletions src/components/DialogBox/Themes/ApplyThemes.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
>
<div
class="themeSel"
@click="changeTheme($event)"
@click="changeTheme(theme)"
></div>
<span>
<img
Expand Down Expand Up @@ -72,6 +72,7 @@
type="radio"
value="theme"
name="theme"
:checked="theme == selectedTheme || theme == 'Default Theme'"
/>
<label :for="theme.replace(' ', '')">{{
theme
Expand All @@ -98,14 +99,15 @@
<label :for="customTheme" class="customColorLabel">
{{ customTheme }}
({{
customThemesList[customTheme].description
customThemesList[customTheme]?.description
}})
</label>
<input
type="color"
:name="customTheme"
:value="customThemesList[customTheme].color"
:value="customThemesList[customTheme]?.color"
class="customColorInput"
@input="changeCustomTheme($event)"
/>
</div>
<a id="downloadThemeFile" style="display: none"></a>
Expand Down Expand Up @@ -144,48 +146,49 @@

<script lang="ts" setup>
import { useState } from '#/store/SimulatorStore/state'
import { onMounted, onUpdated, ref } from '@vue/runtime-core'
import { onMounted, onUpdated, ref, reactive } from '@vue/runtime-core'
import themeOptions from '#/simulator/src/themer/themes'
import {
getThemeCardSvg,
updateBG,
updateThemeForStyle,
} from '#/simulator/src/themer/themer'
const SimulatorState = useState()
import { CreateAbstraction } from '#/simulator/src/themer/customThemeAbstraction'
import { CreateAbstraction, Themes } from '#/simulator/src/themer/customThemeAbstraction'
import { confirmSingleOption } from '#/components/helpers/confirmComponent/ConfirmComponent.vue'
const themes = ref([''])
const customThemes = ref([''])
const customThemesList = ref([''])
const customThemes = ref<((keyof typeof customThemesList)[]) | undefined>(undefined);
const customThemesList: Themes = reactive({})
const selectedTheme = ref('default-theme')
const iscustomTheme = ref(false)
onMounted(() => {
SimulatorState.dialogBox.theme_dialog = false
selectedTheme.value = localStorage.getItem('theme')
selectedTheme.value = localStorage.getItem('theme') ?? 'default-theme'
themes.value = Object.keys(themeOptions)
themes.value.splice(-1, 1)
customThemesList.value = CreateAbstraction(themeOptions['Custom Theme'])
customThemes.value = Object.keys(customThemesList.value)
const customTheme = CreateAbstraction(themeOptions['Custom Theme'])
Object.keys(customTheme).forEach((key) => {
customThemesList[key as keyof typeof customThemesList] = customTheme[key as keyof typeof customThemesList]
})
customThemes.value = Object.keys(customThemesList) as (keyof typeof customThemesList)[]
})
function changeTheme(e) {
e.preventDefault()
$('.selected').removeClass('selected')
let themeCard = $(e.target.parentElement)
themeCard.addClass('selected')
// Extract radio button
var radioButton = themeCard.find('input[type=radio]')
radioButton.trigger('click') // Mark as selected
updateThemeForStyle(themeCard.find('label').text()) // Extract theme name and set
function changeTheme(theme: string) {
selectedTheme.value = theme;
updateThemeForStyle(theme)
updateBG()
}
function changeCustomTheme(e) {
customThemesList.value[e.target.name].color = e.target.value
customThemesList.value[e.target.name].ref.forEach((property) => {
themeOptions['Custom Theme'][property] = e.target.value
})
function changeCustomTheme(e: InputEvent) {
const customTheme = customThemesList[(e.target as HTMLInputElement).name as keyof typeof customThemesList];
if (customTheme) {
customTheme.color = (e.target as HTMLInputElement).value;
customTheme.ref.forEach((property: string) => {
themeOptions['Custom Theme'][property] = (e.target as HTMLInputElement).value
})
}
customThemesList[(e.target as HTMLInputElement).name as keyof typeof customThemesList] = customTheme
updateThemeForStyle('Custom Theme')
updateBG()
}
Expand Down Expand Up @@ -224,8 +227,11 @@ function applyCustomTheme() {
$('.selected').addClass('set')
}
function receivedText(e) {
const lines = JSON.parse(e.target.result)
function receivedText(e: ProgressEvent<FileReader>) {
let lines = []
if(typeof e.target?.result === 'string') {
lines = JSON.parse(e.target.result)
}
let customTheme = CreateAbstraction(lines)
themeOptions['Custom Theme'] = lines
// preview theme
Expand All @@ -234,39 +240,43 @@ function receivedText(e) {
// update colors in dialog box
SimulatorState.dialogBox.theme_dialog = false
SimulatorState.dialogBox.theme_dialog = true
customThemesList.value = CreateAbstraction(themeOptions['Custom Theme'])
customThemes.value = Object.keys(customThemesList.value)
$('.customColorInput').on('input', (e) => {
changeCustomTheme(e)
const customThemeValues = CreateAbstraction(themeOptions['Custom Theme'])
Object.keys(customThemeValues).forEach((key) => {
customThemesList[key as keyof typeof customThemesList] = customThemeValues[key as keyof typeof customThemesList]
})
customThemes.value = Object.keys(customThemesList) as (keyof typeof customThemesList)[]
}
function importCustomTheme() {
$('#importThemeFile').click()
$('#importThemeFile').on('change', (event) => {
var File = event.target.files[0]
if (File !== null && File.name.split('.')[1] === 'json') {
var fr = new FileReader()
const fileInput = document.createElement('input')
fileInput.type = 'file'
fileInput.accept = '.json'
fileInput.style.display = 'none'
fileInput.addEventListener('change', (event) => {
const file = (event.target as HTMLInputElement).files?.[0]
if (file && file.name.split('.')[1] === 'json') {
const fr = new FileReader()
fr.onload = receivedText
fr.readAsText(File)
$('#importThemeFile').val('')
fr.readAsText(file)
} else {
// alert('File Not Supported !')
confirmSingleOption('File Not Supported !')
}
})
document.body.appendChild(fileInput)
fileInput.click()
document.body.removeChild(fileInput)
}
function exportCustomTheme() {
const dlAnchorElem = document.getElementById('downloadThemeFile')
dlAnchorElem.setAttribute(
dlAnchorElem?.setAttribute(
'href',
`data:text/json;charset=utf-8,${encodeURIComponent(
JSON.stringify(themeOptions['Custom Theme'])
)}`
)
dlAnchorElem.setAttribute('download', 'CV_CustomTheme.json')
dlAnchorElem.click()
dlAnchorElem?.setAttribute('download', 'CV_CustomTheme.json')
dlAnchorElem?.click()
}
function closeThemeDialog() {
Expand All @@ -278,9 +288,10 @@ function closeThemeDialog() {
function closeCustomThemeDialog() {
SimulatorState.dialogBox.theme_dialog = false
setTimeout(() => (iscustomTheme.value = false), 1000)
themeOptions['Custom Theme'] =
JSON.parse(localStorage.getItem('Custom Theme')) ||
themeOptions['Default Theme'] // hack for closing dialog box without saving
const customTheme = localStorage.getItem('Custom Theme')
if (customTheme) {
themeOptions['Custom Theme'] = JSON.parse(customTheme) || themeOptions['Default Theme'] // hack for closing dialog box without saving
}
// Rollback to previous theme
updateThemeForStyle(localStorage.getItem('theme'))
updateBG()
Expand Down
Loading

0 comments on commit f89cdea

Please sign in to comment.