Commit 582443e

mo khan <mo@mokhan.ca>
2017-02-16 20:48:35
move layout specific css to separate file matching layout name.
1 parent 5ec7227
Changed files (7)
app/assets/stylesheets/application.scss
@@ -15,21 +15,6 @@
  *= require_self
  */
 
-//@import "**/*";
-header {
-  padding: 0.5em 0;
-  h1 {
-    background: asset-url('logos.svg');
-    height: 150px;
-    background-position: 0 -676px;
-    background-repeat: no-repeat;
-    margin: 5px auto 0 auto;
-    width: 150px;
-    span {
-      display: block;
-      overflow: hidden;
-      text-indent: 100%;
-      white-space: nowrap;
-    }
-  }
+@import "**/*";
+.application {
 }
app/assets/stylesheets/public.scss
@@ -0,0 +1,19 @@
+.public {
+  header {
+    padding: 0.5em 0;
+    h1 {
+      background: asset-url('logos.svg');
+      height: 150px;
+      background-position: 0 -676px;
+      background-repeat: no-repeat;
+      margin: 5px auto 0 auto;
+      width: 150px;
+      span {
+        display: block;
+        overflow: hidden;
+        text-indent: 100%;
+        white-space: nowrap;
+      }
+    }
+  }
+}
app/helpers/application_helper.rb
@@ -28,6 +28,10 @@ module ApplicationHelper
     content_tag(:div, iframe, class: "flex-video")
   end
 
+  def current_layout
+    controller.send(:_layout, []) || :application
+  end
+
   def class_for_flash(type)
     case type.to_sym
     when :notice
app/views/application/_navigation.html.erb
@@ -1,14 +1,10 @@
-<div class="container">
+<header class="container">
   <nav class="nav">
     <div class="nav-left">
-      <a class="nav-item is-brand" href="https://www.stronglifters.com">
-        <%= image_tag("logos.svg") %>
-      </a>
+      <%= link_to t("app"), root_path, class: 'nav-item is-brand' %>
       <%= link_to t(".home"), dashboard_path, class: 'nav-item' %>
       <%= link_to t(".workouts"), workouts_path, class: 'nav-item' %>
-      <a class="nav-item" href="http://slog.stronglifters.com">
-        Blog
-      </a>
+      <%= link_to t(".blog"), "http://slog.stronglifters.com", class: 'nav-item' %>
     </div>
     <div class="nav-center">
       <a class="nav-item" href="https://github.com/stronglifters/">
@@ -42,4 +38,4 @@
       <%= link_to t(".nav.user.log_out"), session_path('me'), method: :delete, class: 'nav-item is-tab' %>
     </div>
   </nav>
-</div>
+</header>
app/views/layouts/application.html.erb
@@ -12,7 +12,7 @@
     <%= javascript_include_tag "https://maps.googleapis.com/maps/api/js?key=#{ENV['GOOGLE_MAPS_API_KEY']}" %>
     <%= yield(:head) %>
   </head>
-  <body class="<%= controller_name %> <%= action_name %>">
+  <body class="<%= current_layout %> <%= controller_name %> <%= action_name %>">
     <%= render partial: "navigation" %>
     <%= render partial: 'flash' %>
     <%= render partial: 'loading' %>
app/views/layouts/public.html.erb
@@ -9,7 +9,7 @@
     <%= stylesheet_link_tag :application %>
     <%= javascript_include_tag :application %>
   </head>
-  <body class="<%= controller_name %> <%= action_name %>">
+  <body class="<%= current_layout %> <%= controller_name %> <%= action_name %>">
     <header>
       <div class="columns">
         <div class="column is-4 is-offset-4">
@@ -17,7 +17,7 @@
         </div>
       </div>
     </header>
-    <%= render partial: 'layouts/flash' %>
+    <%= render partial: 'flash' %>
     <%= yield %>
     <script type="text/javascript" charset="utf-8">
       <%= content_for :javascript %>
config/locales/en.yml
@@ -41,6 +41,7 @@ en:
         social_tolerance: Social Tolerance
       user:
         import_address: Send-to-Stronglifters
+  app: 'Stronglifters'
   application:
     navigation:
       home: Home