Skip to content
This repository has been archived by the owner on Nov 10, 2020. It is now read-only.

IE SVG map fixes #1424

Merged
merged 32 commits into from
May 19, 2016
Merged

IE SVG map fixes #1424

merged 32 commits into from
May 19, 2016

Conversation

shawnbot
Copy link
Contributor

@shawnbot shawnbot commented May 18, 2016

😅 Preview on Federalist

This wraps up #1403 with some IE11-specific SVG fixes, specifically:

  1. We've included a fork of svg4everybody, which shims support for SVG "external resources" (referenced by the <use> element) in older/non-compliant browsers. Caveats:
    • For now we're referencing our forked branch in package.json, but we've opened an upstream pull request with our first round of improvements, and will be filing another one if that one is merged.
  2. We've implemented the padding hack with some base CSS and a svg_viewbox_padding template filter, which you can see in action in state, county, and land ownership maps. Caveats:
    • This particular method is by no means a "final" solution, because currently it requires us to mirror the non-100 width percentages in both the CSS and the templates, which is 💩 . More research is needed to find a more sustainable way of handling this, or if we can get away with simply setting the percentage widths on an outer element.
    • For now I've done away with the Chrome-specific technique of using CSS padding to add a "buffer" around the bounds of our zoomed in maps, because it doesn't work in any of the other browsers I've tested. I'm looking for another way to do this, but for now we'll either have to 1) be okay with the bounds of states running right up to the edge of state maps, or 2) go back to buffering the viewBox values in our SVG generation scripts.
  3. I also fixed a naming collision with an IE-specific table element property, cells, in the bar chart component. These now work in IE11, too!

# if we get a string, split it into 4 parts and map its strings to floats
# (otherwise we'll get integer precision in the division below)
if viewBox.is_a? String
viewBox = viewBox.split(" ").map{ |n| n.to_f }

Choose a reason for hiding this comment

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

Space missing to the left of {.
Pass &:to_f as an argument to map instead of a block.
Use snake_case for variable names.

Choose a reason for hiding this comment

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

Space missing to the left of {.
Pass &:to_f as an argument to map instead of a block.
Use snake_case for variable names.

# (otherwise we'll get integer precision in the division below)
if viewBox.is_a? String
viewBox = viewBox.split(" ").map{ |n| n.to_f }
elsif not viewBox.is_a? Array

Choose a reason for hiding this comment

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

Use ! instead of not.

Choose a reason for hiding this comment

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

Use ! instead of not.

# if we get a string, split it into 4 parts and map its strings to floats
# (otherwise we'll get integer precision in the division below)
if viewbox.is_a? String
viewbox = viewbox.split(' ').map(&:to_f)

Choose a reason for hiding this comment

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

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

border: 1px solid $mid-gray;
}

table .numeric {

Choose a reason for hiding this comment

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

Merge rule table .numeric with rule on line 1

@shawnbot
Copy link
Contributor Author

@gemfarmer do you have opinions on the liberal whitespace around the plugin module definitions? Hound's default Ruby lint config doesn't seem to like them, but I'm not up on the linter that it uses. I don't even know how to run the linter locally... 😬

@shawnbot shawnbot mentioned this pull request May 19, 2016
4 tasks
@gemfarmer
Copy link
Contributor

@shawnbot I'm not too worried about the whitespace in those plugins. Glad you found the bar issue too!

Merging!

@gemfarmer gemfarmer merged commit 71bdf5b into state-pages May 19, 2016
@gemfarmer gemfarmer deleted the ie-svg-fix branch May 19, 2016 15:09
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants