Created
May 30, 2019 03:01
-
-
Save jsmithdev/53e2bcdbd077f7e2fed5ee8a0ee1924f to your computer and use it in GitHub Desktop.
LWC test of loading style from resource; style.css is uploaded as a static resource named style
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.target { | |
min-width: 300px; | |
min-height: 300px; | |
background: blue !important; | |
color: white !important; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<h3>{header}</h3> | |
<div class="target"> | |
Bleep bloop | |
</div> | |
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* eslint-disable no-console */ | |
import { api, LightningElement } from 'lwc'; | |
import { loadStyle } from 'lightning/platformResourceLoader'; | |
import styles from '@salesforce/resourceUrl/style'; | |
export default class TestStyle extends LightningElement { | |
@api header | |
renderedCallback() { | |
console.log('styles') | |
console.log(styles) | |
loadStyle(this, styles) | |
.then(() => console.log('Files loaded.')) | |
.catch(error => console.log("Error " + error.body.message)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment