0.0.2 • Published 5 years ago

wrappers.js v0.0.2

Weekly downloads
1
License
ISC
Repository
-
Last release
5 years ago

Wrappers.js

A collection of invisible components to do the dirty work for you

Introduction

wrapper Components is a collection of invisible elements you can wrap around your HTML.

For example

<grid-wrapper template-columns="1fr 1fr 1fr">
  <space-wrapper p="5" style="background: #eee">Grid Column</space-wrapper>
  <space-wrapper p="5" style="background: #eee">Grid Column</space-wrapper>
  <space-wrapper p="5" style="background: #eee">Grid Column</space-wrapper>
</grid-wrapper>

Installation

CDN

Create an index.html file and include Customel with the CDN:

<script src="https://unpkg.com/wrapper-components"></script>

NPM

npm install --save wrapper-components

Components

space-wrapper

The space-wrapper is an easy way to implement spacing.

AttributeTypeDefaultDecription
pnumbervar(--space-0, 0)Padding
pxnumbervar(--space-0, 0)Padding left and right
pynumbervar(--space-0, 0)Padding top and bottom
plnumbervar(--space-0, 0)Padding left
plnumbervar(--space-0, 0)Padding left
ptnumbervar(--space-0, 0)Padding top
pbnumbervar(--space-0, 0)Padding bottom

Spacing with equal padding and margin

<div class="margin-helper">
  <space-wrapper style="background: #eee" p="5" m="5">
    This is a space wrapper
  </space-wrapper>
</div>

Spacing with different sizes

<div class="margin-helper">
  <space-wrapper
    style="background: #eee"
    px="2"
    py="3"
    ml="4"
    mr="2"
    mt="3"
    mb="5"
  >
    This is a space wrapper
  </space-wrapper>
</div>

image-wrapper

The image-wrapper is an enhanced version of the img tag.

AttributeTypeDefaultDecription
lazybooleanfalseLoad the image lazily
loadedbooleanfalseGets updated to true when image is loaded
fadebooleanfalseFade in the image when loaded
srcstringThe URL of the image src
object-fitstringcoverThe object fit of the image
widthstring100%The width of the image. Can use with breakpoints.
heightstring100%The width of the image. Can use with breakpoints.
altstringAlt text to the image.
is-backgroundbooleanfalseUse a div with background-image instead of an img with src
overlaybooleanfalseOverlay image with a darker shade so it's easier to put text on

Lazy loading

<image-wrapper
  height="300px"
  width="100%"
  fade
  lazy
  src="media/image.jpg"
></image-wrapper>

Background image (hero)

<image-wrapper
  height="400px"
  width="100%"
  is-background
  overlay
  src="media/image.jpg"
>
  <flex-wrapper justify-content="center" align-items="center" align="center">
    <div style="color: white">
      <h1>The most awesome hero title</h1>
      <p>Subtitle about something</p>
    </div>
  </flex-wrapper>
</image-wrapper>

grid-wrapper

The grid-wrapper is an easy way to implement a grid system.

AttributeTypeDefaultDecription
template-columnsstringvar(--grid-wrapper-template-columns, 1fr)Template columns
column-gapstringvar(--grid-wrapper-column-gap, 1rem)Column gap
row-gapstringvar(--grid-wrapper-row-gap, 1rem)Row gap

Because default values are css variables, you can also choose to use css instead of writing the values inline as attributes.

Grid with gap

<grid-wrapper column-gap="100px" row-gap="50px">
  <div style="background: #eee">Grid Column</div>
  <div style="background: #eee">Grid Column</div>
  <div style="background: #eee">Grid Column</div>
</grid-wrapper>

scroll-wrapper

The scroll-wrapper is an enhanced version of the img tag.

AttributeTypeDefaultDecription
template-columnsstringvar(--grid-wrapper-template-columns, 1fr)Template columns
column-gapstringvar(--grid-wrapper-column-gap, 10px)Template columns

Scrolling downwards

<scroll-wrapper max-height="150px" y>
  Lorem Ipsum is simply dummy text of the printing and typesetting industry.
  Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,
  when an unknown printer took a galley of type and scrambled it to make a type
  specimen book. It has survived not only five centuries, but also the leap into
  electronic typesetting, remaining essentially unchanged. It was popularised in
  the 1960s with the release of Letraset sheets containing Lorem Ipsum passages,
  and more recently with desktop publishing software like Aldus PageMaker
  including versions of Lorem Ipsum.
</scroll-wrapper>

Scrolling sideways

<scroll-wrapper max-width="150px" x>
  Lorem Ipsum is simply dummy text of the printing and typesetting industry.
  Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,
  when an unknown printer took a galley of type and scrambled it to make a type
  specimen book. It has survived not only five centuries, but also the leap into
  electronic typesetting, remaining essentially unchanged. It was popularised in
  the 1960s with the release of Letraset sheets containing Lorem Ipsum passages,
  and more recently with desktop publishing software like Aldus PageMaker
  including versions of Lorem Ipsum.
</scroll-wrapper>

modal-wrapper

The modal-wrapper is an enhanced version of the img tag.

AttributeTypeDefaultDecription
showbooleanfalseOpen the modal

Simple modal

<button onclick="document.getElementById('modal-1').show = true">
  Open modal
</button>

<modal-wrapper width="30vw" height="30vh" id="modal-1">
  <h1>Halla</h1>
</modal-wrapper>

Customel is MIT licensed.

0.0.2

5 years ago

0.0.1

5 years ago

0.0.0

5 years ago