Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

Add BBSwitch

天舟425c780ed8d2
diff --git a/frontend/src/bbkit/BBSwitch.vue b/frontend/src/bbkit/BBSwitch.vue
new file mode 100644
index 0000000000..ef90f04265
--- /dev/null
+++ b/frontend/src/bbkit/BBSwitch.vue
@@ -0,0 +1,50 @@
+<template>
+ <div class="flex items-center">
+ <button
+ type="button"
+ class="relative inline-flex flex-shrink-0 h-6 w-11 border-2 border-transparent rounded-full cursor-pointer transition-colors ease-in-out duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-accent"
+ :class="on ? 'bg-accent' : 'bg-gray-200'"
+ aria-pressed="false"
+ @click.prevent="
+ () => {
+ on = !on;
+ $emit('toggle', on);
+ }
+ "
+ >
+ <span class="sr-only">{{ label }}</span>
+ <!-- Enabled: "translate-x-5", Not Enabled: "translate-x-0" -->
+ <span
+ aria-hidden="true"
+ class="pointer-events-none inline-block h-5 w-5 rounded-full bg-white shadow transform ring-0 transition ease-in-out duration-200"
+ :class="on ? 'translate-x-5' : 'translate-x-0'"
+ ></span>
+ </button>
+ <span v-if="label" class="ml-2 text-sm font-medium text-main items-center">
+ {{ label }}
+ </span>
+ </div>
+</template>
+
+<script lang="ts">
+import { ref } from "vue";
+
+export default {
+ name: "BBSwitch",
+ emits: ["toggle"],
+ props: {
+ label: {
+ default: "",
+ type: String,
+ },
+ value: {
+ default: true,
+ type: Boolean,
+ },
+ },
+ setup(props, ctx) {
+ const on = ref(props.value);
+ return { on };
+ },
+};
+</script>
diff --git a/frontend/src/bbkit/index.ts b/frontend/src/bbkit/index.ts
index bf6fa26f08..7e75bb0bf4 100644
--- a/frontend/src/bbkit/index.ts
+++ b/frontend/src/bbkit/index.ts
@@ -5,6 +5,7 @@ import BBContextMenu from "./BBContextMenu.vue";
import BBModal from "./BBModal.vue";
import BBNotification from "./BBNotification.vue";
import BBOutline from "./BBOutline.vue";
+import BBSwitch from "./BBSwitch.vue";
import BBSelect from "./BBSelect.vue";
import BBStepBar from "./BBStepBar.vue";
import BBTab from "./BBTab.vue";
@@ -27,6 +28,7 @@ export {
BBOutline,
BBSelect,
BBStepBar,
+ BBSwitch,
BBTab,
BBTabPanel,
BBTable,
diff --git a/frontend/src/main.js b/frontend/src/main.js
index b2c6a016a4..5175a17aef 100644
--- a/frontend/src/main.js
+++ b/frontend/src/main.js
@@ -18,6 +18,7 @@ import {
BBOutline,
BBSelect,
BBStepBar,
+ BBSwitch,
BBTab,
BBTabPanel,
BBTable,
@@ -62,6 +63,7 @@ app
.component("BBOutline", BBOutline)
.component("BBSelect", BBSelect)
.component("BBStepBar", BBStepBar)
+ .component("BBSwitch", BBSwitch)
.component("BBTab", BBTab)
.component("BBTabPanel", BBTabPanel)
.component("BBTable", BBTable)