-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document custom assets #2475
Merged
Merged
Document custom assets #2475
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 | ||
elias19r marked this conversation as resolved.
Show resolved
Hide resolved
|
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"); | ||
elias19r marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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") |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thank you!
@pablobm @nickcharlton I wonder what we should to do with the following generators:
lib/generators/administrate/assets/assets_generator.rb
lib/generators/administrate/assets/javascripts_generator.rb
lib/generators/administrate/assets/stylesheets_generator.rb
They are another way of customizing assets. As far as I understand, by running those generators, Administrate's non-compiled assets are copied to the users' app. So users can edit a non-compiled asset and compile it themselves if their app is set up for that. And then their assets will take precedence over the ones from the Administrate gem.
I lean toward removing those generators and making users customize assets by appending to Administrate's CSS/JS, just like the example in this PR, instead of completely replacing them with their own.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. I think that this way of customising assets is more likely to cause issues than to solve them. Adding additional, separate assets to add new behaviour (or override CSS) feels like a better solution to me. Then if anyone wants to fully override Administrate's own assets, they can copy them over manually and do that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that makes sense to me 👍