npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@schibstedspain/sui-card

v7.2.2

Published

The SUI-Card component features a placeholder to portray a custom primary and a secondary content. So you can set an image, slider or any media component in one and some other content in the other.

Downloads

83

Readme

Sui-card React Component

The SUI-Card component features a placeholder to portray a custom primary and a secondary content. So you can set an image, slider or any media component in one and some other content in the other.

Demo page

  • Check out a Sui-Card component demo here.

Usage

The SUI-Card allows to pass custom content in the primary placeholder and also provides a sui-Card-primary class as a wrapper. This primary content is required.

Secondary content might be passed or not to SuiCard component. If content is provided will be rendered inside a generic div sui-Card-secondary wrapper. If no content is provided this contained will not be rendered at all.

Check out this example below


ReactDom.render(
    <SuiCard className={'myCustom-class'}
      primary={
        <a href={images[0].link}><img src={images[0].src} /></a>
      }
      secondary={[
        <div>
            <h2 className='sui-Card-title'>
            This is the Card Title
            </h2>
            <p className='sui-Card-description'>
                This is the description
            </p>
        </div>
      }
    />,
  document.getElementById('main')
);

Setting a custom className

The div Card wrapper has a default sui-Card class. You can override it defining a custom class by setting the proptype className as follows:

ReactDom.render(
    <SuiCard className={'myCustom-class'}
      primary={
        <a href={images[0].link}><img src={images[0].src} /></a>
      }
      secondary={[
        <div>
            <h2 className='sui-Card-title'>
            This is the Card Title
            </h2>
            <p className='sui-Card-description'>
                This is the description
            </p>
        </div>
      }
    />,
  document.getElementById('main')
);

Card layout Orientation

The default Card orientation is portrait mode. Use the landscapeLayout={true} parameter to set it landscape where the primary placeholder aligns to the left and the secondary to the right:


ReactDom.render(
    <SuiCard landscapeLayout
      primary={
        <a href={images[0].link}><img src={images[0].src} /></a>
      }
      secondary={[
        <div>
            <h2 className='sui-Card-title'>
                This is the Card Title
            </h2>
            <p className='sui-Card-description'>
                This is the description
            </p>
        </div>
      }
    />,
  document.getElementById('main')
);

Content First Property

When landscapeLayout={true} you can also set secondary content placeholder rendered before primary by setting contentFirst={} to true:


ReactDom.render(
    <SuiCard landscapeLayout contentFirst
      primary={
        <a href={images[0].link}><img src={images[0].src} /></a>
      }
      secondary={[
        <div>
          <h2 className='sui-Card-title'>
          This is the Card Title
          </h2>
          <p className='sui-Card-description'>
          This is the description
          </p>
        </div>
      }
    />,
  document.getElementById('main')
);

Data model used in this example

Use an array of objects:

const images = [{
  src: 'https://scontent-mad1-1.cdninstagram.com/t51.2885-15/e15/11199623_633712610062793_1285693904_n.jpg',
  type: 'image',
  alt: 'Test',
  link: 'https://www.instagram.com/p/TNUdPKpMgM/?taken-by=davecarter'
}];

Installation

To run the component and play with the examples you have to:

Download files from GitHub repo.

  • $ git clone https://github.com/scm-spain/sui-card
  • $ cd sui-card

Install dependencies.

  • $ npm install // Install npm dependencies from package.json

Launch the development environment.

  • $ npm run dev // Run development environment
  • Go to localhost:8080

Bundle

In order to generate the bundle including all React dependencies and the component logic we need to bundle a single JS file running the following command:

$ npm run build

Testing

Execute a complete test by running:

There are two options for executing tests:

* Single mode: `$ npm test`
* Watch mode: `$ npm run test:watch`


## Linting

Linting

We rely on SCSS Lint for , you can run specific test for linting JS and SASS: SASS: (SASS linting rules specified in file .scss-lint.yml)

$ npm run lint:sass

NPM

The SUI-Card component is available as a NPM package here:

npm install @schibstedspain/sui-card