Skip to content

Latest commit

 

History

History
242 lines (181 loc) · 9.79 KB

MIGRATION_GUIDES.md

File metadata and controls

242 lines (181 loc) · 9.79 KB

Migration Guides

2.0.0

Version 2.0.0 rebuilds Assembly with UnoCSS while keeping the existing class names and buildUserAssets API.

Most markup works unchanged. Continue to use assembly.css / assembly.js, or keep calling Assembly.buildUserAssets. Check grids, txt-break-word, and switches for the changes below.

What can change:

  • The contents of assembly.css are generated by UnoCSS, so whitespace, comments, rule order, and source maps may differ from 1.x. Selectors and declarations for public classes stay the same, except for the grid, txt-break-word, and switches.
  • Conflicting margin and padding classes resolve as in 1.x: a single-side class beats an axis class, so px12 pl6 gives 6px of left padding. Versions 2.0.0 to 2.0.2 let the larger value win instead; upgrade to 2.0.3 or later.
  • Layout-scale media variants (px12-mm, w-1/2-ml, and so on) now use the same custom media queries you pass to buildUserAssets, instead of the hardcoded default breakpoints.
  • Focus states use the CSS :focus-visible pseudo-class, so the browser decides when to show them. assembly.js focus control and Assembly.setFocusState now only affect selects. Text inputs and textareas don't get an outline; they keep their darker border color on focus.
  • Focused elements get a 2px solid var(--blue) outline instead of a box-shadow. The --focus-shadow variable is replaced by --focus-outline; if you passed --focus-shadow to buildUserAssets, pass an outline value as --focus-outline instead.
  • @mapbox/assembly now depends on @unocss/core (used when creating custom builds).
  • When the user prefers reduced motion, transitions on every element, including your own, finish instantly.

Switches

Switches were restyled:

  • .switch is 24px tall and .switch--l is 36px tall, matching input--s and input. Use the new .switch--s for the previous 18px height.
  • switch--s-label is removed. .switch-container centers the switch on its label, so delete the class.
  • switch--{color} only colors the track when checked. The unchecked track is always gray-light and the dot is white unless you add switch--dot-{color}.
  • The <div class='switch'> can sit anywhere inside .switch-container, as long as the <input> is a direct child of the container.

New: you can use Assembly as an UnoCSS preset for on-demand CSS:

import { defineConfig } from 'unocss';
import { presetAssembly } from '@mapbox/assembly';

export default defineConfig({
  presets: [presetAssembly()]
});

presetAssembly() tree-shakes utilities from your source. The prebuilt assembly.css uses presetAssembly({ safelist: true }). Reset, forms, buttons, and other component CSS are preflight and always included.

The generated CSS still uses Assembly's CSS variables and custom media queries, so it needs a PostCSS step with postcss-custom-properties and postcss-custom-media. See presetAssembly in the README for the config.

grid is CSS Grid

grid is now a 12-column CSS Grid instead of a flexbox row. grid, col, w-1/12 to w-11/12, and grid--gut{size} keep their names. Check grids that rely on flexbox behavior:

  • col--auto is removed. For columns that share the remaining space, use flex with flex-child-grow on the children.
  • A col without a width class spans the full row instead of sizing to its content. For content-sized columns, use flex.
  • flex-child-* classes have no effect on a col.
  • Left and right margin classes on a col are ignored. ml-1/12 to ml-11/12 still offset a col, and need a w-* fraction class next to them. mr-1/12 to mr-11/12 have no grid equivalent.
  • Give every direct child of grid the col class, including children that only have a w-* fraction class.
  • grid--gut{size} sets column-gap instead of a negative margin on grid and padding on col. Add gapy{size} for space between rows.

txt-break-word

txt-break-word uses overflow-wrap: anywhere instead of word-break: break-all, so words break only when they would overflow their container.

New utilities

These are additive with 1.x class names:

  • gap12 / gapx12 / gapy12 (padding scale) for flex and grid spacing.
  • aspect-16/9, object-cover, flex--space-evenly-main, rotate90, scale50.
  • animation-shimmer, visible-on-parent-hover, bg-canvas, bg-canvas--dark.

1.0.0+

Version 1.0.0 of Assembly introduces breaking changes – learn how to resolve them with this handy guide.

In addition to the changes outlined in this guide, 1.0.0 drops support for IE11. If you need to continue supporting IE11, we recommend staying on an older version of Assembly or migrating to another CSS framework.

Changes to viewport-{x}

These classes have been renamed to make room for new viewport width classes:

  • viewport-third → h-viewport-1/3
  • viewport-half → h-viewport-1/2
  • viewport-twothirds → h-viewport-2/3
  • viewport-almost → h-viewport-11/12
  • viewport-full → h-viewport-full

Changes to flex and flex-child

flex-child has been removed and flex-child--{x} modifiers are no longer modifiers:

  • flex-child no longer exists. In almost all cases, it only impacted rendering in IE11, so you may safely to remove all instances of this class.
  • flex-child--grow → flex-child-grow
  • flex-child--no-shrink → flex-child-no-shrink

