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(core): create Image component #26

Merged
merged 14 commits into from
Sep 23, 2022
Merged

feat(core): create Image component #26

merged 14 commits into from
Sep 23, 2022

Conversation

ojvribeiro
Copy link
Owner

@ojvribeiro ojvribeiro commented Sep 7, 2022

Resolves #24.

This component is indented to use in static image files located in the assets/img folder. When the user runs npm run dev (or yarn dev), those images in that folder will be automatically optimized and a WebP version will be created. The Image component will be responsible for replacing the original image src with the optimized one:

<Image src="path/to/image.jpg" />

will generate...

<img src="path/to/optimized/image@[size].webp" alt="Image" title="" width="" height="" loading="lazy" />

You also have the option to disable the WebP version (enabled by default) with the webp attribute set to false.

<Image src="path/to/image.jpg" webp="false" />

will generate...

<img src="path/to/optimized/image@[size].jpg" alt="Image" title="" width="" height="" loading="lazy" />

Features

  • Lazy loading based on viewport visibility
  • Load adequate image intrinsic size depending on the image rendered size
  • SEO friendly by default, with default alt, title, width and height attributes
  • Auto optimization and WebP convertion on build time.

@ojvribeiro ojvribeiro added the enhancement New feature or request label Sep 7, 2022
@ojvribeiro ojvribeiro self-assigned this Sep 7, 2022
@ojvribeiro ojvribeiro changed the title Created Image component for assets feat(core): create Image component Sep 7, 2022
@ojvribeiro ojvribeiro merged commit c6aa925 into main Sep 23, 2022
@ojvribeiro ojvribeiro deleted the feat-image-component branch September 23, 2022 09:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Image component
1 participant