-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create a Wikibase discovery page (#719)
* Create a Wikibase discovery page * Show first page of results when modifying filters * Enable empty Wikibase filter * Adjust empty Wikibase filter positioning * Fix content width for larger displays * Update copy for when Wikibase stats are unavailable * Switch to a masonry grid layout * Rename components * Remove semicolons and trailing commas * Add mock data * Fix logo url for mock data * Set page count as the default sort order * Enter key should open Wikibase * Update copy for discovery page * Scroll to top after list is updated * Adjust content margins and breakpoints * Fix linting errors * Switch to a rounded avatar for Wikibase logos * Simplify diff for merge
- Loading branch information
1 parent
5181d01
commit 6dcae41
Showing
9 changed files
with
514 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
src/components/Pages/Discovery/Components/DiscoveryCard.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<template> | ||
<v-card @click="goToWiki" @keyup.enter="goToWiki"> | ||
<v-container class="content"> | ||
<v-row no-gutters> | ||
<v-col class="flex-grow-0"> | ||
<v-avatar rounded :color="color"> | ||
<img v-if="logo" :src="logo.href"> | ||
<span v-else class="white--text">{{character}}</span> | ||
</v-avatar> | ||
</v-col> | ||
<v-col class="details"> | ||
<div class="text-h5 font-weight-regular">{{name}}</div> | ||
<div v-if="stats" class="text-body-2 pages">No. of pages: {{pages}}</div> | ||
<div v-else class="text-body-2 pages">No. of pages: <i>currently unavailable</i></div> | ||
</v-col> | ||
</v-row> | ||
</v-container> | ||
</v-card> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
name: 'DiscoveryCard', | ||
props: { | ||
name: { | ||
type: String, | ||
required: true | ||
}, | ||
url: { | ||
type: URL, | ||
required: true | ||
}, | ||
logo: { | ||
type: URL, | ||
required: false | ||
}, | ||
stats: { | ||
type: Boolean, | ||
required: true | ||
}, | ||
pages: { | ||
type: Number, | ||
required: false | ||
} | ||
}, | ||
computed: { | ||
character: function () { | ||
return this.name.substring(0, 1).toUpperCase() | ||
}, | ||
color: function () { | ||
const colors = ['red', 'blue', 'green', 'purple'] | ||
return this.logo ? 'white' : colors[Math.floor(Math.random() * colors.length)] | ||
} | ||
}, | ||
methods: { | ||
goToWiki () { | ||
window.open(this.url.href, '_blank') | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
.content { | ||
padding: 16px 16px; | ||
} | ||
.details.col { | ||
padding-left: 16px !important; | ||
word-wrap: anywhere; | ||
} | ||
.pages { | ||
padding-top: 4px; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<template> | ||
<div class="grid" ref="grid"> | ||
<slot/> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
name: 'MasonryGrid', | ||
data () { | ||
return { | ||
timer: null | ||
} | ||
}, | ||
methods: { | ||
resizeCards () { | ||
const cards = this.$refs.grid.children | ||
const style = window.getComputedStyle(this.$refs.grid) | ||
const rowGap = parseInt(style.getPropertyValue('row-gap')) | ||
const gridAutoRows = parseInt(style.getPropertyValue('grid-auto-rows')) | ||
const rowHeight = rowGap + gridAutoRows | ||
Array.from(cards).forEach((card) => { | ||
const cardHeight = card.firstChild.getBoundingClientRect().height + rowGap | ||
const numRows = Math.round(cardHeight / rowHeight) | ||
card.style['grid-row'] = 'span ' + numRows | ||
}) | ||
}, | ||
debounceResize (time) { | ||
clearTimeout(this.timer) | ||
this.timer = setTimeout(() => { | ||
this.resizeCards() | ||
}, time) | ||
}, | ||
windowResized () { | ||
this.debounceResize(50) | ||
} | ||
}, | ||
created () { | ||
window.addEventListener('resize', this.windowResized) | ||
}, | ||
destroyed () { | ||
window.removeEventListener('resize', this.windowResized) | ||
}, | ||
updated () { | ||
this.$nextTick(() => { | ||
this.resizeCards() | ||
}) | ||
} | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
.grid { | ||
display: grid; | ||
row-gap: 16px; | ||
grid-template-columns: repeat(auto-fill, minmax(288px, 1fr)); | ||
grid-auto-rows: 1px; | ||
} | ||
</style> |
Oops, something went wrong.