This repository has been archived by the owner on Feb 8, 2024. It is now read-only.
/
Circuit.vue
75 lines (68 loc) · 1.91 KB
/
Circuit.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<template>
<div class="circuit">
<QubitLine
v-for="(qubitLine, index) in circuitState"
:key="index"
:circuit-state="qubitLine"
:auto-measure-gate="autoMeasureGate"
:max-gates="maxGates"
@onGatesChanged="OnGatesChanged"
/>
<button
v-if="circuitState.length < maxLines"
class="circuit__add-button"
@click="addLine()"
>
<svg width="16" height="16" viewBox="0 0 10 10" xmlns="http://www.w3.org/2000/svg">
<path d="M5.5 4.5V0.5H4.5V4.5H0.5V5.5H4.5V9.5H5.5V5.5H9.5V4.5H5.5Z" />
</svg>
</button>
</div>
</template>
<script lang="ts">
import { Options, Vue, prop } from 'vue-class-component'
import QubitLine from './QubitLine.vue'
import { ComposerGate } from './composerTypes'
import { GateName } from './gateUtils'
class Props {
name = prop<String>({ default: GateName.H, required: true })
circuitState = prop<ComposerGate[][]>({ default: [[]], required: true })
autoMeasureGate = prop<boolean>({ default: true, required: true })
maxLines = prop<Number>({ default: 1, required: true })
maxGates = prop<Number>({ default: -1, required: true })
}
@Options({
components: {
QubitLine
}
})
export default class Circuit extends Vue.with(Props) {
OnGatesChanged () {
this.$emit('onCircuitChanged')
}
addLine () {
this.circuitState.push([])
this.$emit('onCircuitChanged')
}
}
</script>
<style scoped lang="scss">
@import 'carbon-components/scss/globals/scss/typography';
@import 'carbon-components/scss/globals/scss/layout';
@import '../../../scss/variables/colors.scss';
@import '~/../scss/variables/mq.scss';
.circuit {
padding: $spacing-02 0;
&__add-button {
cursor: pointer;
padding: $spacing-02;
fill: $text-color-dark;
background-color: transparent;
transition: ease-in .2s;
&:hover {
fill: $text-active-color;
background-color: $background-color-light;
}
}
}
</style>