forked from thoughtbot/administrate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Document using custom assets (thoughtbot#2475)
We weren't documenting any custom assets, which is a common thing for people to want to do. This does that and also provides an example change in the `example_app`.
- Loading branch information
Showing
9 changed files
with
80 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,5 @@ | |
|
||
//= link_tree ../images | ||
//= link_tree ../builds | ||
//= link admin.css | ||
//= link admin.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
//= require_tree ./admin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
let mainContent = document.querySelector(".main-content"); | ||
if (mainContent) { | ||
mainContent.addEventListener("click", evt => { | ||
if (evt.target.classList.contains("identity__become-action")) { | ||
if (!confirm("Change identity?")) { | ||
evt.preventDefault(); | ||
} | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/* | ||
*= require_tree ./admin | ||
*/ |
38 changes: 38 additions & 0 deletions
38
spec/example_app/app/assets/stylesheets/admin/identity.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
.identity__banner { | ||
margin: 0; | ||
|
||
} | ||
.identity__banner.identity__banner--admin { | ||
--color-rainbow-violet: #ee82ee; | ||
--color-rainbow-indigo: #4b0082; | ||
--color-rainbow-blue: #00f; | ||
--color-rainbow-green: #0f0; | ||
--color-rainbow-yellow: #ff0; | ||
--color-rainbow-orange: #ffa500; | ||
--color-rainbow-red: #f00; | ||
|
||
animation: rainbow 1s ease; | ||
background-clip: text; | ||
background-image: repeating-linear-gradient( | ||
45deg, | ||
var(--color-rainbow-violet), | ||
var(--color-rainbow-indigo), | ||
var(--color-rainbow-blue), | ||
var(--color-rainbow-green), | ||
var(--color-rainbow-yellow), | ||
var(--color-rainbow-orange), | ||
var(--color-rainbow-red), | ||
var(--color-rainbow-violet) | ||
); | ||
background-size: 800% 800%; | ||
text-align: center; | ||
-webkit-text-fill-color: transparent; | ||
} | ||
|
||
@keyframes rainbow { | ||
0% { background-position: 0% 50%; } | ||
|
||
50% { background-position: 100% 25%; } | ||
|
||
100% { background-position: 0% 50%; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 1 addition & 4 deletions
5
spec/example_app/app/views/admin/customers/_index_header.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,5 @@ | ||
<% content_for(:header_middle) do %> | ||
<div> | ||
You are logged in as <em><%= pundit_user.name %></em>. | ||
<%= link_to("Become the Admin", become_admin_customer_path("admin")) unless pundit_user.admin? %> | ||
</div> | ||
<p class="identity__banner<%= " identity__banner--admin" if pundit_user.admin? %>">You are logged in as <em><%= pundit_user.name %></em>. <%= link_to("Become the Admin", become_admin_customer_path("admin"), class: "identity__become-action") unless pundit_user.admin? %></p> | ||
<% end %> | ||
|
||
<%= render template: 'administrate/application/_index_header', locals: local_assigns %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Administrate::Engine.add_stylesheet("admin") | ||
Administrate::Engine.add_javascript("admin") |