Skip to content

Instantly share code, notes, and snippets.

View ketan-benegal's full-sized avatar

ketan-benegal

  • CloudFountain Inc.
View GitHub Profile
@ketan-benegal
ketan-benegal / ToastComponent.cmp.xml
Last active March 12, 2018 03:34
Lightning Toast
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId,flexipage:availableForAllPageTypes" access="global" >
<div>
<lightning:button label="Information" variant="brand" onclick="{!c.showInfoToast}" />
<lightning:button label="Error" variant="destructive" onclick="{!c.showErrorToast}" />
<lightning:button label="Warning" variant="inverse" onclick="{!c.showWarningToast}" class = "warning_cls" />
<lightning:button label="Success" variant="inverse" onclick="{!c.showSuccessToast}" class = "success_cls" />
</div>
</aura:component>
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata" fqn="helloWorld">
<apiVersion>45.0</apiVersion>
<isExposed>true</isExposed>
<targets>
import { LightningElement, track } from 'lwc';
export default class CloudFountain extends LightningElement {
@track greeting = 'Cloud Fountain';
}
}
<img class="wp-image-2079" src="https://www.thecloudfountain.com/wp-content/uploads/2019/03/word-image-4.png" />
<h3><a id="post-2074-_lioho6iizjtj"></a>3. Create a Lightning web component</h3>
<ol>
<li>In Visual Studio code, press Command + Shift + P on a Mac or Ctrl + Shift + P on Windows.</li>
<li>Type <em>SFDX</em>.</li>
<li>Select <em>SFDX: Create Lightning Web Component.</em></li>
<li>Press <em>Enter</em> to accept the default <em>force-app/main/default/lwc.</em></li>
</ol>
<template>
<lightning-card title="CloudFountain" icon-name="custom:custom14">
<div class="slds-m-around_medium">
<p>Hello, {greeting}!</p>
</div>
</lightning-card>
</template>
<template>
<lightning-card title="HelloWorld" icon-name="custom:custom14">
<div class="slds-m-around_medium">
<p>Hello, {upperCaseName}!</p>
<lightning-input name="last_name" label="Last Name" onchange={changeHandler}></lightning-input>
<template if:false={showLastNameOnly}>
<div>
<lightning-input name="first_name" label="First Name" onchange={changeHandler}></lightning-input>
</div>
</template>
import { LightningElement, track } from 'lwc';
export default class HelloWorld extends LightningElement {
// @track greeting = 'World';
@track firstName = '';
@track lastName = '';
@track showLastNameOnly = false;
changeHandler(event) {
// this.greeting = event.target.value;
const fldValue = event.target.name;
if(fldValue === 'first_name')
<template>
<lightning-card title="Related Contacts" icon-name="custom:custom63">
<div class="slds-m-around_medium">
<template if:true={contacts.data}>
<template for:each={contacts.data} for:item="contact">
<p key={contact.Id}>{contact.name}</p>
</template>
<template iterator:it={contacts.data}>
<li class="slds-item" style="list-style-type: none;" key={it.value.Id}>
<article class="slds-tile slds-tile_board">
/*eslint no-console: ["error", { allow: ["warn", "error"] }] */
import { LightningElement, track, wire, api } from 'lwc';
import findContacts from '@salesforce/apex/ContactController.getContacts';
/** The delay used when debouncing event handlers before invoking Apex. */
const DELAY = 300;
export default class ApexWireMethodWithParams extends LightningElement {
@track searchKey = '';
@api recordId;
public class ContactController {
public List<Contact> contactList {get;set;}
public ContactController(){
this.contactList = new List<Contact>();
}
@AuraEnabled(cacheable=true)
public static list<Contact> getContacts(string searchKey){
List<Contact> lst = new List<Contact>([SELECT Id, Name, Title, Phone, Email FROM Contact WHERE Accountid = :searchKey ]);
return lst;