Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: APPS-2916 fix hydration and undefined errors #623

Merged
merged 21 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
a6038d3
feat: set ref ismobile to false and update it in onmounted client side
pghorpade Sep 16, 2024
a4550b1
fix: hydration error and undefined errors by adding watchers
pghorpade Sep 20, 2024
368051c
fix: replace globalstore with useWindowSize from vueuse , also revert…
pghorpade Sep 27, 2024
78d4f4c
feat: APPS-2943 Add initialTab setting option to TabToggle (#611)
tinuola Sep 17, 2024
e264726
chore(release): set `package.json` to 3.19.0 [skip ci]
semantic-release-bot Sep 17, 2024
d311455
feat: APPS-2945 FTVA Variation of SectionTeaserList (#613)
jendiamond Sep 20, 2024
a87e146
chore(release): set `package.json` to 3.20.0 [skip ci]
semantic-release-bot Sep 20, 2024
09f58e6
feat: APPS-2946 Create Two Column Layout component (#614)
farosFreed Sep 24, 2024
0dc3970
chore(release): set `package.json` to 3.21.0 [skip ci]
semantic-release-bot Sep 24, 2024
f52f755
fix: APPS-2947 Update NavBreadcrumb logic to display route title or p…
tinuola Sep 24, 2024
e82cfe7
chore(release): set `package.json` to 3.21.1 [skip ci]
semantic-release-bot Sep 24, 2024
2d68746
feat: APPS-2957 Create FTVA Pullquote (#617)
farosFreed Sep 24, 2024
04b1bff
chore(release): set `package.json` to 3.22.0 [skip ci]
semantic-release-bot Sep 24, 2024
a125bfd
fix: APPS-2982 Remove excess padding values (#620)
tinuola Sep 25, 2024
ddcf71c
chore(release): set `package.json` to 3.22.1 [skip ci]
semantic-release-bot Sep 25, 2024
ad7dc0e
chore: APPS-2962 move styles from page to story (#619)
farosFreed Sep 25, 2024
5113587
feat: Apps-2951 card meta changes for article detail page (#618)
farosFreed Sep 27, 2024
9fea87e
chore(release): set `package.json` to 3.23.0 [skip ci]
semantic-release-bot Sep 27, 2024
e9bf3e5
fix: hydration error and undefined errors by adding watchers
pghorpade Sep 20, 2024
e683799
Merge branch 'main' into APPS-2916
pghorpade Sep 27, 2024
74ae7f2
fix: lint errors
pghorpade Sep 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/lib-components/HeaderMain.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,15 @@ const parseTitle = computed(() => {

<template>
<header class="header-main">
<NavSecondary :items="secondaryNav" :is-microsite="parseTitle" />
<NavPrimary class="primary" :items="primaryNav" :title="title" />
<NavSecondary
:items="secondaryNav"
:is-microsite="parseTitle"
/>
<NavPrimary
class="primary"
:items="primaryNav"
:title="title"
/>
</header>
</template>

Expand Down
85 changes: 50 additions & 35 deletions src/lib-components/HeaderSmart.vue
Original file line number Diff line number Diff line change
@@ -1,56 +1,71 @@
<script>
import { mapState } from 'pinia'
<script setup>
import { markRaw, onMounted, ref, watch } from 'vue'
import { useWindowSize } from '@vueuse/core'
import { storeToRefs } from 'pinia'
import { useGlobalStore } from '@/stores/GlobalStore'
import SiteBrandBar from '@/lib-components/SiteBrandBar'
import HeaderMainResponsive from '@/lib-components/HeaderMainResponsive'
import HeaderMain from '@/lib-components/HeaderMain'
import { useGlobalStore } from '@/stores/GlobalStore'

export default {
name: 'HeaderSmart',
components: {
SiteBrandBar,
HeaderMainResponsive,
HeaderMain,
// Props
const props = defineProps({
title: {
type: String,
default: '',
},
props: {
title: {
type: String,
default: '',
},
})

// Access the global store
const globalStore = useGlobalStore()
const { header } = storeToRefs(globalStore)

// Use refs for primary, secondary menu items, and header type
const primaryMenuItems = ref(header.value.primary || [])
const secondaryMenuItems = ref(header.value.secondary || [])

// Mark components as raw to prevent them from being reactive
const currentHeader = ref(markRaw(HeaderMain))

const isMobile = ref(false)
onMounted(() => {
const { width } = useWindowSize()
watch(width, (newWidth) => {
console.log('newWidth', newWidth)
isMobile.value = newWidth <= 1200
currentHeader.value = markRaw(isMobile.value ? HeaderMainResponsive : HeaderMain)
},
computed: {
...mapState(useGlobalStore, ['header', 'winWidth']),
primaryMenuItems() {
return this.header.primary
},
secondaryMenuItems() {
return this.header.secondary
},
isMobile() {
return this.winWidth <= 1024
},
whichHeader() {
return this.isMobile ? 'header-main-responsive' : 'header-main'
{ immediate: true })

watch(
header,
(newVal, oldVal) => {
console.log('Header updated from parent page', newVal, oldVal)
primaryMenuItems.value = newVal.primary
secondaryMenuItems.value = newVal.secondary
},
},
}
{ deep: true, immediate: true }
)
})
</script>

<template>
<header class="header-smart">
<SiteBrandBar class="brand-bar" />
<component
:is="whichHeader" :class="isMobile ? 'mobile-header' : 'desktop-header'" :primary-nav="primaryMenuItems"
:secondary-nav="secondaryMenuItems" :title="title"
:is="currentHeader"
:class="isMobile ? 'mobile-header' : 'desktop-header'"
:primary-nav="primaryMenuItems"
:secondary-nav="secondaryMenuItems"
:title="title"
/>
</header>
</template>

<style lang="scss" scoped>
@media #{$medium} {
.brand-bar {
position: absolute;
width: 100%;
}
.brand-bar {
position: absolute;
width: 100%;
}
}
</style>
105 changes: 63 additions & 42 deletions src/lib-components/IconWithLink.vue
Original file line number Diff line number Diff line change
Expand Up @@ -209,65 +209,86 @@ export default {

<template>
<div class="icon-with-link">
<SmartLink v-if="to" :to="to" class="icon-with-link-container link">
<component :is="iconName" class="icon" aria-hidden="true" />
<div class="text" v-text="text" />
<SmartLink
v-if="to"
:to="to"
class="icon-with-link-container link"
>
<component
:is="iconName"
class="icon"
aria-hidden="true"
/>
<div
class="text"
v-text="text"
/>
</SmartLink>
<div v-else class="icon-with-link-container">
<component :is="iconName" class="icon" aria-hidden="true" />
<div class="text" v-text="text" />
<div
v-else
class="icon-with-link-container"
>
<component
:is="iconName"
class="icon"
aria-hidden="true"
/>
<div
class="text"
v-text="text"
/>
</div>
</div>
</template>

<style lang="scss" scoped>
.icon-with-link {
--link-color: var(--color-primary-blue-03);
--icon-color: var(--color-primary-blue-03);
--icon-color-highlight: var(--color-default-cyan-03);
--link-color: var(--color-primary-blue-03);
--icon-color: var(--color-primary-blue-03);
--icon-color-highlight: var(--color-default-cyan-03);

display: inline-block;
line-height: 1;
display: inline-block;
line-height: 1;

.text {
@include button;
white-space: pre-wrap;
}
.text {
@include button;
white-space: pre-wrap;
}

.link {
color: var(--link-color);
}
.link {
color: var(--link-color);
}

.icon-with-link-container {
display: inline-flex;
flex-direction: row;
flex-wrap: nowrap;
justify-content: flex-start;
align-items: center;
gap: var(--space-xs);
}
.icon-with-link-container {
display: inline-flex;
flex-direction: row;
flex-wrap: nowrap;
justify-content: flex-start;
align-items: center;
gap: var(--space-xs);
}

.icon {
flex-shrink: 0;
.icon {
flex-shrink: 0;

.svg__stroke--primary-blue-03 {
stroke: var(--icon-color);
}
.svg__stroke--primary-blue-03 {
stroke: var(--icon-color);
}

.svg__fill--primary-blue-03 {
fill: var(--icon-color);
}
.svg__fill--primary-blue-03 {
fill: var(--icon-color);
}

.svg__stroke--default-cyan-03 {
stroke: var(--icon-color-highlight);
}
.svg__stroke--default-cyan-03 {
stroke: var(--icon-color-highlight);
}
}

// Hover states
@media #{$has-hover} {
.link:hover {
@include link-hover;
}
// Hover states
@media #{$has-hover} {
.link:hover {
@include link-hover;
}
}
}
</style>
Loading
Loading