Skip to content

Commit

Permalink
feat(chat cards): add accordian animation on damage rolls (#165)
Browse files Browse the repository at this point in the history
  • Loading branch information
MangoFVTT authored Nov 20, 2024
1 parent 0e392fe commit 932f96b
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 17 deletions.
36 changes: 31 additions & 5 deletions src/style/chat/module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -418,8 +418,9 @@
.dice-total {
font-weight: bold;
font-size: var(--font-size-24);
padding: 0;
font-family: var(--plotweaver-font-normal);
color: var(--plotweaver-color-dark-1);
padding: 0;
position: relative;

&.ignored {
Expand All @@ -446,6 +447,9 @@
}

.dice-subtotal {
border-right: 1px solid var(--plotweaver-color-light-4);
transition: all 200ms ease;

padding: 0 0.5rem;
font-weight: 600;
display: flex;
Expand All @@ -465,12 +469,34 @@
text-transform: uppercase;
}

&.right {
border-left: 1px solid var(--plotweaver-color-light-4);
&:last-child {
border-right: 0;
}

&.left {
border-right: 1px solid var(--plotweaver-color-light-4);
&.active {
padding: 0;
font-weight: bold;
display: flex;
flex-direction: column;
width: 80%;

&.pad-left {
padding-left: 20%;
}

&.pad-right {
padding-right: 20%;
}

.value {
color: var(--plotweaver-color-dark-1);
font-size: var(--font-size-24);
font-family: var(--plotweaver-font-normal);
}

.label {
display: none;
}
}
}
}
Expand Down
11 changes: 3 additions & 8 deletions src/system/documents/chat-message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -580,19 +580,14 @@ export class CosmereChatMessage extends ChatMessage {
private onSwitchDamageMode(event: JQuery.ClickEvent) {
const toggle = $(event.currentTarget as HTMLElement);

if (toggle.css('opacity') === '0') return;
if (toggle.hasClass('active')) return;

event.preventDefault();
event.stopPropagation();

this.useGraze = !this.useGraze;
toggle.attr('style', 'opacity: 0;');
toggle.siblings('.dice-subtotal').attr('style', '');
toggle
.siblings('p')
.text(
this.useGraze ? this.totalDamageGraze : this.totalDamageNormal,
);
toggle.addClass('active');
toggle.siblings('.dice-subtotal').removeClass('active');
}

/**
Expand Down
7 changes: 3 additions & 4 deletions src/templates/chat/roll-damage.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@
</div>
<div class="dice-roll-damage">
<h4 class="dice-total">
<div class="dice-subtotal left" style="opacity: 0">
<div class="dice-subtotal pad-left active">
<span class="label">{{localize "DICE.Damage.Full"}}</span>
<span class="value">{{totalNormal}}</span>
<span class="value">{{totalNormal}}</span>
</div>
<p>{{totalNormal}}</p>
<div class="dice-subtotal right">
<div class="dice-subtotal pad-right ">
<span class="label">{{localize "DICE.Damage.Graze"}}</span>
<span class="value">{{totalGraze}}</span>
</div>
Expand Down

0 comments on commit 932f96b

Please sign in to comment.