-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from betty2310/feat_diode_cp
feat(components): support Diode model 1N914
- Loading branch information
Showing
11 changed files
with
168 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<script lang="ts" setup> | ||
import { onMounted, ref } from 'vue' | ||
import { Handle, type NodeProps, Position, useVueFlow } from '@vue-flow/core' | ||
import { NodeToolbar } from '@vue-flow/node-toolbar' | ||
import IconComponent from '@/assets/svgs/Diode.svg?component' | ||
import type { DiodeData } from '@/types' | ||
const props = defineProps<NodeProps<DiodeData>>() | ||
defineOptions({ | ||
inheritAttrs: false | ||
}) | ||
const { updateNodeData, onNodeClick, removeNodes } = useVueFlow() | ||
onMounted(() => { | ||
const id = props.id.split(' ')[1] | ||
updateNodeData<DiodeData>(props.id, { | ||
id: `D${id}`, | ||
type: 'diode', | ||
description: 'Diode model 1N914', | ||
toolbarPosition: Position.Right, | ||
toolbarVisible: false | ||
}) | ||
}) | ||
const toolbarVisible = ref(props.data.toolbarVisible) | ||
onNodeClick((event) => { | ||
if (event.node.id !== props.id) return | ||
toolbarVisible.value = !toolbarVisible.value | ||
}) | ||
const handleRemoveNode = () => { | ||
removeNodes(props.id, true) | ||
} | ||
</script> | ||
|
||
<template> | ||
<div class="font-mono">{{ props.data.id }}</div> | ||
<NodeToolbar | ||
:is-visible="toolbarVisible" | ||
:position="data.toolbarPosition" | ||
style="display: flex; gap: 0.5rem; align-items: center" | ||
> | ||
<div class="flex flex-col gap-2"> | ||
<button class="btn btn-error" @click="handleRemoveNode">x</button> | ||
</div> | ||
</NodeToolbar> | ||
|
||
<IconComponent /> | ||
  | ||
|
||
<Handle :position="Position.Left" type="source" /> | ||
<Handle :position="Position.Right" type="target" /> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<template> | ||
<!-- <div class="flex items-center justify-between mx-4">--> | ||
<!-- <label for="input-field" class="mr-2">Diode</label>--> | ||
<!-- <div class="relative">--> | ||
<!-- <input--> | ||
<!-- type="number"--> | ||
<!-- id="input-field"--> | ||
<!-- class="px-3 py-2 input input-bordered w-auto"--> | ||
<!-- v-model="inductance"--> | ||
<!-- @change="handleUpdate"--> | ||
<!-- />--> | ||
<!-- <span class="absolute right-2 top-1/2 transform -translate-y-1/2 text-gray-500">H</span>--> | ||
<!-- </div>--> | ||
<!-- </div>--> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import type { DiodeData } from '@/types' | ||
const props = defineProps<DiodeData>() | ||
// const inductance = ref(props.inductance) | ||
// watch( | ||
// () => props.inductance, | ||
// (value) => { | ||
// inductance.value = value | ||
// } | ||
// ) | ||
// | ||
// const circuitStore = useCircuitStore() | ||
// | ||
// function handleUpdate() { | ||
// const node = circuitStore.getSelectedNode() | ||
// if (!node) return | ||
// node.data.inductance = inductance.value | ||
// } | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Component } from '@/logic/models/Component' | ||
|
||
export class Diode extends Component { | ||
// TODO: diode have model | ||
|
||
constructor(id: string) { | ||
super(id) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import { Component } from './Component' | ||
import { Resistor, Capacitor, Inductor } from './Passive' | ||
import { Capacitor, Inductor, Resistor } from './Passive' | ||
import { Ground } from './Ground' | ||
import { Diode } from './Diode' | ||
import { ACVoltageSource, DCVoltageSource } from './Sources' | ||
|
||
export { Component, Resistor, Capacitor, Inductor, DCVoltageSource, ACVoltageSource, Ground } | ||
export { Component, Resistor, Capacitor, Inductor, DCVoltageSource, ACVoltageSource, Ground, Diode } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters