Skip to content
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

Replace Gridster with CSS flex grids #128

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions templates/dashboard/%name%.erb.tt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<div class="gridster">
<ul>
<li data-row="1" data-col="1" data-sizex="1" data-sizey="1">
<div data-id="my_widget" data-view="Text"></div>
</li>
</ul>
<div class="grid">
<div class="row">
<div data-span-cols="4" data-id="my_widget" data-view="Text"></div>
</div>
</div>
28 changes: 16 additions & 12 deletions templates/project/assets/javascripts/application.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,22 @@
console.log("Yeah! The dashboard has started!")

Dashing.on 'ready', ->
Dashing.widget_margins ||= [5, 5]
Dashing.widget_base_dimensions ||= [300, 360]
set_size()
Dashing.numColumns ||= 4

contentWidth = (Dashing.widget_base_dimensions[0] + Dashing.widget_margins[0] * 2) * Dashing.numColumns
handle_resize = ->
set_size()
$(".rickshaw_graph svg").each (i, elem) -> elem.remove()
for widget_type of Dashing.widgets
for widget_name of Dashing.widgets[widget_type]
widget = Dashing.widgets[widget_type][widget_name]
if widget.graph != undefined
widget.graph = undefined
widget.ready()
console.log("Resized widgets to " + Dashing.widget_base_dimensions + ".")

Batman.setImmediate ->
$('.gridster').width(contentWidth)
$('.gridster ul:first').gridster
widget_margins: Dashing.widget_margins
widget_base_dimensions: Dashing.widget_base_dimensions
avoid_overlapped_widgets: !Dashing.customGridsterLayout
draggable:
stop: Dashing.showGridsterInstructions
start: -> Dashing.currentWidgetPositions = Dashing.getWidgetPositions()
set_size = ->
Dashing.widget_base_dimensions = [$(".widget").width(), $(".widget").height()];
Dashing.widget_margins = [parseInt($(".widget").css("margin-top")), parseInt($(".widget").css("margin-left"))]

window.onresize = handle_resize
37 changes: 0 additions & 37 deletions templates/project/assets/javascripts/dashing.gridster.coffee

This file was deleted.

This file was deleted.

This file was deleted.

109 changes: 35 additions & 74 deletions templates/project/assets/stylesheets/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ $background-warning-color-1: #eeae32;
$background-warning-color-2: #ff9618;
$text-warning-color: #fff;

$widget-width: 200px;
$widget-height: 250px;
$widget-margin: 5px;

