# ECL v5 migration notes The following guidelines aim to facilitate the migration from ECL v4 to v5. - [New components in ECL 5](#new-components-in-ecl-5) - [Style modifications](#style-modifications) - [Component modifications](#component-modifications) - [Packages modifications](#packages-modifications) ## New components in ECL 5 The following components are new in ECL 5 and have no direct equivalent in ECL 4: - **Add to calendar** (`@ecl/add-to-calendar`) — button that exports an event to calendar apps - **Animated numbers** (`@ecl/animated-numbers`) — displays counters that animate into view - **Highlight box** (`@ecl/highlight-box`) — visually prominent box for key content - **News ticker** (`@ecl/news-ticker`) — cycling list of short news items - **Page information** (`@ecl/page-information`) — metadata block (dates, authors, etc.) - **Page summary** (`@ecl/page-summary`) — structured summary card for a page or article - **Popover** (`@ecl/popover`) — floating panel with richer content than a tooltip - **Quiz** (`@ecl/quiz`) — interactive quiz / poll card - **Slogan ticker** (`@ecl/slogan-ticker`) — scrolling text banner - **Spotlight** (`@ecl/spotlight`) — highlighted content block with image and text - **Text and media** (`@ecl/text-media`) — large media file with corresponding textual information - **Tooltip** (`@ecl/tooltip`) — contextual tooltip attached to an element The **Tabs** component (`@ecl/tabs`) existed in ECL 4 as a static pattern; in ECL 5 it gained interactive JavaScript behaviour (responsive overflow, keyboard navigation). ## Style modifications Color definition and usage have greatly changed for ECL 5, with the introduction of color modes in EC. Typography has also changed quite drastically in EC. ### Grid - The main container max-width at the XL breakpoint has been extended to 1368px, making better use of wide screens. The breakpoint labels themselves (`xs`, `s`, `m`, `l`, `xl`) are unchanged. - Grid gutters are now changing based on the breakpoints. ### [EC] Color scales Main semantic colors (primary, secondary) are still present, but now use a new unified scale, going from `[color]-25` to `[color]-950`. Color values have also been changed. Dark and neutral colors have been merged into a single palette: `neutral`. A few palettes are also provided for grey and white colors: `grey`, `grey-alpha`, `monochrome` and `white-alpha`. Not all colors have a direct correspondence with ECL 4, but here are the main ones: | ECL4 | ECL5 | | -- | -- | | primary-100 | primary-600 | | secondary-100 | secondary-400 | ### [EC] Color modes A color mode is a set of colors, applied to different elements, and giving a distinct identity to a specific page or site. Currently the color modes are used only on EC. Every color mode is defined in a new file, called `ecl-ec-color-modes.css`. If this file is omitted, the default EC display is used. Components can use one mode or another by adding a CSS class to its root. The CSS class name is `ecl-color-mode--[color mode name]`. A twig parameter called `color_mode` is also provided for components that benefit from it (not all the components are affected by color modes). How it works: - several colors are defined to be part of the color modes, via the use of new CSS properties. It includes background (surface), content (on surface) and borders - some components have a new parameter `color_mode` to switch from one color mode to another, and are using these new CSS color mode properties where needed, with a fallback to previously defined color - EC CSS defines a default value for these color mode properties; EU does not currently use color modes - the new color modes CSS simply overrides the value of some properties The color mode custom properties all use the `--cm-` prefix. They cover surface backgrounds (e.g. `--cm-surface-0`, `--cm-surface-lowest`, `--cm-surface-low-1`, `--cm-surface-variant-1`), foreground/text colors (e.g. `--cm-on-surface`, `--cm-on-surface-highlight`, `--cm-on-surface-swap-1`) and borders (e.g. `--cm-border-low`, `--cm-border`). The full list is available in the theme's custom properties file (`src/themes/ec/_custom-properties.scss`). ### [EC] Typography Font family and scales have changed. The new font (Inter) is quite similar to Arial, but offers more flexibility. Font size now goes from `10xl` to `2xs`, line height goes from `10xl` to `3xs`. **Important note**: default font size (`m`) is now 18px/1.125rem, instead of 16px/1rem. It makes all content displayed larger. There are now 11 levels of font weight, from `thin` to `black`: thin, extra-light, light, semi-regular, regular, medium, semi-bold, near-bold, bold, extra-bold, black. A new very large typography has been added, called `display`. Font variants have been updated too. The variant `font-ui`, previously used to have larger line height, has been deprecated. Corresponding CSS properties and utilities have been updated accordingly: - paragraph utilities now use the new font scale, and go from `ecl-u-type-paragraph-xs` to `ecl-u-type-paragraph-2xl` (previously existing utilities like `ecl-u-type-paragraph-lead` are still valid) - CSS properties are available to handle font-size and line-height directly ### [EC] Shadows EC shadow names have been updated to follow a more easy to read scale. This affects utilities and CSS properties, as they are now using the new names. Here are ECL 5 shadows, and the mapping with ECL 4. | ECL 4 | ECL 5 | | -------------- | ---------------- | | ecl-u-shadow-1 | ecl-u-shadow-1 | | ecl-u-shadow-6 | ecl-u-shadow-2 | | ecl-u-shadow-12 | ecl-u-shadow-3 | | ecl-u-shadow-16 | ecl-u-shadow-4 | | / (new in ECL 5) | ecl-u-shadow-5 | EU shadows have not been modified (name and value). ### [EC] Spacing The scale has been extended in EC, it now has all these values: `5xs`, `4xs`, `3xs`, `2xs`, `xs`, `s`, `m`, `l`, `xl`, `2xl`, `3xl`, `4xl`, `5xl`, `6xl`, `7xl`, `8xl`, `9xl`, `10xl`, `11xl`, `12xl`, `13xl` The primary values used for spacing have largely remained unchanged: `m` is still `16px`, `s` is `12px`, and `l` is `20px`. ### Utilities Utilities have been added for the color modes. They are available for background, border and typography. Here are a few examples: - `ecl-u-bg-surface-0`, `ecl-u-bg-surface-lowest` - `ecl-u-border-color-border-low` Other modifications to the utilities: - `ecl-u-border-radius-1` has been removed, as it was barely visible ### Right to left The way ECL handles right to left has been updated. Previously, we were delivering an optional CSS for that, now the corresponding CSS has been integrated directly in the components. To have the correct right to left display, you should make sure that the HTML `dir` attribute is correctly set on the page (it could be on the `html` or `body` tag for instance). If not specified, the default reading direction remains left to right. ## Component modifications ### Accordion Markup of the accordion title has been updated - It relies on the use of default HTML tags `details` and `summary`. For the standard accordion, Javascript is no longer required as the open/close behaviour is handled natively by the browser. - Items no longer use headings. Corresponding twig parameter `level` has been removed. - New parameter `name` added, enabling the browser-native "only one open at a time" behaviour. - A selector has been added to the first item `.is-first` and to the last item `.is-last` of the accordion, the CSS is now expecting those classes instead of relying on the order of the sibling items in the markup. **Note:** the sidebar variant of the accordion still requires the `Accordion` JS class to be initialized (it handles keeping items open on desktop and collapsed on mobile). The `data-ecl-auto-init="Accordion"` attribute is present on all accordion instances; if you don't use the sidebar variant you can safely skip loading the accordion JS. Event management: For the standard accordion, ECL no longer provides custom javascript events. But the `details` element comes with a [built-in toggle event](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/toggle_event), which can be used directly. ### Banner - Aspect ratio of the banner is now fixed for mobile and tablet: **Mobile: 3/2, Tablet: 3/1**. On desktop the aspect ratio depends on the `size` parameter and differs from mobile/tablet. - Additional font size available for banners, now offering three values: `s`, `m` and `l` (via the `font_size` twig parameter) - New parameter `font_weight` to have light or bold text display - New parameter `overlay` to display a semi-transparent filter on the image ### Breadcrumb - Breadcrumb links are no longer using the "no-visited" variant (class `ecl-link--no-visited`) - Breadcrumb links are no longer using the "standalone" variant (class `ecl-link--standalone`) ### Button - Button variants have been updated, to be more flexible. Available variants are `primary`, `secondary`, `tertiary` - On top of the variants different styles are available: `highlight`, `neutral` and `inverted` Depending on your usage, you may have to update the button classes to match the new ones. Here is the mapping to the new variant / style: | ECL v4 | ECL v5 | | -------------- | ------------------- | | primary | primary | | secondary | secondary | | tertiary | tertiary / neutral | | cta | primary / highlight | | ghost | tertiary | | ghost-inverted | tertiary / inverted | ### Card - New parameter `secondary_meta_direction` to change orientation of secondary meta (default vertical) ### Checkbox - To keep the helper and invalid text accessible, they are duplicated into the `legend` tag, but kept hidden on screen ### Content block - The `data-ecl-title-link` attribute used by the JS script to identify titles containing links has been moved from the `div.content-block__title` to the link element itself. - New parameter `secondary_meta_direction` to change orientation of secondary meta (default vertical) ### Content item - New parameter `secondary_meta_direction` to change orientation of secondary meta (default vertical) ### Datepicker ECL v5 uses [duet datepicker](https://duetds.github.io/date-picker/) which replaces the previous implementation using pikaday. Check the "getting started" page on the ECL website for more information. **Important:** Using an external CDN may not be allowed for your website (this is most probably the case if it is hosted under europa.eu). In that case, you would have to use one of the following options and use: A) the npm package `npm install @duetds/date-picker`, and the whole `dist` folder you'll find inside of it or B) the tarball from https://registry.npmjs.org/@duetds/date-picker/-/date-picker-1.4.0.tgz that is also containing the same `dist` folder inside the `dist` folder there is the `duet.esm.js` script to be loaded in a script tag, mind the fact that it needs all the files in the containing folder to work. The markup is now using the custom element defined by duet js: `