Skip to content

Instantly share code, notes, and snippets.

View jamigibbs's full-sized avatar

Jami Gibbs jamigibbs

View GitHub Profile
@jamigibbs
jamigibbs / getPageRef.js
Created January 8, 2020 16:54
Get Page Ref
import { LightningElement, wire } from 'lwc';
import { CurrentPageReference } from 'lightning/navigation';
export default class PageRefDemo extends LightningElement {
@wire(CurrentPageReference)
currentPageReference;
handleDisplayPageRefObj(){
const pageRefObj = JSON.stringify(this.currentPageReference, null, 4);
@jamigibbs
jamigibbs / utils.js
Last active December 9, 2019 17:43
LWC Utils Collection
import checkPermission from '@salesforce/apex/PermissionService.checkPermission'; // https://github.com/tsalb/lwc-utils
const hasPermission = async (apiName) => {
const response = await checkPermission({ apiName: apiName });
return response;
}
// Straight from component library playground
const fetchFakeDataHelper = async ({ amountOfRecords }) => {
const recordMetadata = {
"use strict";
/* A version number is useful when updating the worker logic,
allowing you to remove outdated cache entries during the update.
*/
var version = 'v1::';
/* These resources will be downloaded and cached by the service worker
during the installation process. If any resource fails to be downloaded,
then the service worker won't be installed either.
// delete all the local branches except master branch
git branch | grep -v "master" | xargs git branch -D
git fetch origin
git checkout feature/example-branch
git reset --hard origin/feature/example-branch
--
git fetch origin
git checkout master
git reset --hard origin/master
import './navbar.scss'
import React from 'react'
const Navbar = () => (
<div>
/* Navigation bar stuff goes here */
</div>
)
export default Navbar
@jamigibbs
jamigibbs / webpack.config.js
Created November 4, 2018 14:36
Webpack config example with sass
const isDev = process.env.NODE_ENV === 'development'
module.exports = {
mode: isDev ? 'development' : 'production',
entry: [
'@babel/polyfill', // enables async-await
'./client/index.js'
],
output: {
path: __dirname,
{{checkType (prod)}}
Handlebars.registerHelper('checkType', (val) => {
console.log(val, '-->', typeof val)
}
// false --> boolean
// true --> boolean
Handlebars.registerHelper('outer-helper', (result, greeting) => {
return `${result} ${greeting}`
})
Handlebars.registerHelper('inner-helper', (name) => {
return `Hello, ${name}.`
})
{{outer-helper (inner-helper 'Jami') 'How are you?'}}