Skip to content

Commit 8ecb527

Browse files
committed
turbo frame debug setup
1 parent 82c47f0 commit 8ecb527

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

app/assets/stylesheets/_debug.scss

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// stolen from https://github.com/guillaumebriday/turbo-frames-debug and slightly modified
2+
// must have TURBO_DEBUG env var set
3+
:root {
4+
--turbo-frame-debug-color: #3B82F6;
5+
--turbo-frame-debug-z-index: 9999;
6+
--turbo-frame-debug-font-size: 0.7rem;
7+
--turbo-frame-debug-border-radius: 0.25rem;
8+
}
9+
10+
.debug-turbo {
11+
turbo-frame {
12+
border: 1px var(--turbo-frame-debug-color) solid;
13+
display: block;
14+
border-radius: var(--turbo-frame-debug-border-radius);
15+
16+
&::before {
17+
content: "#" attr(id);
18+
display: inline-block;
19+
position: relative;
20+
top: -1rem;
21+
right: -0.5rem;
22+
color: var(--turbo-frame-debug-color);
23+
font-size: var(--turbo-frame-debug-font-size);
24+
z-index: var(--turbo-frame-debug-z-index);
25+
background-color: #fff;
26+
padding: 0.05rem;
27+
border: 1px var(--turbo-frame-debug-color) solid;
28+
border-radius: var(--turbo-frame-debug-border-radius);
29+
}
30+
}
31+
}

app/assets/stylesheets/application.sass.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,7 @@
2727
// Layouts
2828
@import "layouts/container";
2929
@import "layouts/header";
30+
31+
// Development helpers: must have env vars set.
32+
// see files and/or application.html.erb
33+
@import "debug";

app/views/layouts/application.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<% end %>
1717
</head>
1818

19-
<body>
19+
<body class="<%= 'debug-turbo' if ENV.fetch("TURBO_DEBUG", false) %>">
2020
<%= render "layouts/navbar" %>
2121
<div id="flash" class="flash">
2222
<%= render "layouts/flash" %>

0 commit comments

Comments
 (0)