Skip to content
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

Added a shortcut + toggle button hidden when less circuits #450

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
38 changes: 31 additions & 7 deletions v0/src/components/TabsBar/TabsBar.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<template>
<div
id="tabsBar"
ref="tabsBarRef"
class="noSelect pointerCursor"
:class="[embedClass(), { maxHeightStyle: showMaxHeight }]"
:class="[embedClass() , {maxHeightStyle: showMaxHeight}]"
>
<draggable
:key="updateCount"
Expand Down Expand Up @@ -43,10 +44,10 @@
</div>
</template>
</draggable>
<button v-if="!isEmbed()" @click="createNewCircuitScope()">
<button v-if="!isEmbed()" @click="createNewCircuitScope().then(updateTabsBarHeight)">
&#43;
</button>
<button class="tabsbar-toggle" @click="toggleHeight">
<button v-if="tabsBarHeight>=31" class="tabsbar-toggle" @click="toggleHeight">
<i :class="showMaxHeight ? 'fa fa-chevron-down' : 'fa fa-chevron-up'"></i>
</button>
</div>
Expand All @@ -68,7 +69,7 @@
<script lang="ts" setup>
import draggable from 'vuedraggable'
import { showMessage, truncateString } from '#/simulator/src/utils'
import { ref, Ref } from 'vue'
import { ref, Ref ,onMounted , onBeforeUnmount} from 'vue'
import {
createNewCircuitScope,
// deleteCurrentCircuit,
Expand All @@ -84,12 +85,35 @@ const SimulatorState = <SimulatorStateType>useState()
const drag: Ref<boolean> = ref(false)
const updateCount: Ref<number> = ref(0)

const showMaxHeight = ref(true)
const showMaxHeight = ref(false)
const tabsBarRef = ref<HTMLElement | null>(null)
const tabsBarHeight = ref(0)

function toggleHeight() {
showMaxHeight.value = !showMaxHeight.value
}

function updateTabsBarHeight() {
if (tabsBarRef.value) {
tabsBarHeight.value = tabsBarRef.value.clientHeight
}
}

const userClickArrowUp = ({ code,altKey }) => {
if (altKey && code === 'KeyN') {
createNewCircuitScope().then(updateTabsBarHeight)
}
};

onMounted(() => {
updateTabsBarHeight() ;
document.addEventListener('keyup', userClickArrowUp, true);
})

onBeforeUnmount(() => {
document.removeEventListener('keyup', userClickArrowUp, true);
})

// const persistentShow: Ref<boolean> = ref(false)
// const messageVal: Ref<string> = ref('')
// const buttonArr: Ref<Array<buttonArrType>> = ref([{ text: '', emitOption: '' }])
Expand Down Expand Up @@ -335,8 +359,8 @@ function isEmbed(): boolean {
}

.maxHeightStyle {
height: 30px;
max-height: 30px;
height: 32px !important;
max-height: 32px !important;
}

.toolbarButton{
Expand Down