-
Notifications
You must be signed in to change notification settings - Fork 3
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
Nick Berens GridList Component Test #10
Open
nickberens360
wants to merge
37
commits into
funkhaus:master
Choose a base branch
from
nickberens360:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
44d3aa8
add initial GalleryList component and story
nickberens360 e8cb625
add data object and import mock data into story
nickberens360 ff89a94
add component logic and default story
nickberens360 af3d1eb
add 404 error story
nickberens360 379d4eb
add comment
nickberens360 425eb7d
add logic to check for multiple error types
nickberens360 74c513e
group galler-item css rules
nickberens360 26a72ba
group remaining css properties
nickberens360 9d1cbcf
import WpImage into story and component
nickberens360 4c012d5
optimize lodash import
nickberens360 5182ca7
move mock-api-error.json data into story
nickberens360 f3f0572
fix merge conflict after sync
nickberens360 97556e2
change caption styling to have darker background and white text
nickberens360 82a6153
import font into the component because it doesn't appear to set globally
nickberens360 97fc015
change status class names to be more consistent with fuxthaus convent…
nickberens360 2af9596
move font-size from item-title into link
nickberens360 b09394a
move hover events to h3 and make display-inline to trigger bg only wh…
nickberens360 7181598
decrease ul/li nesting
nickberens360 5469a33
check if caption exists in data if not use item title
nickberens360 6384735
add comment about importing font
nickberens360 bad1633
change caption value in story to null instead of empty string to matc…
nickberens360 0190563
remove WpImage import from component
nickberens360 c3a8647
remove list class from gallery-list
nickberens360 a3966a8
lighten caption background a smidge
nickberens360 c755240
remove WpImage from storybook file
nickberens360 f515b27
remove WpImage import
nickberens360 d2fdc77
refactor loop structure
nickberens360 33eb2cb
remove unused .item-main class
nickberens360 8962200
use fuxt package.json and nuxt.config.js because storybook was failin…
nickberens360 86ecdd7
remove font import from component
nickberens360 9cbbf83
move shapeListData to utils
nickberens360 5a78120
remove commented out shapeListData method
nickberens360 18428d1
decrease mobile caption size
nickberens360 fcbd842
remove component import from story
nickberens360 5c6f184
remove alt tag which is handled by WpImage
nickberens360 573a07e
add .env.example back in
nickberens360 6231703
uncomment mouseout
nickberens360 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,262 @@ | ||
<template> | ||
<div class="gallery-list"> | ||
<nav class="list-main"> | ||
<ul | ||
v-for="(main) in preparedList" | ||
class="list" | ||
> | ||
<li | ||
v-for="(item) in main.listItems" | ||
:key="item.id" | ||
class="item" | ||
> | ||
<h3 | ||
class="item-title" | ||
@mouseout="mouseOut()" | ||
@mouseover="mouseOver(item)" | ||
> | ||
<nuxt-link | ||
:to="item.uri" | ||
class="link" | ||
> | ||
{{ item.title }} | ||
</nuxt-link> | ||
</h3> | ||
</li> | ||
</ul> | ||
</nav> | ||
|
||
<transition | ||
mode="out-in" | ||
name="fade" | ||
> | ||
<wp-image | ||
v-if="image" | ||
:key="image.id" | ||
:caption="caption" | ||
:class="imageClasses" | ||
:image="image" | ||
mode="fullbleed" | ||
@error-video="videoError" | ||
@error-image="imageError" | ||
@loaded-image="imageLoaded" | ||
@loaded-video="videoLoaded" | ||
/> | ||
</transition> | ||
</div> | ||
</template> | ||
<script> | ||
|
||
|
||
|
||
import _shapeListData from "~/utils/_shapeListData" | ||
|
||
export default { | ||
name: "List", | ||
props: { | ||
items: { | ||
type: Array, | ||
default: () => [] | ||
}, | ||
}, | ||
data() { | ||
return { | ||
isImageLoaded: false, | ||
isVideoLoaded: false, | ||
isImageError: false, | ||
isVideoError: false, | ||
caption: '', | ||
image: null | ||
} | ||
}, | ||
computed: { | ||
imageClasses() { | ||
return [ | ||
{ | ||
'has-loaded-media': this.isImageLoaded || this.isVideoLoaded, | ||
'has-full-media-error': this.isVideoError && this.isImageError && !this.isImageLoaded && !this.isVideoLoaded, | ||
} | ||
] | ||
|
||
}, | ||
preparedList() { | ||
let tempData = this.items | ||
let {right, left} = _shapeListData(tempData, 3) | ||
let trimmed = _shapeListData(left, 2) | ||
|
||
return [ | ||
{ | ||
listItems: trimmed.left | ||
}, | ||
{ | ||
listItems: trimmed.right | ||
}, | ||
{ | ||
listItems: right | ||
} | ||
] | ||
}, | ||
|
||
}, | ||
methods: { | ||
videoLoaded() { | ||
this.isVideoLoaded = true | ||
}, | ||
imageLoaded() { | ||
this.isImageLoaded = true | ||
}, | ||
videoError() { | ||
this.isVideoError = true | ||
}, | ||
imageError() { | ||
this.isImageError = true | ||
}, | ||
|
||
mouseOver(item) { | ||
this.caption = item.featuredImage.node.caption !== null ? item.featuredImage.node.caption : `Who the fuxt is ${item.title}?` | ||
this.image = item.featuredImage.node | ||
}, | ||
mouseOut() { | ||
this.isVideoLoaded = false | ||
this.isImageLoaded = false | ||
this.isVideoError = false | ||
this.isImageError = false | ||
this.caption = '' | ||
this.image = null | ||
}, | ||
} | ||
|
||
} | ||
</script> | ||
|
||
|
||
<style lang="scss" scoped> | ||
|
||
.gallery-list { | ||
position: relative; | ||
z-index: 0; | ||
|
||
max-width: 1280px; | ||
min-height: var(--unit-100vh); | ||
margin: 0 auto; | ||
padding: 0 var(--unit-gap); | ||
box-sizing: border-box; | ||
|
||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
|
||
font-family: var(--font-primary); | ||
|
||
.list { | ||
margin: 0; | ||
padding: 0; | ||
list-style: none; | ||
} | ||
|
||
.list-main { | ||
position: relative; | ||
z-index: 20; | ||
|
||
max-width: 1180px; | ||
width: 100%; | ||
height: 100%; | ||
box-sizing: border-box; | ||
margin: 0 auto; | ||
|
||
display: flex; | ||
justify-content: space-between; | ||
} | ||
|
||
|
||
.item-title { | ||
display: inline-block; | ||
|
||
margin: 0; | ||
} | ||
|
||
.link { | ||
padding: 17px 0; | ||
|
||
display: block; | ||
|
||
font-size: 24px; | ||
color: var(--color-yellow); | ||
} | ||
|
||
.wp-image { | ||
position: absolute; | ||
z-index: 10; | ||
|
||
max-width: 960px; | ||
width: 100%; | ||
max-height: 540px; | ||
height: 100%; | ||
margin: auto; | ||
overflow: hidden; | ||
box-sizing: border-box; | ||
|
||
&.has-loaded-media { | ||
// don't hide media if video has 404 but item still has an image | ||
/deep/ .media { | ||
opacity: 1; | ||
} | ||
} | ||
|
||
&.has-full-media-error { | ||
// set overflow to visible in case the item name is long | ||
overflow: visible; | ||
// hide the sizer so the broken image icon isn't visible on 404 images | ||
/deep/ .sizer { | ||
visibility: hidden; | ||
} | ||
|
||
// display the caption | ||
/deep/ .caption { | ||
opacity: 1; | ||
} | ||
} | ||
} | ||
|
||
/deep/ .caption { | ||
height: 100%; | ||
|
||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
|
||
background: #212121; | ||
text-align: right; | ||
font-size: 8vw; | ||
line-height: 1; | ||
text-transform: uppercase; | ||
color: #FFFFFFFF; | ||
opacity: 0; | ||
|
||
transition: opacity .4s ease-in-out; | ||
transition-delay: .4s; // add slight delay so you don't see a flash of the caption on items that have image 404s but still have videos | ||
} | ||
|
||
|
||
@media #{$has-hover} { | ||
.link { | ||
&:hover { | ||
color: var(--color-white); | ||
} | ||
} | ||
} | ||
|
||
@media #{$lt-phone} { | ||
.list-main { | ||
display: block; | ||
|
||
text-align: center; | ||
} | ||
|
||
/deep/ .caption { | ||
font-size: 18vw; | ||
} | ||
} | ||
} | ||
</style> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you were just trying to show off classes, then cool.
But I think
wp-image
adds error and loading classes to itself already.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WpImage adds the class
has-error
if there is a video error OR image error. So if the video fails to load but the image fallback does load WpImage still adds the classhad-error
. I needed to add a class based on whether or not one of the two media types loaded successfully.has-loaded-media
. I also needed a way to add a class based on whether or not both the image and video fully errored.has-full-media-error
and then show the caption if so.