Add category filter for skills (#979)

Co-authored-by: Emruz Hossain <hossainemruz@gmail.com>
This commit is contained in:
JY Hsu 2024-09-20 08:57:14 +08:00 committed by GitHub
parent 0f6737eee0
commit 9da3e3420b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 39 additions and 7 deletions

View file

@ -4,4 +4,5 @@ import './sidebar'
import './education'
import './achievements'
import './projects'
import './skills'
import './publications'

View file

@ -0,0 +1,15 @@
import Filterizr from 'filterizr'
document.addEventListener('DOMContentLoaded', () => {
// ================== Skill cards =====================
// setup skill filter buttons
const skillCardHolder = document.getElementById('skill-card-holder')
if (skillCardHolder != null && skillCardHolder.children.length !== 0) {
// eslint-disable-next-line no-new
new Filterizr('.filtr-skills', {
layout: 'sameWidth',
controlsSelector: '.skill-filtr-control'
})
}
})

View file

@ -1,4 +1,6 @@
<div class="col-xs-12 col-sm-6 col-lg-4 pt-2">
<div class="col-xs-12 col-sm-6 col-lg-4 pt-2 filtr-item"
data-category='all, {{ with .categories }}{{ delimit . ","}}{{ end }}'
>
<a class="text-decoration-none" {{ if .url }}href="{{ .url }}" title="{{ .name }}" target="_blank" rel="noopener"{{ end }}>
<div class="card">
<div class="card-head d-flex">
@ -18,7 +20,7 @@
<h5 class="card-title">{{ .name }}</h5>
{{ end }}
</div>
<div class="card-body">
<div class="card-body text-justify pt-1 pb-1">
<p class="card-text">{{ .summary | markdownify }}</p>
</div>
</div>

View file

@ -3,7 +3,7 @@
{{ $sectionID = .section.id }}
{{ end }}
<div class="container-fluid anchor pb-5 skills-section">
<div class="container-fluid anchor pb-5 skills-section" id="{{ $sectionID }}">
{{ if not (.section.hideTitle) }}
<h1 class="text-center">
<span id="{{ $sectionID }}"></span>{{ .section.name }}</h1>
@ -11,8 +11,22 @@
<h1 class="text-center" style="display: none">
<span id="{{ $sectionID }}"></span>{{ .section.name }}</h1>
{{ end }}
{{ if .section.filter }}
<div class="container ms-auto text-center">
<div class="btn-group flex-wrap" role="group" id="skill-filter-buttons">
{{ range .buttons }}
<button type="button" class="btn btn-dark skill-filtr-control" data-filter="{{ .filter }}">
{{ .name }}
</button>
{{ end }}
</div>
</div>
<div class="container d-flex-block filtr-skills">
<div class="row" id="skill-card-holder" style="margin-left:unset">
{{ else }}
<div class="container d-flex-block">
<div class="row" id="primary-skills">
{{ end }}
{{ range .skills }}
{{ partial "cards/skill.html" . }}
{{ end }}