@-webkit-keyframes status-warning-background {
0% { background-color: $background-warning-color-1; }
50% { background-color: $background-warning-color-2; }
Expand All @@ -39,6 +43,8 @@ html {
font-size: 100%;
-webkit-text-size-adjust: 100%;
-ms-text-size-adjust: 100%;
width: 100%;
height: 99%; // prevent a scroll bar
}

body {
Expand All @@ -47,6 +53,8 @@ body {
font-size: 20px;
color: $text-color;
font-family: 'Open Sans', "Helvetica Neue", Helvetica, Arial, sans-serif;
width: 100%;
height: 100%;
}

b, strong {
Expand Down Expand Up @@ -82,11 +90,6 @@ td {
vertical-align: middle;
}

ul, ol {
padding: 0;
margin: 0;
}

h1, h2, h3, h4, h5, p {
padding: 0;
margin: 0;
Expand All @@ -112,8 +115,17 @@ h3 {
// ----------------------------------------------------------------------------
// Base widget styles
// ----------------------------------------------------------------------------
.gridster {
.grid {
margin: 0px auto;
display: flex;
flex-direction: column;
height: 100%;
}

.row {
display: flex;
flex-direction: row;
flex: 1;
}

.icon-background {
Expand All @@ -133,17 +145,6 @@ h3 {
list-style: none;
}

.gridster ul {
list-style: none;
}

// https://github.com/Shopify/dashing/issues/110
// Prevent widgets growing outside of their designated size
.gridster li {
overflow: hidden;
display: list-item;
}

.gs_w {
width: 100%;
display: table;
Expand All @@ -152,10 +153,21 @@ h3 {

.widget {
text-align: center;
width: inherit;
height: inherit;
display: table-cell;
vertical-align: middle;
display: flex;
justify-content: center;
align-items:center;
flex-direction: column;
margin: $widget-margin;
min-width: $widget-width;
min-height: $widget-height;
flex: 1;
}

.widget[data-span-cols="2"] {
min-width: 2 * $widget-width;
padding-left: $widget-margin;
padding-right: $widget-margin;
flex: 2;
}

.widget.status-warning {
Expand Down Expand Up @@ -187,72 +199,22 @@ h3 {

.more-info {
font-size: 15px;
position: absolute;
bottom: 32px;
left: 0;
right: 0;
}

.updated-at {
font-size: 15px;
position: absolute;
bottom: 12px;
left: 0;
right: 0;
}

#save-gridster {
display: none;
position: fixed;
top: 0;
margin: 0px auto;
left: 50%;
z-index: 1000;
background: black;
width: 190px;
text-align: center;
border: 1px solid white;
border-top: 0px;
margin-left: -95px;
padding: 15px;
}

#save-gridster:hover {
padding-top: 25px;
}

#saving-instructions {
display: none;
padding: 10px;
width: 500px;
height: 122px;
z-index: 1000;
background: white;
top: 100px;
color: black;
font-size: 15px;
padding-bottom: 4px;

textarea {
white-space: nowrap;
width: 494px;
height: 80px;
}
}

#lean_overlay {
position: fixed;
z-index:100;
top: 0px;
left: 0px;
height:100%;
width:100%;
background: #000;
display: none;
}

#container {
padding-top: 5px;
width: 100%;
height: 100%;
}


Expand All @@ -262,4 +224,3 @@ h3 {
.clearfix:before, .clearfix:after { content: "\0020"; display: block; height: 0; overflow: hidden; }
.clearfix:after { clear: both; }
.clearfix { zoom: 1; }

8 changes: 0 additions & 8 deletions templates/project/dashboards/layout.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,5 @@
<div id="container">
<%= yield %>
</div>

<% if development? %>
<div id="saving-instructions">
<p>Paste the following at the top of <i><%= params[:dashboard] %>.erb</i></p>
<textarea id="gridster-code"></textarea>
</div>
<a href="#saving-instructions" id="save-gridster">Save this layout</a>
<% end %>
</body>
</html>
34 changes: 11 additions & 23 deletions templates/project/dashboards/sample.erb
Original file line number Diff line number Diff line change
@@ -1,25 +1,13 @@
<% content_for :title do %>My super sweet dashboard<% end %>
<div class="gridster">
<ul>
<li data-row="1" data-col="1" data-sizex="2" data-sizey="1">
<div data-id="welcome" data-view="Text" data-title="Hello" data-text="This is your shiny new dashboard." data-moreinfo="Protip: You can drag the widgets around!"></div>
</li>

<li data-row="1" data-col="1" data-sizex="1" data-sizey="1">
<div data-id="synergy" data-view="Meter" data-title="Synergy" data-height="200" data-width="200" data-min="0" data-max="100" data-suffix="%"></div>
</li>

<li data-row="1" data-col="1" data-sizex="1" data-sizey="2">
<div data-id="buzzwords" data-view="List" data-unordered="true" data-title="Buzzwords" data-moreinfo="# of times said around the office"></div>
</li>

<li data-row="1" data-col="1" data-sizex="1" data-sizey="1">
<div data-id="valuation" data-view="Number" data-title="Current Valuation" data-moreinfo="In billions" data-prefix="$"></div>
</li>

<li data-row="1" data-col="1" data-sizex="2" data-sizey="1">
<div data-id="convergence" data-view="Graph" data-title="Convergence" style="background-color:#ff9618"></div>
</li>
</ul>
<center><div style="font-size: 12px">Try this: curl -d '{ "auth_token": "YOUR_AUTH_TOKEN", "text": "Hey, Look what I can do!" }' \http://<%=request.host%>:<%=request.port%>/widgets/welcome</div></center>
<div class="grid">
<div class="row">
<div data-id="welcome" data-view="Text" data-title="Hello" data-text="This is your shiny new dashboard." data-moreinfo="Protip: You can resize this window"></div>
<div data-id="synergy" data-view="Meter" data-title="Synergy" data-height="200" data-width="200" data-min="0" data-max="100" data-suffix="%"></div>
<div data-span-cols="2" data-id="buzzwords" data-view="List" data-unordered="true" data-title="Buzzwords" data-moreinfo="# of times said around the office"></div>
</div>
<div class="row">
<div data-span-cols="2" data-id="valuation" data-view="Number" data-title="Current Valuation" data-moreinfo="In billions" data-prefix="$"></div>
<div data-span-cols="2" data-id="convergence" data-view="Graph" data-title="Convergence" style="background-color:#ff9618"></div>
</div>
<div style="font-size: 12px; text-align: center;">Try this: curl -d '{ "auth_token": "YOUR_AUTH_TOKEN", "text": "Hey, Look what I can do!" }' \http://<%=request.host%>:<%=request.port%>/widgets/welcome</div>
</div>
Loading