This is a custom block theme built by Viget. It is meant to be a starting place then customize and build out your theme. Please update this file to reflect your custom built theme.
The theme.json
holds a lot of the core WordPress theme settings. The theme.json
is build using several js files in /src/theme-json
, Vite builds all of these files and exports a theme.json
for both dev
and build
. Do not edit directly theme.json
as it will be over written on build.
Several of the Tailwind variables are pulled in and Tailwind should be used as the primary way to style elements. If you need to, you can pull in more Tailwind variable for custom styling in theme.json
.
The files that create the theme.json
can be used to set custom settings for blocks, global theme, or for custom templates. Here are a few references:
Blocks are build using ACF and core WordPress blocks. Styles for the blocks are in src/styles/blocks
.
- Accordion
- Alert Banner
- CTA
- Image Caption
- Logo Grid
- Text Icon Cards
- Text Image
- Video Embed
The theme is set up with plop which will auto generate a new block based on the options you input. In order build a new block run:
ddev npm run plop block
It will ask you a few question:
- What is the block name? - This can be whatever you want.
- What is the slug for your theme? - This would your theme slug. If you are unsure of what that is, you can look at
textdomain:
in side of anyblock.json
files. - Pick a WordPress icon for the block - Icons are from WordPress Icons and you can change the icon if you don't see one you want.
- Do you need block styles? - Adds the option for adding a class to the block’s wrapper - Block Styles
- Do you need block variations? - Adds the option for a block variant - Block Variations
Fonts are pulled in by typography.js. Update the src
to pull in the font files in /src/fonts
. For more info on setting up WordPress fonts check out fullsiteediting.
The default font settings can be found in _index.js.
You have access to all of Tailwind's colors but feel free to create your own custom colors in the Tailwind config.
The theme comes with one accent color. The color name can be set in the top of the Tailwind config and the color are set in config theme.
Colors are pulled from Tailwind into /src/theme-json/settings/color.js
to be used in Gutenberg and WordPress.
Prefix the Gutenberg color slug by adding dark-
to flag that color as a dark enough for text, buttons to change color to dark mode.
The default spacing is fluid, meaning that it is larger on desktops and smaller on mobile screens.
Class | Min | Max |
---|---|---|
.fluid-xs |
2px |
16px |
.fluid-sm |
20px |
40px |
.fluid-md |
32px |
64px |
.fluid-lg |
56px |
112px |
.fluid-xl |
96px |
160px |
.fluid-2x |
144px |
240px |
To adjust the spacing you can edit them in tailwind.config.js
under spacing > fluid
. The fluid
spacing is getting pull into /src/theme-json/settings/spacing.js
and being used as the spacing for both margin and padding in Gutenberg.
WordPress button styles are normally built in the theme.json
but because there is a limitations on hover/focus for button variants all the buttons style are build in Tailwind.
The button styles are getting applied to the HTML in /src/styles/core-blocks/buttons.css
.
If you have need to apply the buttons style to the mark up you can add one of two button classes.
Button Classes |
---|
.btn-default |
.btn-outline |
If you need to add more button styles you can register a new block style on the core/button
.
register_block_style(
'core/button',
[
'name' => 'icon-only',
'label' => __( 'Icon Only', 'theme-slug' ),
]
);
This will attach a class to the block in the pattern of is-style-[name]
. Once you have the new button style registered you add the Tailwind style in /src/styles/core-blocks/buttons.css
. It is recommended that you create descriptive button styles and not generic styles like "primary" or "secondary".
The theme has a custom filter to add in custom icons for buttons. You can your custom SVG icons into /src/images/icons/
and then pull in that SVG icon in inc/icons.php
. In order for your SVG icon to update with the text you need to set fill
or stroke
(depending on your icon) to currentColor
.
The navigation has been set up to be fully accessible and is built using Alpine and the styles are set in CSS. You can edit the JS in /src/components/dropdown.js
and the CSS in /src/styles/core-blocks/navigation.css
if you need to customize the navigation.
The WP Editor requires WOFF2 fonts. TTF/OTF fonts will load on render for templates/pages, but will not display correctly in the Editor view unless they’re in WOFF2 format.
The Editor loads the generated Tailwind output, which means you need to run ddev npm run build
to generate CSS the Editor will import.
If you edit a template part in the CMS (like the Header), WP will use the database version. To reset to the Code version:
- Open the template part in the Editor
- Click the part name in the top middle to bring up the Command Palette
- Type ‘Reset’ and select the command. This will remove DB modifications and reset to the code version.
Not all the properties are completely documented, if you’re having trouble try:
- The block schema at the main WP repo: https://github.com/WordPress/gutenberg/blob/trunk/schemas/json/block.json