power-compass 0.2.2 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Rakefile +25 -0
- data/app/assets/stylesheets/compass/layout.scss +41 -0
- data/app/assets/stylesheets/compass/navigation/_all.scss +6 -0
- data/app/assets/stylesheets/compass/navigation/_header.scss +168 -0
- data/app/assets/stylesheets/compass/navigation/_label.scss +31 -0
- data/app/assets/stylesheets/compass/navigation/_main-page-content.scss +61 -0
- data/app/assets/stylesheets/compass/navigation/_recent-crumbs.scss +17 -0
- data/app/assets/stylesheets/compass/navigation/_sidebar.scss +123 -0
- data/app/assets/stylesheets/compass/navigation/_spinner.scss +27 -0
- data/app/components/compass/application_component.rb +8 -0
- data/app/components/compass/layout/banner.html.erb +3 -0
- data/app/components/compass/layout/banner.rb +14 -0
- data/app/components/compass/layout/breadcrumb_item.html.erb +20 -0
- data/app/components/compass/layout/breadcrumb_item.rb +19 -0
- data/app/components/compass/layout/breadcrumbs.html.erb +14 -0
- data/app/components/compass/layout/breadcrumbs.rb +9 -0
- data/app/components/compass/layout/content_container_component.html.erb +3 -0
- data/app/components/compass/layout/content_container_component.rb +9 -0
- data/app/components/compass/layout/header/dropdown_menu.html.erb +15 -0
- data/app/components/compass/layout/header/dropdown_menu.rb +36 -0
- data/app/components/compass/layout/header/logo.html.erb +8 -0
- data/app/components/compass/layout/header/logo.rb +17 -0
- data/app/components/compass/layout/header/search_input.html.erb +1 -0
- data/app/components/compass/layout/header/search_input.rb +11 -0
- data/app/components/compass/layout/header/tasks_menu.html.erb +3 -0
- data/app/components/compass/layout/header/tasks_menu.rb +12 -0
- data/app/components/compass/layout/header.html.erb +23 -0
- data/app/components/compass/layout/header.rb +32 -0
- data/app/components/compass/layout/impersonation_banner.html.erb +3 -0
- data/app/components/compass/layout/impersonation_banner.rb +9 -0
- data/app/components/compass/layout/sidebar.html.erb +5 -0
- data/app/components/compass/layout/sidebar.rb +9 -0
- data/app/components/compass/layout.html.erb +51 -0
- data/app/components/compass/layout.rb +44 -0
- data/app/components/concerns/compass/config_props.rb +20 -0
- data/app/controllers/compass/application_controller.rb +6 -11
- data/app/controllers/compass/info_controller.rb +12 -0
- data/config/routes.rb +2 -0
- data/lib/compass/configuration.rb +1 -0
- data/lib/compass/engine.rb +31 -0
- data/lib/compass/search/provider.rb +1 -4
- data/lib/compass/version.rb +1 -1
- data/vendor/assets/stylesheets/compass/layout.css +843 -0
- metadata +57 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<div data-compass-component="SearchInput" style="width: 100%;" data-compass-component-props="<%= compass_props.to_json %>"></div>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<%= pb_rails("background", props: { classname: "navigation-topbar", background_color: "primary" }) do %>
|
|
2
|
+
<%= pb_rails("flex", props: { classname: "navigation-topbar-label", cursor: "default" }) do %>
|
|
3
|
+
<% labels.each do |label| %>
|
|
4
|
+
<%= pb_rails("background", props: { background_color: "category_6" }) do %>
|
|
5
|
+
<%= label %>
|
|
6
|
+
<% end %>
|
|
7
|
+
<% end %>
|
|
8
|
+
<% end %>
|
|
9
|
+
|
|
10
|
+
<%= pb_rails("flex", props: { classname: "navigation-topbar-left", align_items: "center", justify_content: "start" }) do %>
|
|
11
|
+
<div data-compass-component="SideMenuIcon"></div>
|
|
12
|
+
<%= logo if logo? %>
|
|
13
|
+
<% end %>
|
|
14
|
+
<%= pb_rails("flex", props: { classname: "navigation-topbar-center", align_items: "center", justify_content: "center" }) do %>
|
|
15
|
+
<%= search if search? %>
|
|
16
|
+
<% end %>
|
|
17
|
+
<%= pb_rails("flex", props: { classname: "navigation-topbar-right", align_items: "center", justify_content: "end" }) do %>
|
|
18
|
+
<%= tasks_menu if tasks_menu? %>
|
|
19
|
+
<% dropdowns.each do |dropdown| %>
|
|
20
|
+
<%= dropdown %>
|
|
21
|
+
<% end %>
|
|
22
|
+
<% end %>
|
|
23
|
+
<% end %>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Compass
|
|
4
|
+
class Layout
|
|
5
|
+
class Header < ApplicationComponent
|
|
6
|
+
include ConfigProps
|
|
7
|
+
|
|
8
|
+
prop :avatar_url
|
|
9
|
+
prop :impersonating
|
|
10
|
+
prop :labels, default: []
|
|
11
|
+
|
|
12
|
+
renders_one :search, Compass::Layout::Header::SearchInput
|
|
13
|
+
renders_one :logo, Compass::Layout::Header::Logo
|
|
14
|
+
renders_one :tasks_menu, Compass::Layout::Header::TasksMenu
|
|
15
|
+
renders_many :dropdowns, Compass::Layout::Header::DropdownMenu
|
|
16
|
+
|
|
17
|
+
def initialize(dropdowns: [], **)
|
|
18
|
+
super(**)
|
|
19
|
+
|
|
20
|
+
@dropdown_menus = dropdowns
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
private
|
|
24
|
+
|
|
25
|
+
def before_render
|
|
26
|
+
@dropdown_menus.each do |(dropdown_menu, block)|
|
|
27
|
+
with_dropdown(**dropdown_menu, &block)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
|
|
4
|
+
<head>
|
|
5
|
+
<!-- meta name="viewport" content="width=device-width, initial-scale=1.0" -->
|
|
6
|
+
<%# the above doesn't work due to this iOS9 issue -> https://forums.developer.apple.com/thread/13510 %>
|
|
7
|
+
<meta name="viewport" content="initial-scale=1.0001, minimum-scale=1.0001, maximum-scale=1.0001, user-scalable=no">
|
|
8
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
9
|
+
<meta http-equiv="content-type" content="text/html; charset=utf-8">
|
|
10
|
+
<meta http-equiv="Cache-Control" content="no-cache">
|
|
11
|
+
<meta name="robots" content="noindex,nofollow,nosnippet,noodp,noarchive,noimageindex">
|
|
12
|
+
<meta name="format-detection" content="telephone=no">
|
|
13
|
+
<meta name="apple-mobile-web-app-capable" content="yes">
|
|
14
|
+
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
|
15
|
+
<meta name="apple-mobile-web-app-title" content="<%= app_title %>">
|
|
16
|
+
<title><%= page_title %></title>
|
|
17
|
+
|
|
18
|
+
<% heads.each do |head| %>
|
|
19
|
+
<%= head %>
|
|
20
|
+
<% end %>
|
|
21
|
+
|
|
22
|
+
<%= stylesheet_link_tag "compass/layout", media: "all", "data-turbo-track": "reload" %>
|
|
23
|
+
|
|
24
|
+
<%= csrf_meta_tags %>
|
|
25
|
+
</head>
|
|
26
|
+
|
|
27
|
+
<%= content_tag :body, id: page_body_id, class: body_class do %>
|
|
28
|
+
<%= content_tag(:div, class: "nitro-navigation") do %>
|
|
29
|
+
<% banners.each do |banner| %>
|
|
30
|
+
<%= banner %>
|
|
31
|
+
<% end %>
|
|
32
|
+
<%= impersonation if impersonation? %>
|
|
33
|
+
<%= header %>
|
|
34
|
+
<%= breadcrumbs if breadcrumbs? %>
|
|
35
|
+
<% end if header? %>
|
|
36
|
+
|
|
37
|
+
<%= content_tag(:div, class: "page-container #{"page-container-mobile" if mobile_view}") do %>
|
|
38
|
+
<%= content_tag :div, id: "main-view", class: ("full-width" if full_width) do %>
|
|
39
|
+
<%= sidebar if sidebar? %>
|
|
40
|
+
|
|
41
|
+
<div class="main-page-content">
|
|
42
|
+
<%= render content_container.new(content: content, **values) %>
|
|
43
|
+
</div>
|
|
44
|
+
<% end %>
|
|
45
|
+
<% end %>
|
|
46
|
+
|
|
47
|
+
<% footers.each do |footer| %>
|
|
48
|
+
<%= footer %>
|
|
49
|
+
<% end %>
|
|
50
|
+
<% end %>
|
|
51
|
+
</html>
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Compass
|
|
4
|
+
class Layout < ApplicationComponent
|
|
5
|
+
# Page Props
|
|
6
|
+
prop :body_class
|
|
7
|
+
prop :full_width
|
|
8
|
+
prop :mobile_view
|
|
9
|
+
prop :page_body_id
|
|
10
|
+
prop :app_title
|
|
11
|
+
prop :page_title
|
|
12
|
+
|
|
13
|
+
# Component Overrides
|
|
14
|
+
prop :content_container, default: Compass::Layout::ContentContainerComponent
|
|
15
|
+
|
|
16
|
+
# Slots
|
|
17
|
+
renders_one :impersonation, Compass::Layout::ImpersonationBanner
|
|
18
|
+
renders_one :breadcrumbs, Compass::Layout::Breadcrumbs
|
|
19
|
+
renders_one :sidebar, Compass::Layout::Sidebar
|
|
20
|
+
renders_one :header, ->(dropdowns: [], **kwargs) do
|
|
21
|
+
Compass::Layout::Header.new(dropdowns: [ *dropdowns, *self.dropdowns ],
|
|
22
|
+
impersonating: impersonation?, **kwargs)
|
|
23
|
+
end
|
|
24
|
+
renders_many :banners, Compass::Layout::Banner
|
|
25
|
+
renders_many :heads
|
|
26
|
+
renders_many :footers
|
|
27
|
+
|
|
28
|
+
def with_dropdown(**kwargs, &block)
|
|
29
|
+
dropdowns << [ kwargs, block ]
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
private
|
|
33
|
+
|
|
34
|
+
def dropdowns
|
|
35
|
+
@dropdowns ||= []
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def before_render
|
|
39
|
+
Compass.config.layout.before_render_blocks.each do |block|
|
|
40
|
+
instance_exec(self, &block)
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Compass
|
|
4
|
+
# Concern for components that need to access Compass configuration.
|
|
5
|
+
#
|
|
6
|
+
# @private
|
|
7
|
+
module ConfigProps
|
|
8
|
+
extend ActiveSupport::Concern
|
|
9
|
+
|
|
10
|
+
included do
|
|
11
|
+
private
|
|
12
|
+
|
|
13
|
+
def current_context_id = instance_exec(&Compass.config.context_id)
|
|
14
|
+
|
|
15
|
+
def current_backends = Compass.config.backends
|
|
16
|
+
|
|
17
|
+
def compass_props = { backends: current_backends, contextId: current_context_id }
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -6,16 +6,15 @@ module Compass
|
|
|
6
6
|
etag { current_context_id }
|
|
7
7
|
etag { context_modified_at }
|
|
8
8
|
|
|
9
|
-
before_action
|
|
10
|
-
|
|
11
|
-
end
|
|
9
|
+
before_action :authenticate
|
|
10
|
+
before_action :validate_context
|
|
12
11
|
|
|
13
|
-
|
|
14
|
-
head(:
|
|
12
|
+
def authenticate
|
|
13
|
+
head(:forbidden) unless instance_exec(&Compass.config.authenticate)
|
|
15
14
|
end
|
|
16
15
|
|
|
17
|
-
def
|
|
18
|
-
|
|
16
|
+
def validate_context
|
|
17
|
+
head(:bad_request) unless current_context_id.to_s.eql?(params[:context_id])
|
|
19
18
|
end
|
|
20
19
|
|
|
21
20
|
def current_context
|
|
@@ -30,10 +29,6 @@ module Compass
|
|
|
30
29
|
instance_exec(&Compass.config.modified_at)
|
|
31
30
|
end
|
|
32
31
|
|
|
33
|
-
def validate_context_id
|
|
34
|
-
current_context_id.to_s.eql?(params[:context_id])
|
|
35
|
-
end
|
|
36
|
-
|
|
37
32
|
def set_cache_headers(config)
|
|
38
33
|
if config
|
|
39
34
|
expires_in(*Array(config))
|
data/config/routes.rb
CHANGED
|
@@ -35,6 +35,7 @@ module Compass
|
|
|
35
35
|
config_accessor :authenticate, default: -> { false }
|
|
36
36
|
config_accessor :context, default: -> { {} }
|
|
37
37
|
config_accessor :context_id, default: -> { }
|
|
38
|
+
config_accessor :backends, default: Set.new
|
|
38
39
|
config_accessor :modified_at, default: -> { }
|
|
39
40
|
|
|
40
41
|
config_accessor :menu, default: Compass::Configuration::Menu
|
data/lib/compass/engine.rb
CHANGED
|
@@ -10,10 +10,41 @@ module Compass
|
|
|
10
10
|
config.generators.api_only = true
|
|
11
11
|
config.compass = Compass.config
|
|
12
12
|
|
|
13
|
+
config.try(:after_routes_loaded) do
|
|
14
|
+
Compass.config.backends << Compass::Engine.routes.url_helpers.root_path
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
config.paths["app"].skip_autoload!
|
|
18
|
+
config.paths["app"].skip_eager_load!
|
|
19
|
+
config.paths.add "app/components", autoload: true
|
|
20
|
+
config.paths.add "app/components/concerns", autoload: true
|
|
21
|
+
|
|
13
22
|
initializer "compass.logger" do
|
|
14
23
|
Compass.logger ||= Rails.logger.respond_to?(:tagged) ? Rails.logger.tagged("Compass") : Rails.logger
|
|
15
24
|
end
|
|
16
25
|
|
|
26
|
+
initializer "compass.view_components", before: :set_autoload_paths do
|
|
27
|
+
unless defined?(ViewComponent::Base)
|
|
28
|
+
config.paths["app/components"].skip_autoload!
|
|
29
|
+
config.paths["app/components/concerns"].skip_autoload!
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
initializer "compass.assets" do |app|
|
|
34
|
+
if app.config.respond_to?(:assets)
|
|
35
|
+
if root.join("vendor", "assets", "stylesheets", "compass", "layout.css").exist?
|
|
36
|
+
Compass.logger.info "Using precompiled compass/layout.css"
|
|
37
|
+
app.config.assets.paths << root.join("vendor", "assets", "stylesheets")
|
|
38
|
+
else
|
|
39
|
+
Compass.logger.info "Compiling compass/layout.css from source"
|
|
40
|
+
app.config.assets.paths << root.join("app", "assets", "stylesheets")
|
|
41
|
+
app.config.sass.load_paths << root.join("app", "assets", "stylesheets")
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
app.config.assets.precompile += %w[compass/layout.css]
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
17
48
|
initializer "compass.search.view_paths", after: "action_controller.set_configs" do |app|
|
|
18
49
|
ActiveSupport.on_load(:action_controller) do
|
|
19
50
|
Compass.config.search.view_paths = ActionController::Base.view_paths
|
data/lib/compass/version.rb
CHANGED