Skip to content

Commit

Permalink
feat: add background animation and footer stats
Browse files Browse the repository at this point in the history
  • Loading branch information
cmgzn committed Oct 17, 2024
1 parent 0325a92 commit 3c51ce9
Show file tree
Hide file tree
Showing 6 changed files with 204 additions and 0 deletions.
2 changes: 2 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ defaults:
layout: page
permalink: /:title/

backgroud_animation: true

sass:
style: compressed

Expand Down
52 changes: 52 additions & 0 deletions _includes/animated-background.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<div id="animation">
<div class="animation-circle"></div>
<div class="animation-circle"></div>
<div class="animation-circle"></div>
<div class="animation-circle"></div>
<div class="animation-circle"></div>
<div class="animation-circle"></div>
<div class="animation-circle"></div>
<div class="animation-circle"></div>
<div class="animation-circle"></div>
<div class="animation-circle"></div>
<div class="animation-circle"></div>
<div class="animation-circle"></div>
<div class="animation-circle"></div>
<div class="animation-circle"></div>
<div class="animation-circle"></div>
<div class="animation-circle"></div>
<div class="animation-circle"></div>
<div class="animation-circle"></div>
<div class="animation-circle"></div>
<div class="animation-circle"></div>
<div class="animation-circle"></div>
<div class="animation-circle"></div>
<div class="animation-circle"></div>
<div class="animation-circle"></div>
<div class="animation-circle"></div>
<div class="animation-circle"></div>
<div class="animation-circle"></div>
<div class="animation-circle"></div>
<div class="animation-circle"></div>
<div class="animation-circle"></div>
<div class="animation-circle"></div>
<div class="animation-circle"></div>
<div class="animation-circle"></div>
<div class="animation-circle"></div>
<div class="animation-circle"></div>
<div class="animation-circle"></div>
<div class="animation-circle"></div>
<div class="animation-circle"></div>
<div class="animation-circle"></div>
<div class="animation-circle"></div>
<div class="animation-circle"></div>
<div class="animation-circle"></div>
<div class="animation-circle"></div>
<div class="animation-circle"></div>
<div class="animation-circle"></div>
<div class="animation-circle"></div>
<div class="animation-circle"></div>
<div class="animation-circle"></div>
<div class="animation-circle"></div>
<div class="animation-circle"></div>
</div>
4 changes: 4 additions & 0 deletions _includes/footer-busuanzi.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<!-- 不蒜子站点统计,放在页脚处 (footer.html 中插入) -->
<script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
<i class="fa fa-user" aria-hidden="true"></i> <span id="busuanzi_value_site_uv"></span> |
<i class="fa fa-eye" aria-hidden="true"></i> <span id="busuanzi_value_site_pv"></span>
54 changes: 54 additions & 0 deletions _includes/footer.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<!-- The Footer -->

<footer
aria-label="Site Info"
class="
d-flex flex-column justify-content-center text-muted
flex-lg-row justify-content-lg-between align-items-lg-center pb-lg-3
"
>
<p>
{{- '©' }}
<time>{{ 'now' | date: '%Y' }}</time>

{% if site.social.links %}
<a href="{{ site.social.links[0] }}">{{ site.social.name }}</a>.
{% else %}
<em class="fst-normal">{{ site.social.name }}</em>.
{% endif %}

{% if site.data.locales[include.lang].copyright.brief %}
<span
data-bs-toggle="tooltip"
data-bs-placement="top"
title="{{ site.data.locales[include.lang].copyright.verbose }}"
>
{{- site.data.locales[include.lang].copyright.brief -}}
</span>
{% endif %}
</p>

<p>
{%- capture _platform -%}
<a href="https://jekyllrb.com" target="_blank" rel="noopener">Jekyll</a>
{%- endcapture -%}

{%- capture _theme -%}
<a
data-bs-toggle="tooltip"
data-bs-placement="top"
title="v{{ theme.version }}"
href="https://github.com/cotes2020/jekyll-theme-chirpy"
target="_blank"
rel="noopener"
>Chirpy</a>
{%- endcapture -%}

{{ site.data.locales[include.lang].meta | replace: ':PLATFORM', _platform | replace: ':THEME', _theme }}
</p>

<!-- 站点统计 -->
<p>
{% include footer-busuanzi.html %}
</p>
</footer>
4 changes: 4 additions & 0 deletions _layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
{% capture prefer_mode %}data-mode="{{ site.theme_mode }}"{% endcapture %}
{% endif %}

{% if site.backgroud_animation %}
{% include animated-background.html %}
{% endif %}

<!-- `site.alt_lang` can specify a language different from the UI -->
<html lang="{{ page.lang | default: site.alt_lang | default: site.lang }}" {{ prefer_mode }}>
{% include head.html %}
Expand Down
88 changes: 88 additions & 0 deletions assets/css/jekyll-theme-chirpy.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
---
---

@import 'main
{%- if jekyll.environment == 'production' -%}
.bundle
{%- endif -%}
';

/* append your custom style below */

/* 生成动画 */
@keyframes infirot {
from {
-webkit-transform: rotate(0deg);
}

to {
-webkit-transform: rotate(360deg);
}
}

.icon-loading1 {
display: inline-block;
animation: infirot 1s linear infinite;
-webkit-animation: infirot 1s linear infinite;
}

@function random_range($min, $max) {
$rand: random();
$random_range: $min + floor($rand * (($max - $min) + 1));
@return $random_range;
}

#animation {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
overflow: hidden;
pointer-events: none;

@keyframes animate {
0% {
transform: translateY(0) rotate(0deg);
opacity: 1;
border-radius: 0;
}
100% {
transform: translateY(-1200px) rotate(720deg);
opacity: 0;
border-radius: 50%;
}
}

@media all and (min-width: 1200px) {
.animation-circle {
position: absolute;
left: var(--circle-left);
bottom: -300px;
display: block;
background: var(--circle-background);
width: var(--circle-side-length);
height: var(--circle-side-length);
animation: animate 25s linear infinite;
animation-duration: var(--circle-time);
animation-delay: var(--circle-delay);
pointer-events: none;

@for $i from 0 through 50 {
&:nth-child(#{$i}) {
--circle-left: #{random_range(0%, 100%)};
--circle-background: rgba(#{random_range(0, 255)}, #{random_range(0, 255)}, #{random_range(0, 255)}, 0.06); // 最后一个数为透明度
--circle-side-length: #{random_range(20px, 200px)};
--circle-time: #{random_range(10s, 45s)};
--circle-delay: #{random_range(0s, 25s)};
}
}
}
}

@media all and (max-width: 1199px) {
.animation-circle {
display: none;
}
}
}

0 comments on commit 3c51ce9

Please sign in to comment.