Skip to content
This repository has been archived by the owner on Aug 30, 2018. It is now read-only.

Reudced selector specificity. New form and list defaults. #348

Merged
merged 12 commits into from
Mar 12, 2015
148 changes: 54 additions & 94 deletions assets/timber.scss.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -978,14 +978,6 @@ hr {
margin-bottom: $gutter / 2;
}

ul, ol {
margin-left: 35px;
}

ul {
@extend ul.disc;
}

li {
margin-bottom: 0.4em;
}
Expand Down Expand Up @@ -1022,10 +1014,11 @@ html input[disabled] {
.btn {
display: inline-block;
padding: 8px 10px;
width: auto;
margin: 0;
line-height: 1.42;
font-weight: bold;
text-decoration: none;
text-decoration: none!important;
text-align: center;
vertical-align: middle;
white-space: nowrap;
Expand Down Expand Up @@ -1059,8 +1052,7 @@ html input[disabled] {
}
}

.btn--secondary,
input.btn--secondary {
.btn--secondary {
@extend .btn;
background-color: $colorBtnSecondary;

Expand Down Expand Up @@ -1103,20 +1095,26 @@ input.btn--secondary {
#Lists
==============================================================================*/
ul, ol {
margin: 0 0 $gutter;
margin: 0 0 $gutter 20px;
padding: 0;

&.inline-list {
margin-left: 0;
}
}

ul { list-style: none outside; }
ol { list-style: decimal; }
ul ul, ul ol,
ol ol, ol ul { margin: 4px 0 5px 20px; }
li { margin-bottom: 0.25em; }

ol, ul.square, ul.disc { margin-left: 20px; }
ul.square { list-style: square outside; }
ul.disc { list-style: disc outside; }
ol.alpha { list-style: lower-alpha outside; }
.no-bullets {
list-style: none outside;
margin-left: 0;
}

.inline-list li {
display: inline-block;
Expand Down Expand Up @@ -1223,45 +1221,25 @@ form {
margin-bottom: $gutter;
}

input,
textarea,
button,
select {
font-size: 1em;
@include at-query($max, $medium) {
input,
textarea {
font-size: 16px;
}
}

button,
input[type="text"],
input[type="search"],
input[type="password"],
input[type="email"],
input[type="file"],
input[type="number"],
input[type="tel"],
input[type="submit"],
input[type="url"],
input,
textarea {
-webkit-appearance: none;
-moz-appearance: none;
}

input,
textarea,
select,
fieldset {
border-radius: $radius;
max-width: 100%;

&.input-full {
width: 100%;
}
}

input,
select,
textarea {
padding: 8px 10px;
line-height: 1.42;
button {
background: none;
border: none;
display: inline-block;
cursor: pointer;
}

fieldset {
Expand All @@ -1274,40 +1252,21 @@ legend {
padding: 0;
}

optgroup {
font-weight: bold;
}

input {
display: inline-block;
width: auto;
}

button,
input[type="submit"] {
cursor: pointer;
}

input[type="submit"] {
@extend .btn;
}

/*================ Input width and border ================*/
input[type="text"],
input[type="search"],
input[type="password"],
input[type="email"],
input[type="file"],
input[type="number"],
input[type="tel"],
input[type="url"],
input,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't think we should be this opinionated about form input styling by default. There was a good discussion about this in FED slack earlier today, but by styling form elements directly, if you want to create any variation within the theme for those elements, you'd need to undo all of these styles in that variant.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does timber as a base even need form styles out of the box? Presumably these are overwritten by each theme anyway?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... i still think this is too opinionated as a default? How would these be overwritten if a variant on an input was required? @cshold

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a step to reduce selector specificity, which I think it accomplishes. It's not perfect, so we'll revisit the reset vs base styles in another PR shortly.

textarea,
select {
border: 1px solid $colorBorder;
width: 100%;
max-width: 100%;
display: block;
margin: 0 0 1em;
padding: 8px 10px;
border-radius: $radius;

&:focus {
border: 1px solid darken($colorBorder, 10%);
Expand All @@ -1319,17 +1278,38 @@ select {
background-color: $disabledGrey;
border-color: $disabledBorder;
}

&.input-full {
width: 100%;
}
}

textarea {
min-height: 100px;
}

/*================ Input element overrides ================*/
input[type="checkbox"],
input[type="radio"] {
display: inline;
margin: 0;
margin: 0 10px 0 0;
padding: 0;
width: auto;
}

input[type="checkbox"] {
-webkit-appearance: checkbox;
-moz-appearance: checkbox;
}

input[type="radio"] {
-webkit-appearance: radio;
-moz-appearance: radio;
}

input[type="image"] {
padding-left: 0;
padding-right: 0;
}

select {
Expand All @@ -1356,6 +1336,10 @@ select {
}
}

optgroup {
font-weight: bold;
}

// Force option color (affects IE only)
option {
color: #000;
Expand Down Expand Up @@ -1394,33 +1378,16 @@ legend {
}
}

/*================ We don't want the same label treatment for checkboxes/radios ================*/
input[type="checkbox"] + label,
input[type="radio"] + label {
font-weight: normal;
}

label[for] {
cursor: pointer;
}

.label-hint {
color: #999;
}

/*================ Horizontal Form ================*/
form.form-horizontal,
.form-horizontal {
margin-bottom: 0;

input[type="text"],
input[type="search"],
input[type="password"],
input[type="email"],
input[type="file"],
input[type="number"],
input[type="tel"],
input[type="url"],
input,
textarea,
select,
label {
Expand All @@ -1431,14 +1398,7 @@ form.form-horizontal,
}

/*================ Error styles ================*/
input[type="text"],
input[type="search"],
input[type="password"],
input[type="email"],
input[type="file"],
input[type="number"],
input[type="tel"],
input[type="url"],
input,
textarea {
&.error {
border-color: $errorRed;
Expand Down