Last active
November 18, 2019 15:44
-
-
Save justin-lyon/9046de7ead457829d829f6c988df1ee3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<aura:tokens extends="force:base"> | |
<aura:token | |
name="myYellow" | |
value="#fcba03" /> | |
<aura:token | |
name="colorWarning" | |
value="{!colorBackgroundWarning}" /> | |
<aura:token | |
name="colorBrand" | |
value="{!colorBrand}" /> | |
</aura:tokens> |
This file contains hidden or 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
div.box { | |
width: 100%; | |
height: 5rem; | |
} | |
div.box.warning { | |
background-color: var(--lwc-colorWarning,#fc3000); | |
} | |
div.box.slds-warning { | |
} | |
div.box.brand { | |
background-color: var(--lwc-myColorBrand,#7eeba2); | |
} | |
div.box.slds-brand { | |
background-color: var(--lwc-colorBrand,#7eeba2); | |
} |
This file contains hidden or 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> | |
<div class="slds-grid slds-gutters slds-wrap"> | |
<div class="slds-col slds-size_1-of-3 slds-m-top_x-small"> | |
<div class="box warning"> | |
<div>lwc</div> | |
custom warning, fall back red | |
</div> | |
</div> | |
<div class="slds-col slds-size_1-of-3 slds-m-top_x-small"> | |
<div class="box warning"> | |
<div>lwc</div> | |
custom warning, fall back red | |
</div> | |
</div> | |
<div class="slds-col slds-size_1-of-3 slds-m-top_x-small"> | |
<div class="box warning"> | |
<div>lwc</div> | |
Cannot save .css with "--lwc-colorBackgroundWarning", Internal Token, not Global Access | |
</div> | |
</div> | |
<div class="slds-col slds-size_1-of-3 slds-m-top_x-small"> | |
<div class="box brand"> | |
<div>lwc</div> | |
custom brand, fall back green | |
</div> | |
</div> | |
<div class="slds-col slds-size_1-of-3 slds-m-top_x-small"> | |
<div class="box brand"> | |
<div>lwc</div> | |
custom brand, fall back green | |
</div> | |
</div> | |
<div class="slds-col slds-size_1-of-3 slds-m-top_x-small"> | |
<div class="box slds-brand"> | |
<div>lwc</div> | |
slds-brand, fall back green | |
</div> | |
</div> | |
</div> | |
</template> |
This file contains hidden or 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
<aura:component description="TokenContainer" | |
implements="flexipage:availableForAllPageTypes" | |
access="global"> | |
<div class="aura-box"> | |
Aura, colorBackgroundWarning | |
</div> | |
<div class="slds-box"> | |
<div>Aura > LWC</div> | |
<c:designTokenDemo /> | |
</div> | |
</aura:component> |
This file contains hidden or 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
.THIS.aura-box { | |
background-color: t(colorWarning); | |
width: 100%; | |
height: 5rem; | |
} |
Experimenting with SLDS Design Tokens for LWC.
According to the docs, a single Aura component with Design Tokens must be in the page - does not need to be a parent of the LWC - in order for the LWC to use Design Tokens.
What I've found is that an Aura Component is not necessary to use Design Tokens in an LWC - however, custom design tokens are not supported, and ONLY Globally Accessible Tokens are available to LWC.
Design Tokens Docs:
https://developer.salesforce.com/docs/component-library/documentation/lwc/lwc.interop_components_css_aura
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Screen Shot
https://prnt.sc/pym2yc