Atlas ships with a variety of useful blocks. The advantages of these blocks over others in WordPress, is:
A great way to learn how the blocks work is to just play with them in Gutenberg. All the properties have appropriate controls and help text.
Here they are:
Box
Column
& Row
grid-column-template
for fine-tuned control over how much space each cell occupies. Place any other blocks in the column or row. Nest Box
components for more control over things like horizontal and vertical alignment within a cell.Grid
Prose
Image
Atlas blocks are just normal React components, so using them is trivial. Everything is in Typescript, so you're type-safe as well:
import { Box, Prose } from '@asmartbear/gutenberg- bridge/ dist/ registerAll'; ...return <><AtlasContainer theme={theme}><Box marginLeft={1} marginRight={1} innerMaxWidth="850px" backgroundColor="backdrop"><Prose preset="h1" content="Hello Atlas" /><Box alignH="center" backgroundColor="mirage" marginTop={1} marginBottom={1}><Prose content="Thisis some centered text. " /> </Box><AtlasGutenberg htmlRaw={raw} /><CopyBlockConfig /></Box></AtlasContainer></>;
Here the outer Box
maintains margins horizontally, never allows the inner content to get very wide, and uses a theme palette color from the previous example.
Note the use of Prose
with the preset for the h1
tag. This may seem useless, but watch what happens when you reduce the width of the browser: The font size scales down appropriately for smaller devices. Note that heading fonts scale down much faster than regular text, which again is appropriate for that form-factor. All this is tuneable in the theme.
Also note that the text in the inner Prose
is white, even though we never told the system what color it should be. It automatically understood that because mirage
is a dark color, the text has to be light-colored to be visible. But note that the mirage
background color was set on a parent object -- the parent Box
. This demonstrates another convenient feature of the Atlas theme and block system: Styles like colors and fonts aren't just inherited because of CSS cascade, but React is aware of it as well. That means a Prose
component can know what background color it's rendered on, and select an appropriate text color in Javascript.
To see how powerful this system is, try switching to dark mode with new
. Watch as the mirage
color becomes pastel (because dark colors on black backgrounds vibrate or are unreadable), and also notice how the text becomes dark to contrast with that background. (More about dark mode here.)
This system is so smart, it even works with gradients! Try supplying linear-
for the background color of the text, and then see what happens in light mode and dark mode.
All these blocks are configurable in Gutenberg.
Furthermore, all theme settings are represented as well. Here's a box with the theme palette colors that we used in our example from before. Typeface, presets, palette colors, spacing -- everything is transposed into Gutenberg so that everyone is synchronized to the same design.
And, if you update the theme, all the blocks in Gutenberg will still have the correct settings.
Now that we're familiar with Atlas blocks, let's create our first custom block by composing existing blocks into a layout.