Skip to content

Commit

Permalink
Add ID to Slices
Browse files Browse the repository at this point in the history
  • Loading branch information
MelanieMEB committed Nov 27, 2020
1 parent 28d7e65 commit 088c147
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 6 deletions.
6 changes: 5 additions & 1 deletion components/slices/Article.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div :style="[background]">
<div :id="id" :style="[background]">
<div
class="article"
:class="{
Expand Down Expand Up @@ -70,6 +70,7 @@

<script>
import CtaButton from '../CtaButton'
import textToId from '@/services/text-to-id'
export default {
name: 'Article',
Expand Down Expand Up @@ -109,6 +110,9 @@ export default {
this.content.article_background && this.content.article_background.url
)
},
id() {
return textToId(this.content.article_title[0].text)
},
isOnlyTextLayout() {
return this.content.article_layout === 'only-text'
},
Expand Down
6 changes: 5 additions & 1 deletion components/slices/LatestNews.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<section class="latest-news">
<section :id="id" class="latest-news">
<prismic-rich-text
v-if="shouldDisplayTitle && hasTitle"
class="latest-news__title"
Expand Down Expand Up @@ -30,6 +30,7 @@

<script>
import NewsItemCard from '../NewsItemCard'
import textToId from '@/services/text-to-id'
export default {
name: 'LatestNews',
Expand Down Expand Up @@ -60,6 +61,9 @@ export default {
this.slice.primary.latest_news_items.length
)
},
id() {
return textToId(this.slice.primary.latest_news_title[0].text)
},
},
methods: {},
}
Expand Down
6 changes: 5 additions & 1 deletion components/slices/MultipleBlock.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<section :class="blockClass" :style="[background]">
<section :id="id" :class="blockClass" :style="[background]">
<prismic-rich-text
v-if="hasTitle && shouldDisplayTitle"
:class="`${blockClass}__title`"
Expand Down Expand Up @@ -44,6 +44,7 @@ import {
EXTRA_LARGE_SCREEN_MIN_WIDTH,
DESKTOP_MIN_WIDTH,
} from '~/config/breakpoints'
import textToId from '@/services/text-to-id'
export default {
name: 'MultipleBlock',
Expand All @@ -67,6 +68,9 @@ export default {
blockClass() {
return this.slice.primary.block_style
},
id() {
return textToId(this.slice.primary.block_title[0].text)
},
items() {
return this.slice.items
},
Expand Down
7 changes: 6 additions & 1 deletion components/slices/PartnersLogos.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<section class="partners-logos">
<section :id="id" class="partners-logos">
<prismic-rich-text
v-if="hasTitle && shouldDisplayTitle"
class="partners-logos__title"
Expand All @@ -19,6 +19,8 @@
</template>

<script>
import textToId from '@/services/text-to-id'
export default {
name: 'PartnersLogosSlice',
props: {
Expand All @@ -28,6 +30,9 @@ export default {
},
},
computed: {
id() {
return textToId(this.slice.primary.logos_title[0].text)
},
items() {
return this.slice.items
},
Expand Down
7 changes: 5 additions & 2 deletions components/slices/Stat.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div class="stat">
<div :id="id" class="stat">
<prismic-rich-text :field="content.block_title" />
<prismic-rich-text :field="content.block_presentation" />
<chart-section :data="chartData" />
Expand All @@ -8,6 +8,7 @@

<script>
import ChartSection from '~/components/ChartSection'
import textToId from '@/services/text-to-id'
export default {
name: 'StatSlice',
Expand All @@ -27,7 +28,9 @@ export default {
data() {
return this.slice.items
},
id() {
return textToId(this.content.block_title[0].text)
},
chartData() {
function backgroundColorFrom(color) {
const hex = color.replace('#', '')
Expand Down
1 change: 1 addition & 0 deletions tests/components/slices/Stat.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ describe('Stat slice', () => {
propsData: {
slice: {
primary: {
block_title: [{ text: 'Title of Data' }],
block_data_name: [{ text: 'Data name' }],
block_graph_color: '#4700ff',
},
Expand Down

0 comments on commit 088c147

Please sign in to comment.