Vanilla Breeze v0.7.4

Vanilla Breeze v0.7.4 released

0.7.4 gives the Ambient pack weather. A page names one feed URL on its own site, and the pack sets data-weather from it, uses its sunrise and sunset for dawn and dusk, and never shows a stale observation. Helpers for producing the feed from Open-Meteo are included. Ambient p…

Read the release notes

browser-console

A web component that captures the page's console calls and shows them in a panel, with color for each log level and value type, tables, timers, groups and stack traces. The Vanilla Breeze stylesheet sets all of its colors from the active theme.

At a glance

Package@profpowell/browser-console, version 1.1.1
Elements<browser-console>
Renders inShadow DOM
Sourcegithub.com/ProfPowell/browser-console
Documentationprofpowell.github.io/browser-console
LicenceMIT
In Vanilla BreezeNot bundled. Load it yourself. The VB stylesheet includes the rules that theme it.

Install

Load the component from a CDN. It is one file with no dependencies and no stylesheet.

Or install it from npm and import it in your own script.

Demo

A console panel on a Vanilla Breeze page. The buttons call console methods in the page, and the panel shows each call.

Usage

Add the element and give it a height. It fills the height of its container, so without one it has no room to show logs. From the moment it is on the page it captures every console call the page makes. The calls still reach the browser's own console.

To show only entries you choose, turn off capture and add entries yourself.

Reference

Attributes

AttributeValuesDefaultPurpose
auto-hookfalse to turn offOnCaptures the page's console calls as soon as the element is added to the page.
themedark, lightdarkChooses the component's built-in palette. See the theming section for how this behaves with Vanilla Breeze.
max-logsNumber1000Most entries kept. Older entries are dropped.

Methods and properties

MemberPurpose
hookConsole()Starts capturing console calls.
unhookConsole()Stops capturing and restores the original console methods. Also runs when the element is removed.
addLog(entry)Adds an entry. entry is { method, data, timestamp }, where data is an array of values and timestamp is a Date.
clearLogs()Removes all entries.
setFilter(level)Shows one level: 'log', 'info', 'warn' or 'error'. Pass null to show all.
setSearchQuery(text)Shows only entries that contain the text.
setTheme(theme)Sets the theme attribute to 'light' or 'dark'.
copyLogs()Copies the visible entries to the clipboard as plain text. Returns a promise.
getExpansionStates(), restoreExpansionStates(states)Reads and restores which objects and groups are expanded, as a Map.
logsArray of captured entries.
filter, searchQuery, theme, maxLogsCurrent filter level, search text, theme and entry limit.

The component fires no custom events. It captures log, info, warn, error, debug, table, dir, trace, assert, clear, time, timeEnd, timeLog, count, countReset, group, groupCollapsed and groupEnd.

CSS custom properties

All 34 properties start with --bc-. The table lists the suffix. Set them on the element or on any ancestor.

GroupProperties
Backgroundsbg-primary (panel), bg-secondary (header), bg-tertiary (inputs and stack traces), bg-hover, bg-warn, bg-error
Text and borderstext-primary, text-secondary, border-color
Log levelscolor-log, color-info, color-warn, color-error, color-debug, color-table, color-time
Value typesvalue-string, value-number, value-boolean, value-null, value-function, value-date, value-regexp, value-element
Controls and tablesbtn-bg, btn-border, btn-hover, btn-active, table-border, table-header-bg, table-row-hover
Scrollbarscrollbar-track, scrollbar-thumb, scrollbar-thumb-hover

See the browser-console documentation for the full detail.

With Vanilla Breeze

A token is a CSS custom property that holds one design value, such as --color-surface. This component does not read VB tokens itself. Each color is a --bc-* property with a built-in dark or light value behind it.

The connection is a token bridge in the VB stylesheet: a rule with the selector browser-console that sets every --bc-* property from a VB token. It ships in vanilla-breeze.css and vanilla-breeze-core.css, so there is no extra file to load and no attribute to add.

VB tokenSet on
--color-surfacePanel background and scrollbar track
--color-surface-raisedHeader, inputs, buttons and table header
--color-hover-bgHover background of rows and buttons
--color-textText, and the accent of log and table entries
--color-text-mutedTimestamps and labels, debug and timer entries, and null values
--color-borderBorders, table borders and the scrollbar thumb
--color-infoinfo entries, numbers and dates
--color-warningwarn entries and their row tint, and booleans
--color-errorerror entries and their row tint, and regular expressions
--color-successStrings
--color-accentFunctions
--color-primaryDOM elements
--color-interactiveActive filter button and focus outline

The order is: the --bc-* property if it is set, then the built-in color for the current theme. With VB loaded, the bridge sets all 34 properties, so the panel follows the VB theme in both light and dark mode. The theme attribute and the theme button in the panel's header then change none of those colors.

Without the VB stylesheet the panel is dark by default and does not follow the page. Set theme="light" for the light palette.

The bridge sits in a cascade layer, so any rule you write outside a layer wins. To change one panel, set the property on it.

Accessibility

↑