Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Mar 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
11 changes: 11 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,16 @@

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

// Respect 'display cutout' safe area (avoids notches and rounded corners)
@supports (padding: unquote("max(calc(0px))")) {
$padding-safe-area-right: calc(#{govuk-spacing(3)} + env(safe-area-inset-right));
$padding-safe-area-left: calc(#{govuk-spacing(3)} + env(safe-area-inset-left));

// Use max() to pick largest padding, default or with safe area
// Escaped due to Sass max() vs. CSS native max()
padding-right: unquote("max(#{govuk-spacing(3)}, #{$padding-safe-area-right})");
padding-left: unquote("max(#{govuk-spacing(3)}, #{$padding-safe-area-left})");
}
}
}
28 changes: 28 additions & 0 deletions src/objects/_width-container.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,43 @@
// On mobile, add half width gutters
margin: 0 $govuk-gutter-half;

// Respect 'display cutout' safe area (avoids notches and rounded corners)
@supports (margin: unquote("max(calc(0px))")) {
$gutter-safe-area-right: calc(#{$govuk-gutter-half} + env(safe-area-inset-right));
$gutter-safe-area-left: calc(#{$govuk-gutter-half} + env(safe-area-inset-left));

// Use max() to pick largest margin, default or with safe area
// Escaped due to Sass max() vs. CSS native max()
margin-right: unquote("max(#{$govuk-gutter-half}, #{$gutter-safe-area-right})");
margin-left: unquote("max(#{$govuk-gutter-half}, #{$gutter-safe-area-left})");
}

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

// Respect 'display cutout' safe area (avoids notches and rounded corners)
@supports (margin: unquote("max(calc(0px))")) {
$gutter-safe-area-right: calc(#{$govuk-gutter-half} + env(safe-area-inset-right));
$gutter-safe-area-left: calc(#{$govuk-gutter-half} + env(safe-area-inset-left));

// Use max() to pick largest margin, default or with safe area
// Escaped due to Sass max() vs. CSS native max()
margin-right: unquote("max(#{$govuk-gutter}, #{$gutter-safe-area-right})");
margin-left: unquote("max(#{$govuk-gutter}, #{$gutter-safe-area-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;

// Since a safe area may have previously been set above,
// we need to duplicate this margin that centers the page.
@supports (margin: unquote("max(calc(0px))")) {
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