Open github-learning-lab[bot] opened 4 years ago
:white_check_mark::white_check_mark::white_check_mark::white_check_mark:
:white_check_mark: Getting file
:white_check_mark: Rich-text should not be rendered by flex-layout.row
:white_check_mark: Add a flex-layout.col
inside of flex-layout.row
:white_check_mark: Define two images as children of flex-layout.col with the correct props for each image
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.