Skip to content

Commit

Permalink
Add polaris_html_classes helper
Browse files Browse the repository at this point in the history
  • Loading branch information
kirillplatonov committed Feb 9, 2024
1 parent 275b042 commit 5880e9f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
4 changes: 4 additions & 0 deletions app/helpers/polaris/view_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ def polaris_icon_source(name)
doc.to_html.html_safe
end

def polaris_html_classes
"Polaris-Summer-Editions-2023"
end

def polaris_html_styles
%(--pc-frame-global-ribbon-height:0px; --pc-frame-offset:0px;)
end
Expand Down
2 changes: 1 addition & 1 deletion demo/app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html class="no-js Polaris-Summer-Editions-2023" style="<%= polaris_html_styles %>">
<html class="no-js <%= polaris_html_classes %>" style="<%= polaris_html_styles %>">
<head>
<title>Demo</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
Expand Down
8 changes: 4 additions & 4 deletions lib/install/install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@
insert_into_file APPLICATION_LAYOUT_PATH.to_s, "\n <%= stylesheet_link_tag \"polaris_view_components\" %>", before: /\s*<\/head>/

if File.read(APPLICATION_LAYOUT_PATH).include?("<body>")
say "Add Polaris inline styles for <html> in application layout"
gsub_file APPLICATION_LAYOUT_PATH.to_s, "<html", "<html style=\"<%= polaris_html_styles %>\""
say "Add Polaris classes and inline styles for <html> in application layout"
gsub_file APPLICATION_LAYOUT_PATH.to_s, "<html", "<html class=\"<%= polaris_html_classes %>\" style=\"<%= polaris_html_styles %>\""

say "Add Polaris inline styles for <body> in application layout"
gsub_file APPLICATION_LAYOUT_PATH.to_s, "<body>", "<body style=\"<%= polaris_body_styles %>\">"
else
say "<body> tag is not found in application layout.", :red
say " Replace <html> with <html style=\"<%= polaris_html_styles %>\"> in your custom layour."
say " Replace <html> with <html class=\"<%= polaris_html_classes %>\" style=\"<%= polaris_html_styles %>\"> in your custom layour."
say " Replace <body> with <body style=\"<%= polaris_body_styles %>\"> in your custom layour."
end
else
say "Default application.html.erb is missing!", :red
say " 1. Add <%= stylesheet_link_tag \"polaris_view_components\" %> within the <head> tag in your custom layout."
say " 2. Replace <html> with <html style=\"<%= polaris_html_styles %>\"> in your custom layour."
say " 2. Replace <html> with <html class=\"<%= polaris_html_classes %>\" style=\"<%= polaris_html_styles %>\"> in your custom layour."
say " 3. Replace <body> with <body style=\"<%= polaris_body_styles %>\"> in your custom layour."
end

Expand Down

0 comments on commit 5880e9f

Please # to comment.