Skip to content

Commit

Permalink
various improvements to CSS
Browse files Browse the repository at this point in the history
    Changes:
     - changed autocomplete widget height,
     - changed form spacing.
  • Loading branch information
ar4s committed Sep 18, 2015
1 parent d64639d commit 4ef3e08
Show file tree
Hide file tree
Showing 19 changed files with 159 additions and 78 deletions.
4 changes: 4 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ var gulp = require('gulp');
bower = require('gulp-bower'),
prefixer = require('gulp-autoprefixer'),
sass = require('gulp-sass'),
sourcemaps = require('gulp-sourcemaps'),
qunit = require('node-qunit-phantomjs');

var config = {
Expand All @@ -15,6 +16,7 @@ var config = {
}

var sass_config = {
outputStyle: 'compressed',
includePaths: [
config.bowerDir + 'foundation/scss',
config.bowerDir + 'fontawesome/scss',
Expand All @@ -28,8 +30,10 @@ gulp.task('bower', function() {


gulp.task('scss', function() {
gulp.src(config.srcRoot + 'scss/*.scss')
.pipe(sourcemaps.init())
.pipe(sass(sass_config).on('error', sass.logError))
.pipe(prefixer())
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(config.staticRoot + 'css/'))
});

Expand Down
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
"repository": "allegro/ralph",
"version": "3.0.0",
"dependencies": {
"bower": "~1.4.1",
"gulp": "~3.9.0",
"gulp-autoprefixer": "~2.3.1",
"gulp-bower": "0.0.10",
"gulp-rename": "~1.2.2",
"run-sequence": "~1.1.0",
"gulp-sass": "~2.0.1",
"gulp-autoprefixer": "~2.3.1",
"bower": "~1.4.1",
"jshint": "~2.8.0"
"gulp-sourcemaps": "^1.5.2",
"jshint": "~2.8.0",
"run-sequence": "~1.1.0"
},
"devDependencies": {
"gulp-watch": "~4.2.4",
Expand Down
2 changes: 1 addition & 1 deletion src/ralph/admin/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from django import forms
from django.forms import ValidationError
from django.forms.util import ErrorList
from django.forms.utils import ErrorList
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext as _

Expand Down
3 changes: 2 additions & 1 deletion src/ralph/admin/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,8 @@ def changeform_view(
def formfield_for_manytomany(self, db_field, request=None, **kwargs):
if db_field.name in ('user_permissions', 'permissions'):
kwargs['widget'] = widgets.PermissionsSelectWidget()
return db_field.formfield(**kwargs)
return db_field.formfield(**kwargs)
return super().formfield_for_manytomany(db_field, request, **kwargs)


class RalphAdmin(
Expand Down
1 change: 0 additions & 1 deletion src/ralph/admin/templates/admin/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
{% endif %}
<div class="row">
<div class="large-12 columns content">
<div id="magicsuggest"></div>
{% block content %}{% endblock %}
</div>
</div>
Expand Down
54 changes: 28 additions & 26 deletions src/ralph/admin/templates/admin/related_widget_wrapper.html
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
{% load i18n admin_static %}
<div class="related-widget-wrapper row">
<div class="large-12 columns">
{{ widget }}
{% block links %}
{% if can_change_related %}
<a class="related-widget-wrapper-link change-related" id="change_id_{{ name }}"
data-href-template="{{ change_related_template_url }}?{{ url_params }}"
title="{% blocktrans %}Change selected {{ model }}{% endblocktrans %}">
<i class="fa fa-pencil fa-lg"></i>
</a>
{% endif %}
{% if can_add_related %}
<a class="related-widget-wrapper-link add-related" id="add_id_{{ name }}"
href="{{ add_related_url }}?{{ url_params }}"
title="{% blocktrans %}Add another {{ model }}{% endblocktrans %}">
<i class="fa fa-plus-circle fa-lg"></i>
</a>
{% endif %}
{% if can_delete_related %}
<a class="related-widget-wrapper-link delete-related" id="delete_id_{{ name }}"
data-href-template="{{ delete_related_template_url }}?{{ url_params }}"
title="{% blocktrans %}Delete selected {{ model }}{% endblocktrans %}">
<i class="fa fa-trash fa-lg"></i>
</a>
{% endif %}
{% endblock %}
</div>
<div class="widget">
{{ widget }}
</div>
<div class="links">
{% block links %}
{% if can_change_related %}
<a class="related-widget-wrapper-link change-related" id="change_id_{{ name }}"
data-href-template="{{ change_related_template_url }}?{{ url_params }}"
title="{% blocktrans %}Change selected {{ model }}{% endblocktrans %}">
<i class="fa fa-pencil fa-lg"></i>
</a>
{% endif %}
{% if can_add_related %}
<a class="related-widget-wrapper-link add-related" id="add_id_{{ name }}"
href="{{ add_related_url }}?{{ url_params }}"
title="{% blocktrans %}Add another {{ model }}{% endblocktrans %}">
<i class="fa fa-plus-circle fa-lg"></i>
</a>
{% endif %}
{% if can_delete_related %}
<a class="related-widget-wrapper-link delete-related" id="delete_id_{{ name }}"
data-href-template="{{ delete_related_template_url }}?{{ url_params }}"
title="{% blocktrans %}Delete selected {{ model }}{% endblocktrans %}">
<i class="fa fa-trash fa-lg"></i>
</a>
{% endif %}
{% endblock %}
</div>
</div>
19 changes: 8 additions & 11 deletions src/ralph/admin/templates/admin/search_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,18 @@

{% if search_fields %}
<div class="contextual_search">
<form id="changelist-search" action="{{ search_url }}" method="get">
<div class="row collapse">
<div class="small-10 columns">
<input type="text" size="40" name="{{ search_var }}" value="{{ cl.query }}" id="searchbar" placeholder="{% trans "Search by" %} {{ search_fields|join:", " }}" />
</div>
<div class="small-2 columns">
<button type="submit" class="button expand search">
<i class="fa fa-search"></i>
</button>
</div>
<form id="changelist-search" action="{{ search_url }}" method="get" class="row collapse">
<div class="small-10 columns">
<input type="text" size="40" name="{{ search_var }}" value="{{ cl.query }}" id="searchbar" placeholder="{% trans "Search by" %} {{ search_fields|join:", " }}" />
</div>
<div class="small-2 columns">
<button type="submit" class="button expand search">
<i class="fa fa-search"></i>
</button>
</div>
{% for pair in cl.params.items %}
{% ifnotequal pair.0 search_var %}<input type="hidden" name="{{ pair.0 }}" value="{{ pair.1 }}"/>{% endifnotequal %}
{% endfor %}
</form>
</div>
<script type="text/javascript">document.getElementById("searchbar").focus();</script>
{% endif %}
3 changes: 2 additions & 1 deletion src/ralph/assets/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ class ServiceEnvironmentInline(RalphTabularInline):
class ServiceAdmin(RalphAdmin):
exclude = ['environments']
inlines = [ServiceEnvironmentInline]
search_fields = ['name', 'uid']
filter_horizontal = ['business_owners', 'technical_owners']
search_fields = ['name']


@register(Manufacturer)
Expand Down
22 changes: 11 additions & 11 deletions src/ralph/lib/foundation/templates/foundation_form/form_field.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@
<div class="small-3 columns">
{% if show_label %}
{% label field %}
{% if admin_field.help_text %}
<span class="help-text">
<i
class="fa fa-lg fa-info-circle has-tip tip-top"
data-tooltip
aria-haspopup="true"
title="{{ admin_field.help_text | escape }}"
>
</i>
</span>
{% endif %}
{% endif %}
</div>
<div class="small-7 end columns {% if field.errors %} error{% endif %}">
Expand All @@ -18,17 +29,6 @@
<small class="error">{{ error }}</small>
{% endfor %}
{% endif %}
{% if admin_field.help_text %}
<span class="help-text">
<i
class="fa fa-lg fa-info-circle has-tip tip-top"
data-tooltip
aria-haspopup="true"
title="{{ admin_field.help_text | escape }}"
>
</i>
</span>
{% endif %}
</div>
</div>
</div>
2 changes: 1 addition & 1 deletion src/ralph/static/src/scss/_overrides.scss
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ select {
display: none;
}
#{text-inputs(all, 'input')}, select{
margin: rem-calc(5) 0;
margin: 0;
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/ralph/static/src/scss/_settings.scss
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ $button-font-lrg: rem-calc(14);
$button-margin-bottom: 0;
$button-radius: 0;

$form-spacing: rem-calc(12);
$form-label-font-size: rem-calc(12);

$fieldset-border-style: solid;
Expand Down
1 change: 1 addition & 0 deletions src/ralph/static/src/scss/_styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ select {
label, label.inline, select, #{text-inputs(all, 'input')} {
padding: $input-padding;
height: auto;
margin: $form-spacing / 2 0;
}

button.button.search {
Expand Down
56 changes: 38 additions & 18 deletions src/ralph/static/src/scss/components/autocomplete_field.scss
Original file line number Diff line number Diff line change
@@ -1,31 +1,41 @@
$item-padding: 0.1rem;
$widget-padding: $input-padding - $item-padding;
$lookup-icon-width: 20px;
$item-padding: 0.25rem;
$lookup-icon-width: 25px;
$icons-count: 2;
$icons-wrapper-margin: 5px;
$font-size: rem-calc(16);

@mixin right-lookup() {
width: calc(100% - #{($lookup-icon-width * 2)});
width: calc(100% - #{($lookup-icon-width * $icons-count) + $icons-wrapper-margin});
float: left;
}

@mixin common-styles() {
padding: $item-padding 0;
font-size: $input-font-size;
}

.autocomplete-widget {
position: relative;
margin: 0 0 $form-spacing 0;
margin: $form-spacing / 2 0;
.widget-wrapper {
overflow: hidden;
background: $input-bg-color;
border: {
style: $input-border-style;
width: $input-border-width;
color: $input-border-color;
}
}
box-shadow: $input-box-shadow;
padding: $widget-padding;
.item-wrapper {
@include right-lookup;
.item {
display:inline;
line-height: 1rem;
display: inline-block;
background: #ededed;
padding: $item-padding 0;
border: 1px solid #cacaca;
white-space: nowrap;
margin: 1px;
@include common-styles;
.title {
margin-left: $item-padding;
}
Expand All @@ -40,16 +50,25 @@ $lookup-icon-width: 20px;
padding: 0 4px;
}
}
.widget-icons .fa {
font-size: rem-calc(18);
.widget-icons {
width: #{($lookup-icon-width * $icons-count)};
float: right;
text-align: right;
margin-top: 5px;
margin-right: $icons-wrapper-margin;
.fa {
font-size: $font-size;
}
}
.input {
@include right-lookup;
padding: $item-padding;
margin: 0;
@include common-styles;
display: none;
float: left;
padding-left: 4px;
margin: 4px 0;
border: 0;
border-left: 0;
border-right: 0;
}
.delete, .title, .related-lookup {
font-size: $input-font-size;
Expand All @@ -62,11 +81,11 @@ $lookup-icon-width: 20px;
}
.status{
position: absolute;
top: 5px;
right: 48px;
top: 8px;
right: 45px;
.fa {
display: none;
font-size: 1.25rem;
font-size: $font-size;
&.fa-spin {
-webkit-animation-duration: 1s;
animation-duration: 1s;
Expand Down Expand Up @@ -128,7 +147,8 @@ $lookup-icon-width: 20px;
}
}

.error .suggest-field-widget .widget-wrapper {
.error .autocomplete-widget .widget-wrapper {
background-color: #fff5c3;
border-color: $alert-color;
.input {
border: none;
Expand Down
3 changes: 2 additions & 1 deletion src/ralph/static/src/scss/components/contextual_search.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@

.contextual_search {
#searchbar, .search {
padding: rem-calc(6) inherit;
padding: rem-calc(6);
font-size: 1rem;
}
#searchbar {
border-right: 0;
padding-left: rem-calc(6);
margin-bottom: rem-calc(4);
margin-top: 0;
}
.search {
border: 1px solid #5B5B5B;
Expand Down
2 changes: 1 addition & 1 deletion src/ralph/static/src/scss/components/fieldsets.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ fieldset {
.help-text {
position: absolute;
right: -13px;
top: 5px;
top: 11px;
}
9 changes: 9 additions & 0 deletions src/ralph/static/src/scss/components/related_widget.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
form .row .related-widget-wrapper.row {
margin-left: 0;
.links {
position: absolute;
left: 100%;
top: 10px;
width: 60px;
}
}
Loading

0 comments on commit 4ef3e08

Please sign in to comment.