2.0.0 • Published 1 year ago

@gvrs/gatsby-transformer-image-mask v2.0.0

Weekly downloads
-
License
MIT
Repository
gitlab
Last release
1 year ago

@gvrs/gatsby-transformer-image-mask

npm (scoped) NPM PRs Welcome

Refine edges of placeholders with transparent parts

Configuration

// In your gatsby-config.js
module.exports = {
  plugins: [
    `gatsby-plugin-image`,
    `gatsby-plugin-sharp`,
    `gatsby-transformer-sharp`,
    `@gvrs/gatsby-transformer-image-mask`,
  ],
};

Usage example

Fetching data

imageSharp {
  gatsbyImageData
  imageMask {
    base64
  }
}

Rendering

import { GatsbyImage } from "gatsby-plugin-image";
import styled from "@emotion/styled";

const GatsbyImageWithMask = styled(GatsbyImage)`
  & [data-placeholder-image] {
    mask-image: url("${(props) => props.mask}");
    mask-size: "contain";
    mask-position: "center center";
    mask-repeat: "no-repeat";
  }
`;

const Image = ({ gatsbyImageData, imageMask }) => (
  <GatsbyImageWithMask image={gatsbyImageData} mask={imageMask.base64} />
);

Returns

  • base64 (string) — base 64 encoded svg mask

Additional documentation

See also

2.0.0-next.2

1 year ago

2.0.0-next.1

1 year ago

2.0.0

1 year ago

1.0.2-next.1

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.1-next.1

2 years ago

1.0.0

2 years ago

1.0.0-next.2

2 years ago

1.0.0-next.1

2 years ago