Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: scss/_forms.scss

Issue 29365594: Issue 4633 - Default form styles (Closed)
Patch Set: Created Nov. 29, 2016, 4:29 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: scss/_forms.scss
===================================================================
new file mode 100644
--- /dev/null
+++ b/scss/_forms.scss
@@ -0,0 +1,289 @@
+/*!
+ * This file is part of website-defaults
+ * Copyright (C) 2016 Eyeo GmbH
+ *
+ * website-defaults 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * website-defaults 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 website-defaults. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*******************************************************************************
+ * Forms
juliandoucette 2017/01/10 13:40:26 TODO: - move button styles to button.scss - remov
+ *******************************************************************************
+ * 1. Reset
+ * 2. Structure
+ * 3. Consistency
+ * 4. Fields
+ * 5. States
+ ******************************************************************************/
+
+/* 1. Reset
+ ******************************************************************************/
+
+/**
+ * 1. Change the font styles in all browsers (opinionated).
+ * 2. Remove the margin in Firefox and Safari.
saroyanm 2016/12/06 18:26:54 Detail: Why exactly in Firefox and Safari ? I thin
juliandoucette 2016/12/07 17:31:08 Acknowledged. This was taken from normalize.
juliandoucette 2017/01/10 13:40:27 will-do.
+ */
+
+button,
+input,
+optgroup,
saroyanm 2016/12/06 18:26:54 Why do we apply this styles to the optgroup ? Ex.
juliandoucette 2016/12/07 17:31:09 Acknowledged. Don't know. This was taken from nor
+select,
+textarea
+{
+ margin: 0; /* 2 */
saroyanm 2016/12/06 18:26:54 Detail: please specify units where possible.
saroyanm 2016/12/06 18:26:54 I don't think that we need to be that specific reg
juliandoucette 2016/12/07 17:31:08 Acknowledged. Will-do. Again, taken from normali
+ font-family: sans-serif; /* 1 */
+ font-size: 100%; /* 1 */
saroyanm 2016/12/06 18:26:54 Deatail: I think you want to specify 1em here ?
juliandoucette 2016/12/07 17:31:09 Acknowledged. Maybe. I'll investigate. I think no
juliandoucette 2017/01/10 13:40:27 Note: Will change this to em instead of %
+ line-height: inherit;
saroyanm 2016/12/06 18:26:53 I assume you want to setup this according to the c
juliandoucette 2016/12/07 17:31:09 Inherit is the default value. This is a reset styl
juliandoucette 2017/01/10 13:40:26 Acknowledged, will investigate, and determine if w
+}
+
+/**
+ * Make advanced text fields consistent and stylable on chrome, safari, and iOS
+ */
+
+input[type="date"],
saroyanm 2016/12/06 18:26:54 This input types are not supported across most of
juliandoucette 2016/12/07 17:31:09 Acknowledged. - They are supported by HTML5 - The
juliandoucette 2017/01/10 13:40:27 See comment below.
+input[type="time"],
+input[type="datetime-local"],
+input[type="month"]
+{
+ /* stylelint-disable-next-line */
+ -webkit-appearance: listbox;
juliandoucette 2017/01/10 13:40:26 - will investigate if -webkit-appearance is necess
+ box-sizing: border-box;
+}
+
+/**
+ * 1. Prevent a WebKit bug where (2) destroys native `audio` and `video`
saroyanm 2016/12/06 18:26:53 Not really sure if I understand how this comment i
juliandoucette 2016/12/07 17:31:09 Apparently applying "-webkit-appearance: button" t
+ * controls in Android 4.
+ * 2. Correct the inability to style clickable types in iOS and Safari.
+ */
+
+button,
+html [type="button"], /* 1 */
saroyanm 2016/12/06 18:26:53 [type="button"] selector will be more consistent w
juliandoucette 2016/12/07 17:31:09 Acknowledged. See comment above.
+[type="reset"],
+[type="submit"]
+{
+ /* stylelint-disable-next-line */
+ -webkit-appearance: button; /* 2 */
saroyanm 2016/12/06 18:26:53 I don't think why we need to use this non standard
juliandoucette 2016/12/07 17:31:09 Because webkit based mobile browsers apply default
+}
+
+/**
+ * Remove the inner border and padding in Firefox.
saroyanm 2016/12/06 18:26:54 I can't see if this have any effect on my side.
juliandoucette 2016/12/07 17:31:08 Acknowledged. Looks like this is not relevant to
+ */
+
+button::-moz-focus-inner,
+[type="button"]::-moz-focus-inner,
+[type="reset"]::-moz-focus-inner,
+[type="submit"]::-moz-focus-inner
+{
+ padding: 0;
+ border-style: none;
+}
+
+/**
+ * Restore the focus styles unset by the previous rule.
saroyanm 2016/12/06 18:26:54 Again: why do we need this non standard reset ? Al
juliandoucette 2016/12/07 17:31:08 Acknowledged. See comment above.
+ */
+
+button:-moz-focusring,
+[type="button"]:-moz-focusring,
+[type="reset"]:-moz-focusring,
+[type="submit"]:-moz-focusring
+{
+ outline: 1px dotted ButtonText;
+}
+
+/**
+ * 2. Remove the padding in IE 10-.
saroyanm 2016/12/06 18:26:53 I don't think that this style is specific for only
juliandoucette 2016/12/07 17:31:09 Acknowledged. Again, this comes from normalize. A
+ */
+
+[type="checkbox"],
+[type="radio"]
+{
+ padding: 0; /* 2 */
+}
+
+/**
+ * 1. Correct the odd appearance in Chrome and Safari.
saroyanm 2016/12/06 18:26:55 What odd appearance is this fixing, I can't see an
juliandoucette 2016/12/07 17:31:09 Search input has border radius by default on chrom
+ * 2. Correct the outline style in Safari.
+ */
+
+[type="search"]
+{
+ /* stylelint-disable-next-line */
+ -webkit-appearance: textfield; /* 1 */
+ outline-offset: -2px; /* 2 */
+}
+
+/**
+ * Work around a Firefox/IE bug where the transparent `button` background
+ * results in a loss of the default `button` focus styles.
+ */
+
+button:focus
+{
+ outline: 1px dotted;
+ /* stylelint-disable-next-line */
+ outline: 5px auto -webkit-focus-ring-color;
saroyanm 2016/12/06 18:26:54 I don't think that we want to use a webkit specifi
juliandoucette 2016/12/07 17:31:08 Acknowledged. This is restoring the default behav
juliandoucette 2017/01/10 13:40:27 Agreed. Let's use a non-webkit color.
+}
+
+/**
+ * Add the correct display in IE 10-.
+ */
+
+[hidden]
saroyanm 2016/12/06 18:26:53 Are we planing to use hidden attribute ? I can't s
juliandoucette 2016/12/07 17:31:08 It's common to use this attribute to hide custom f
+{
+ display: none;
+}
+
+/* 2. Structure
+ ******************************************************************************/
+
+fieldset {
saroyanm 2016/12/06 18:26:54 Detail: the opening braces should go to the next l
juliandoucette 2016/12/07 17:31:08 Acknowledged. (Sorry)
+ display: block;
+ /* undo browser default */
+ margin: 0em;
+ padding: 0em;
+ border: 0em;
+}
+
+legend {
+ display: block;
+ margin: 2em 0em 0em 0em;
+ /* undo browser default */
+ padding: 0em;
+ font-size: 1.25em;
+ font-weight: $bold-weight;
+ /* undo browser default */
+ line-height: inherit;
saroyanm 2016/12/06 18:26:53 deatail: As far as I remember we decided to specif
juliandoucette 2016/12/07 17:31:08 Acknowledged. The intention here was to unset bro
+}
+
+label {
+ display: block;
+ margin: 1em 0em 0.25em 0em;
+}
+
+/* 3. Consistency
+ ****************************************************************************************/
+
+[type="text"],
+[type="search"],
+[type="tel"],
+[type="url"],
+[type="email"],
+[type="password"],
+[type="date"],
saroyanm 2016/12/06 18:26:54 Some of this input type, like date and time are no
juliandoucette 2016/12/07 17:31:08 Acknowledged. I got this list from the HTML5 spec
juliandoucette 2017/01/10 13:40:26 See comment above.
+[type="time"],
+[type="number"],
+select,
+textarea
+{
+ width: 100%;
+ border: 1px solid $secondary;
+ background-color: $primary-light;
+}
+
+[type="text"],
+[type="search"],
+[type="tel"],
+[type="url"],
+[type="email"],
+[type="password"],
+[type="date"],
+[type="time"],
+[type="number"],
+select
+{
+ height: 1.75em;
+ padding: 0 0.25em;
+}
+
+/* 4. Fields
+ ****************************************************************************************/
+
+textarea
+{
+ /* Progressively disable horizontal resizing */
+ /* stylelint-disable-next-line no-unsupported-browser-features */
+ resize: vertical;
+ overflow: auto;
saroyanm 2016/12/06 18:26:53 Why we need to setup overflow to auto ?
juliandoucette 2016/12/07 17:31:08 Acknowledged. I don't know :/ . Will investigate.
+}
+
+select
+{
+ /* stylelint-disable */
+ /* Undo chrome default border radius */
+ -webkit-appearance: none;
saroyanm 2016/12/06 18:26:54 The way we are designing select boxes are not reli
juliandoucette 2016/12/07 17:31:09 I styled select this way to specifically address t
+ -moz-appearance: none;
+ border-radius: 0;
+ /* Make the caret consistent across modern browsers */
+ background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' version='1.1' width='32' height='24' viewBox='0 0 32 24'><polygon points='0,0 32,0 16,24' style='fill: rgb%28138, 138, 138%29'></polygon></svg>");
saroyanm 2016/12/06 18:26:54 I think we can use PNG and made a wider support.
juliandoucette 2016/12/07 17:31:09 SVG is smaller and supports highDPI. We cannot rep
juliandoucette 2017/01/10 13:40:27 - will double check double backgrounds - will doub
+ background-size: 9px 6px;
saroyanm 2016/12/06 18:26:54 I think we can use background shorthand property.
juliandoucette 2016/12/07 17:31:09 Maybe. This may affect browser support.
+ background-position: right 8px center;
+ background-repeat: no-repeat;
+ padding-right: 25px;
saroyanm 2016/12/06 18:26:54 I thought we awere planing to use EMs instead.
juliandoucette 2016/12/07 17:31:09 The padding-right is in px because the caret icon
+ /* stylelint-enable */
+}
+
+[dir="rtl"] select
+{
+ padding-right: 25px;
saroyanm 2016/12/06 18:26:54 You already setup padding right above.
juliandoucette 2016/12/07 17:31:08 Acknowledged. Maybe I got this backwards :/
juliandoucette 2017/01/10 13:40:26 Verified. I got this backwards.
+ padding-left: 0.25em;
+ background-position: left 8px center;
+}
+
+/* stylelint-disable-next-line */
+[type="checkbox"],
+[type="radio"]
+{
+ margin-right: 0.15em;
saroyanm 2016/12/06 18:26:53 What if the label will be before the checkbox ? E
juliandoucette 2016/12/07 17:31:08 Acknowledged. Good point.
+}
+
+[type="button"],
+[type="reset"]
+{
+ @extend .button;
saroyanm 2016/12/06 18:26:54 I'll suggest not to use @extend if there is no rea
juliandoucette 2016/12/07 17:31:09 Acknowledged.
juliandoucette 2017/01/10 13:40:26 We will move button styles to button.scss
+}
+
+[type="submit"]
+{
+ @extend .button;
+ @extend .submit;
+}
+
+/* 5. States
+ ****************************************************************************************/
+
+.invalid
+{
+ color: $error;
+}
+
+.invalid input,
+.invalid textarea,
+.invalid select
+{
+ border-color: $error;
+}
+
+.disabled
+{
+ color: $secondary;
+}
+
+.disabled input,
saroyanm 2016/12/06 18:26:54 Why not to use disabled attribute ?
juliandoucette 2016/12/07 17:31:08 Because this class is intended to apply to the par
juliandoucette 2017/01/10 13:40:26 - Will use attribute here instead
+.disabled textarea,
+.disabled select
+{
+ background-color: $secondary-light;
+ /* Progressively set disabled cursor */
+ /* stylelint-disable-next-line */
+ cursor: not-allowed;
+}

Powered by Google App Engine
This is Rietveld