Skip to content

Commit

Permalink
Define size of inputs etc in pixels rather than em
Browse files Browse the repository at this point in the history
Remove the calls to the `em` function from Frontend, so that all measurements
are defined in pixels. The `em` conversions were originally added in an attempt
to make form elements line up. However, they cause problems when you try to use
Frontend in an application that defines font sizes, especially when those font
sizes are nested.

This also removes the em() call from `govuk-c-details` as the above problems
apply to this component too. For now, `govuk-c-table` still calls `em` - I'll
find out from Anika if there's any particular reason tables in Elements used
them.
  • Loading branch information
hannalaakso committed Feb 1, 2018
1 parent ca44b86 commit 5f4d20c
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
16 changes: 8 additions & 8 deletions src/components/checkboxes/_checkboxes.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
position: relative;

margin-bottom: $govuk-spacing-scale-2;
padding: 0 0 0 em(40px, 19px);
padding: 0 0 0 40px;

clear: left;
}
Expand Down Expand Up @@ -39,7 +39,7 @@

.govuk-c-checkboxes__label {
display: block;
padding: em(8px, 19px) em($govuk-spacing-scale-3, 19px) em($govuk-spacing-scale-1, 19px);
padding: 8px $govuk-spacing-scale-3 $govuk-spacing-scale-1;
cursor: pointer;
// remove 300ms pause on mobile
-ms-touch-action: manipulation;
Expand All @@ -52,8 +52,8 @@
position: absolute;
top: 0;
left: 0;
width: em(40px, 19px);
height: em(40px, 19px);
width: 40px;
height: 40px;
border: $govuk-border-width-form-element solid $govuk-text-colour;
background: transparent;

Expand All @@ -64,10 +64,10 @@
content: "";

position: absolute;
top: em(11px, 19px);
left: em(9px, 19px);
width: em(18px, 19px);
height: em(7px, 19px);
top: 11px;
left: 9px;
width: 18px;
height: 7px;

transform: rotate(-45deg);
border: solid;
Expand Down
2 changes: 1 addition & 1 deletion src/components/details/_details.scss
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@

.govuk-c-details__text p {
margin-top: 0;
margin-bottom: em($govuk-spacing-scale-4, 19px);
margin-bottom: $govuk-spacing-scale-4;
}

.govuk-c-details__text p:last-child {
Expand Down
2 changes: 1 addition & 1 deletion src/components/input/_input.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

box-sizing: border-box;
width: 100%;
height: em(40px, 19px);
height: 40px;
margin-top: 0;
@include govuk-responsive-margin($govuk-spacing-responsive-6, "bottom");

Expand Down
18 changes: 9 additions & 9 deletions src/components/radios/_radios.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
position: relative;

margin-bottom: $govuk-spacing-scale-2;
padding: 0 0 0 em($govuk-spacing-scale-7, 19px);
padding: 0 0 0 $govuk-spacing-scale-7;

clear: left;
}
Expand All @@ -32,8 +32,8 @@
top: 0;
left: 0;

width: em($govuk-spacing-scale-7, 19px);
height: em($govuk-spacing-scale-7, 19px);
width: $govuk-spacing-scale-7;
height: $govuk-spacing-scale-7;

cursor: pointer;

Expand All @@ -46,7 +46,7 @@

.govuk-c-radios__label {
display: block;
padding: em(8px, 19px) em($govuk-spacing-scale-3, 19px) em($govuk-spacing-scale-1, 19px);
padding: 8px $govuk-spacing-scale-3 $govuk-spacing-scale-1;
cursor: pointer;
// remove 300ms pause on mobile
-ms-touch-action: manipulation;
Expand All @@ -60,8 +60,8 @@
top: 0;
left: 0;

width: em($govuk-spacing-scale-7, 19px);
height: em($govuk-spacing-scale-7, 19px);
width: $govuk-spacing-scale-7;
height: $govuk-spacing-scale-7;

border: $govuk-border-width-form-element solid;
border-radius: 50%;
Expand All @@ -72,13 +72,13 @@
content: "";

position: absolute;
top: em($govuk-spacing-scale-2, 19px);
left: em($govuk-spacing-scale-2, 19px);
top: $govuk-spacing-scale-2;
left: $govuk-spacing-scale-2;

width: 0;
height: 0;

border: em($govuk-spacing-scale-2, 19px) solid;
border: $govuk-spacing-scale-2 solid;
border-radius: 50%;
opacity: 0;
background: currentColor;
Expand Down
2 changes: 1 addition & 1 deletion src/components/select/_select.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

box-sizing: border-box; // should this be global?
width: 100%;
height: em(40px, 19px);
height: 40px;
@include govuk-responsive-margin($govuk-spacing-responsive-6, "bottom");

padding: $govuk-spacing-scale-1; // was 5px 4px 4px - size of it should be adjusted to match other form elements
Expand Down

0 comments on commit 5f4d20c

Please sign in to comment.