flex-parent and all modifiers have been renamed:

  • flex-parent → flex
  • flex-parent-inline → inline-flex
  • flex-parent--column → flex--column
  • flex-parent--column-reverse → flex--column-reverse
  • flex-parent--row → flex--row
  • flex-parent--row-reverse → flex--row-reverse
  • flex-parent--center-main → flex--center-main
  • flex-parent--center-cross → flex--center-cross
  • flex-parent--start-main → flex--start-main
  • flex-parent--start-cross → flex--start-cross
  • flex-parent--end-main → flex--end-main
  • flex-parent--end-cross → flex--end-cross
  • flex-parent--wrap → flex--wrap
  • flex-parent--stretch-cross → flex--stretch-cross
  • flex-parent--space-between-main → flex--space-between-main

Changes to col

col no longer declares flex-basis:0 or flex-grow: 1;. As a result, elements that use the col class without a width class will no longer grow to fill available space. To reintroduce the previous behavior, add the col--auto modifier to elements that use col without a width class.

Changes to col--{x} modifiers

Generic percentage based width classes now take the place of col--{n} & col--off{'r' | 'l'}{n} modifier classes.

  • col--1 → w-1/12
  • col--2 → w-1/6
  • col--3 → w-1/4
  • col--4 → w-1/3
  • col--5 → w-5/12
  • col--6 → w-1/2
  • col--7 → w-7/12
  • col--8 → w-2/3
  • col--9 → w-3/4
  • col--10 → w-5/6
  • col--11 → w-11/12
  • col--12 → w-full
  • col--offr1 → mr-1/12
  • col--offr2 → mr-1/6
  • col--offr3 → mr-1/4
  • col--offr4 → mr-1/3
  • col--offr5 → mr-5/12
  • col--offr6 → mr-1/2
  • col--offr7 → mr-7/12
  • col--offr8 → mr-2/3
  • col--offr9 → mr-3/4
  • col--offr10 → mr-5/6
  • col--offr11 → mr-11/12
  • col--offl1 → ml-1/12
  • col--offl2 → ml-1/6
  • col--offl3 → ml-1/4
  • col--offl4 → ml-1/3
  • col--offl5 → ml-5/12
  • col--offl6 → ml-1/2
  • col--offl7 → ml-7/12
  • col--offl8 → ml-2/3
  • col--offl9 → ml-3/4
  • col--offl10 → ml-5/6
  • col--offl11 → ml-11/12

Changes to scroll-{*}

All scroll-{*} classes except scroll-styled have been renamed to to overflow-{*}.

  • scroll-always → overflow-scroll
  • scroll-auto → overflow-auto
  • scroll-hidden → overflow-hidden

Changes to loading

Previously, loading included margin:auto to center the loader horizontally by default. Add mx-auto to the loading element to reintroduce this behavior.

limiter removal

Before 1.0.0, Assembly had a complex limiter class that was convenient but inflexible. You can use these existing classes to exactly imitate limiter: wmax1200 w-11/12-mm w-5/6-ml mx-auto px24 px0-mm.

Icon removal

Every icon has been redrawn in 1.0.0 and some icons have been removed. If you use any of the following icons, seek an alternative source:

  • adjust-stroke
  • apple renamed to ios
  • facebook
  • instagram
  • js
  • lifebouy
  • linkedin
  • nofolder
  • qt
  • slack
  • tooltip
  • unity
  • wechat

Other removed classes

col--offl12 and col--offr12 no longer exist. Reintroduce them with:

.col--offl12 {
  margin-left: 100% !important;
}
.col--offr12 {
  margin-right: 100% !important;
}

txt-spacing4 no longer exists. Reintroduce it with:

.txt-spacing4 {
  letter-spacing: 0.4em !important;
}

btn--stroke--2 no longer exists. Reintroduce it with:

.btn--stroke--2 {
  box-shadow: inset 0 0 0 2px currentColor;
}

.btn.btn--stroke--2:disabled {
  box-shadow: inset 0 0 0 2px var(--inactive-text-color);
}

.btn--pill-stroke.btn--stroke--2.btn--pill-hc {
  margin-left: -2px;
  margin-right: 0;
}

.btn--pill-stroke.btn--stroke--2.btn--pill-hr {
  margin-left: -2px;
}

.btn--pill-stroke.btn--stroke--2.btn--pill-vc {
  margin-top: -2px;
  margin-bottom: 0;
}

.btn--pill-stroke.btn--stroke--2.btn--pill-vb {
  margin-top: -2px;
}

Changes to element sizes, colors, and default styles

  • The height of toggle is now 30px, down from 36px and the height of toggle-s is now 18px, down from 24px.
  • The default form control color is gray, originally blue, for all form types.
  • The typographic scale has been updated. Notably txt-m is now 16px, up from 15px and many headings have a smaller font-size.
  • Shadow classes now have a y-offset.
  • The default select is now borderless. To add a border, use select--stroke.