| 1 |
<template> |
| 2 |
<header class="ivyforms-header"> |
| 3 |
<div class="ivyforms-header__left"> |
| 4 |
<IvyButtonAction |
| 5 |
v-if="isExpanded && isFormBuilderPage" |
| 6 |
priority="tertiary" |
| 7 |
icon-start="chevron-left" |
| 8 |
icon-start-category="arrows" |
| 9 |
icon-start-type="outline" |
| 10 |
@click="goToAllForms" |
| 11 |
> |
| 12 |
{{ getLabel('all_forms') }} |
| 13 |
</IvyButtonAction> |
| 14 |
<IvyLogo v-else class="ivyforms-header__logo" orientation="logoOnly" /> |
| 15 |
<PageHeaderDivider /> |
| 16 |
<div |
| 17 |
v-if="pageTitle && !isExpanded" |
| 18 |
class="ivyforms-header__title ivyforms-flex-1 ivyforms-align-items-center ivyforms-gap-12 medium-18" |
| 19 |
> |
| 20 |
<span>{{ pageTitle }}</span> |
| 21 |
</div> |
| 22 |
<slot name="left"></slot> |
| 23 |
</div> |
| 24 |
<div class="ivyforms-header__center"> |
| 25 |
<slot name="center"></slot> |
| 26 |
</div> |
| 27 |
<div class="ivyforms-header__right"> |
| 28 |
<IvyTooltip |
| 29 |
:content="theme === 'dark' ? getLabel('light_theme') : getLabel('dark_theme')" |
| 30 |
theme="inverted" |
| 31 |
placement="bottom" |
| 32 |
> |
| 33 |
<IvyThemeSwitch v-model="theme" :aria-label="getLabel('theme_switch')" /> |
| 34 |
</IvyTooltip> |
| 35 |
<!-- <IvyTooltip--> |
| 36 |
<!-- :content="'Get help or contact our support team for assistance with any issues or questions.'"--> |
| 37 |
<!-- >--> |
| 38 |
<!-- <IvyButtonAction--> |
| 39 |
<!-- priority="tertiary"--> |
| 40 |
<!-- icon-start="chat-dots"--> |
| 41 |
<!-- icon-start-type="outline"--> |
| 42 |
<!-- @click="openSupport"--> |
| 43 |
<!-- />--> |
| 44 |
<!-- </IvyTooltip>--> |
| 45 |
<PageHeaderDivider /> |
| 46 |
<slot name="right"></slot> |
| 47 |
<IvyTooltip |
| 48 |
:content="isExpanded ? getLabel('collapse') : getLabel('full_screen')" |
| 49 |
theme="inverted" |
| 50 |
:disabled="closeTooltip" |
| 51 |
> |
| 52 |
<IvyButtonAction |
| 53 |
priority="tertiary" |
| 54 |
icon-start-category="arrows" |
| 55 |
:icon-start="isExpanded ? 'collapse' : 'expand'" |
| 56 |
@click="toggleFullScreen" |
| 57 |
/> |
| 58 |
</IvyTooltip> |
| 59 |
</div> |
| 60 |
</header> |
| 61 |
</template> |
| 62 |
|
| 63 |
<script setup lang="ts"> |
| 64 |
import { useCookies } from '@vueuse/integrations/useCookies' |
| 65 |
import { useGlobalState } from '@/stores/useGlobalState.ts' |
| 66 |
import { inject, onBeforeMount, onMounted, onUnmounted, ref, computed } from 'vue' |
| 67 |
import { useTheme } from '@/composables/useTheme' |
| 68 |
import type { ThemeType } from '@/types/theme' |
| 69 |
import { useLabels } from '@/composables/useLabels' |
| 70 |
import utilRedirect from '@/utils/utilRedirects' |
| 71 |
import { IVYFORMS_ALLFORMS_PAGE } from '@/constants/pages.ts' |
| 72 |
const { getLabel } = useLabels() |
| 73 |
const { redirectToWordPressAdminPage } = utilRedirect() |
| 74 |
|
| 75 |
//const { openContextMenu } = useContextMenuStore() |
| 76 |
|
| 77 |
const cookies = useCookies() |
| 78 |
|
| 79 |
const isExpanded = ref(false) |
| 80 |
const globalState = useGlobalState() |
| 81 |
|
| 82 |
const pageTitle = inject<string>('pageTitle', '') |
| 83 |
|
| 84 |
const closeTooltip = ref(false) |
| 85 |
|
| 86 |
const isFormBuilderPage = computed(() => { |
| 87 |
const currentPage = new URLSearchParams(window.location.search).get('page') |
| 88 |
|
| 89 |
return currentPage === 'ivyforms-builder' |
| 90 |
}) |
| 91 |
|
| 92 |
// Get theme from our composable |
| 93 |
const { theme, setTheme } = useTheme() |
| 94 |
|
| 95 |
onBeforeMount(() => { |
| 96 |
setTheme((cookies.get('ivyforms_theme') as ThemeType) || 'light') |
| 97 |
}) |
| 98 |
|
| 99 |
// const showActionsAndTools = () => { |
| 100 |
// openContextMenu({ |
| 101 |
// actions: actions, |
| 102 |
// contextMenuButtonRef: contextHeaderMenuButtonRef, |
| 103 |
// }) |
| 104 |
// } |
| 105 |
|
| 106 |
const toggleFullScreen = () => { |
| 107 |
isExpanded.value = !isExpanded.value |
| 108 |
globalState.setFullScreenMode(isExpanded.value) |
| 109 |
|
| 110 |
closeTooltip.value = true |
| 111 |
|
| 112 |
const adminBody = document.body |
| 113 |
const adminMenuMain = document.getElementById('adminmenumain') |
| 114 |
const wpContent = document.getElementById('wpcontent') |
| 115 |
const adminBar = document.getElementById('wpadminbar') |
| 116 |
const wpToolbar = document.getElementsByClassName('wp-toolbar')[0] |
| 117 |
|
| 118 |
// Save the fullscreen state to localStorage |
| 119 |
localStorage.setItem('ivyFullscreenMode', isExpanded.value ? 'true' : 'false') |
| 120 |
|
| 121 |
if (isExpanded.value) { |
| 122 |
adminBody.classList.add('ivyforms-fullscreen-mode') |
| 123 |
if (adminMenuMain) adminMenuMain.style.display = 'none' |
| 124 |
if (wpContent) { |
| 125 |
wpContent.style.marginLeft = '0' |
| 126 |
wpContent.style.width = '100vw' |
| 127 |
wpContent.style.height = '100vh' |
| 128 |
} |
| 129 |
if (adminBar) adminBar.style.display = 'none' |
| 130 |
if (wpToolbar instanceof HTMLElement) { |
| 131 |
wpToolbar.style.padding = '0' |
| 132 |
} |
| 133 |
} else { |
| 134 |
adminBody.classList.remove('ivyforms-fullscreen-mode') |
| 135 |
if (adminMenuMain) adminMenuMain.style.display = '' |
| 136 |
if (wpContent) { |
| 137 |
wpContent.style.marginLeft = '' |
| 138 |
wpContent.style.width = '' |
| 139 |
wpContent.style.height = '' |
| 140 |
} |
| 141 |
if (adminBar) adminBar.style.display = '' |
| 142 |
if (wpToolbar instanceof HTMLElement) { |
| 143 |
wpToolbar.style.padding = '' |
| 144 |
} |
| 145 |
} |
| 146 |
setTimeout(() => { |
| 147 |
closeTooltip.value = false |
| 148 |
}, 1000) |
| 149 |
} |
| 150 |
|
| 151 |
const goToAllForms = () => { |
| 152 |
redirectToWordPressAdminPage(IVYFORMS_ALLFORMS_PAGE) |
| 153 |
} |
| 154 |
|
| 155 |
onMounted(() => { |
| 156 |
const savedState = localStorage.getItem('ivyFullscreenMode') |
| 157 |
if (savedState === 'true') { |
| 158 |
isExpanded.value = true |
| 159 |
globalState.setFullScreenMode(isExpanded.value) |
| 160 |
document.body.classList.add('ivyforms-fullscreen-mode') |
| 161 |
|
| 162 |
const adminMenuMain = document.getElementById('adminmenumain') |
| 163 |
const wpContent = document.getElementById('wpcontent') |
| 164 |
const adminBar = document.getElementById('wpadminbar') |
| 165 |
const wpToolbar = document.getElementsByClassName('wp-toolbar')[0] |
| 166 |
|
| 167 |
if (adminMenuMain) adminMenuMain.style.display = 'none' |
| 168 |
if (wpContent) { |
| 169 |
wpContent.style.marginLeft = '0' |
| 170 |
wpContent.style.width = '100vw' |
| 171 |
wpContent.style.height = '100vh' |
| 172 |
} |
| 173 |
if (adminBar) adminBar.style.display = 'none' |
| 174 |
if (wpToolbar instanceof HTMLElement) { |
| 175 |
wpToolbar.style.padding = '0' |
| 176 |
} |
| 177 |
} |
| 178 |
}) |
| 179 |
|
| 180 |
onUnmounted(() => { |
| 181 |
document.body.classList.remove('ivyforms-fullscreen-mode') |
| 182 |
|
| 183 |
const adminMenuMain = document.getElementById('adminmenumain') |
| 184 |
if (adminMenuMain) adminMenuMain.style.display = '' |
| 185 |
}) |
| 186 |
</script> |
| 187 |
|
| 188 |
<style scoped lang="scss"> |
| 189 |
// Header |
| 190 |
.ivyforms-header { |
| 191 |
padding: 12px 24px; |
| 192 |
display: flex; |
| 193 |
align-items: center; |
| 194 |
justify-content: space-between; |
| 195 |
background: var(--map-ground-level-1-foreground); |
| 196 |
box-shadow: 0 4px 15px 0 rgba(0, 0, 0, 0.05); |
| 197 |
gap: 8px; |
| 198 |
position: relative; |
| 199 |
|
| 200 |
// Title |
| 201 |
&__title { |
| 202 |
white-space: nowrap; |
| 203 |
color: var(--map-base-text-0); |
| 204 |
} |
| 205 |
|
| 206 |
// Logo |
| 207 |
&__logo { |
| 208 |
height: 32px; |
| 209 |
width: 32px; |
| 210 |
align-items: center; |
| 211 |
justify-content: center; |
| 212 |
} |
| 213 |
|
| 214 |
&__center { |
| 215 |
position: absolute; |
| 216 |
left: 50%; |
| 217 |
transform: translateX(-50%); |
| 218 |
display: flex; |
| 219 |
align-items: center; |
| 220 |
justify-content: center; |
| 221 |
} |
| 222 |
|
| 223 |
&__left, |
| 224 |
&__right { |
| 225 |
display: flex; |
| 226 |
gap: 8px; |
| 227 |
position: relative; |
| 228 |
flex: 0 0 auto; |
| 229 |
} |
| 230 |
|
| 231 |
&__left { |
| 232 |
align-items: center; |
| 233 |
} |
| 234 |
|
| 235 |
&__right { |
| 236 |
align-items: center; |
| 237 |
} |
| 238 |
} |
| 239 |
</style> |
| 240 |
|