Skip to content

Commit

Permalink
feat: rename noUseAspectRatio to no_ratio, update logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Morse committed Feb 6, 2019
1 parent 8267ce0 commit 9b7191b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/components/bolt-image/image.schema.yml
Expand Up @@ -40,7 +40,7 @@ properties:
enum:
- true
- false
noUseAspectRatio:
no_ratio:
type: boolean
description: Override the default useAspectRatio behavior. Used only on the web component, where the presence of a boolean property always equates to `true`.
default: false
Expand Down
6 changes: 3 additions & 3 deletions packages/components/bolt-image/src/image.js
Expand Up @@ -29,7 +29,7 @@ class BoltImage extends withLitHtml() {
noLazy: props.boolean,
srcset: props.string,
sizes: props.string,
noUseAspectRatio: props.boolean,
noRatio: props.boolean,
width: props.string,
height: props.string,
zoom: props.boolean,
Expand Down Expand Up @@ -93,15 +93,15 @@ class BoltImage extends withLitHtml() {
noLazy,
srcset,
sizes,
noUseAspectRatio,
noRatio,
width,
height,
zoom,
} = this.validateProps(this.props);

// negate and rename variables for readability
const lazyload = !noLazy;
const useAspectRatio = !noUseAspectRatio;
const useAspectRatio = !noRatio;

const imageExt = path.extname(src);
const imageData = this.getImageData(src);
Expand Down
4 changes: 2 additions & 2 deletions packages/components/bolt-image/src/image.twig
Expand Up @@ -22,7 +22,7 @@

{% set alt = alt ? alt : null %}

{% if ratio is defined and ratio == false %}
{% if (ratio is defined and ratio == false) or no_ratio %}
{% set useAspectRatio = false %}
{% endif %}
{% set useAspectRatio = useAspectRatio ?? true %}
Expand Down Expand Up @@ -94,7 +94,7 @@
{% if sizes %}sizes="{{ sizes }}"{% endif %}
{% if width %}width="{{ width }}"{% endif %}
{% if height %}height="{{ height }}"{% endif %}
{% if useAspectRatio %}use-aspect-ratio{% endif %}
{% if not useAspectRatio %}no-ratio{% endif %}
{% if zoom %}zoom{% endif %}
{% if not lazyload %}no-lazy{% endif %}
{% if placeholder_color and ext == "jpg" %} style="background-color: {{ placeholder_color }};" {% endif %}
Expand Down

0 comments on commit 9b7191b

Please sign in to comment.