Skip to content

Conversation

@aparlato
Copy link
Collaborator

@aparlato aparlato commented Mar 1, 2022

Closes #9

Creates a module from the diff tool following the format of https://github.com/stamen/mapbox-gl-style-format.

I updated the format of the output to look like the output we get in Maputnik which more clearly references a compare diff than the setStyle properties.

To have parity with the existing tool, I also left the standalone stamen-diff.html in place, and let it reference the old format letting it run without additional changes to keep this work scoped.

🚨 @ebrelsford also I see we're failing copying to S3, but I'm not sure why:
fatal error: An error occurred (InvalidAccessKeyId) when calling the ListObjectsV2 operation: The AWS Access Key Id you provided does not exist in our records. Did our credentials change since this repo last had changes? I don't see anything here that should cause this and I pushed a test branch that's identical to master and that failed as well.

Followup

Right now, as mentioned, the standalone compare tool is using the old formatted output of the diff function. We should update it to use the latest format for clarity and further work.

Also, the format from diff.js gets updated by an additional function appended to diff.js for the sake of simplicity/keeping this work scoped small (that function is now named diffStyles and the previous output comes from diffStylesSetStyle), but ideally we'd remove this additional formatting function and just update the rest of the diffing function code to output to this format without further alteration.

Let me know if we want to handle either of these followups in this PR or if they make sense to address after as lower priority. Also, I feel like the standalone tool seems fine to leave in here, but we might consider another home for it on the consumer or at least excluding it from the module.

}

// Added this function to change the output format to be more helpful
const diffStyles = (before, after) => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Noting that this last function is the only change in this file (other than being moved). It formats the output we were getting to be more helpful.

</script>
</html>
<script src="https://d3js.org/d3.v4.min.js"></script>
<script src="src/lib/diff.js"></script>
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The only thing in this file that changed is the path on this script tag and removing sampleSet.js which I don't think we need. Prettier reformatted the file, but I'm happy to revert formatting if you prefer.

Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like we should load the built version of the tool (dist/main.js) instead, otherwise the formatting is great.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This makes sense although I'm getting this error on trying to import from there:
image

Then if I use dist/module.js it only works if I specify the built function name: $cc04822511c4cad9$var$diffStylesSetStyle as opposed to diffStylesSetStyle

Should I go ahead with that ☝️ or do you think there's a better way?

We could also leave this script reference as-is and build the viewer into dist too with a parcel script: serve: parcel stamen-diff.html . This will build the viewer into our dist dir as well with module references (although these appear to be redundant).

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah okay, that's fair. Let's leave this be for now in favor of the follow-up issues.

@aparlato aparlato changed the title [WIP] Create module Create module Mar 1, 2022
@aparlato aparlato marked this pull request as ready for review March 1, 2022 22:07
@aparlato aparlato requested a review from ebrelsford March 1, 2022 22:07
@ebrelsford
Copy link
Contributor

I see we're failing copying to S3, but I'm not sure why [...] Did our credentials change since this repo last had changes?

Yes they did change! As mentioned in #11 I think we need to re-work how deploying this tool works, it's safe to ignore these checks for the moment.

Copy link
Contributor

@ebrelsford ebrelsford left a comment

Choose a reason for hiding this comment

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

This is a great start, thanks for putting it together! I have a small tweak around how we load the JS in the viewer, otherwise let's get this in place.

</script>
</html>
<script src="https://d3js.org/d3.v4.min.js"></script>
<script src="src/lib/diff.js"></script>
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like we should load the built version of the tool (dist/main.js) instead, otherwise the formatting is great.

@ebrelsford
Copy link
Contributor

I'd like to propose these follow-up issues:

  • remove the GitHub Action that copies this to S3
  • move the viewer to its own repo (mapbox-gl-style-diff-viewer?)
  • (in the new repo) update the viewer to use the new diff format as you suggest @aparlato
  • (in the new repo) write instructions for bringing the viewer into your project and deploying it

@ebrelsford ebrelsford self-requested a review March 4, 2022 22:01
Copy link
Contributor

@ebrelsford ebrelsford left a comment

Choose a reason for hiding this comment

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

Let's merge this and create follow-up issues.

@aparlato aparlato merged commit 9085503 into master Mar 7, 2022
@aparlato aparlato deleted the create-module branch March 7, 2022 15:37
@aparlato aparlato mentioned this pull request Apr 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Turn this repo into module

3 participants