Skip to content

Commit 3b25f2e

Browse files
authored
Add animated_badge (#27)
* Add animated_badge * linting * linting
1 parent 9799fc9 commit 3b25f2e

File tree

6 files changed

+123
-0
lines changed

6 files changed

+123
-0
lines changed

Gemfile.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,7 @@ GEM
385385
PLATFORMS
386386
aarch64-linux
387387
arm64-darwin-21
388+
arm64-darwin-22
388389
arm64-darwin-23
389390
x86_64-linux
390391

app/assets/stylesheets/application.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@
1111
@import 'components/tab';
1212
@import 'components/modal';
1313
@import 'components/autocomplete';
14+
@import 'components/animated_badge';
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
.pulsating-badge {
2+
animation-name: pulse;
3+
animation-duration: var(--animation-duration, 1s);
4+
animation-timing-function: ease-in-out;
5+
animation-iteration-count: infinite;
6+
padding: 2px 8px;
7+
display: inline-flex;
8+
border: 2px solid var(--border-color, black);
9+
border-radius: 0.75rem;
10+
margin: 0 16px 32px 0;
11+
12+
@keyframes pulse {
13+
from {
14+
transform: scale3d(1, 1, 1);
15+
}
16+
50% {
17+
transform: scale3d(var(--pulse-scale, 1.05), var(--pulse-scale, 1.05), var(--pulse-scale, 1.05));
18+
}
19+
to {
20+
transform: scale3d(1, 1, 1);
21+
}
22+
}
23+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# frozen_string_literal: true
2+
3+
class AnimatedBadgeComponentPreview < Lookbook::Preview
4+
include LookbookHelper
5+
6+
# Interactive playground for experimenting with badge styles and animations.
7+
# @param title text "Badge Title"
8+
# @param colour select :theme_choices
9+
# @param border_color color "Border Color"
10+
# @param duration number "Animation Duration (seconds)"
11+
# @param pulse_scale text "Scale Value"
12+
# @source ../../../app/views/components/animated_badges/_playground.html.erb
13+
def playground(
14+
title: 'Animated badge',
15+
colour: 'primary',
16+
border_color: 'black',
17+
duration: 1,
18+
pulse_scale: 1.05
19+
)
20+
render 'components/animated_badges/playground',
21+
title: title,
22+
colour: colour,
23+
border_color: border_color,
24+
duration: duration,
25+
pulse_scale: pulse_scale
26+
end
27+
28+
# @source ../../../app/views/components/animated_badges/_themes.html.erb
29+
def themes
30+
render 'components/animated_badges/themes'
31+
end
32+
end
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<div class="pulsating-badge bg-<%= colour %>"
2+
style="
3+
--border-color: <%= border_color %>;
4+
animation-duration: <%= duration %>s;
5+
--pulse-scale: <%= pulse_scale.to_f %>;
6+
">
7+
<span class="badge">
8+
<%= title %>
9+
</span>
10+
</div>
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<div class="mb-8">
2+
<h5>Different colors</h5>
3+
<div class="pulsating-badge bg-success">
4+
<span class="badge">Success</span>
5+
</div>
6+
7+
<div class="pulsating-badge bg-warning">
8+
<span class="badge">Warning</span>
9+
</div>
10+
11+
<div class="pulsating-badge bg-danger">
12+
<span class="badge">Danger</span>
13+
</div>
14+
15+
<div class="pulsating-badge bg-info">
16+
<span class="badge">Info</span>
17+
</div>
18+
19+
<div class="pulsating-badge bg-primary">
20+
<span class="badge">Primary</span>
21+
</div>
22+
23+
<div class="pulsating-badge bg-secondary">
24+
<span class="badge">Secondary</span>
25+
</div>
26+
</div>
27+
28+
<div>
29+
<h5>Different durations</h5>
30+
<div class="pulsating-badge bg-primary" style="animation-duration: 1s;">
31+
<span class="badge">1s</span>
32+
</div>
33+
34+
<div class="pulsating-badge bg-primary" style="animation-duration: 2s;">
35+
<span class="badge">2s</span>
36+
</div>
37+
38+
<div class="pulsating-badge bg-primary" style="animation-duration: 5s;">
39+
<span class="badge">5s</span>
40+
</div>
41+
</div>
42+
43+
<div>
44+
<h5>Different scales</h5>
45+
<div class="pulsating-badge bg-primary" style="--pulse-scale: 1.1;">
46+
<span class="badge">1.1 Scale</span>
47+
</div>
48+
49+
<div class="pulsating-badge bg-primary" style="--pulse-scale: 1.2;">
50+
<span class="badge">1.2 Scale</span>
51+
</div>
52+
53+
<div class="pulsating-badge bg-primary" style="--pulse-scale: 1.5;">
54+
<span class="badge">1.5 Scale</span>
55+
</div>
56+
</div>

0 commit comments

Comments
 (0)