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

feat: global default parameters #134

Merged
merged 7 commits into from
Dec 5, 2018
Merged

Conversation

frederickfogerty
Copy link
Contributor

Description

This PR allows developers to set default parameters for every img tag. This prevents them from having to set the same parameters over and over again.

This fixes #129

Steps to test

Review new unit tests.

@frederickfogerty frederickfogerty changed the base branch from master to fred/clean-up November 22, 2018 13:17
Copy link
Contributor

@jayeb jayeb left a comment

Choose a reason for hiding this comment

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

A couple of minor issues, but otherwise looks good. A few larger things, though:

  1. Would love to see some tests for this
  2. Other global settings for imgix.js can be applied via <meta> tags as well, in an attempt to make the library fully configurable with HTML only. Should we apply the same principle here? What do you think?

src/ImgixTag.js Outdated
var params;
var params = {};

if (this.settings.defaultParams) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we type-check this to make sure it's an object?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, I can do this

src/ImgixTag.js Outdated
@@ -49,10 +49,14 @@ var ImgixTag = (function() {
}

ImgixTag.prototype._extractBaseParams = function() {
var params;
var params = {};
Copy link
Contributor

Choose a reason for hiding this comment

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

[nit] Spaces and tabs, my friend... spaces and tabs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@frederickfogerty
Copy link
Contributor Author

frederickfogerty commented Nov 26, 2018

  1. I've added two tests for this in spec/ImgixTagSpec.js - are these sufficient?
  2. I think this is a good idea - I'll update this PR once I've implemented this.

@frederickfogerty frederickfogerty changed the base branch from fred/clean-up to master December 1, 2018 17:33
@frederickfogerty
Copy link
Contributor Author

@jayeb (1) was discussed offline, and I believe I've implemented (2). Could you give this another review?

Copy link
Contributor

@jayeb jayeb left a comment

Choose a reason for hiding this comment

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

Looks good, but there are tab/space issues all over these changes.

src/ImgixTag.js Outdated
@@ -81,7 +83,7 @@ var ImgixTag = (function() {

if (this.settings.includeLibraryParam) {
params.ixlib = 'imgixjs-' + imgix.VERSION;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

[nit] Tabs & spaces, again. Is this perchance a Prettify thing that's breaking down?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Gah! I think it's time to tame the beast and work out what's going on here.

@@ -2,7 +2,8 @@ module.exports = {
// URL assembly
host: null,
useHttps: true,
includeLibraryParam: true,
includeLibraryParam: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

[nit] T&S

* master:
  fix: remove support for value-less search parameters (#135)
@frederickfogerty
Copy link
Contributor Author

@jayeb those pesky space and tab issues should be gone for good now!

@frederickfogerty frederickfogerty merged commit ab42f74 into master Dec 5, 2018
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.

Add default params configuration
2 participants