Teradata Covalent
repository·main·Indexed 25 days ago
https://github.com/teradata/covalentTeradata's design system providing a library of web components and Angular support to create consistent, branded user experiences. Version 11.20.1 includes specialized modules such as @covalent/code-editor for Monaco Editor integration, @covalent/dynamic-forms for configuration-driven form generation, and @covalent/echarts for declarative ECharts visualizations including bar series, axes, and dataset management.
What's inside Covalent
- Covalent is a UI Platform designed to solve common enterprise needs. It follows the Material Design specification and is designed to work alongside Angular Material to provide a unified user experience. The platform is distributed as a collection of specialized npm packages.
Structure a side sheet with directives and components
mainWhen defining the template for your side sheet, use the following directives and components to apply standard Covalent styling and behavior:
td-sidesheet-title: Adds title styling to an element (optional).td-side-sheet-close: An attribute directive that closes the side sheet when the element is clicked or interacted with (e.g., via Enter key).td-side-sheet-content: A component that provides a container for content with Material-spec margins and automatic scrolling if the content exceeds the viewport.td-sidesheet-actions: A component that creates a sticky footer for holding multiple action buttons (optional).
<span td-sidesheet-title> Side Sheet Title <button mat-icon-button td-side-sheet-close>close</button> </span> <td-side-sheet-content> Sidesheet Content </td-side-sheet-content> <td-sidesheet-actions> <button mat-icon-button td-side-sheet-close>close</button> <button mat-icon-button td-side-sheet-close>save</button> </td-sidesheet-actions>Define menu structure with IMenuItem
mainThe
IMenuIteminterface allows you to create n-level deep cascading menus. Items fall into one of four roles based on their properties:- Submenu trigger: Includes a
childrenproperty (an array ofIMenuItem). - URL link: Includes a
linkproperty (a relative or fully qualified URL). UsenewTab: booleanto control if it opens in a new browser tab. - Action link: Includes an
actionproperty. Clicking this item emits theitemClickedevent. - Grouping label: Includes neither
children,link, noractionproperties.
Common Properties
id: Optional identifier.text: Display text.icon: Optional icon name.svgIcon: Optional SVG icon path.iconClasses: Optional array of styling classes.
- Submenu trigger: Includes a
Handle Props and Events in Covalent React
mainThe React wrapper simplifies interaction with the underlying web components:
- Props: Pass props naturally. The wrapper automatically distinguishes between attributes (strings) and properties (objects, arrays, etc.) and sets them correctly on the web component.
- Events: Use standard React
on-prefixed event handlers (e.g.,onClick,onRowClick). The wrapper maps native DOM events from the web component to these React handlers. - Type Safety: Components come with auto-generated TypeScript types for both props and events.
import { cvDataTable } from '@covalent/components-react'; function TableDemo() { const columns = [{ label: 'Name', key: 'name' }]; const data = [{ name: 'Item 1' }, { name: 'Item 2' }]; return ( <cvDataTable columns={columns} data={data} onRowClick={(event) => console.log('Row clicked:', event.detail)} /> ); }How Utility Classes vs Classless/Semantic modes work
mainCovalent Foundations offers two distinct ways to apply styles:
- Utility Classes (
covalent.css): You apply explicit classes (e.g.,cv-headline-1) to elements. Use this when you need different styles for the same element type on a single page. - Classless/Semantic (
elements.css): Standard HTML elements (like<h1>,<p>,<ul>) are automatically styled. Use this for Markdown content, blogs, or documentation sites where you want zero configuration.
- Utility Classes (
Compare Core Web Components vs. React Wrapper
mainUsing
@covalent/components-reactis preferred over using the raw@covalent/componentsweb components directly in React because it eliminates boilerplate and provides a native React developer experience.Task With Core Web Components (No Wrapper) With React Wrapper Passing Data Manually distinguish between attributes (strings) and properties (objects). Pass props naturally; the wrapper handles conversion. Event Handling Use refto add event listeners.Use React-style onEventprops.Type Support No built-in TypeScript types. Full TypeScript support. Code Readability More boilerplate. Clean, declarative JSX. Configure tour step attachment and advancement
mainWhen defining
IGuidedTourStep, you can control how steps are attached to elements and how users advance through them usingattachToOptionsandadvanceOnOptions.attachToOptions
Used to anchor the tour step to a specific DOM element.
highlight: booleanretries: number (attempts to find element)skipIfNotFound: booleanelse: string (step ID to go to if element not found)goBackTo: string (step ID for the back button)skipFromStepCount: boolean
advanceOnOptions
Used to define triggers for moving to the next step.
jumpTo: string (next button will jump to this step ID)allowGoBack: boolean
advanceOn
An array of
ITourEventOnobjects defining which events (e.g.,'click','keyup','added') trigger advancement.Best practices for using Dialogs
mainWhen implementing Dialogs in your application, follow these UX guidelines:
- Use sparingly: Only use a dialog when the user must make a decision immediately.
- Prefer 'Undo' over 'Confirm': It is better to perform an action immediately and provide an "undo" option rather than interrupting the user with an "Are you sure?" dialog.
- Use Snackbars for notifications: For less intrusive user notifications, use the snackbar component instead of a dialog.
Covalent Package Ecosystem
mainCovalent is modular. Depending on your requirements, you can install specific packages from the following ecosystem:
- @covalent/core: The foundation, containing 20+ UI components including layouts, data tables, wizard steppers, custom pipes, services, and utility functions.
- @covalent/echarts: Atomic components for data visualization, supporting 9+ chart types (e.g., bar, scatter, treemap).
- @covalent/highlight: Provides syntax highlighting for multiple programming languages.
- @covalent/markdown-parser: Parses GitHub flavored markdown.
- @covalent/flavored-markdown: Converts markdown into Material Design components.
- @covalent/markdown-navigator: Tools for navigating markdown sources, including a draggable window for inline documentation.
- @covalent/dynamic-forms: Enables building forms dynamically from a JavaScript object.
- @covalent/code-editor: A multi-language code editor component.
- @covalent/text-editor: A simple markdown text editor component.
Anatomy of a List Item
mainA
cv-list-itemwithin acv-listcan be composed of several elements to provide context and information:- Text Lines: Supports 1, 2, or 3 lines of text. Use the
twolineattribute to enable a secondary line. - Leading Graphic: An icon or avatar image placed at the start of the item using the
graphicattribute (e.g.,graphic="avatar") and theslot="graphic"on acv-icon. - Trailing Meta: An icon or metadata placed at the end of the item using the
slot="meta"on acv-icon. - Secondary Text: Additional text content placed in the
slot="secondary".
<cv-list> <cv-list-item graphic="avatar" hasMeta twoline> <span>Two-line list item</span> <span slot="secondary">Secondary line</span> <cv-icon slot="graphic">folder</cv-icon> <cv-icon slot="meta">help</cv-icon> </cv-list-item> </cv-list>- Text Lines: Supports 1, 2, or 3 lines of text. Use the
Compare Utility Classes vs Classless/Semantic styles
mainCovalent offers two distinct styling approaches. You can use them independently or combine them.
Utility Classes (
covalent.css)- Setup: Requires adding specific classes to your HTML elements.
- Control: Provides full control over every element.
- Best For: Complex applications and UIs.
- Markdown: Requires post-processing to apply classes.
Classless/Semantic (
elements.css)- Setup: Zero configuration; just import the CSS.
- Control: Styles are applied to tag types (e.g.,
<h1>,<p>), offering less granular control. - Best For: Documentation, blogs, and rapid prototyping.
- Markdown: Works directly with standard Markdown output.
Combining Both
For the best results, import
elements.cssfor base styling and usecovalent.cssutility classes to override specific elements.<link rel="stylesheet" href="themes/light.css" /> <link rel="stylesheet" href="elements.css" /> <!-- Base styles --> <link rel="stylesheet" href="covalent.css" /> <!-- Override utilities --> <h1 class="">Normal heading</h1> <!-- Uses elements.css --> <h1 class="cv-headline-3">Smaller heading</h1> <!-- Override with utility -->Use td-chart-dataset to manage chart data
mainThe
td-chart-datasetelement allows you to set thedatasetoption inside atd-chart. This provides flexibility by separating data management from theseriesproperty, enabling data reuse across different series and enabling data encoding. It is the Angular equivalent of creating a JavaScript dataset object in ECharts.Note: If you provide data via
series.data, it will override the data provided indataset.source.<td-chart [style.height.px]="300"> <td-chart-x-axis></td-chart-x-axis> <td-chart-y-axis [type]="'category'"> </td-chart-y-axis> <td-chart-series td-bar></td-chart-series> <td-chart-dataset [source]="[['product', '2015', '2016', '2017'], ['Matcha Latte', 43.3, 85.8, 93.7], ['Milk Tea', 83.1, 73.4, 55.1], ['Cheese Cocoa', 86.4, 65.2, 82.5], ['Walnut Brownie', 72.4, 53.9, 39.1]]" > </td-chart-dataset> </td-chart>