In Salesforce we will customise the UI with the assistance of salesforce declarative strategy and Aura / LWC (Lightning Internet Parts) elements. Additionally, on high of that we’re utilizing SLDS for wealthy UI.
In customized UI improvement, SLDS gives Prepared-to-use HTML and CSS (Cascading Model Sheets) UI parts for Salesforce expertise.
Throughout the front-end improvement, we have to focus following areas
- Readability – Allow folks to see, perceive, and act with confidence.
- Effectivity – Intelligently anticipate wants to assist folks work higher, smarter, and quicker.
- Consistency – Create familiarity and strengthen instinct by making use of the identical answer to the identical drawback.
- Magnificence – Exhibit respect for folks’s time and a focus by means of considerate and chic craftsmanship. Exhibit respect for folks’s time and a focus by means of considerate and chic craftsmanship.
Customise – Don’t Change the Core
In case you are writing customized CSS that cancels out the styling of the Lightning Design System, you’re overriding as an alternative of customizing.
Within the above instance we’ve taken each LWC and Aura part CSS examples.
- In LWC instance we try to use the padding. Right here the primary two strains overriding the usual slds core padding properties.
- In Aura instance, we try to use the margin. The primary line overriding the slds core margin. The second line is the easiest way.
Design tokens are named entities that retailer visible design attributes, resembling margins and spacing values, font sizes and households, or hex values for colours.
Lightning net elements can use any Lightning Design System design token marked International Entry.
To reference a design token in your Lightning net part’s CSS, use the –lwc- prefix and reference the token title in camelCase.
Why is Design Token vital?
Take an instance: we’re going to construct a brand new group portal within the expertise cloud. It’s absolutely based mostly on Figma. All the online pages may have the next sections.
- Content material
On this all part a few of the properties will probably be widespread for all of the pages for instance
Font coloration, Font Measurement, Font Household, Margin or Padding, this sort of properties might be maintained in design tokens so CSS file will probably be in clear construction.
First up is practising good CSS hygiene. Just a few guidelines of thumb (be taught extra at MDN!):
- Don’t use sort selectors with courses, for instance,
They elevate your CSS specificity and create a dependency in your markup that’s more likely to trigger points sooner or later.
- Keep away from lengthy, nested selectors. This can be a main pink flag that your CSS has specificity points, and they’re solely going to worsen until you tackle them.
- Keep away from the common selector, for instance, * guidelines . Its vary is just too broad, which makes it too unpredictable; you’re setting your self up for styling conflicts.
- Don’t use !vital declaration as a hammer. Uncommon exceptions however, that is one other pink flag; in case you are utilizing the !vital declaration as a final resort, you could diagnose why.
In different phrases, don’t write CSS like this! That is like the ultimate boss of dangerous CSS.
There are some key factors you’ll be able to comply with to make sure constant and efficient implementation.
- Observe SLDS documentation: The Salesforce Lightning Design System developer information is your most important useful resource. It gives detailed pointers, elements with exemplifications.
- Design for responsiveness: SLDS comes with responsive elements that can work on completely different display sizes. Develop your elements and layouts to be responsive, making certain a constant expertise throughout all gadgets.
- SLDS CSS courses and utility courses: SLDS gives a set of CSS courses and utility courses that you should utilize to model your elements. Stick to those courses as a lot as doable to take care of consistency and cut back customized CSS.
- Use SLDS elements: SLDS gives a set of pre-built elements resembling
- Listing view
- Desk and extra.
Make the most of these elements as an alternative of constructing customized ones. They’re well-tested, accessible, and guarantee a constant person expertise.
- Internet Accessibility: Examine your SLDS implementation with the next accessibility pointers.
- Use semantic markup,
- present various textual content for photographs,
check your elements with accessibility instruments to make sure they’re usable by everybody.
- Internet Efficiency optimization: Optimize your SLDS implementation.
- Decrease the variety of HTTP requests
- Optimize any customized code you write.
- Sustain with SLDS updates: Salesforce usually finetune SLDS with new elements, options, and pointers. Keep linked to those updates and implement them into your design. It should make it easier to benefit from the newest enhancements and guarantee compatibility with future releases.
- Take a look at throughout all main browsers and gadgets: SLDS was created to work throughout varied browsers and gadgets. Take a look at your implementation totally on completely different browsers, working methods, and gadgets to ensure every part works advantageous.
- Doc your customizations: If you could customise an SLDS part or create a brand new one, doc your modifications within the module itself, which is able to make it simpler for different builders to know and preserve your code.
Simply comply with these greatest practices, you’ll be able to create efficient, maintainable, and user-friendly Internet Utility utilizing SLDS.
#Salesforce #Lightning #Apply #SLDS #DevFacts #Tech #Weblog #Developer #Group #Developer #Information