This repository has been archived by the owner on Feb 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathBlockWork.vue
115 lines (101 loc) · 3.04 KB
/
BlockWork.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<!-- Author: @drewbaker -->
<template>
<nuxt-link class="block-work" :to="to">
<!-- Component declartion is kebab cased -->
<wp-image class="image" :image="image" />
<!-- We use v-html because most of the time the text comes out of our CMS with HTML tags in it-->
<h2 class="title" v-html="title" />
<!-- Nice to prepend SVG component names to not confuse them with regaulr components -->
<svg-logo-funkhaus class="logo" />
</nuxt-link>
</template>
<script>
import NuxtLink from "@/components/global/NuxtLink"
import WpImage from "@/components/global/WpImage"
import SvgLogoFunkhaus from "@/assets/svgs/logo-funkhaus.svg"
export default {
// Name matches filename and top-level class name
name: "BlockWork",
components: {
NuxtLink,
WpImage,
SvgLogoFunkhaus
},
props: {
// All props have type and default on them
image: {
type: Object,
default: () => {}
},
title: {
type: String,
default: ""
},
to: {
type: String,
default: ""
}
}
}
</script>
<style lang="scss" scoped>
// SCSS with scoped tag
.block-work {
position: relative;
z-index: 0; // Localize the z-index to this component
display: block;
max-width: 50%;
.image {
border: 4px solid var(--color-black);
transition: border 0.4s ease-in-out; // Only animate properties that are needed. 1s, 0.8s, 0.4s are common durations.
}
.title {
font-size: 18px;
font-weight: bold;
margin: 0; // It's OK to use pixel for margins (no need for REM or anything like that)
position: absolute;
top: 0;
left: 0;
z-index: 10; // Increment z-index by 10's
height: 100%;
width: 100%;
// Text over image normally gets a slight color over it.
// It's tempting to use a brightness filter on the image, but wp-image image can also be a video,
// which has really bad performance with CSS filters.
background-color: rgba(#000000, 0.2); // Always use full color code, lowercase.
color: #ffffff; // Always use full color code, lowercase.
// Nice to group related styles, no need for prefixes thanks to build process.
display: flex;
flex-direction: column;
flex-wrap: wrap;
justify-content: center;
align-content: center;
align-items: center;
}
.logo {
position: absolute;
top: 20px;
right: 20px;
width: 100px;
height: auto;
z-index: 20;
// This is how you style an SVG
path {
fill: #ffffff;
}
}
// Hover states
@media #{$has-hover} {
&:hover .image {
border: 4px solid var(--color-brand);
}
}
// Breakpoints
@media #{$lt-tablet} {
max-width: 100%;
.image {
border: 4px solid #ff0000; // Always use full color code, lowercase.
}
}
}
</style>