com.vaadin.flow.component.icon.AbstractIcon Maven / Gradle / Ivy
/*
* Copyright 2000-2024 Vaadin Ltd.
*
* 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 com.vaadin.flow.component.icon;
import com.vaadin.flow.component.ClickNotifier;
import com.vaadin.flow.component.Component;
import com.vaadin.flow.component.Tag;
import com.vaadin.flow.component.dependency.JsModule;
import com.vaadin.flow.component.dependency.NpmPackage;
import com.vaadin.flow.component.shared.HasTooltip;
import com.vaadin.flow.dom.ElementConstants;
/**
* Abstract base class for icon components
*
* @author Vaadin Ltd
*/
@Tag("vaadin-icon")
@NpmPackage(value = "@vaadin/polymer-legacy-adapter", version = "24.4.5")
@JsModule("@vaadin/polymer-legacy-adapter/style-modules.js")
@NpmPackage(value = "@vaadin/icon", version = "24.4.5")
@JsModule("@vaadin/icon/src/vaadin-icon.js")
public abstract class AbstractIcon> extends Component
implements ClickNotifier, HasTooltip {
/**
* Sets the width and the height of the icon.
*
* The size should be in a format understood by the browser, e.g. "100px" or
* "2.5em".
*
* @param size
* the size to set, may be null
to clear the value
*/
public void setSize(String size) {
if (size == null) {
getStyle().remove(ElementConstants.STYLE_WIDTH);
getStyle().remove(ElementConstants.STYLE_HEIGHT);
} else {
getStyle().set(ElementConstants.STYLE_WIDTH, size);
getStyle().set(ElementConstants.STYLE_HEIGHT, size);
}
}
/**
* Sets the color of the icon.
*
* The color should be in a format understood by the browser, e.g. "orange",
* "#FF9E2C" or "rgb(255, 158, 44)".
*
* @param color
* the color to set, may be null
to clear the value
*/
public abstract void setColor(String color);
/**
* Gets the color of this icon as a String.
*
* @return the color of the icon, or null
if the color has not
* been set
*/
public abstract String getColor();
}