From 4e065e6279e6e65344a2c5c0e9de5cd9d7ecfa13 Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Sat, 20 Aug 2016 14:22:44 -0400 Subject: add menu --- src/guff/views/panel.cr | 72 ++++++++++++++++++++++++++++++++++++++ src/guff/views/panes/admin/home.cr | 71 ++++++++++++++++++++++++++++++++----- 2 files changed, 134 insertions(+), 9 deletions(-) create mode 100644 src/guff/views/panel.cr (limited to 'src') diff --git a/src/guff/views/panel.cr b/src/guff/views/panel.cr new file mode 100644 index 0000000..025cc13 --- /dev/null +++ b/src/guff/views/panel.cr @@ -0,0 +1,72 @@ +module Guff::Views::Panel + TEMPLATE = Template.new(%{ +
+
+ + + + + + %{name|h} + +
+ +
+ %{body} +
+
+ }.strip) + + def self.make( + type : String, + id : String, + name : String, + body : String = "", + config : Hash(String, String) = {} of String => String, + panel_class : String = "panel-default", + ) + TEMPLATE.run({ + "type" => type, + "id" => id, + "name" => name, + "body" => body, + "config" => config.to_json, + "panel_class" => panel_class, + }) + end +end diff --git a/src/guff/views/panes/admin/home.cr b/src/guff/views/panes/admin/home.cr index 6010fd4..00bffed 100644 --- a/src/guff/views/panes/admin/home.cr +++ b/src/guff/views/panes/admin/home.cr @@ -28,20 +28,73 @@ class Guff::Views::Panes::Admin::Home < Guff::Views::Panes::Admin::Pane }.strip, + + "add-menu-category" => %{ + + }.strip, + + "divider" => %{ + + }.strip, }) - ADD_MENU_ITEMS = [{ - "id" => "test-1", - "name" => "Test 1", + ADD_MENU = [{ + "type" => "label", + "name" => "Content", + }, { + "id" => "pages", + "name" => "Pages", + }, { + "id" => "projects", + "name" => "Projects", + }, { + "id" => "quick-post", + "name" => "Quick Post", + }, { + "id" => "releases", + "name" => "Releases", + }, { + "type" => "divider", }, { - "id" => "test-2", - "name" => "Test 2", - }].map { |row| - TEMPLATES["add-menu-item"].run(row) - }.join + "type" => "label", + "name" => "Logs", + }, { + "id" => "activity", + "name" => "Activity", + }, { + "id" => "logins", + "name" => "Logins", + }, { + "id" => "traffic", + "name" => "Traffic", + }, { + "type" => "divider", + }, { + "type" => "label", + "name" => "Other", + }, { + "id" => "image-viewer", + "name" => "Image Viewer", + }, { + "id" => "tutorial", + "name" => "Tutorial", + }] private def add_menu - ADD_MENU_ITEMS + ADD_MENU.map { |row| + key = case row["type"]? + when "divider" + "divider" + when "label" + "add-menu-category" + else + "add-menu-item" + end + + TEMPLATES[key].run(row) + }.join end private def cols_menu -- cgit v1.2.3