Skip to content

Upgrade to v2 Arc Blocks

The following sections guide you through configuring your feature pack to use Arc Blocks v2.

You can also view the Themes starter repository in our Arc XP Github organization:

Themes v2 Starter

1. Configure Feature Pack

This section provides the steps to update the Themes release version, the blocks.json file, and configure environment variables and dependencies for Arc Blocks v2.

For compatible node, npm, and Engine versions to use with Themes versions, see How to run PageBuilder Engine locally.

blocks.json

This section lists the changes you must make to your blocks.json file as part of the upgrade. Take the following steps:

  1. Update the themesReleaseVersion value to the latest 2.x.x version:

    "themesReleaseVersion": "arc-themes-release-version-2.4.1",
  2. Add the new themeComponents key to enable the React arc-themes-components package:

    "themeComponents": "@wpmedia/arc-themes-components",
  3. Add the new theme key that defines which out-of-the-box styles to apply by default.

    "theme": "news",
  4. Remove the following line from the blocks.json file:

    "engineSDK": "@wpmedia/engine-theme-sdk",
  5. Add the new Arc Blocks to the blocks array. The new blocks are required for local development:

    "blocks": [
    ...
    "@wpmedia/alias-tokens",
    "@wpmedia/breakpoint-tokens",
    "@wpmedia/global-phrases-block",
    "@wpmedia/global-tokens",
    "@wpmedia/signing-service-content-source-block"
    ],
  6. Add the new value for resizerURL. Arc Blocks use Image Resizer v2 by default. To enable Image Resizer v2 in Arc Blocks, add the following line:

    "resizerURL": "/resizer/v2/"
  7. Enable Arc XP blocks styling functionality (and compiler) by adding the following line:

    "buildSiteStyles": true,

Additional notes on Image Resizer v2

Image Resizer v2 enables you to add SEO-friendly names for images. Additionally, the authentication token is included in the image ANS and is good for all resize variations, so you won’t have to worry about storing the secret key.

After you upgrade to Arc Blocks v2, the images in all blocks are fully migrated to Image Resizer v2. However, see the specific image components and blocks deprecations that may require updating during your upgrade to Arc Blocks v2.

For custom content sources, see Migrate from Resizer v1 to v2

