Skip to content

Instantly share code, notes, and snippets.

@arufian
arufian / dynamicFields.js
Last active February 25, 2024 22:19
How to use dynamic fields at @wire getRecord - LWC (Lightning Web Component)
import { LightningElement, track, wire, api } from 'lwc';
export default class DynamicFields extends LightningElement {
@api recordId;
@track fields;
@api objectApiName;
@wire(getRecord, { recordId: '$recordId', fields: '$fields' })
record;
@lfreeland
lfreeland / gist:8e94c727df3ba0e7b832c79b18c883ec
Created April 9, 2018 00:07
Collapsible Section Lightning Component Controller
({
handleSectionHeaderClick : function(component, event, helper) {
var button = event.getSource();
button.set('v.state', !button.get('v.state'));
var sectionContainer = component.find('collapsibleSectionContainer');
$A.util.toggleClass(sectionContainer, "slds-is-open");
}
})
@lfreeland
lfreeland / gist:56920e809a13c1374717b9890de65a8a
Created April 9, 2018 00:05
Collapsible Section Lightning Component Markup
<aura:component>
<aura:attribute name="title" type="String" />
<div class="slds-section slds-is-open"
aura:id="collapsibleSectionContainer">
<h3 class="slds-section__title slds-theme_shade">
<!-- button state defaults to false so state
represents "is collapsed"
-->
<lightning:buttonStateful labelWhenOff="{! v.title }"
@ahmed-musallam
ahmed-musallam / console.html
Created December 11, 2017 19:34
A simple browser console-like html setup
<!--
I use this setup primarely on jsfiddle where I do not want to open chrome console while testing js code.
example: https://jsfiddle.net/wybmxgop/1/
-->
<!-- a Mono-spaced font-->
<link href="https://fonts.googleapis.com/css?family=Roboto+Mono" rel="stylesheet">
<style>
ul#console {
list-style-type: none;
@danic85
danic85 / gist:4c48f7dd1d4532049b491c8cd1d47f31
Created December 7, 2016 14:46
Binding lightning:input checkbox value. Must bind to 'checked' not 'value'
<aura:attribute name="testBoolean" type="Boolean" default="false" />
<lightning:input name="testBoolean" label="Test Boolean" type="checkbox" checked="{!v.testBoolean}" />
@adamreisnz
adamreisnz / package.json
Last active January 19, 2024 13:01
Simple pure npm scripts build process
{
"name": "project-name",
"description": "Template for static sites",
"version": "1.0.0",
"homepage": "http://www.project-name.com",
"author": {
"name": "Adam Reis",
"url": "http://adam.reis.nz"
},
"license": "UNLICENSED",