JSFiddle - React, Tailwind, and code Playground

by kryo

HTML

<script src="http://dev.sencha.com/deploy/ext-4.0.0/bootstrap.js"></script>
<link rel="stylesheet" href="http://dev.sencha.com/deploy/ext-4.0.0/resources/css/ext-all.css">
<div id="placeholder"></div>

CSS

.signature {
  padding: 5px;
  border: 1px solid black;
  margin: 10px;
}
.signature a {
  color: #505050;
  text-decoration: none;
}
.signature a:hover {
  color: black;
  text-decoration: underline;
}
.signature .name {
  font-size: 1.5em;
}
.signature .department{
  font-size: 0.8em;
  font-style: italic;
}
.signature .phone {
  color: silver;
  margin: 5px 0 0 5px;
}
.signature .phone .number {
  color: black;
  display: inline-block;
  margin-right: 5px;
}
.signature .email {
  color: silver;
  margin: 5px 0 0 5px;
}
.signature .email .address {
  color: gray;
  display: inline-block;
  margin-right: 5px;
}

/* dynamic content management */
.signature .phone:before { content: '#: '; }
.signature .email:before { content: '@: '; }
.signature .phone .number:after,
.signature .email .address:after { content: ','; }
.signature .phone .number.last:after,
.signature .email .address.last:after { content: ''; }

JavaScript

Ext.define('Ext.ux.Signature', {
  
  // new ExtJs 4 method for defining objects
  extend: "Ext.Component",
  alternateClassName : 'Ext.Signature',

  // these are the signature configurations
  config: {
    name: '',
    department: '',
    phoneNumbers: [],
    emailAddresses: []
  },

  // define our template right here (to allow extensions)
  signatureTpl: [
  '<div class="signature">',
    '<div class="name">{name}</div>',
    '<div class="department">{department}</div>',
    '<ul class="phone">',
      '<tpl for="phoneNumbers">',
      '<li class="number{[xindex === xcount ? " last" : ""]}">{number} ({rel})</li>',
      '</tpl>',
    '</ul>',
    '<ul class="email">',
      '<tpl for="emailAddresses">',
      '<li class="address{[xindex === xcount ? " last" : ""]}"><a href="mailto:{.}">{.}</a></li>',
      '</tpl>',
    '</ul>',
  '</div>'
  ],
    
  constructor: function(c){

    // call superclass constructor method
    this.callParent(arguments);

    // add event support into our class
    this.addEvents(['beforereload','reload']);
    // initialize our config from arguments, this is an Ext.define helper method
    this.initConfig(c);

    // (re)load the signature template
    this.reloadTemplate();
      
    return this;
  },
    
  reloadTemplate:  function(){

    // initialize our template, store in private variable to be recycled
    this._signatureTemplate = Ext.isObject(this.signatureTpl) ?
                                this.signatureTpl:
                                new Ext.XTemplate(this.signatureTpl);

    // compile the template to save on multiple iterations
    this._signatureTemplate.compile();

    // (re)load the signature template's data and container body
    this.reload();
  },

  reload : function() {

    // define default signature variables.
    var signatureVars = {
      name: this.getName(),
      department: this.getDepartment(),
      phoneNumbers: this.getPhoneNumbers(),
      emailAddresses:...