Skip to content

Commit

Permalink
turbo frame debug setup
Browse files Browse the repository at this point in the history
  • Loading branch information
thejonroberts committed Jul 6, 2024
1 parent 82c47f0 commit 8ecb527
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
31 changes: 31 additions & 0 deletions app/assets/stylesheets/_debug.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// stolen from https://github.com/guillaumebriday/turbo-frames-debug and slightly modified
// must have TURBO_DEBUG env var set
:root {
--turbo-frame-debug-color: #3B82F6;
--turbo-frame-debug-z-index: 9999;
--turbo-frame-debug-font-size: 0.7rem;
--turbo-frame-debug-border-radius: 0.25rem;
}

.debug-turbo {
turbo-frame {
border: 1px var(--turbo-frame-debug-color) solid;
display: block;
border-radius: var(--turbo-frame-debug-border-radius);

&::before {
content: "#" attr(id);
display: inline-block;
position: relative;
top: -1rem;
right: -0.5rem;
color: var(--turbo-frame-debug-color);
font-size: var(--turbo-frame-debug-font-size);
z-index: var(--turbo-frame-debug-z-index);
background-color: #fff;
padding: 0.05rem;
border: 1px var(--turbo-frame-debug-color) solid;
border-radius: var(--turbo-frame-debug-border-radius);
}
}
}
4 changes: 4 additions & 0 deletions app/assets/stylesheets/application.sass.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,7 @@
// Layouts
@import "layouts/container";
@import "layouts/header";

// Development helpers: must have env vars set.
// see files and/or application.html.erb
@import "debug";
2 changes: 1 addition & 1 deletion app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<% end %>
</head>

<body>
<body class="<%= 'debug-turbo' if ENV.fetch("TURBO_DEBUG", false) %>">
<%= render "layouts/navbar" %>
<div id="flash" class="flash">
<%= render "layouts/flash" %>
Expand Down

0 comments on commit 8ecb527

Please sign in to comment.