Block Group

  • It will repeat the blocks.

Features/Functionality

  • Click and hover functionality on each block.
  • It will repeat in horizontal direction but if the options.isVertical is true, it will change the direction.
  • In small screen, direction will be vertical by default.
  • Click event callback will called on click.
  • Component is responsive.
  • It is cross browser compatible. (IE11, Edge, Firefox, chrome).

Basic Usage

Dependency

  • jquery
  • shared styles
  • shared scripts

HTML Structure

<require from="{user_path}/block_groups/block_group"></require>
<cst-block-group items.bind="{items}" input-id.bind="{inputId}" readable-item.bind="{readableItem}" options.bind="{options}" other-info.bind="{otherInfo}" ext-disabled.bind="{disabled}" evt-click-callback.bind="{evtClickCallback}"></cst-block-group>

Bindable Properties

PropertyData TypeRequiredDescription
itemsarrayYesData to be passed to component.
inputIdstring/intNoSelected value's id will be set in inputId. It is two way communication property. Once the data sent will be set, then whatever selected value changes page can get it.(Data type as per optins.propId)
readableItemobjectNoTo get selected value in this object. Inisially bind this object as empty.
optionsobjectNoBasic component options
otherInfoanyNoExtra info to be passed on event
extDisabledbooleanNoDisables any functionality on component.
evtClickCallbackmethodNoMethod to be called on click event.

Structure of bindable properties

items

items = [
{
id: '', // id is required
label: ''
},...
]

readableItem

readableItem = {} // If we want selected value in this object, pass it as empty

options

options = {
propId: '', // This is the key of items object, which we consider as id. Default value = 'id'.
propLabel: '', // This is the key of items object, which we consider as label. Default value = 'label'.
isVertical: '', // Default block repeat direction is left to right. If value is true, repeat direction will be top to bottom.
pageLabel: {}, // Override page labels
pageColorData: {} // Override css colour porperty
}

evtClickCallback

evtClickCallback(_event,_info);
_info = {
overrideContext: overrideContext,
otherInfo: otherInfo,
value: item
}

CSS Overrinding

  • Following classes are given to override CSS:
    • .cst-block-group-container-override : Container Class
    • .cst-block-group-element-override: Element Class

Note

  • While giving the classes in page, give them in nested structure.

Rules

  • Bind events with jquery if bind method is given.
  • Use disabled property as external property so that change can be handled.
  • Do not use classes as bindable properties, Instead give a class overridable class name to div which we want to override and in page give the class inside the component div.
  • Always keep overridable, id and label property in options.
  • In Js file, the bindable properties names are changed.

Component measurements

Image of measurements

** box-sizing: border-box is used. So width and height will be dimensions + padding.

Working Example

HTML

<template>
<require from="./components/block-groups/block-groups"></require>
<div>
<cst-block-group items.bind="items" input-id.bind="inputId" readable-item.bind="readableItem" options.bind="options" other-info.bind="otherInfo" ext-disabled.bind="disabled" evt-click-callback.bind="evtClickCallback"></cst-block-group>
</div>
</template>

CSS

.cst-ex-block {
.cst-block-group-element-override {
width: 80px !important;
height: 40px !important;
background-color: white !important;
color: blue !important;
}
.cst-block-group-container-override{
justify-content: center !important;
}
}

JS

class MyCls{
constructor(){
this.otherInfo = {
qId : '1'
}
this.items = [
{
key: 1,
value: 'Poor'
},
{
key: 2,
value: 'Good'
},
{
key: 3,
value: 'Excellent'
}
];
this.inputId = '';
this.options = {
propId: 'key', // If items object's property is not id
propLabel: 'value' // If items object's property is not label
};
this.disabled = false;
this.readableItem = {};
}
evtClickCallback(_event,_info){
console.log(_event);
console.log(_info);
}
}
export { MyCls }

Example Screen Shots

Desktop

  • If isVertical = false and disabled

Image of Ex

  • If isVertical = true

Image of Ex


IE Desktop

  • If isVertical = false and disabled

Image of Ex

  • If isVertical = true

Image of Ex


Tab

  • If isVertical = false and disabled

Image of Ex

  • If isVertical = true

Image of Ex


Mobile

Image of Ex


Demo Link
Demo

Mark down usage
https://guides.github.com/features/mastering-markdown/

VersionDateDeveloped ByInformation ClassificationReviewed ByApproved By
1.004-10-2019TarunINTERNALGunjan and PrasanPrasan