@s-ui/react-card-subscription

1.15.0 • Public • Published

CardSubscription

SUI CardSubscription component is a card with a title, an image, an input and a button.

By submitting the form, a handler is triggered via prop and receives the input value. In case of responseError, the component will render the responseContent next to the form and will flag the input with class has-error. Otherwise responseContent will replace the component.

Installation

$ npm install --save @s-ui/react-card-subscription

Usage

import React, { Component } from 'react'
import CardSubscription from '@s-ui/react-card-subscription'
const errorEmail = 'error@test.com'
const placeholder = 'Escribe tu email'
const title = 'Recibe todas las novedades'

const responseOk = () => (
  <p style={successStyles}>Hello! This is a success message</p>
)

const responseKo = () => (
  <p style={errorStyles}>This is an error message</p>
)



class MyCardSubscription extends React.Component {
  constructor (...args) {
    super(...args)
    this.state = {
      responseContent: null
    }
  }

  _handleSubmit = (value) => {
    this.setState({
      responseContent: value === errorEmail ? responseKo : responseOk,
      responseError: value === errorEmail
    })
  }

  render () {
    return (
      <div>
        <CardSubscription
          iconButton={ArrowRight}
          onSubmit={this._handleSubmit}
          placeholder={placeholder}
          responseContent={this.state.responseContent}
          responseError={this.state.responseError}
          title={title}
        />
      </div>
    )
  }
}

return (<MyCardSubscription />)

Readme

Keywords

none

Package Sidebar

Install

npm i @s-ui/react-card-subscription

Weekly Downloads

2

Version

1.15.0

License

ISC

Unpacked Size

19.9 kB

Total Files

9

Last publish

Collaborators

  • thomas.page.ext
  • victoria.pasichnyk.ext
  • daniel.perez.ext
  • albert.peiro
  • frandelacasa-adevinta
  • mariapaula.forero.ext
  • hpintos_adevinta
  • sziauberyte
  • victor.perez.adevinta
  • oscar-raig-adevinta
  • carlos.gonzalezl
  • carolina.mallo.ext
  • david.nieto
  • ferran.simon
  • xavi_conejo
  • sergi.quintela
  • jamile.radloff
  • xavi_ballestar
  • luz_adv
  • ignacio.rodriguez
  • carlosvillu-adevinta
  • diegomr
  • arturo.vicente
  • adria.velardos
  • emiliovz
  • dann41
  • ruben-martin
  • pol.valls
  • cristina.rodriguez.duque
  • sergio.escano
  • marc.benito
  • azahara
  • patricio.sartore
  • giovanny.sayas.ext
  • david.cuadrado.ext
  • alex.castells
  • beatrizip
  • pablo.rey-adevinta
  • sergiocollado
  • mango.sanchezredondo
  • cristhianb
  • alisa_bayanova
  • davidmartin2108
  • ferrangbtw
  • estefania_garcia
  • belen.santos
  • alfredo.arronte
  • joanleon-adv
  • giodelabarrera.adevinta
  • luis-garrido
  • aitor.rodriguez
  • jordi.munoz
  • oscar_ramirez
  • ignacio_navarro
  • a.ferrer
  • gfabregoadv
  • izeller
  • salvador.juan
  • oriol.egea
  • ivanmlaborda
  • alejandro.ferrante
  • pa.chruscinski.ext
  • isabelgomez87
  • jenifer.lopez
  • daniela.aguilera
  • pablogs
  • javier.miguel
  • oscar.gomez
  • marian.lucaci
  • alverd004
  • oriol.puig
  • nacho_torrella
  • xavi.murcia
  • chloe.leteinturier
  • javiauso
  • alfredo.zimperz
  • francisco.ruiz.lloret
  • fermin.adevinta
  • andresadv
  • schibstedspain