Open github-learning-lab[bot] opened 4 years ago
:white_check_mark::white_check_mark::x::x::x::white_check_mark::white_check_mark::white_check_mark::white_check_mark::white_check_mark::white_check_mark::white_check_mark::white_check_mark::white_check_mark::white_check_mark::white_check_mark::white_check_mark::white_check_mark:
:white_check_mark: Getting the file :white_check_mark: First test - Code compilation :x: You haven't declared .infoCardContainer classes for the image :x: You haven't declared the attributes correctly for the image - .infoCardContainer :x: You haven't declared the attributes values correctly for the image - .infoCardContainer :white_check_mark: Check Css Classes - Text :white_check_mark: Check Css Attributes - Text :white_check_mark: Check Css Attributes values - Text :white_check_mark: Check Css Classes - Button :white_check_mark: Check Css Attributes - Button :white_check_mark: Check Css Classes and Metal blockClass :white_check_mark: Check Css Attribute Values - Metal blockclass :white_check_mark: Check Css Classes and Vintage blockClass :white_check_mark: Check Css Attribute Values - Vintage :white_check_mark: Check Css Attributes values - Button :white_check_mark: Check Css Classes - Button Hover :white_check_mark: Check Css Attributes - Button Hover :white_check_mark: Check Css Attributes values - Button Hover
:white_check_mark::white_check_mark::white_check_mark::white_check_mark::white_check_mark::white_check_mark::white_check_mark::white_check_mark::white_check_mark::white_check_mark::white_check_mark::white_check_mark::white_check_mark::white_check_mark::white_check_mark::white_check_mark::white_check_mark::white_check_mark:
:white_check_mark: Getting the file :white_check_mark: First test - Code compilation :white_check_mark: Check Css Classes - Image :white_check_mark: Check Css Attributes - Image :white_check_mark: Check Css Attributes values - Image :white_check_mark: Check Css Classes - Text :white_check_mark: Check Css Attributes - Text :white_check_mark: Check Css Attributes values - Text :white_check_mark: Check Css Classes - Button :white_check_mark: Check Css Attributes - Button :white_check_mark: Check Css Classes and Metal blockClass :white_check_mark: Check Css Attribute Values - Metal blockclass :white_check_mark: Check Css Classes and Vintage blockClass :white_check_mark: Check Css Attribute Values - Vintage :white_check_mark: Check Css Attributes values - Button :white_check_mark: Check Css Classes - Button Hover :white_check_mark: Check Css Attributes - Button Hover :white_check_mark: Check Css Attributes values - Button Hover
CSS Handles and the power of customizing blocks
:sparkles: Branch: csshandles
Introduction
Taking a quick look at your online store, you'll notice that components have similar styles, even without applying any customization.
All of them, including the recently configured Info Card, share pre-established values for font, background color, main color, button format, etc.
This is due to the
style.json
, the file responsible for declaring generic customization values for every Store Framework store.To create a unique identity for your store's components, you can overwrite these values using CSS customizations.
Analyzing the recipe employed to customize stores using CSS, we can notice that several steps will be needed in order to apply your own style, such as:
Create a new file in the
CSS
folder, naming itvtex.{AppName}.css
Use the CSS Handle of the component that will be customized in this file in the following format:
Lacking CSS Handles, apply permitted CSS Selectors, such as
:global(vtex-{componentName})
.To apply CSS to a specific block and not to every block of that type, use the blockClass resource, which appears next to the CSS Handles when inspecting your code. The blockClass must be declared as a prop in the block in question, and thus be referenced in the style file as shown below:
Customizing the Info Card
To uncover a component's CSS Handles, such as the Info Card, simply access your documentation's
Customization
section.According to the description of CSS Handles and to the store customization recipe using CSS, we can implement a customized Info Card example, editing its title and call-to-action button configurations by adding the following code to the
vtex.store-components.css
file, found in/styles/css
:You can check the effect of these changes by running the
vtex link
command.Next, we'll add a specific style to the vintage info card. To begin, add the
blockClass
prop toinfo-card#button-right
, as shown below:Thereafter, declare a
background-color
for this specific info card in your CSS file:Check out the result by linking your app.
Activity
vtex.store-components.css
file, copy the above-mentioned code and use it in your theme's CSS file, according to the recipe on store customizations using CSS;max-width
) of1260px
for all info cards, a margin of0 auto
and a padding of0
.black
;bold
;white
;vintage
blockClass, apply a new block class calledmetal
to the info cardinfo-card#button-left
and apply the#e1e1e1
background color to it.:no_entry_sign: Are you lost?
Is there any problem with this step? What about sending us a feedback? :pray:
Submit feedback
If you're still unsure as to how to send your answers, click here.