0.0.0 • Published 6 years ago

container-components v0.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
6 years ago

Container Components

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

Introduction

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

For example

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

Installation

CDN

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

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

NPM

npm install --save container-components

Components

space-container

The space-container 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-container style="background: #eee" p="5" m="5">
    This is a space container
  </space-container>
</div>

Spacing with different sizes

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

image-container

The image-container 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-container
  height="300px"
  width="100%"
  fade
  lazy
  src="media/image.jpg"
></image-container>

Background image (hero)

<image-container
  height="400px"
  width="100%"
  is-background
  overlay
  src="media/image.jpg"
>
  <flex-container 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-container>
</image-container>

grid-container

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

AttributeTypeDefaultDecription
template-columnsstringvar(--grid-container-template-columns, 1fr)Template columns
column-gapstringvar(--grid-container-column-gap, 1rem)Column gap
row-gapstringvar(--grid-container-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-container 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-container>

scroll-container

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

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

Scrolling downwards

<scroll-container 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-container>

Scrolling sideways

<scroll-container 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-container>

modal-container

The modal-container 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-container width="30vw" height="30vh" id="modal-1">
  <h1>Halla</h1>
</modal-container>

Customel is MIT licensed.

0.0.0

6 years ago