-
-
Notifications
You must be signed in to change notification settings - Fork 164
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add the slide component and use it on related posts
- Loading branch information
Showing
9 changed files
with
112 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
(() => { | ||
'use strict' | ||
|
||
const scroll = (element) => { | ||
const inner = element.parentElement.querySelector('.slide-inner') | ||
const step = inner.offsetWidth | ||
if (element.classList.contains('slide-control-left')) { | ||
inner.scrollLeft -= step | ||
} else { | ||
inner.scrollLeft += step | ||
} | ||
|
||
} | ||
document.addEventListener('DOMContentLoaded', () => { | ||
document.querySelectorAll('.slide-control-left').forEach(element => { | ||
element.addEventListener('click', () => { | ||
scroll(element) | ||
}) | ||
}) | ||
document.querySelectorAll('.slide-control-right').forEach(element => { | ||
element.addEventListener('click', () => { | ||
scroll(element) | ||
}) | ||
}) | ||
}) | ||
})() |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
.slide { | ||
position: relative; | ||
display: flex; | ||
} | ||
|
||
.slide-inner { | ||
flex-wrap: nowrap; | ||
overflow: hidden; | ||
width: 100%; | ||
margin: 0; | ||
} | ||
|
||
.slide-control-left, | ||
.slide-control-right { | ||
border: none; | ||
background: transparent; | ||
color: var(--#{$prefix}secondary); | ||
height: 100%; | ||
position: absolute; | ||
width: 80px; | ||
|
||
&:hover { | ||
color: var(--#{$prefix}primary); | ||
} | ||
} | ||
|
||
.slide-control-left { | ||
left: 0; | ||
top: 0; | ||
} | ||
|
||
.slide-control-right { | ||
right: 0; | ||
top: 0; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
.post-card { | ||
img { | ||
@extend .card-img-top; | ||
|
||
height: 120px; | ||
margin-bottom: 0.5rem; | ||
object-fit: cover; | ||
} | ||
} | ||
|
||
.post-card-default-img { | ||
filter: blur(1px); | ||
height: 120px; | ||
width: 100%; | ||
} |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
@import 'card'; | ||
@import 'panel'; | ||
@import 'toc'; | ||
@import 'taxonomy'; | ||
|
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,9 @@ | ||
{{- $img := partialCached "post/thumbnail" . . }} | ||
{{- with $img }} | ||
{{ . }} | ||
{{- else }} | ||
<div | ||
class="post-card-default-img card-img-top d-flex align-items-center justify-content-center bg-body-secondary mb-1"> | ||
NO IMAGE | ||
</div> | ||
{{- end }} |
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,9 @@ | ||
<div class="post-card card card-body p-0 border-0 surface"> | ||
{{ partial "post/card-img" . }} | ||
<a class="post-title" href="{{ .RelPermalink }}"> | ||
{{ partial "helpers/title" . }} | ||
</a> | ||
<div class="post-meta mb-0"> | ||
{{ partial "helpers/post-date" . }} | ||
</div> | ||
</div> |
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