1.2.8 • Published 1 day ago

@frankhoodbs/image-cmp v1.2.8

Weekly downloads
-
License
ISC
Repository
-
Last release
1 day ago

Image Cmp

A component that allows displaying images optimized for various devices and formats, ensuring that the browser loads the most appropriate image based on its capabilities and the user's device size.

Componente che consente di visualizzare immagini ottimizzate per diversi dispositivi e formati, garantendo che il browser carichi l'immagine più appropriata in base alle sue capacità e alle dimensioni del dispositivo dell'utente.

Version License

API Reference

Props

NameTypeDescription
data-grid-breakpointsRecord<string, string>Required Breakpoint Object.
data-sourcesSource[]Source items, see below.

SourceItem

type definition for each item in data-sources prop

nameTypeDescription
typestringImage format, can be null.
switch_breakpointstringIndicates at which breakpoint the srcset should switch, can be null.
srcsetstringDifferent image to load, based on different type or different breakpoint.

You can use this prop to switch the image at different breakpoints, put at least 2 element, a desktop and a mobile image, the order is important, put the images with the highest breakpoint first and proceed in DESC order.

[
  {
    type: null,
    switch_breakpoint: 'lg',
    srcset: '/image3.png',
  }, // Desktop image
  {
    type: null,
    switch_breakpoint: 'md',
    srcset: '/image2.png',
  }, // Tablet image
  {
    type: null,
    switch_breakpoint: null,
    srcset: '/image1.png',
  }, // Mobile image
]

You can use this prop to load image in different format

[
  {
    type: 'image/avif',
    switch_breakpoint: null,
    srcset: '/image2.png',
  }, // avif
  {
    type: 'image/webp',
    switch_breakpoint: null,
    srcset: '/image1.png',
  }, // webp
]

CSS theme classes

NameDescription
.bg-imageIf present on the component instance the image is treated like a background.
.left-topWorks in combination with .bg-image. Set the object-position.
.left-centerWorks in combination with .bg-image. Set the object-position.
.left-centerWorks in combination with .bg-image. Set the object-position.
.left-bottomWorks in combination with .bg-image. Set the object-position.
.center-topWorks in combination with .bg-image. Set the object-position.
.center-centerWorks in combination with .bg-image. Set the object-position.
.center-bottomWorks in combination with .bg-image. Set the object-position.
.right-topWorks in combination with .bg-image. Set the object-position.
.right-centerWorks in combination with .bg-image. Set the object-position.
.right-bottomWorks in combination with .bg-image. Set the object-position.
.fillWorks in combination with .bg-image. Set the object-fit.
.containWorks in combination with .bg-image. Set the object-fit.
.coverWorks in combination with .bg-image. Set the object-fit.
.noneWorks in combination with .bg-image. Set the object-fit.
.scale-downWorks in combination with .bg-image. Set the object-fit.

Usage/Examples

<image-cmp
  :data-sources="[
    {
      type: null,
      switch_breakpoint: 'lg',
      srcset: 'https://picsum.photos/id/100/1440/800',
    },
    {
      type: null,
      switch_breakpoint: 'md',
      srcset: 'https://picsum.photos/id/101/1024/560',
    },
    {
      type: null,
      switch_breakpoint: null,
      srcset: 'https://picsum.photos/id/102/767/943',
    },
  ]"
  :dataGridBreakpoints="gridBreakpoints"
>
  <img
    width="1440"
    height="800"
    src="https://picsum.photos/id/100/1440/800"
    alt="Demo image"
  />
</image-cmp>
1.2.8

1 day ago

1.2.7

1 day ago

1.2.4

2 days ago

1.2.3

6 days ago

1.2.2

19 days ago

1.2.1

22 days ago

1.2.0

23 days ago

1.1.17

23 days ago

1.1.16

2 months ago

1.1.15

2 months ago

1.1.14

2 months ago

1.1.13

2 months ago

1.1.12

3 months ago

1.1.11

3 months ago

1.1.10

4 months ago

1.1.9

4 months ago

1.1.8

4 months ago

1.1.7

4 months ago

1.1.6

4 months ago

1.1.1

4 months ago

1.1.3

4 months ago

1.1.2

4 months ago

1.0.17

7 months ago

1.0.16

7 months ago

1.0.12

7 months ago

1.0.11

7 months ago

1.0.9

7 months ago

1.0.8

8 months ago

1.0.7

8 months ago

1.0.6

8 months ago

1.0.5

8 months ago

1.0.4

8 months ago

1.0.3

8 months ago

1.0.2

8 months ago

1.0.1

8 months ago

1.0.0

8 months ago