Package com.storedobject.ui
Class CardGrid
java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.HtmlComponent
com.vaadin.flow.component.HtmlContainer
com.vaadin.flow.component.html.Div
com.storedobject.ui.CardGrid
- All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier,com.vaadin.flow.component.ClickNotifier<com.vaadin.flow.component.html.Div>,com.vaadin.flow.component.DetachNotifier,com.vaadin.flow.component.HasComponents,com.vaadin.flow.component.HasElement,com.vaadin.flow.component.HasEnabled,com.vaadin.flow.component.HasOrderedComponents,com.vaadin.flow.component.HasSize,com.vaadin.flow.component.HasStyle,com.vaadin.flow.component.HasText,Serializable
- Direct Known Subclasses:
ObjectCardGrid
public class CardGrid
extends com.vaadin.flow.component.html.Div
A CardGrid is a UI component designed to display a grid of cards.
The grid is dynamic and adjusts to the available space while maintaining
a consistent card width and gap between the cards.
CardGrid extends the
Div component and provides methods for customizing
the appearance and behavior of the grid layout. It supports setting a custom card width
and gap size, and it can also be linked to a CardDashboard for managing its content.- Author:
- Syam
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.vaadin.flow.component.HasText
com.vaadin.flow.component.HasText.WhiteSpace -
Constructor Summary
ConstructorsConstructorDescriptionCardGrid()Constructs a new CardGrid instance and initializes its default styling and layout. -
Method Summary
Modifier and TypeMethodDescriptionintReturns the width of the cards in the grid.Returns the associatedCardDashboardinstance for thisCardGrid.intgetGap()Retrieves the size of the gap between cards in the grid layout.voidsetCardWidth(int cardWidth) Sets the width of the cards displayed in the grid.voidsetGap(int gap) Sets the gap size between cards in the grid layout.Methods inherited from class com.vaadin.flow.component.HtmlComponent
getTitle, setTitleMethods inherited from class com.vaadin.flow.component.Component
addListener, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setVisibleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface com.vaadin.flow.component.ClickNotifier
addClickListener, addClickShortcut, addDoubleClickListener, addSingleClickListenerMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.HasComponents
add, add, add, addComponentAsFirst, addComponentAtIndex, remove, remove, removeAllMethods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods inherited from interface com.vaadin.flow.component.HasEnabled
isEnabled, setEnabledMethods inherited from interface com.vaadin.flow.component.HasOrderedComponents
getChildren, getComponentAt, getComponentCount, indexOf, replaceMethods inherited from interface com.vaadin.flow.component.HasSize
getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFullMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassNameMethods inherited from interface com.vaadin.flow.component.HasText
getText, getWhiteSpace, setText, setWhiteSpace
-
Constructor Details
-
CardGrid
public CardGrid()Constructs a new CardGrid instance and initializes its default styling and layout. The CardGrid uses a CSS grid layout with specific configurations:- display is set to "grid". - grid rows have a dynamic height with a minimum of 50px. - content alignment is set to stretch horizontally and start vertically. - the grid width occupies 100% of the container.
Additionally, the default gap size and card width are set:- The initial gap size between grid items is 16 pixels. - The initial card width for grid items is 350 pixels.
-
-
Method Details
-
setGap
public void setGap(int gap) Sets the gap size between cards in the grid layout. The gap size defines the spacing in pixels and will be clamped to a minimum value of 0 to ensure non-negative spacing.- Parameters:
gap- the gap size in pixels to be set between cards
-
getGap
public int getGap()Retrieves the size of the gap between cards in the grid layout. The gap determines the spacing between individual cards.- Returns:
- the current gap size in pixels
-
setCardWidth
public void setCardWidth(int cardWidth) Sets the width of the cards displayed in the grid. If the specified width is less than 1, the method defaults the card width to 350 pixels. The card width is used to dynamically configure the grid layout so that the cards fit within the available space while maintaining the specified width.- Parameters:
cardWidth- the width to be set for the cards, in pixels. A value less than 1 will reset the card width to 350 pixels.
-
getCardWidth
public int getCardWidth()Returns the width of the cards in the grid.- Returns:
- the card width in pixels
-
getDashboard
Returns the associatedCardDashboardinstance for thisCardGrid. TheCardDashboardmay contain additional logic, behavior, or state associated with the grid's content and layout.- Returns:
- the
CardDashboardlinked to thisCardGrid, ornullif no dashboard is currently set.
-