Project

General

Profile

Download (4.48 KB) Statistics
| Branch: | Tag: | Revision:
1
pfSense on bootstrap
2
====================
3

    
4
We are migrating pfSense to Bootstrap. You can help! Please respect these code-guidelines:
5

    
6
* use tabs (tabstop=4) for indenting (except the license-header which contains 3 lines that are indented with "\t   ")
7
* no trailing whitespace
8
* limited echoing of HTML from php, please use proper templating syntax instead (eg. foreach/endforeach)
9
* limited attributes on elements; _no style attributes_
10
* no inline javascript
11
* html attributes should be using double-quoted attribute-values. This means your php-code should probably use single-quoted strings
12
* we use icons for status-indication and buttons for actions
13

    
14
If you feel adventurous you can sometimes rewrite some PHP & javascript code as well; but try to keep this to a minimum.
15

    
16
# Cleaner
17

    
18
Before diving into a template, clean it with the supplied cleaner (`clean.sh`). This script tries to remove most of the unnecessary element attributes and does a bunch of other replaces which have to be done in every template.
19

    
20
# Template migration conventions
21

    
22
All migrated templates are formatted with default [Bootstrap](http://getbootstrap.com/) components. Custom CSS goes into `usr/www/bootstrap/css/pfSense.css`, but try to keep this to a minimum.
23

    
24
The Bootstrap grid system is used for defining columns. We've chosen the 'small' breakpoint as the default breakpoint to collapse from a horizontal to vertical layout. You should define your column widths with `.col-sm-*`, unless there's a good (and documented ;) ) reason to deviate from this default.
25

    
26
## Forms
27

    
28
* Every form should have at least one 'panel' which contains the form fields. If certain fields can be grouped together, you can add multiple panels to a form.
29
* A field consists of an outer wrapper `.form-group` which contains a `label` and the `input`
30
* The submit button should be placed outside of the panels to prevent confusion (e.g., the save button saves the whole form and not just the last panel).
31
* Checkboxes are placed within a label (see example below). The wrapping div needs an additional `.checkbox` class
32
* Additional field descriptions can be placed in the `.help-block` `span`
33

    
34
An example (which omits everything but relevant Bootstrap classes):
35

    
36
```html
37
<form class="form-horizontal">
38
	<div class="panel panel-default">
39
		<div class="panel-heading">
40
			<h2 class="panel-title">Form or panel heading</h2>
41
		</div>
42
		<div class="panel-body">
43
			<div class="form-group">
44
				<label for="input" class="col-sm-2 control-label">Labeltext</label>
45
				<div class="col-sm-10">
46
					<input class="form-control" id="input" />
47
				</div>
48
			</div>
49
			<div class="form-group">
50
                <label for="second-input" class="col-sm-2 control-label">Second label</label>
51
                <div class="col-sm-10">
52
                    <input class="form-control" id="second-input" />
53
                    <span class="help-block">What's this all about?</span>
54
                </div>
55
			</div>
56
			<div class="form-group">
57
                <label for="second-input" class="col-sm-2 control-label">Checkboxl</label>
58
                <div class="col-sm-10 checkbox">
59
                	<label>
60
                    	<input type="checkbox" id="checkbox" /> Checkbox description
61
                    </label>	
62
                </div>
63
			</div>
64

    
65
			<!-- And more form-groups -->
66

    
67
		</div>
68
	</div>
69

    
70
	<!-- And more panels -->
71

    
72
	<div class="col-sm-10 col-sm-offset-2">
73
		<input type="submit" class="btn btn-primary" value="Save" />
74
	</div>
75
</form>
76
```
77

    
78
## Tables
79

    
80
* Wrap your tables in a `<div class="table-responsive">` to make them scroll horizontally on small devices.
81
* Tables get a standard set of classes: `table table-striped table-hover`
82
* Please add a `thead` (with corresponding `th`'s) and `tbody`
83

    
84
## Buttons
85

    
86
Many tables have 'action' buttons per row, like 'edit', 'move' and 'delete'. The old template uses icons for these actions, but in most cases there are not sufficient different icons and / or the icons aren't very self explanatory. We've chosen to replace these icons with (small) buttons:
87

    
88
```html
89
<a class="btn btn-xs btn-primary">edit</a> <a class="btn btn-xs btn-danger">delete</a>
90
```
91

    
92
The button colours aren't set in stone, but the variants used so far are:
93

    
94
* edit - dark blue, `btn-primary`
95
* enable / disable - yellow, `btn-warning`
96
* delete - red, `btn-danger`
97
* copy - neutral, `btn-default`
98

    
99
## Icons
100

    
101
Icons are primarily used for status indications. Try to supply a legend when the icon is not 100% self explanatory. See `usr/local/www/firewall_rules.php` for an good example of icon usage and a legend.
(3-3/5)