| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277 |
- // Homepage grid
- <template lang="pug">
- .page--index.f-col.between
- header.w-max(v-if="allPages.welcome")
- .page-content(v-html="allPages.welcome.content")
-
- article.w-max
- //- sticky section
- section(v-if="allSticky && Object.keys(allSticky).length").stickies
- ul(:class="[`sticky-${Object.keys(allSticky).length}`, 'flipped']")
- //- if sticky
- li.post.shadow(v-for="sticky in allSticky")
- card(:content="sticky" :type="`${sticky.type}`")
-
- //- firstRow: ['episode', 'exhibition', 'event', 'short', 'post'], exceprt on episode only.
- section
- ul
- li.post.shadow(v-for="type in firstRow")
- card(:content="firstPostOfType(type)" :type="type")
-
- //- secondRow: 'artist', // This is only ONE post, excerpt on artist
- section.max
- ul.w-max
- li.post.shadow(v-for="post in randomPosts.filter(p => p.type == secondRow)")
- card(v-if="post" :content="post" :type="`${post.type}`" :wide="true")
-
- //- (thirdRow) firstRow.flipped: ['object', 'technique', 'publication', 'center', 'guide'], exceprt on guide only
- section
- ul.flipped
- li.post.shadow(v-for="type in thirdRow")
- .random--wrapper(v-for="post in [...randomPosts, ...allPages.filter(p => p.slug == 'center')].filter(p => p.type == type)")
- card(:content="post" :type="type")
- </template>
-
- <script>
- import { postTypeGetters, scrollTop, heroUtils } from './mixin-post-types'
- import card from '@/components/card.vue'
-
- import { convertTitleCase, postTypes, sortTypes } from '@/utils/helpers'
-
- export default {
- mixins: [postTypeGetters, scrollTop, heroUtils],
- components: { card },
- data() {
- return {
- firstRow: ['episode', 'exhibition', 'event', 'short', 'post'],
- secondRow: 'artist', // This is only ONE post
- thirdRow: ['object', 'technique', 'publication', 'page', 'guide'],
- // ideal iteration
- // thirdRow: ['object', 'talks', 'publication', 'center', 'guide'],
- }
- },
- async created() {
- // console.log(wp)
- const omit = ['page']
- for (let type of postTypes) {
- const action = `getAll${convertTitleCase(type)}s`
-
- // Limit the amount of posts because we
- // only need the most recent
- const params = { limit: 1 }
-
- // We try and fetch EVERYTHING except
- // for EVENTS and EXHIBITIONS
- if (['event', 'exhibition'].includes(type)) {
- // Only grab the current or upcoming on load
- const eventsOrExhibitions = await this.$store.dispatch(action, {
- sortType: sortTypes.currentAndUpcoming,
- params,
- })
- // If no current or upcoming, get past events
- // to fill in the blanks
- if (eventsOrExhibitions.length < 1) {
- this.$store.dispatch(action, {
- sortType: sortTypes.past,
- params,
- })
- }
- } else if (!omit.includes(type)) {
- this.$store.dispatch(action, { sortType: null, params })
- }
- }
- if (!this['allPagesLoaded']) {
- await this.$store.dispatch('getAllPages', {
- sortType: null,
- params: null,
- })
- }
- await this.checkAndSetHero('welcome')
- await this.$store.dispatch('getRandomPosts', [
- 'artist',
- 'guide',
- 'object',
- 'technique',
- 'publication',
- 'post',
- ])
- },
- methods: {
- firstPostOfType(type) {
- return Object.values(this[`all${convertTitleCase(type)}s`])[0]
- },
- async checkAndSetHero(type) {
- this._clearHero(this.$store)
-
- // We always set a hero no matter what
- // Because the hero component will deal
- // with how to render based on hero.url
- if (!this.allPages) return console.warn('no pages in state', this)
- const page = this.allPages.filter(page => page.slug == type)[0]
- if (!page) return console.warn(`no page for ${type} found`)
-
- this.$store.commit('SET_HERO', this._setHeroInfo(page))
- },
- },
- }
- </script>
-
- <style lang="postcss">
- // prettier-ignore
- @import '../sss/variables.sss'
- @import '../sss/theme.sss'
- .page--index
- > header
- padding: $ms-0
- > article
- display: flex
- justify-content: space-around
- flex-direction: column
- align-items: stretch
- section
- ul
- list-style: none
- li.post
- background-color: white
- margin: 0 0 0.65em 0
- .featured-or-hero-image img
- max-height: $max-card-img-height
- p.excerpt
- -webkit-line-clamp: $card-line-clamp
- &.flipped
- li
- &:nth-of-type(4)
- /* p.excerpt, p.read-more
- display: none */
- header
- padding: 0.57em 0
- a
- display: none
- &.max
- > ul
- grid-template-columns:
- auto
- grid-template-rows:
- auto
- &.stickies // stickies grid on mobile
- ul
- display: grid
- grid-template-columns: repeat(2, 1fr)
- grid-gap: $ms--2
-
- &.flipped
- li
- &:nth-of-type(4)
- header
- padding: 0
- a
- display: block
-
- /* min-width 768px */
- @media (min-width: $medium)
- .page--index
- > article
- grid-gap: $ms--2 0
- > section
- ul
- display: grid
- grid-template-columns:
- 49.5% 24.35% 24.35%
- grid-template-rows: repeat(2, 1fr)
- gap: 0 $ms--2
- li
- margin: 0
- min-height: 10em
- &:nth-of-type(2), &:nth-of-type(3), &:nth-of-type(4), &:nth-of-type(5)
- /* p.excerpt
- -webkit-line-clamp: $card-line-clamp */
- .featured-or-hero-image img
- /* max-height: calc($max-card-img-height / 2) */
- max-height: $max-card-img-height
- /* n1 episode */
- &:nth-of-type(1)
- grid-column-start: 1
- grid-row-start: 1
- grid-row-end: 3
- /* n2 exhibition, n3 events */
- &:nth-of-type(2), &:nth-of-type(3)
- grid-column-start: 2
- grid-row-start: 1
- &:nth-of-type(3)
- grid-column-start: 3
-
- /* n4 artists, n5 posts */
- &:nth-of-type(4), &:nth-of-type(5)
- grid-column-start: 2
- grid-row-start: 2
- &:nth-of-type(5)
- grid-column-start: 3
- &.flipped
- grid-template-columns:
- 24.35% 24.35% 49.5%
- li
- &:nth-of-type(1)
- grid-row-end: 2
- &:nth-of-type(3)
- grid-column-start: 1
- grid-row-start: 2
- &:nth-of-type(5)
- grid-row-start: 1
- grid-row-end: 3
- &.max
- li .featured-or-hero-image img
- max-height: $max-card-img-height
- &.stickies
- .post
- min-width: 24.35%
- max-width: 32.73%
- ul
- &.flipped
- grid-template-columns:
- 24.35% 24.35% 49.5%
- li
- &:nth-of-type(1)
- grid-row-end: 2
- &:nth-of-type(3)
- grid-column-start: 1
- grid-row-start: 2
- &:nth-of-type(5)
- grid-row-start: 1
- grid-row-end: 3
- &:nth-of-type(4)
- header
- padding: 0
- a
- display: block
- &[class^="sticky-"]
- display: flex
- &.sticky-1
- > li .card--info
- display: flex
- > a:first-of-type
- width: 100%
- &.sticky-5
- grid-template-columns:
- 24.35% 24.35% 49.5%
- grid-template-rows:
- repeat(2, 1fr)
- gap: 3% 1%
- > li
- &:nth-of-type(1)
- grid-row-end: 2
- &:nth-of-type(2)
- grid-column-start: 2
- grid-row-start: 1
- grid-row-end: 2
- &:nth-of-type(3)
- grid-column-start: 1
- grid-row-start: 2
- margin: 0 0 8% 0
- &:nth-of-type(4)
- grid-column-start: 2
- grid-row-start: 2
- margin: 0 0 8% 0
- &:nth-of-type(5)
- grid-column-start: 3
- margin: 0 0 4% 0
- </style>
|