Development

Primo is a new approach to web development in that, instead of editing text files in a file directory, you edit code within a focused context - be that a site, a page, or a component. The goal of this strategy is that developers only ever see the code which they're actively working on.

Component Editor

Components allow you to write complex UI elements which you can use across any and all of your Primo sites. Since Primo components are written in Svelte, they're capable of powerful interactivity and functionality (Primo itself is built with Svelte).

Component Editor

Code

HTML

From the HTML tab, you can integrate the fields created under the Fields tab with the component so that content entered in the CMS can be compiled into static HTML.

To integrate a field, reference its Field ID as a variable from your HTML and JS and use Svelte's templating syntax to connect it.

  • Templating
  • Events
  • Reactivity

HTML component code

CSS

Your component's encapsulated CSS is fed through PostCSS before making it to Svelte, which enables support for nesting and auto prefixing. Note that any styles in your Site CSS & Page CSS are respectively added above your component's CSS, so that your component looks in the preview as it will on the page.

  • Encapsulation
  • Nesting
  • Autoprefixing

JavaScript

Just like in your component's HTML, you can access and modify field values as variables from your JS based on their Field ID. To import JS libraries, write absolute import statements like you would in a bundler (i.e. import lodash from 'lodash') - primo imports them in the background from skypack.dev. All of Svelte's superpowers are available from your JS - including transitions, stores, reactive statements, and more.

  • Libraries
  • Transitions
  • Reactivity

Fields

Component Fields allow you to define form fields that appear on the CMS side of primo. When the site is published, the value of those fields is compiled into static HTML.

At the moment, you can define 7 basic input types (text, image, Markdown, number, switch, URL, link), 1 informational type, and 2 composite types (group & repeater).

  • Text
  • Image - accessible with {image.url} and {image.alt}
  • Markdown - accessible with {@html description}
  • Number
  • Switch (true/false)
  • URL
  • Link - accessible with {link.url} and {link.label}
  • Info (enables writing instructions to CMS users)
  • Group (used to group fields together)
  • Repeater (used for content lists)

HTML

Component Libraries

This is where you manage the components for your site. You can create new ones, upload existing ones that you've downloaded from another site, and add ready-to-use components from the Primo and Community Libraries.

Site Library

The components contained within your site

HTML

Primo Library

Theme-able components designed & built by the Primo team

HTML

Community Library

An assortment of components submitted by the community

HTML

Page & Site

HTML

Head tag

HTML added to the Page will be added below any HTML added to the Site. HTML added to the Site will appear on every page on the site.

Code placed here will appear within the head tag of the page. This is typically where you'd put meta and link tags. You can also use variables which correspond to the page/site Fields.

Before closing body tag

Code placed here will appear before the closing body tag. Variables can also be used here.

HTML

Site CSS

Templates in Primo come with pre-written CSS written at the site level which makes it easier to get started with building sites. CSS is included for standardizing styles, setting theme values (for themeing components), elements like heading and button, and for styling Content Sections. Any styles added in Site CSS can be overwritten by Page CSS and Component CSS in a natural cascading order from general to specific.

CSS

Reset

These are styles to standardize how components look across different browsers and devices.

Theme Values

Theme values are CSS Custom Properties (or variables) that correspond to particular style declarations within Primo Library components, enabling them to be added to any site and automatically conforming to its design. They do this by using these values for particular properties like color, border-radius, box-shadow, etc. which should remain consistent within a site but are variable across different sites (e.g. rounded corners across one site, sharp corners across another).

Primo Classes

Primo adds certain classes to your page, sections, and components that make it easier to style your site within Primo and prevents styles from affecting the app's UI (e.g. overwriting the toolbar's font family).

  • .primo-page is added to every page's body tag, and should be used in place of body or html when possible
  • .primo-section is added to the root element of every section. It can be used in conjunction with .has-content and .has-component to target sections containing Content or a Component, respectively.
  • .primo-content and .primo-component wrap Content and Components, respectively. They create an additional wrapper within .primo-section that enables more fine-grained control. See more on .primo-content below.

Elements

These are classes used across most Primo Library components and Content Sections which keep their design consistent. They're listed here in order from most to least frequently used.

  • .heading applies to all component headings except for those within Hero components.
  • .section-container maintains a fixed max-width and padding for most components, while allowing others to maintain a full page width. It gets added automatically to each Content Section as well, enabling you to keep them consistent with the Component Sections.
  • .link is for links and is automatically added to links created in Content Sections to keep them consistent with links created in Components.
  • .button styles buttons.

Content Section

.primo-content enables you to write nested styles for all the elements created by Content Editors in the Content Section.

  • p
  • img
  • h1, h2, h3, etc. - headings defined with markdown (#, ##, ###, etc)
  • ul and ol
  • blockquote
  • mark - highlighted text
  • strong - bolded text

Fields

Fields added to the Page are accessible from the Page HTML and any components on the page. Fields added to the Site are accessible from the Page & Site HTML, as well as any components on the site.

Site fields can be overwritten by Page fields by using the same field ID, and Component fields can overwrite Page fields by using the same ID.

Fields