Closed rodriggj closed 2 years ago
View / Command Palette / SFDX: Create Lightning Web Component
carFilter
and hit Enter
. Enter
, which will place the file in the default lwc
directory in the folder structure.carFilter.html
carFilter.js
carFilter.js-meta.xml
carFilter.html
and lets add the details of the lightning component by using the lighting-card
tag. As the inteli-text indicates, the lightning-card
is a container that is provided to us by Lighting Web Components Library. We will use standard HTML to assign a title
to the container. And then use an attribute of the lightning-card
, which is the icon-name
to provide a standard icon to the container.
<template>
<lightning-card title="Filters" icon-name="standard:calibration">
</lightning-card>
</template>
carFilter.js-meta.xml
file which is what Salesforce uses as a configuration file for this component. We need to tell Salesforce in this configuration file, that it is "available" and we need to specify where this component will be used, (aka the targets
/ target
). To do this nav to carFilter.js-meta.xml
and add the following code: <?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>52.0</apiVersion>
<isExposed>true</isExposed>
<masterLabel>Car Filter</masterLabel>
<targets>
<target>lightning__AppPage</target>
</targets>
</LightningComponentBundle>
carFilter
parent folder and selecting Deploy to Source Org
. NOTE: By default there is no
.css
file that is created. You can add acarFilter.css
file if you want to implement some explicit styling, but it is not created for you.
Go to View / Command Palette / SFDX: Create Lightning Web Component
When prompted for a file name enter carTileList
and hit Enter
.
When prompted for file location hit Enter
, which will place the file in the default lwc
directory in the folder structure.
Now if you view the directory you should see 3 files created by default:
carTileList.html
carTileList.js
carTileList.js-meta.xml
Again, create a lighting-card
tag and this time provide a different Title
and icon-name
<template>
<lightning-card title="Car Tile List" icon-name="standard:account">
</lightning-card>
</template>
carTileList.js-meta.xml
file. <?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>52.0</apiVersion>
<isExposed>true</isExposed>
<masterLabel>Car Tile List</masterLabel>
<targets>
<target>lightning__AppPage</target>
</targets>
</LightningComponentBundle>
Deploy to Source Org
Go to View / Command Palette / SFDX: Create Lightning Web Component
When prompted for a file name enter carTile
and hit Enter
.
When prompted for file location hit Enter
, which will place the file in the default lwc
directory in the folder structure.
Now if you view the directory you should see 3 files created by default:
carTile.html
carTile.js
carTile.js-meta.xml
Again, create a lighting-card
tag and this time provide a different Title
. We won't provide an icon for this one.
<template>
<lightning-card title="Car Tile">
</lightning-card>
</template>
carTile.js-meta.xml
file. <?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>52.0</apiVersion>
<isExposed>true</isExposed>
<masterLabel>Car Tile</masterLabel>
<targets>
<target>lightning__AppPage</target>
</targets>
</LightningComponentBundle>
Deploy to Source Org
Go to View / Command Palette / SFDX: Create Lightning Web Component
When prompted for a file name enter carCard
and hit Enter
.
When prompted for file location hit Enter
, which will place the file in the default lwc
directory in the folder structure.
Now if you view the directory you should see 3 files created by default:
carCard.html
carCard.js
carCard.js-meta.xml
Again, create a lighting-card
tag and this time provide a different Title
and icon-name
<template>
<lightning-card title="Car Card" icon-name="standard:apex_plugin">
</lightning-card>
</template>
carCard.js-meta.xml
file. <?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>52.0</apiVersion>
<isExposed>true</isExposed>
<masterLabel>Car Card</masterLabel>
<targets>
<target>lightning__AppPage</target>
</targets>
</LightningComponentBundle>
Deploy to Source Org
Car Hub
applicationSetup / Lighting App Manager /
on the Car Hub
line item click Edit
. And you should be directed back to your Application Editor. On the lower left, you should see all the Custom
components we just created and deployed to our DevOrg. Save
. App Manager
to navigate to the Car Hub
application and you should now see components on our Layout. Recall in our "Development" we created 4 components, and placed them on our Custom Layout.
Recall also that Automated Testing Tools
are going to use Document Object Model (DOM)
Elements as Locators to identify UI Elements that we will test. So let's take one of the Components we created and see what DOM
Impact it has.
Let's look at the carTileList
component and see what the DOM Elements and therefore Locator Options are.
Here is the code we wrote, for the carTileList
component. Realize we haven't given it any real content or functionality ... right now its just a "placeholder". Here we literally wrote/edited 7 lines of code! That's all 7 lines of code
So what did it do to the DOM? Here is what Google Chrome shows as all the DOM identifiers just to get to that carTileList
Component...
And that is all before we even get to the the label "Car Tile List". If you dive lower and open just that header element on the carTileList
Component you see the following...
<slot>
or <lightning-card/>
" tags are.
We will now begin to build out
Components
that make up our front end application.Recognize that
Component
front-end design is all the rave right now. Several "Non-Salesforce" frameworks are widely used to create Component Design for front end interfaces. Examples include Angular, React, View, ANT, etc. therefore, Salesforce has adopted its own version calledLightning Web Components
(LWC)For our app we will ultimately create and use 4 components:
The
carFilter
component will populate our left column ThecarTileList
and a nested componentcarTile
will populate our center column ThecarCard
component will populate our right columnTo build these components we will leverage the
Lighting Web Component Library
which is documentation on pre-built components that Salesforce makes available to developers for use in their own custom applications.