Skip to content

Commit

Permalink
flashを追加
Browse files Browse the repository at this point in the history
  • Loading branch information
manabeai committed Aug 21, 2024
1 parent 29bf3d4 commit 770e7e7
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/assets/stylesheets/application.sass.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// Configuration
@import "config/variables";
@import "config/reset";
@import "config/animations";

// Components
@import "components/btn";
Expand All @@ -13,6 +14,7 @@
@import "components/visually_hidden";
@import "components/quote";
@import "components/navbar";
@import "components/flash";

// Layouts
@import "layouts/container";
Expand Down
24 changes: 24 additions & 0 deletions app/assets/stylesheets/components/_flash.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
.flash {
position: fixed;
top: 5rem;
left: 50%;
transform: translateX(-50%);

display: flex;
flex-direction: column;
align-items: center;
gap: var(--space-s);

max-width: 100%;
width: max-content;
padding: 0 var(--space-m);

&__message {
font-size: var(--font-size-s);
color: var(--color-white);
padding: var(--space-xs) var(--space-m);
background-color: var(--color-dark);
animation: appear-then-fade 4s both;
border-radius: 999px;
}
}
12 changes: 12 additions & 0 deletions app/assets/stylesheets/config/_animations.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@keyframes appear-then-fade {

0%,
100% {
opacity: 0
}

5%,
60% {
opacity: 1
}
}
2 changes: 2 additions & 0 deletions app/javascript/application.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Entry point for the build script in your package.json
import "@hotwired/turbo-rails"
import "./controllers"

Turbo.session.drive = false
5 changes: 5 additions & 0 deletions app/views/layouts/_flash.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<% flash.each do |flash_type, message| %>
<div class="flash__message">
<%= message %>
</div>
<% end %>

0 comments on commit 770e7e7

Please sign in to comment.