animations

This commit is contained in:
Jordan Vidrine 2025-01-03 11:44:06 -06:00
parent 72b5ab50c5
commit a36c61c92c
5 changed files with 150 additions and 16 deletions

View File

@ -16,6 +16,10 @@ export default class Reactions extends Component {
).reduce((acc, count) => acc + count, 0); ).reduce((acc, count) => acc + count, 0);
} }
get randomModifier() {
return Math.random();
}
@action @action
computePercentage(count) { computePercentage(count) {
return `${((count / this.totalPostUsedReactions) * 100).toFixed(2)}%`; return `${((count / this.totalPostUsedReactions) * 100).toFixed(2)}%`;
@ -31,7 +35,10 @@ export default class Reactions extends Component {
<h3 class="rewind-report-title">Most received reactions in topics</h3> <h3 class="rewind-report-title">Most received reactions in topics</h3>
<div class="rewind-report-container"> <div class="rewind-report-container">
{{#each-in @report.data.post_received_reactions as |emojiName count|}} {{#each-in @report.data.post_received_reactions as |emojiName count|}}
<div class="rewind-card scale"> <div
class="rewind-card scale"
style="--rand: {{this.randomModifier}}"
>
<span class="rewind-card__emoji">{{replaceEmoji <span class="rewind-card__emoji">{{replaceEmoji
(concat ":" emojiName ":") (concat ":" emojiName ":")
}}</span> }}</span>

View File

@ -1,5 +1,6 @@
import Component from "@glimmer/component"; import Component from "@glimmer/component";
// eslint-disable-next-line ember/no-empty-glimmer-component-classes
export default class ReadingTime extends Component { export default class ReadingTime extends Component {
<template> <template>
<div class="rewind-report-page"> <div class="rewind-report-page">

View File

@ -1,16 +1,24 @@
import Component from "@glimmer/component"; import Component from "@glimmer/component";
// eslint-disable-next-line ember/no-empty-glimmer-component-classes
export default class WordCloud extends Component { export default class WordCloud extends Component {
get randomModifier() {
return Math.random();
}
<template> <template>
<div class="rewind-report-page -word-cloud"> <div class="rewind-report-page -word-cloud">
<h3 class="rewind-report-title">Most used words</h3> <h3 class="rewind-report-title">Most used words</h3>
<div class="rewind-report-container"> <div class="rewind-report-container">
{{#each-in @report.data as |word count|}} {{#each-in @report.data as |word count|}}
<div
class="rewind-card__wrapper"
style="--rand: {{this.randomModifier}}"
>
<div class="rewind-card"> <div class="rewind-card">
<span class="rewind-card__title">{{word}}</span> <span class="rewind-card__title">{{word}}</span>
<span class="rewind-card__data">{{count}} times</span> <span class="rewind-card__data">{{count}} times</span>
</div> </div>
</div>
{{/each-in}} {{/each-in}}
</div> </div>
</div> </div>

View File

@ -1,4 +1,38 @@
.rewind-card { body {
--ambientAmount: 0.1;
--easeAmount: 0;
animation: ambientMovement;
animation-duration: 24s;
animation-iteration-count: infinite;
animation-timing-function: ease-in-out;
}
.rewind-report-container {
perspective: 1000px;
transform-style: preserve-3d;
}
.rewind-card__wrapper {
will-change: transform;
transform-style: preserve-3d;
background-color: hsla(0deg, 0%, 0%, 10%);
border-radius: 0.25vw;
cursor: pointer;
animation-name: ambientMovement;
animation-duration: 4000ms;
animation-delay: calc(-4000ms * var(--rand));
animation-iteration-count: infinite;
animation-timing-function: ease-in-out;
transform: rotateZ(calc(var(--ambientAmount) * 10deg));
&__title {
font-weight: 600;
}
&__data {
font-family: monospace;
font-weight: normal;
font-size: 14px;
}
.rewind-card {
box-shadow: 0 0 0 1px var(--primary-200); box-shadow: 0 0 0 1px var(--primary-200);
border-radius: var(--d-border-radius); border-radius: var(--d-border-radius);
display: flex; display: flex;
@ -9,4 +43,86 @@
align-items: center; align-items: center;
justify-content: center; justify-content: center;
background: var(--secondary); background: var(--secondary);
will-change: transform;
position: relative;
transform-style: preserve-3d;
}
&:hover .rewind-card {
animation-name: easeOutElastic;
animation-duration: 400ms;
animation-fill-mode: forwards;
transform: translateZ(calc(var(--easeAmount) * 50px));
box-shadow: 0 0.15em calc(0.5em + (var(--easeAmount) * 0.5em))
calc(-0.25em - (var(--easeAmount) * 0.25em)) currentColor;
z-index: 1;
}
}
@keyframes ambientMovement {
0% {
--ambientAmount: 0.1;
}
50% {
--ambientAmount: -0.1;
}
100% {
--ambientAmount: 0.1;
}
}
@keyframes card-hover {
0% {
transform: translateY(0) rotate(0);
}
25% {
transform: translateY(-2px) rotate(2deg);
}
50% {
transform: translateY(-4px) rotate(-1deg);
}
75% {
transform: translateY(2px) rotate(-2deg);
}
100% {
transform: translateY(0) rotate(0);
}
}
@keyframes easeOutElastic {
0% {
--easeAmount: 0;
}
16% {
--easeAmount: 1.3227;
}
28% {
--easeAmount: 0.8688;
}
44% {
--easeAmount: 1.0463;
}
59% {
--easeAmount: 0.9836;
}
73% {
--easeAmount: 1.0058;
}
88% {
--easeAmount: 0.998;
}
100% {
--easeAmount: 1;
}
}
@property --easeAmount {
syntax: "<number>";
inherits: true;
initial-value: 0;
}
@property --ambientAmount {
syntax: "<number>";
inherits: true;
initial-value: 0.1;
} }

View File

@ -7,3 +7,5 @@
@import "best-posts"; @import "best-posts";
@import "best-topics"; @import "best-topics";
@import "word-cloud"; @import "word-cloud";
@import "favorite-tags";
@import "favorite-categories";