Skip to content

Commit f0a5711

Browse files
Mattia RoccobertonMattia Roccoberton
authored andcommitted
Styles improvements: menu, tabs - Added readonly form field
1 parent 75ce934 commit f0a5711

8 files changed

Lines changed: 82 additions & 3 deletions

File tree

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Features:
77
- CSS only theme with clean UI
88
- compact nested forms
99
- [customizable](#customize): colors, sidebar position, scroll on cells
10-
- custom boolean input: [toggle](#toggle)
10+
- custom controls / components: [toggle](#toggle), [Sidebar menu](#sidebar-menu), [Readonly field](#readonly-field)
1111
- Blaze CSS [widgets](#blaze-widgets)
1212

1313
## Install
@@ -120,6 +120,18 @@ A sidebar menu (*priority* option permit to put the sidebar above the filters):
120120
end
121121
```
122122

123+
![menu](screenshot4.jpg)
124+
125+
### Readonly field
126+
127+
Some readonly fields in form:
128+
129+
`f.readonly 'Code', 'Automatically set after save'`
130+
131+
`f.readonly :position, f.object.position`
132+
133+
`f.readonly nil, 'Value only, no label'`
134+
123135
## Blaze widgets
124136

125137
See components avaible in Blaze CSS [docs](http://blazecss.com/components/buttons/).

app/assets/stylesheets/activeadmin_blaze_theme/theme.scss

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ body.active_admin {
5555
input[type='search'],
5656
input[type='tel'],
5757
input[type='text'],
58+
input[type='time'],
5859
input[type='url'],
5960
select,
6061
textarea {
@@ -141,6 +142,24 @@ body.active_admin {
141142
margin-top: 0;
142143
}
143144
}
145+
.readonly-field {
146+
div {
147+
display: inline-block;
148+
line-height: $height-inputs;
149+
min-width: 450px;
150+
}
151+
.field_label {
152+
display: block;
153+
float: left;
154+
width: 20%;
155+
}
156+
.field_value {
157+
border-bottom: 1px dashed #ccc;
158+
display: inline-block;
159+
width: 100%;
160+
padding: 0 6px;
161+
}
162+
}
144163

145164
// filter forms
146165
&.filter_form {
@@ -163,6 +182,7 @@ body.active_admin {
163182
input[type='search'],
164183
input[type='tel'],
165184
input[type='text'],
185+
input[type='time'],
166186
input[type='url'], {
167187
max-width: 100px;
168188
width: auto;
@@ -194,6 +214,7 @@ body.active_admin {
194214
input[type='search'],
195215
input[type='tel'],
196216
input[type='text'],
217+
input[type='time'],
197218
input[type='url'],
198219
select,
199220
textarea {
@@ -241,6 +262,7 @@ body.active_admin {
241262
input[type='search'],
242263
input[type='tel'],
243264
input[type='text'],
265+
input[type='time'],
244266
input[type='url'],
245267
select {
246268
min-width: auto;
@@ -362,6 +384,28 @@ body.active_admin {
362384
padding-bottom: 0;
363385
padding-top: 25px;
364386
}
387+
.ui-tabs-nav {
388+
li {
389+
a {
390+
background: #eee;
391+
color: #555;
392+
}
393+
&:first-child a {
394+
border-top-left-radius: 6px;
395+
border-bottom-left-radius: 6px;
396+
}
397+
&:last-child a {
398+
border-top-right-radius: 6px;
399+
border-bottom-right-radius: 6px;
400+
}
401+
&.ui-tabs-active a {
402+
color: #222;
403+
border-color: #AAA;
404+
background-image: none;
405+
background-color: #fff;
406+
}
407+
}
408+
}
365409

366410
// misc
367411
a.c-button {
@@ -392,6 +436,10 @@ body.active_admin {
392436
}
393437
}
394438
ul.tabs {
439+
>li {
440+
margin-left: 1px;
441+
padding: 0;
442+
}
395443
li {
396444
height: $height-topbar;
397445
line-height: $height-topbar;
@@ -400,6 +448,8 @@ body.active_admin {
400448
color: $fg-menu-items;
401449
height: $height-topbar;
402450
line-height: $height-topbar;
451+
padding-left: 20px;
452+
padding-right: 20px;
403453
}
404454
li:hover, li.current {
405455
background: $bg-menu-active;
@@ -541,6 +591,7 @@ body.active_admin {
541591
input[type='search'],
542592
input[type='tel'],
543593
input[type='text'],
594+
input[type='time'],
544595
input[type='url'],
545596
textarea {
546597
background-color: $bg-inputs;
@@ -791,8 +842,10 @@ body.active_admin {
791842
@extend .u-high;
792843
li {
793844
@extend .c-card__item;
845+
padding: 0;
794846
a {
795847
display: block;
848+
padding: 0.5em;
796849
text-decoration: none;
797850
}
798851
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
ActiveAdmin::Views::ActiveAdminForm.class_eval do
2+
def readonly( field_label, field_value )
3+
li class: 'readonly-field' do
4+
if !field_label.blank?
5+
label field_label, for: nil, class: 'field_label'
6+
else
7+
span ' '.html_safe, class: 'field_label'
8+
end
9+
div do
10+
span !field_value.blank? ? raw( field_value ) : '', class: 'field_value'
11+
end
12+
end
13+
end
14+
end

lib/activeadmin_blaze_theme.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
require 'activeadmin/views/activeadmin_form'
12
require 'activeadmin_blaze_theme/version'
2-
33
# require 'formtastic/inputs/blaze_array_input'
44
require 'formtastic/inputs/blaze_toggle_input'
55

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module ActiveAdminBlazeTheme
2-
VERSION = '0.5.0'
2+
VERSION = '0.5.4'
33
end

screenshot2.jpg

-26.9 KB
Loading

screenshot3.jpg

-19.4 KB
Loading

screenshot4.jpg

38.2 KB
Loading

0 commit comments

Comments
 (0)