Skip to content

Commit

Permalink
various www-frontend parity fixes (#598)
Browse files Browse the repository at this point in the history
* removing BlockTwitterEmbed

* fixing /home/ prefix in BaseButton links

* making sure all links are using either BaseLink or BaseButton

* fixing passing query params in NavSearchForm

* fixing hydration error in SwimlaneCTA

* fixing vue build error
  • Loading branch information
stephiescastle authored Sep 5, 2024
1 parent 6f74333 commit 563964d
Show file tree
Hide file tree
Showing 12 changed files with 44 additions and 110 deletions.
2 changes: 0 additions & 2 deletions packages/vue/lib/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ import BlockStreamfield from './../src/components/BlockStreamfield/BlockStreamfi
import BlockTable from './../src/components/BlockTable/BlockTable.vue'
import BlockTeaser from './../src/components/BlockTeaser/BlockTeaser.vue'
import BlockText from './../src/components/BlockText/BlockText.vue'
import BlockTwitterEmbed from './../src/components/BlockTwitterEmbed/BlockTwitterEmbed.vue'
import BlockVideo from './../src/components/BlockVideo/BlockVideo.vue'
import BlockVideoEmbed from './../src/components/BlockVideoEmbed/BlockVideoEmbed.vue'
import CalendarButton from './../src/components/CalendarButton/CalendarButton.vue'
Expand Down Expand Up @@ -280,7 +279,6 @@ export {
BlockTable,
BlockTeaser,
BlockText,
BlockTwitterEmbed,
BlockVideo,
BlockVideoEmbed,
CalendarButton,
Expand Down
10 changes: 9 additions & 1 deletion packages/vue/src/components/BaseButton/BaseButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ export default defineComponent({
}
return undefined
},
computedTo() {
let toValue = this.to
// filter out unnecessary `/home/` prefix from wagtail default site urlPaths
if (toValue && typeof toValue === 'string' && toValue.startsWith('/home/')) {
toValue = toValue.replace('/home/', '/')
}
return toValue
},
variantClass(): string {
let classes = variants[this.variant]
if (!this.$slots.default && this.$slots.icon) {
Expand All @@ -99,7 +107,7 @@ export default defineComponent({
:aria-label="ariaLabel"
:disabled="disabled"
:href="theHref"
:to="to ? to : undefined"
:to="computedTo ? computedTo : undefined"
@click="$emit('click')"
>
<span class="label block">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
>
{{ data.heading }}
</BaseHeading>
<ul
v-for="(link, index) in data.links"
:key="index"
class="sm:w-3/4 md:w-2/3 lg:w-3/4 xl:w-2/3 mb-2 print:list-disc print:ml-4"
>
<li>
<ul class="sm:w-3/4 md:w-2/3 lg:w-3/4 xl:w-2/3 print:list-disc print:ml-4">
<li
v-for="(link, index) in data.links"
:key="index"
class="mb-2"
>
<template v-if="link.externalLink">
<RelatedLink
variant="external"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
<component
:is="tag"
:to="to"
variant="none"
:href="href"
class="bg-gray-light group text-body-lg flex items-center justify-between px-4 py-4 cursor-pointer print:px-0 print:py-0 print:block"
link-class="bg-gray-light group text-body-lg flex items-center justify-between w-full print:block"
:target="target"
rel="noopener"
>
Expand All @@ -19,6 +21,7 @@
</template>
<script lang="ts">
import { defineComponent, resolveComponent } from 'vue'
import BaseLink from './../BaseLink/BaseLink.vue'
import IconArrow from './../Icons/IconArrow.vue'
import IconDownload from './../Icons/IconDownload.vue'
import IconExternal from './../Icons/IconExternal.vue'
Expand All @@ -36,6 +39,7 @@ export const variants: Variants = {
export default defineComponent({
name: 'BlockRelatedLinks',
components: {
BaseLink,
IconArrow,
IconDownload,
IconExternal
Expand All @@ -59,7 +63,7 @@ export default defineComponent({
computed: {
tag() {
if (this.to) {
return resolveComponent('NuxtLink')
return resolveComponent('BaseLink')
} else {
return 'a'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,6 @@
<BlockImageComparison :data="block" />
</LayoutHelper>

<BlockTwitterEmbed
v-else-if="block.blockType == 'TwitterEmbedBlock'"
:key="`twitterEmbedBlock${index}`"
class="lg:mb-18 mb-10"
:data="block"
/>

<LayoutHelper
v-else-if="block.blockType == 'IframeEmbedBlock'"
:key="`iframeEmbedBlock${index}`"
Expand Down Expand Up @@ -271,7 +264,6 @@ import BlockRelatedLinks, {
import BlockTable from './../BlockTable/BlockTable.vue'
import BlockTeaser from './../BlockTeaser/BlockTeaser.vue'
import BlockText from './../BlockText/BlockText.vue'
import BlockTwitterEmbed from './../BlockTwitterEmbed/BlockTwitterEmbed.vue'
import BlockIframeEmbed from './../BlockIframeEmbed/BlockIframeEmbed.vue'
import BlockGist from './../BlockGist/BlockGist.vue'
import BlockVideo from './../BlockVideo/BlockVideo.vue'
Expand Down Expand Up @@ -311,7 +303,6 @@ export default defineComponent({
BlockTable,
BlockTeaser,
BlockText,
BlockTwitterEmbed,
BlockIframeEmbed,
BlockGist,
BlockVideo,
Expand Down

This file was deleted.

This file was deleted.

5 changes: 3 additions & 2 deletions packages/vue/src/components/HeroMedium/HeroMedium.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
'my-6 lg:mt-0 lg:mb-10': compact
}"
>
<nuxt-link
<BaseLink
variant="none"
:to="feature.url"
class="lg:w-1/2 xl:w-5/12 block"
>
Expand Down Expand Up @@ -79,7 +80,7 @@
<IconArrow class="inline" />
</span>
</p>
</nuxt-link>
</BaseLink>
<BaseLink
:to="feature.url"
class="lg:block hidden"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
<span class="sr-only">.</span>
</p>
<component
:is="item.externalLink || (item.page && item.page.url) ? 'BaseLink' : 'div'"
:is="tag"
variant="none"
link-class="block"
:href="item.externalLink ? item.externalLink : null"
Expand Down Expand Up @@ -98,7 +98,7 @@
</div>
</template>
<script lang="ts">
import { defineComponent } from 'vue'
import { defineComponent, resolveComponent } from 'vue'
import type { PropType } from 'vue'
import type { ImageObject } from '../../interfaces'
import BaseLink from './../BaseLink/BaseLink.vue'
Expand Down Expand Up @@ -128,7 +128,16 @@ export default defineComponent({
props: {
item: {
type: Object as PropType<Slide>,
required: false
default: undefined
}
},
computed: {
tag() {
if (this.item?.externalLink || (this.item?.page && this.item?.page.url)) {
return resolveComponent('BaseLink')
} else {
return 'div'
}
}
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const clearSearch = () => {
}
const submitSearch = () => {
emit('submitForm')
router.push({ path: '/search', query: searchQuery.value })
router.push({ path: '/search', query: { query: searchQuery.value } })
}
</script>
<template>
Expand Down
4 changes: 2 additions & 2 deletions packages/vue/src/components/SwimlaneCTA/SwimlaneCTA.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
link-class="max-w-screen-3xl block w-full mx-auto"
>
<div
v-bind-once="{ style: 'background-image: url(' + randomizeImage + ');' }"
role="presentation"
:class="'SwimlaneCTA lg:block hidden' + computedClass"
:style="'background-image: url(' + randomizeImage + ');'"
>
<div class="absolute inset-0 z-10 bg-black bg-opacity-25"></div>
<div
Expand Down Expand Up @@ -61,9 +61,9 @@
</div>
</div>
<div
v-bind-once="{ style: 'background-image: url(' + randomizeImageSmall + ');' }"
role="presentation"
:class="'SwimlaneCTA lg:hidden block' + computedClass"
:style="'background-image: url(' + randomizeImageSmall + ');'"
>
<div
class="lg:flex-row lg:pr-12 lg:py-5 flex flex-col justify-center w-full px-5 py-6 bg-black bg-opacity-25"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<template>
<nuxt-link
<BaseLink
v-if="data"
variant="none"
:to="data.url"
class="TopicDetailMissionCarouselItem ThemeVariantLight group block cursor-pointer"
>
Expand Down Expand Up @@ -59,7 +60,7 @@
/>
</div>
</div>
</nuxt-link>
</BaseLink>
</template>

<script lang="ts">
Expand All @@ -69,6 +70,7 @@ import type { ClockType } from '../MissionDetailStats/MissionDetailStats.vue'
import type { PropType } from 'vue'
import type { ImageObject } from '../../interfaces'
import MissionDetailStatsMicro from './../MissionDetailStats/MissionDetailStatsMicro.vue'
import BaseLink from './../BaseLink/BaseLink.vue'
import BaseImage from './../BaseImage/BaseImage.vue'
import BaseImagePlaceholder from './../BaseImagePlaceholder/BaseImagePlaceholder.vue'
Expand All @@ -87,7 +89,8 @@ export default defineComponent({
components: {
MissionDetailStatsMicro,
BaseImage,
BaseImagePlaceholder
BaseImagePlaceholder,
BaseLink
},
props: {
data: {
Expand Down

0 comments on commit 563964d

Please sign in to comment.