All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.dominokit.domino.ui.loaders.TimerLoader Maven / Gradle / Ivy

There is a newer version: 2.0.3
Show newest version
/*
 * Copyright © 2019 Dominokit
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.dominokit.domino.ui.loaders;

import static org.dominokit.domino.ui.utils.Domino.*;

import elemental2.dom.HTMLDivElement;
import org.dominokit.domino.ui.IsElement;
import org.dominokit.domino.ui.elements.DivElement;
import org.dominokit.domino.ui.utils.DominoElement;

/**
 * A loader component that displays a timer-based animation.
 *
 * 

The TimerLoader displays an animation with timer-based progress. It is often used to indicate * loading or processing that is time-based. This loader consists of a timer-based progress bar. * *

Example usage: * *

 * TimerLoader loader = TimerLoader.create();
 * loader.setLoadingText("Loading...");
 * // Add the loader to a container element
 * container.appendChild(loader.element());
 * 
*/ public class TimerLoader extends BaseLoader implements IsElement { private final DivElement progress1 = div().addCss(wait_me_progress_elem_1, dui_loader_darker); private final DivElement progress2 = div().addCss(wait_me_progress_elem_2, dui_loader_darker); private final DivElement loader = div() .addCss(wait_me_progress, timer, dui_loader_border_darker) .appendChild(progress1) .appendChild(progress2); private final DivElement content = div() .addCss(wait_me_content, dui_vertical_center) .appendChild(loader) .appendChild(loadingText); private final DivElement element = div().addCss(wait_me).style("background: var(--dui-loader-background);").appendChild(content); /** Initializes a new instance of the {@code TimerLoader} class. */ public TimerLoader() { init(this); } /** * Creates a new instance of the {@code TimerLoader} class. * * @return A new {@code TimerLoader} instance. */ public static TimerLoader create() { return new TimerLoader(); } /** * Sets the loading text to be displayed by the loader. * * @param text The text to display as loading text. */ @Override public void setLoadingText(String text) { loadingText.textContent = text; } /** * Sets the size of the loader. * * @param width The width of the loader. * @param height The height of the loader. */ @Override public void setSize(String width, String height) { onAttached(mutationRecord -> loader.setWidth(width).setHeight(height)); } /** Removes the loading text from the loader. */ @Override public void removeLoadingText() { onAttached(mutationRecord -> loadingText.remove()); } /** * Gets the content element of the loader. * * @return A {@code DominoElement} representing the content element. */ @Override public DominoElement getContentElement() { return content.toDominoElement(); } /** * Gets the HTMLDivElement element associated with this loader. * * @return The HTMLDivElement element of the loader. */ @Override public HTMLDivElement element() { return element.element(); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy