Skip to content

Commit

Permalink
Accommodate camera notches on new devices (iPhone X, Google Pixel 3 etc)
Browse files Browse the repository at this point in the history
  • Loading branch information
colinrotherham committed Feb 6, 2019
1 parent afd0ea5 commit 56f9f57
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 2 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@

([PR #N](https://github.com/alphagov/govuk-frontend/pull/N))

- Accommodate camera notches on new devices (iPhone X, Google Pixel 3 etc)

On newer devices with "camera notches", browsers reserve a safe area in landscape orientation (known as pillarboxing) so content isn't obscured.

To avoid this, support has been added for `viewport-fit=cover` as shown here:
https://webkit.org/blog/7929/designing-websites-for-iphone-x/

([PR #1176](https://github.com/alphagov/govuk-frontend/pull/1176))

🔧 Fixes:

- Pull Request Title goes here
Expand Down
2 changes: 1 addition & 1 deletion docs/installation/examples/webpack/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>GOV.UK Frontend</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<!--[if !IE 8]><!-->
<link rel="stylesheet" href="../../public/css/app.css">
<!--<![endif]-->
Expand Down
6 changes: 6 additions & 0 deletions src/components/skip-link/_skip-link.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,11 @@

display: block;
padding: govuk-spacing(2) govuk-spacing(3);

// Add safe area (e.g. iPhone X, Google Pixel 3)
@supports (padding: env(safe-area-inset-left)) {
padding-right: unquote("max(#{govuk-spacing(3)}, env(safe-area-inset-right))");
padding-left: unquote("max(#{govuk-spacing(3)}, env(safe-area-inset-left))");
}
}
}
17 changes: 17 additions & 0 deletions src/objects/_width-container.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,32 @@
// On mobile, add half width gutters
margin: 0 $govuk-gutter-half;

// Add safe area (e.g. iPhone X, Google Pixel 3)
@supports (margin: env(safe-area-inset-left)) {
margin-right: unquote("max(#{$govuk-gutter-half}, env(safe-area-inset-right))");
margin-left: unquote("max(#{$govuk-gutter-half}, env(safe-area-inset-left))");
}

// On tablet, add full width gutters
@include govuk-media-query($from: tablet) {
margin: 0 $govuk-gutter;

// Add safe area (e.g. iPhone X, Google Pixel 3)
@supports (margin: env(safe-area-inset-left)) {
margin-right: unquote("max(#{$govuk-gutter}, env(safe-area-inset-right))");
margin-left: unquote("max(#{$govuk-gutter}, env(safe-area-inset-left))");
}
}

// As soon as the viewport is greater than the width of the page plus the
// gutters, just centre the content instead of adding gutters.
@include govuk-media-query($and: "(min-width: #{($govuk-page-width + $govuk-gutter * 2)})") {
margin: 0 auto;

// Add safe area (e.g. iPhone X, Google Pixel 3)
@supports (margin: env(safe-area-inset-left)) {
margin: 0 auto;
}
}

@include govuk-if-ie8 {
Expand Down
2 changes: 1 addition & 1 deletion src/template.njk
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<head>
<meta charset="utf-8" />
<title>{% block pageTitle %}GOV.UK - The best place to find government services and information{% endblock %}</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<meta name="theme-color" content="{{ themeColor | default('#0b0c0c') }}" /> {# Hardcoded value of $govuk-black #}
{# Ensure that older IE versions always render with the correct rendering engine #}
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
Expand Down

0 comments on commit 56f9f57

Please sign in to comment.