1.5.2 • Published 6 years ago

z-card v1.5.2

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

z-card

Build SemVer License

A block container component to organize your web app. It is useful as a widget that can display brief information and perform related actions.

Table of contents

Install

The package is available to download through npm:

npm install z-card --save

Import as HTML/CSS component

The simple case

The package will be located inside the node_modules folder, you can import it into the HTML document as follows:

<link rel="stylesheet" href="node_modules/z-card/dist/style.css">

When bundling an web app

For bundlers that support CSS, like Webpack, you can use it like this:

require('z-card/dist/style.css');

Import as a Stateless Functional Component (SFC)

The package does not include the renderer, you can use any renderer that supports SFCs. You could use React, Preact, Inferno, etc.

Notice: This package contains CSS styling, you may need a bundler that's capable of requiring CSS files like Webpack with css-loader.

Once you have chosen the renderer you can include the package in your project as follows:

// Assuming the React renderer is being used
const React = require('react');
const render = require('react-dom').render;

// Passing the render function when importing
const ZCard = require('z-card')(React.createElement);

// Render it on page, using JSX here :)
render(<ZCard header={'Title'} content={'Card content'} footer={'Footer'} />, document.body);

How to use

CSS component

Just add the HTML structure and CSS classes to reproduce the UI component.

Class hierarchy

Recommended HTML tagsParentClassDescriptionType
div, section, main, articleroot.z-cardRoot containerBlock
div, section.z-card.z-card__headerThe header of the card, what's going to render before the contentElement
div, section.z-card.z-card__contentThe content of the card, where the main information should beElement
div, section.z-card.z-card__footerThe footer of the card, a good place to state the available actionsElement
Any containing .z-cardroot.z-card--borderedAdds a border to the cardModifier
Any containing .z-cardroot.z-card--animatedAnimate elevation changesModifier
Any containing .z-cardroot.z-card--flatRemoves the card shadowModifier
Any containing .z-cardroot.z-card--elevated-** can be 1 to 5. Higher the number, bigger the shadowModifier

Full working example:

<div class="z-card">
  <div class="z-card__header">Title</div>
  <div class="z-card__content">Content</div>
  <div class="z-card__footer">Footer</div>
</div>

Stateless Functional Component

Render the HTML by using the SFC and passing props.

Supported Props

Prop nameExpected TypeDescription
headerAn HTMLElement or a TextNodeThe header of the card, what's going to render before the content
contentAn HTMLElement or a TextNodeThe content of the card, where the main information should be
footerAn HTMLElement or a TextNodeThe footer of the card, a good place to state the available actions
borderedbooleanSet to true to add a border to the card
animatedbooleanSet to true to turn on animations for elevation changes
flatbooleanSet to true to make the card flat, removing the shadows
elevationnumber, 1 to 5Set the elevation of the card, the spread of the shadow

Full example (JSX):

<ZCard header={'Title'} content={'Content'} footer={'Footer'} />

LICENSE

MIT

1.5.2

6 years ago

1.5.1

6 years ago

1.5.0

6 years ago

1.4.0

6 years ago

1.3.0

6 years ago

1.2.0

6 years ago

1.1.0

6 years ago

1.0.1

8 years ago

1.0.0

8 years ago