Skip to content

Commit

Permalink
Spent way too much time making the blue navbar full-width on iPhone X
Browse files Browse the repository at this point in the history
  • Loading branch information
swrobel committed Jan 27, 2018
1 parent 1b605de commit 3c48af1
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 7 deletions.
25 changes: 24 additions & 1 deletion app/assets/stylesheets/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,21 @@ $enable-gradients: true;
@import "bootstrap";
@import "partials/animation";

@mixin padding-safe($direction) {
padding-#{$direction}: env(safe-area-inset-#{$direction})
}

nav {
$nav-opacity: 0.5;
$nav-begin-color: rgba(38, 143, 255, $nav-opacity);
$nav-end-color: rgba(0, 123, 255, $nav-opacity);
background: $nav-end-color linear-gradient(180deg, $nav-begin-color, $nav-end-color) repeat-x;

.region-label {
padding-left: 10px;
// Hack to avoid using sass max function and instead pass max through to css
padding-left: m#{a}x(10px, env(safe-area-inset-left));
}
}

#forecast-table {
Expand Down Expand Up @@ -51,8 +61,18 @@ nav {
margin-left: 10px;
}

.subregion-container {
margin-top: 44px;
}

.safe-padding {
@include padding-safe(left);
@include padding-safe(right);
}

.spot-header {
$opacity: 0.65;
padding-left: 5px;

&:first-child {
margin-top: 5px
Expand All @@ -63,7 +83,6 @@ nav {
}

a {
margin-left: 18px;
opacity: $opacity;
color: inherit;

Expand All @@ -73,6 +92,10 @@ nav {
}
}

.icon {
margin-left: 18px;
}

img {
height: 26px;
vertical-align: baseline;
Expand Down
4 changes: 2 additions & 2 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ def display_number(value)
end

def map_link(target)
link_to image_tag('map.svg', alt: 'Map Icon'), target, target: 'gmap', title: 'Google Map'
link_to image_tag('map.svg', alt: 'Map Icon'), target, target: 'gmap', title: 'Google Map', class: 'icon'
end

def forecast_link(image_file, service, target, icon_label = nil)
link_to target, target: service, title: "#{service} Forecast Page", class: 'text-dark' do
link_to target, target: service, title: "#{service} Forecast Page", class: 'icon text-dark' do
span_tag = tag.span(icon_label, class: 'forecast-icon-label') if icon_label
image_tag(image_file, alt: "#{service} Logo") + span_tag
end
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/application.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
title= "#{"#{yield(:title)} | " if content_for?(:title)}Meta Surf Forecast"
= csrf_meta_tags
= action_cable_meta_tag
meta name='viewport' content='width=device-width, initial-scale=1, shrink-to-fit=no'
meta name='viewport' content="width=device-width, initial-scale=1, shrink-to-fit=no#{yield(:meta)}"
meta property='og:description' content='Pulls data from Surfline, MagicSeaweed & Spitcast APIs to display an aggregated surf forecast.'
meta property='og:image' content=image_url('wave.jpg')
link rel='apple-touch-icon' href=image_url('wave.png')
Expand Down
7 changes: 4 additions & 3 deletions app/views/subregions/show.html.slim
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
- cache @subregion do
- provide(:title, "#{@subregion.name}, #{@region.name}")
- provide(:meta, ', viewport-fit=cover')

nav.navbar.navbar-light.fixed-top
.row.font-weight-light
span.margin-left.text-light Region:
span.text-light.region-label Region:
select.margin-left onchange='window.location = this.value'
- Region.all.each do |region|
optgroup label=region.name
- region.subregions.each do |subregion|
option value=subregion_path(region, subregion) selected=('selected' if subregion == @subregion) =subregion.name
div style='margin-top: 44px'
.subregion-container.safe-padding
- @forecasts.each do |data, forecast|
h2.font-weight-light.margin-left.spot-header id=data[:slug]
h2.font-weight-light.spot-header id=data[:slug]
span= link_to data[:name], spot_path(@region, @subregion, data[:slug])
= map_link(Spot.map_url(data[:lat], data[:lon]))
= spitcast_link(Spot.spitcast_url(data[:spitcast_slug])) if data[:spitcast_slug]
Expand Down

0 comments on commit 3c48af1

Please sign in to comment.