CSS/forms: style them

* login form style should only affect login form
* accessibility: add labels on login page
This commit is contained in:
Thomas Gelf 2014-06-20 16:39:01 +02:00
parent 40c298ceb6
commit 45fa8ca225
3 changed files with 44 additions and 62 deletions

View File

@ -1,32 +1,4 @@
<?php <?php
// @codeCoverageIgnoreStart
// {{{ICINGA_LICENSE_HEADER}}}
/**
* This file is part of Icinga Web 2.
*
* Icinga Web 2 - Head for multiple monitoring backends.
* Copyright (C) 2013 Icinga Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* @copyright 2013 Icinga Development Team <info@icinga.org>
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
* @author Icinga Development Team <info@icinga.org>
*
*/
// {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Form\Authentication; namespace Icinga\Form\Authentication;
@ -49,32 +21,23 @@ class LoginForm extends Form
protected function create() protected function create()
{ {
$this->setName('form_login'); $this->setName('form_login');
$this->addElement( $this->addElement('text', 'username', array(
'text', 'label' => t('Username'),
'username', 'placeholder' => t('Please enter your username...'),
array( 'required' => true,
'required' => true, ));
'placeholder' => t('Username'),
)
);
$this->addElement( $this->addElement('password', 'password', array(
'password', 'label' => t('Password'),
'password', 'placeholder' => t('...and your password'),
array( 'required' => true
'placeholder' => t('Password'), ));
'required' => true
)
);
$user = $this->getElement('username');
// TODO: We need a place to intercept filled forms before rendering // TODO: We need a place to intercept filled forms before rendering
if (isset($_POST['username'])) { if (isset($_POST['username'])) {
$this->getElement('password')->setAttrib('class', 'autofocus'); $this->getElement('password')->setAttrib('class', 'autofocus');
} else { } else {
$user->setAttrib('class', 'autofocus'); $this->getElement('username')->setAttrib('class', 'autofocus');
} }
$this->setSubmitLabel('Login'); $this->setSubmitLabel('Login');
} }
} }
// @codeCoverageIgnoreEnd

View File

@ -30,22 +30,16 @@ label {
} }
input, select { input, select {
box-sizing: border-box;
-moz-box-sizing: border-box; -moz-box-sizing: border-box;
-webkit-box-sizing: border-box; -webkit-box-sizing: border-box;
box-sizing: border-box; border: 1px solid #ddd;
background: #ddd;
color: #333;
padding: 0.2em; padding: 0.2em;
border: 2px solid #ddd; background: #fff;
} }
select { input:focus, select:focus {
/* https://bugzilla.mozilla.org/show_bug.cgi?id=649849 */ border-color: #333;
-moz-appearance: none;
padding-right: 5px;
text-overflow: '';
-webkit-appearance: none;
cursor: pointer;
} }
input[type=submit] { input[type=submit] {

View File

@ -50,18 +50,43 @@
} }
.form label { .form label {
display: none; font-weight: normal;
display: inline-block;
line-height: 2.5em;
width: 10em;
margin-right: 1em;
text-align: right;
} }
form { form {
margin-left: auto; margin-left: auto;
margin-right: auto; margin-right: auto;
width: 20em; width: 40em;
} }
form input { form input {
width: 100%; width: 18em;
padding: 0.5em; padding: 0.5em;
background: #ddd;
color: #333;
border: 1px solid #ddd;
}
form input:focus {
background: white;
}
input[type=submit] {
color: #eee;
border-color: #777;
background: #777;
margin-left: 11em;
}
input[type=submit]:hover, a.button:hover, input[type=submit]:focus {
background-color: #333;
border-color: #333;
} }
.footer { .footer {