environment/*.json

You must add environment variables for Image Resizer v2 to your environment .json files, as well as a siteStyles object that contains your site ID with the site ID you want the styles mapped to as the value. For a single site, this becomes a one-to-one mapping. Add the following to your environment .json files:

"RESIZER_TOKEN_VERSION": "[check the delivery API for current value]",
"SIGNING_SERVICE_DEFAULT_APP": "resizer",
"siteStyles": {
"daily-intelligencer": "daily-intelligencer"
}

For multi-site, this enables you to define one-to-many styles. Meaning you could have one set of styles applied to multiple sites. Like in this case, daily-intelligencer and the-gazette would both have the same styling applied to their blocks while karc would have it’s own.

"siteStyles": {
"daily-intelligencer": "daily-intelligencer",
"the-gazette": "daily-intelligencer",
"karc": "karc"
}

package.json

Update your Arc Fusion CLI to the latest version.

Terminal window
npm install --save-dev @arc-fusion/cli@latest

Use at least @2.1.0

Terminal window
npm install --save-dev @arc-fusion/cli@2.1.0

2. Set up Design System

This section helps you set up the Block Design System with your own tokens. Arc XP offers a script to create and populate the required folder structure in your feature pack:

|-- themes
|-- styles
|-- alias.json
|-- blocks.json
|-- breakpoints.json
|-- components.json
|-- global.json

And for multi-site usage, you can add an optional sites folder to add site-specific styles:

|-- themes
|-- sites
|-- site1
|-- alias.json
|-- blocks.json
|-- breakpoints.json
|-- components.json
|-- global.json
|-- site2
|-- alias.json
...

See How to Design for Arc XP Themes.

Script Setup

  1. Create a file for the script. On your terminal, run:

    touch arc-themes.js
  2. Copy the following code into the arc-themes.js file:

  3. Add "arc-themes": "node arc-themes.js" to your package.json file to make it easy to execute:

    {
    "scripts": {
    ...
    "arc-themes": "node arc-themes.js"
    }
    }

Initialize Folder Structure

To initialize the folder structure, run:

Terminal window
npm run arc-themes -- init

Or for multi-site clients, run the following command using the site IDs that you would like to initialize in your themes/sites folder:

Terminal window
npm run arc-themes -- init --sites site1,site2,site3

Pull Tokens

To all of the out-of-the-box breakpoints, alias tokens, and global tokens, run:

Terminal window
npm run arc-themes -- get-tokens --theme news --version 2.4.1

Or if you’d like to pull the tokens into one of your site folders, run:

Terminal window
npm run arc-themes -- get-component-styles --component button --theme news --version 2.4.1 --site site1

Pull Component Styles

To get the styles for a specific component such as button, run:

Terminal window
npm run arc-themes -- get-component-styles --component button --theme news --version 2.4.1

Or if you’d like to pull the component styles into one of your site folders, run:

Terminal window
npm run arc-themes -- get-component-styles --component button --theme news --version 2.4.1 --site site1

Pull Block Styles

To get the styles for a specific block such as card-list-block, run:

Terminal window
npm run arc-themes -- get-component-styles --component button --theme news --version 2.4.1 --site site1

Or if you’d like to pull the block styles into one of your site folders, run:

Terminal window
npm run arc-themes -- get-styles --block card-list-block --theme news --version 2.4.1 --site site1

The above command is useful if you’ve previously ejected out of an Arc block to apply your own custom styling or have done custom style overrides, this gets you scaffolded out to begin setting the styles you want with the out-of-the-box block again. Keep in mind if it’s ejected and you removed it from your blocks.json, you must to re-add it to your blocks.json array. If it was custom style overrides but you kept the Arc block installed, you must begin transferring them over into the styles object.

3. Convert Custom Blocks

In Arc Blocks v2, there are cases where you have custom blocks that you want to convert to using the Themes Design System or there is a change released that requires you to adapt your custom code.

Blocks Styling

If you have applied custom style overrides or ejected out of an Arc block only to set your own styling. You can update your themes/styles/blocks.json with the blocks and style changes you need.

Refer to the Introduction to Themes design system.

Blocks Styling Using Logical Properties

With the update to support right-to-left languages, blocks now uses CSS logical properties. These properties conflict with older, physical and shorthand CSS properties causing unexpected results. If you are using custom styling in your blocks, you must make updates such as using inline-size and max-inline-size, instead of width and max-width. For the full list of CSS logical properties and their older equivalents, see CSS logical properties and values.

arc-themes-feature-pack/themes/styles/blocks.json
{
"byline": {
"styles": {
"default": {
"font-size": "$body-font-weight-small",
"line-height": "$body-line-height-tiny",
"components": {
"link": {
"text-decoration": "green wavy underline"
},
"link-hover": {
"text-decoration": "green dashed underline"
}
}
},
"desktop": {}
}
}
}

Deprecated Libraries

@wpmedia/engine-theme-sdk and @wpmedia/shared-styles had components, functions, and utilities available to construct your own custom blocks. Most of these have been shifted into the @wpmedia/arc-themes-components package as a direct replacement.

If you are importing utilities, components, or functions from engine-theme-sdk or shared-styles, refer to the following lists to identify which can be converted to importing from @wpmedia/arc-themes-components and which are deprecated where you must replace the import with your own code or copy the deprecated import into your own codebase as custom code to continue using it.

Deprecated Packages

Below is a list of all exports from our deprecated engine-theme-sdk and shared-styles libraries, indicating if there is library they’ve been migrated to and if the 2.0 implementation is a direct replacement (meaning you can just change the library imported from). If the Direct Replacement column is “TRUE”, it is a direct swap to the new library with no code update. There is also a Github link when the replacement exists, or an example of the component used on a block.

@wpmedia/blocks (including image components)

@wpmedia/shared-style

@wpmedia/engine-theme-sdk

@wpmedia/news-theme-css

news-theme-css is not used by any Arc Block in v2, and the Arc Themes Design System is replacing the need for the @wpmedia/news-theme-css dependency. With this release of Themes, there is greater flexibility to define your own global CSS variable tokens and aliases through the Arc Themes Design System, as well as applying targeted block styling to every Arc Block. The dependency is no longer included when deploying with Theme Settings and it does not need included in your blocks.json when developing locally. The removal of these dependencies reduces unnecessary CSS in your bundle.

DeprecatedNew LibraryReference LinkReplacementDirect ReplacementMigration Note
LinkedBackgroundHover@wpmedia/arc-themes-components- Pill
- Link
PillFALSEThe Pill component will render in span for use with backgrounds. If an href is passed as a property, the Pill will render as a simple hyperlink for internal navigation, and is not intended for external navigation. For this functionality, use the Link component as a wrap to the Pill.

If you are using any CSS from @wpmedia/news-theme-css, you must replace it or copy the CSS into your feature pack custom styles. This includes using the JS utilities.

import { framework, calculateRem } from '@wpmedia/news-theme-css/js/framework';

If you need to migrate over any Sass (functions, utilities, variables):

If you have specific classes you’d want to copy out as pure css:

List of news-theme-css classes

To identify what classes you have in use, refer to the list below (and further down is a helper script to run in your codebase).

news-theme-css class finder script

To help identify where these are used in your codebase, you can try using this helper script which will produce the file news-theme-css-results.json that lists every class used in your feature pack files with it’s line number.

To create and use the helper script, follow these steps:

1. Install glob to help search your repo. You can remove this after.

Terminal window
npm i glob --save-dev

2. Copy the following script into the file class-finder.js inside your feature pack folder.

3. Run the following command:

Terminal window
node class-finder.js

styleProperties

Defining styleProperties in blocks.json and Theme Settings is no longer needed with Arc Blocks v2. These properties are:

  • primary-font
  • secondary-font
  • primary-color

Users could then import getThemeStyle from 'fusion:themes'; in their feature pack to use the same style properties the Arc Blocks used. Arc Blocks no longer uses these style properties in Arc Blocks v2 because the Design System is far more robust and enables defining any number of style properties using global tokens and aliases.

Theme Settings no longer displays fields to define these properties, and you can remove them from your blocks.json styleProperties key. If you are importing from getThemeStyle in custom code, these values would no longer be defined, and you must update your custom code.

Change Log Summary

Key Highlights

  • Arc Themes Design System
  • Arc Block Styling
  • Arc Components
  • Resizer v2 support

Breaking Changes

engine-theme-sdk

  • @wpmedia/engine-theme-sdk package has been replaced by @wpmedia/arc-themes-components
  • See deprecated packages

news-theme-css

Arc Blocks do not use news-theme-css, and the Arc Themes Design System is replacing the need for the @wpmedia/news-theme-css dependency. With this release of Themes, there is greater flexibility to define your own global CSS variable tokens and aliases through the Arc Themes Design System, as well as applying targeted block styling to every Arc Block. The dependency is no longer included when deploying with Theme Settings, and it does not need included in your blocks.json when developing locally. The removal of these reduces unnecessary CSS in your bundle.

If you are using any CSS from @wpmedia/news-theme-css, you must replace it.

Deprecated news-theme-css classes in Arc Blocks v2:

Theme Settings

styleProperties

Defining styleProperties in blocks.json and Theme Settings is no longer needed with Arc Blocks v2. These properties are:

  • primary-font
  • secondary-font
  • primary-color

Users could then import getThemeStyle from 'fusion:themes'; in their feature pack to use the same style properties the Arc Blocks used. These are no longer used by Arc Blocks in v2 as the Design System is far more robust and enables defining any number of style properties using global tokens and aliases.

Theme Settings will no longer display fields to define these properties, and they can be removed from your blocks.json styleProperties key. If you are importing from getThemeStyle in custom code, these values would no longer be defined, you will need to update your custom code

siteProperties

Deprecated site properties include:

  • navColor (Navigation Bar Color Scheme)
  • lightBackgroundLogo (Dark Logo)

The navigation bar properties, including color, may be styled using the new Blocks Styling.

The logo fields have been consolidated, logos may be styled for any background color using Blocks Styling.