Skip to content

Beautiful Open-Source Form Builder

Add GitHubStar component to display GitHub star button (#827)

Chirag Chhatrala5499565703f1
diff --git a/client/components/global/GitHubStar.vue b/client/components/global/GitHubStar.vue
new file mode 100644
index 000000000..b1c91d840
--- /dev/null
+++ b/client/components/global/GitHubStar.vue
@@ -0,0 +1,50 @@
+<template>
+ <div v-if="isVisible" class="relative group">
+ <a class="github-button" href="https://github.com/jhumanj/opnform" data-color-scheme="no-preference: light; light: light; dark: dark;" data-size="large" data-show-count="true" aria-label="Star jhumanj/opnform on GitHub">Star</a>
+ <UButton
+ class="absolute -top-2 -right-2 z-10 bg-white dark:bg-gray-800 rounded-full opacity-0 group-hover:opacity-100 transition-opacity"
+ aria-label="Hide"
+ icon="i-heroicons-x-mark"
+ variant="soft"
+ color="error"
+ size="xs"
+ @click="hide"
+ />
+ </div>
+</template>
+
+<script setup>
+const COOKIE_NAME = 'github_star_dismissed'
+const COOKIE_EXPIRY_DAYS = 14
+
+const dismissedCookie = useCookie(COOKIE_NAME, {
+ default: () => false,
+ maxAge: COOKIE_EXPIRY_DAYS * 24 * 60 * 60 * 1000, // 14 days in milliseconds
+ sameSite: 'lax',
+ secure: true,
+ httpOnly: false,
+})
+
+const isVisible = computed(() => !dismissedCookie.value)
+
+function hide() {
+ dismissedCookie.value = true
+}
+
+const scriptTag = computed(() => {
+ if (!isVisible.value) {
+ return []
+ }
+ return [
+ {
+ src: 'https://buttons.github.io/buttons.js',
+ async: true,
+ defer: true,
+ },
+ ]
+})
+
+useHead({
+ script: scriptTag,
+})
+</script>
\ No newline at end of file
diff --git a/client/components/open/forms/components/FormEditorNavbar.vue b/client/components/open/forms/components/FormEditorNavbar.vue
index 22a3b3da1..fe28bc515 100644
--- a/client/components/open/forms/components/FormEditorNavbar.vue
+++ b/client/components/open/forms/components/FormEditorNavbar.vue
@@ -36,6 +36,11 @@
hydrate-on-interaction
/>
+ <GitHubStar
+ v-if="isSelfHosted"
+ class="mt-2 ml-2"
+ />
+
<div class="flex-grow flex justify-center gap-2">
<EditableTag
id="form-editor-title"
@@ -114,6 +119,7 @@ import UndoRedo from '~/components/open/editors/UndoRedo.vue'
import FormSettingsModal from '~/components/open/forms/components/form-components/FormSettingsModal.vue'
import EditableTag from '~/components/app/EditableTag.vue'
import TrackClick from '~/components/global/TrackClick.vue'
+import { useFeatureFlag } from '~/composables/useFeatureFlag'
defineProps({
backButton: {
@@ -145,4 +151,6 @@ const form = computed(() => workingFormStore.content)
const { activeTab } = storeToRefs(workingFormStore)
const settingsModal = ref(false)
+
+const isSelfHosted = computed(() => useFeatureFlag('self_hosted'))
</script>
\ No newline at end of file