Skip to content

Instantly share code, notes, and snippets.

@kenny-io

kenny-io/Tag.js Secret

Created May 11, 2022 11:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kenny-io/7619609cbb36be5f12f3b4eb15e0af5c to your computer and use it in GitHub Desktop.
Save kenny-io/7619609cbb36be5f12f3b4eb15e0af5c to your computer and use it in GitHub Desktop.
import { Cloudinary, Transformation } from "@cloudinary/url-gen";
import { AdvancedImage } from "@cloudinary/react";
import { source } from "@cloudinary/url-gen/actions/overlay";
import { image, text } from "@cloudinary/url-gen/qualifiers/source";
import { scale } from "@cloudinary/url-gen/actions/resize";
import { Position } from "@cloudinary/url-gen/qualifiers";
import { compass } from "@cloudinary/url-gen/qualifiers/gravity";
import { TextStyle } from "@cloudinary/url-gen/qualifiers/textStyle";
import { byRadius } from "@cloudinary/url-gen/actions/roundCorners";
import { brightness } from "@cloudinary/url-gen/actions/adjust";
export default function Tags({ formData }) {
const { name, role, avatar } = formData;
const cld = new Cloudinary({
cloud: {
cloudName: "kennyy",
},
});
let baseImage = cld.image(`base-tag`);
baseImage.overlay(
source(
image(`${avatar}`).transformation(
new Transformation()
.resize(scale().width(400).height(400))
.roundCorners(byRadius(230))
.adjust(brightness(5))
)
).position(new Position().gravity(compass("center")).offsetY(-50))
);
baseImage.overlay(
source(
text(`${name}`, new TextStyle("Nunito", 65)).textColor("white")
).position(new Position().gravity(compass("center")).offsetY(210))
);
baseImage.overlay(
source(
text(`${role}`, new TextStyle("Nunito", 70)).textColor("purple")
).position(new Position().gravity(compass("center")).offsetY(350))
);
return (
<div className="mt-5">
<AdvancedImage cldImg={baseImage} />
</div>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment