Log
The log entry is a single entry in the log.
import { Log } from "@schukai/monster/source/components/state/log.mjs";Introduction
This is a versatile web component. More than just a simple UI element, this component serves as a key element for enhancing interactivity and engagement within various web applications. Whether you are developing a basic website or a complex enterprise-level application, this component is designed to improve user interaction and satisfaction.
Key Features
- Dynamic interaction: Users can interact with content dynamically, making the web experience more intuitive and user-centric.
- Customizable appearance: Customize the appearance of the component to match the design of your brand or application, ensuring visual consistency.
- Accessibility: Designed with accessibility in mind to ensure that all users have a seamless experience, regardless of their browsing environment.
- Visual feedback effect: Provides subtle touch feedback to enhance user interaction, making actions more responsive and engaging.
- Programmatic Control: Offers methods such as trigger, focus, and deactivate, allowing developers to control the component's behavior programmatically and offering greater flexibility.
Improving the user experience
This component goes beyond its traditional functionality to offer an enhanced and interactive user experience. The combination of visual feedback effects and dynamic interaction with content is not only visually appealing, but also provides clear and responsive feedback to user actions, making the web environment more intuitive and user-friendly.
These improvements are supported by user studies that demonstrate a positive impact on user engagement and satisfaction.
Efficiency in the development process
Integrating this component into your development process is straightforward. Its compatibility with standard web technologies and ease of customization ensure seamless integration with your existing tools and libraries. Whether you're working on a small project or a large-scale application, the modular design of this component guarantees easy integration, streamlining your development process and enhancing productivity.
Log
In this simple example, we demonstrate a log element where three different messages are added. As you can see, various types of information can be passed.
Javascript
import "@schukai/monster/source/components/state/log.mjs";
import {Entry} from "@schukai/monster/source/components/state/log/entry.mjs";
const element = document.querySelector('monster-log')
element.addEntry(new Entry({message: "This is a simple log entry"}))
element.addEntry(new Entry({message: "This is a simple log entry", title: "This is a title"}))
element.addEntry(new Entry({message: "This is a simple log entry", title: "This is a title", user: "Administrator"}))HTML
<monster-log></monster-log>Stylesheet
/** no additional stylesheet is defined **/Component Design
This component is built using the Shadow DOM, which encapsulates its internal structure and styling, isolating it from the rest of the webpage. By employing a shadow root, the internal elements of the component are shielded, preventing external styles or scripts from unintentionally altering its layout or behavior.
Shadow DOM and Accessibility
The encapsulation within a shadow root limits direct access to the component's internal elements. Developers are therefore unable to manipulate or style these elements from outside the component. The Shadow DOM maintains design and behavior consistency by safeguarding against external modifications.
Customizing Through Exported Parts
Despite the Shadow DOM's restrictions on direct access, customization is possible through exported parts. Parts of the component are explicitly marked for export, enabling them to be styled using CSS. This approach allows for modifications to the component's appearance without breaching its encapsulation.
Available Part Attributes
control: This part defines the main container of the log entries and the empty state visualizations. It is used to style the container's layout and background.content: This part refers to the text displayed when no entries are present in the log. It allows for styling of this specific message.visual: This part applies to the SVG element used in the empty state display, enabling customization of the SVG's appearance.
Below is an example of how to use CSS part attributes to customize different parts of the Control.
monster-log::part(control) {
background-color: #f0f0f0;
padding: 10px;
}
monster-log::part(content) {
font-weight: bold;
color: #333;
}
monster-log::part(visual) {
fill: #007BFF;
}
Explanation of the Example
monster-log::part(control): Styles the container of the log entries and the empty state visualization, giving it a light background color and some padding.monster-log::part(content): Styles the message displayed when the log is empty, making it bold and darker for better visibility.monster-log::part(visual): Changes the color of the SVG used in the empty state visualization to blue.
Accessibility
Accessibility is a crucial consideration in the design of this component. It adheres to web accessibility best practices, ensuring that users of all abilities can interact with it effectively. This includes support for keyboard navigation, screen readers, and other assistive technologies, fostering an inclusive user experience.
HTML Structure
<monster-log></monster-log>JavaScript Initialization
const element = document.createElement('monster-log');
document.body.appendChild(element);Exported
LogDerived from
CustomElementOptions
The Options listed in this section are defined directly within the class. This class is derived from several parent classes, including the CustomElement class. Therefore, it inherits Options from these parent classes. If you cannot find a specific Options in this list, we recommend consulting the documentation of the CustomElement.
- since
- deprecated
Properties and Attributes
The Properties and Attributes listed in this section are defined directly within the class. This class is derived from several parent classes, including the CustomElement class and ultimately from HTMLElement. Therefore, it inherits Properties and Attributes from these parent classes. If you cannot find a specific Properties and Attributes in this list, we recommend consulting the documentation of the CustomElement.
data-monster-options: Sets the configuration options for the collapse component when used as an HTML attribute.data-monster-option-[name]: Sets the value of the configuration option[name]for the collapse component when used as an HTML attribute.
Methods
The methods listed in this section are defined directly within the class. This class is derived from several parent classes, including the CustomElement class and ultimately from HTMLElement. Therefore, it inherits methods from these parent classes. If you cannot find a specific method in this list, we recommend consulting the documentation of the CustomElement.
Behavioral methods
addEntry(entry)entry{entry}: entry
- {Log}
addMessage(message,date)message{string}: messagedate{date}: date
- {Log}
{TypeError}message is not a string
clear()- {Log}
Static methods
[instanceSymbol]()- {symbol}
instanceof operator.getCSSStyleSheet()- {CSSStyleSheet[]}
getTag()- {string}
Lifecycle methods
Lifecycle methods are called by the environment and are usually not intended to be called directly.
[assembleMethodSymbol]()- {void}
connectedCallback()- {void}
Events
This component does not fire any public events. It may fire events that are inherited from its parent classes.