Skip to content

Commit

Permalink
Merge pull request #21 from betty2310/auth
Browse files Browse the repository at this point in the history
refactor(UI): sidebar can be resizeable and collapse
  • Loading branch information
betty2310 authored May 25, 2024
2 parents 161663c + a29a6b2 commit 9bbb58d
Show file tree
Hide file tree
Showing 55 changed files with 1,437 additions and 551 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"format": "prettier --write src/"
},
"dependencies": {
"@unovis/ts": "^1.4.0",
"@unovis/vue": "^1.4.0",
"@unovis/ts": "^1.4.1",
"@unovis/vue": "^1.4.1",
"@vee-validate/zod": "^4.12.8",
"@vue-flow/background": "^1.3.0",
"@vue-flow/controls": "^1.1.1",
Expand Down
65 changes: 44 additions & 21 deletions src/CustomEdge.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,22 @@
import { computed, ref } from 'vue'
import type { EdgeProps } from '@vue-flow/core'
import { BaseEdge, EdgeLabelRenderer, getSmoothStepPath, useVueFlow } from '@vue-flow/core'
import { Button } from '@/components/ui/button'
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuLabel,
DropdownMenuRadioGroup,
DropdownMenuRadioItem,
DropdownMenuSeparator,
DropdownMenuTrigger
} from '@/components/ui/dropdown-menu'
const props = defineProps<EdgeProps>()
const path = computed(() => getSmoothStepPath(props))
const { findEdge, onEdgeClick, removeEdges } = useVueFlow()
const { findEdge, removeEdges } = useVueFlow()
type SelectedOption = 'Voltmeter' | 'Ammeter' | ''
Expand All @@ -28,37 +38,50 @@ const turnBack = () => {
edge.data = {}
}
}
onEdgeClick((edge) => {
removeEdges(edge.edge)
})
</script>


<script lang="ts">
export default {
inheritAttrs: false
}
</script>

<template>
<BaseEdge :id="props.id" :path="path[0]" :style="{stroke: '#D37987'}" />
<BaseEdge :id="props.id" :path="path[0]" :style="{ stroke: '#D37987' }" />

<EdgeLabelRenderer>
<div :style="{
pointerEvents: 'all',
position: 'absolute',
transform: `translate(-50%, -50%) translate(${path[1]}px,${path[2]}px)`,
}" class="nodrag nopan">
<details v-if="!selectedOption" class="dropdown">
<summary class="btn btn-xs">+</summary>
<ul class="p-2 shadow menu dropdown-content z-[1] bg-base-100 rounded-box w-52">
<li><a @click="selectOption('Voltmeter')">Voltmeter</a></li>
<li><a @click="selectOption('Ammeter')">Ammeter</a></li>
<li><a @click="removeEdges(id)">x</a></li>
</ul>
</details>
<button v-else class="btn btn-xs btn-secondary" @click="turnBack">{{ selectedOption }}</button>
<div
:style="{
pointerEvents: 'all',
position: 'absolute',
transform: `translate(-50%, -50%) translate(${path[1]}px,${path[2]}px)`
}"
class="nodrag nopan"
>
<DropdownMenu>
<DropdownMenuTrigger as-child>
<Button size="xs" variant="outline">
{{ selectedOption === '' ? '+' : selectedOption }}
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent class="w-56">
<DropdownMenuLabel>Select annotation</DropdownMenuLabel>
<DropdownMenuSeparator />
<DropdownMenuRadioGroup v-model="selectedOption">
<DropdownMenuRadioItem @select="selectOption('Voltmeter')" value="Voltmeter">
Voltmeter
</DropdownMenuRadioItem>
<DropdownMenuRadioItem @select="selectOption('Ammeter')" value="Ammeter">
Ammeter
</DropdownMenuRadioItem>
<DropdownMenuSeparator />
<DropdownMenuRadioItem @select="turnBack" value="">
Remove annotation
</DropdownMenuRadioItem>
</DropdownMenuRadioGroup>
<Button size="xs" variant="destructive" @click="removeEdges(id)">Remove edge</Button>
</DropdownMenuContent>
</DropdownMenu>
</div>
</EdgeLabelRenderer>
</template>
28 changes: 25 additions & 3 deletions src/assets/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
@tailwind components;
@tailwind utilities;


@layer base {
:root {
--background: 0 0% 100%;
Expand Down Expand Up @@ -33,6 +32,18 @@
--input: 240 5.9% 90%;
--ring: 142.1 76.2% 36.3%;
--radius: 0.5rem;

--vis-tooltip-background-color: none !important;
--vis-tooltip-border-color: none !important;
--vis-tooltip-text-color: none !important;
--vis-tooltip-shadow-color: none !important;
--vis-tooltip-backdrop-filter: none !important;
--vis-tooltip-padding: none !important;

--vis-primary-color: var(--primary);
/* change to any hsl value you want */
--vis-secondary-color: 160 81% 40%;
--vis-text-color: var(--muted-foreground);
}

.dark {
Expand Down Expand Up @@ -63,15 +74,26 @@
--border: 240 3.7% 15.9%;
--input: 240 3.7% 15.9%;
--ring: 142.4 71.8% 29.2%;

--vis-tooltip-background-color: none !important;
--vis-tooltip-border-color: none !important;
--vis-tooltip-text-color: none !important;
--vis-tooltip-shadow-color: none !important;
--vis-tooltip-backdrop-filter: none !important;
--vis-tooltip-padding: none !important;

--vis-primary-color: var(--primary);
/* change to any hsl value you want */
--vis-secondary-color: 240 3.7% 15.9%;
--vis-text-color: var(--muted-foreground);
}
}


@layer base {
* {
@apply border-border;
}
body {
@apply bg-background text-foreground;
}
}
}
6 changes: 3 additions & 3 deletions src/assets/svgs/ACVoltageSource.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions src/assets/svgs/ACVoltageSourceLight.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions src/assets/svgs/DCVoltageSource.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions src/assets/svgs/DCVoltageSourceLight.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 9bbb58d

Please sign in to comment.