public class Card extends BaseDominoElement<elemental2.dom.HTMLDivElement,Card> implements HasBackground<Card>
A card has two main sub-containers, header and body; the header provides title and description for the card with customizable header actions to perform specific operations while the body provides a container for custom content.
Customize the component can be done by overwriting classes provided by CardStyles
For example:
Card.create("Card Title", "Description text here...")
.appendChild(TextNode.of(SAMPLE_CONTENT))
.addHeaderAction(Icons.ALL.more_vert(), (event) -> {
DomGlobal.console.info("More action selected");
})
BaseDominoElement,
HasBackgroundBaseDominoElement.ElementHandler<T>, BaseDominoElement.ResizeHandler<T>, BaseDominoElement.StyleEditor<E extends elemental2.dom.HTMLElement,T extends org.jboss.elemento.IsElement<E>>, BaseDominoElement.WavesStylerelement| Constructor and Description |
|---|
Card() |
| Modifier and Type | Method and Description |
|---|---|
Card |
addCollapseListener(Collapsible.HideCompletedHandler listener)
Adds listener to be called when the body gets collapsed.
|
Card |
addExpandListener(Collapsible.ShowCompletedHandler listener)
Adds listener to be called when the body gets expanded.
|
Card |
addHeaderAction(BaseIcon<?> icon,
elemental2.dom.EventListener eventListener)
Adds new header action to card header passing the
icon and the eventListener. |
Card |
addHeaderAction(HeaderAction headerAction)
Adds new
HeaderAction |
Card |
appendChild(org.jboss.elemento.IsElement<?> element) |
Card |
appendChild(elemental2.dom.Node content)
Adds element to the body of the card
|
Card |
appendDescriptionChild(org.jboss.elemento.IsElement<?> element)
Same as
appendDescriptionChild(Node) but takes IsElement |
Card |
appendDescriptionChild(elemental2.dom.Node node)
Adds new element to the description element inside the header
|
Style<elemental2.dom.HTMLDivElement,DominoElement<elemental2.dom.HTMLDivElement>> |
bodyStyle() |
Card |
clearBody()
Clears the body element
|
Card |
collapse()
Hide the body
|
static Card |
create()
Creates new card instance with hiding the header
|
static Card |
create(String title)
Creates new card instance with
title. |
static Card |
create(String title,
String description)
Creates new card instance with
title and description |
static Card |
createProfile(String name,
String info)
Profile is a special case of a card which has
margin-bottom to 0px and @link
Color#THEME} as a background |
elemental2.dom.HTMLDivElement |
element() |
Card |
expand()
Show the body
|
Card |
fitContent()
Removes spaces inside the card and fit the body to its content, check
CardStyles.FIT_CONTENT |
DominoElement<elemental2.dom.HTMLDivElement> |
getBody() |
BaseIcon<?> |
getCollapseIcon() |
DominoElement<elemental2.dom.HTMLDivElement> |
getHeader() |
DominoElement<elemental2.dom.HTMLUListElement> |
getHeaderBar() |
DominoElement<elemental2.dom.HTMLElement> |
getHeaderDescription() |
DominoElement<elemental2.dom.HTMLHeadingElement> |
getHeaderTitle() |
Card |
hideHeader()
Hide the header
|
boolean |
isCollapsed()
Checks if the body is hidden
|
Card |
removeCollapseListener(Collapsible.HideCompletedHandler listener)
Removes collapse listener.
|
Card |
removeExpandListener(Collapsible.ShowCompletedHandler listener)
Removes expand listener.
|
Card |
removeHeaderLogo()
Removes the card header logo and hides its container
|
Card |
setBackground(Color background) |
Card |
setBodyBackground(Color bodyBackground)
Sets the background
Color of the body |
Card |
setBodyCollapseStrategy(CollapseStrategy strategy)
Set the card body collapse strategy
|
Card |
setBodyPadding(String padding)
Sets the padding of the body, the
padding value will be the same as CSS defines it. |
Card |
setBodyPaddingBottom(String padding)
Sets the bottom padding of the body
|
Card |
setBodyPaddingLeft(String padding)
Sets the left padding of the body
|
Card |
setBodyPaddingRight(String padding)
Sets the right padding of the body
|
Card |
setBodyPaddingTop(String padding)
Sets the top padding of the body
|
Card |
setCollapsible()
Enables the ability to hide/show the body by adding header action to the card.
|
Card |
setDescription(String descriptionText)
Sets the description of the card
|
Card |
setHeaderBackground(Color headerBackground)
Sets the background
Color of the header |
Card |
setHeaderLogo(org.jboss.elemento.IsElement<?> element)
Same as
setHeaderLogo(Node) but accepts IsElement |
Card |
setHeaderLogo(elemental2.dom.Node node)
Sets the header logo, this will removes the previous logo if set.
|
Card |
setHeaderVisible(boolean headerVisible)
Sets the header visibility
|
Card |
setTitle(String titleText)
Sets the title of the card
|
Card |
showHeader()
Show the header
|
Card |
toggle()
Change the visibility of the body based on its current state; expand if collapsed or collapse
if expanded
|
Card |
unFitContent()
Sets a default padding to the body of the card
|
add, add, addClickListener, addCss, addCss, addEventListener, addEventListener, addEventsListener, addHideListener, addShowListener, alignCenter, alignRight, apply, attr, blur, childNodes, clearElement, contains, contains, contains, containsCss, css, css, cssClassByIndex, cssClassesCount, cssText, disable, elevate, elevate, enable, firstChild, getAttachObserver, getAttribute, getBoundingClientRect, getChildElementCount, getClickableElement, getCollapsible, getCollapsibleElement, getDetachObserver, getDominoId, getElementsCount, getElevation, getFirstChild, getId, getTextContent, getTooltip, getWavesElement, hasAttribute, hasChildNodes, hasDirectChild, hide, hideOn, id, init, insertAfter, insertAfter, insertAfter, insertAfter, insertBefore, insertBefore, insertBefore, insertBefore, insertFirst, insertFirst, insertFirst, isAttached, isDisabled, isEmptyElement, isEqualNode, isForceHidden, isHidden, isReadOnly, item, lastChild, length, onAttached, onDetached, onResize, pullLeft, pullRight, querySelector, querySelectorAll, remove, removeAttachObserver, removeAttribute, removeChild, removeChild, removeCss, removeCss, removeCssProperty, removeDetachObserver, removeEventListener, removeEventListener, removeHideListener, removeHideOn, removeShowListener, removeShowOn, removeTooltip, removeWaves, replaceCss, setAlignItems, setAttribute, setAttribute, setAttribute, setBackgroundColor, setBackgroundColor, setBorder, setBorderColor, setBottom, setBottom, setBoxShadow, setCollapseStrategy, setColor, setColor, setContent, setContent, setCssProperty, setCssProperty, setCursor, setCursor, setDisabled, setDisplay, setDisplay, setDropMenu, setFlex, setFloat, setFloat, setFontSize, setFontSize, setForceHidden, setHeight, setHeight, setId, setInnerHtml, setLeft, setLeft, setLineHeight, setLineHeight, setMargin, setMargin, setMarginBottom, setMarginBottom, setMarginLeft, setMarginLeft, setMarginRight, setMarginRight, setMarginTop, setMarginTop, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setOpacity, setOpacity, setOverFlow, setOverFlow, setOverFlowY, setPadding, setPadding, setPaddingBottom, setPaddingBottom, setPaddingLeft, setPaddingLeft, setPaddingRight, setPaddingRight, setPaddingTop, setPaddingTop, setPointerEvents, setPosition, setPosition, setReadOnly, setRight, setRight, setTabIndex, setTextAlign, setTextAlign, setTextContent, setTooltip, setTooltip, setTooltip, setTooltip, setTop, setTop, setTransitionDuration, setWidth, setWidth, setZIndex, show, showOn, style, style, styler, textContent, toggleDisplay, toggleDisplay, withWaves, withWavesclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitisExpandedadd, add, remove, remove, removeProperty, replace, setProperty, setPropertypublic static Card create()
public static Card create(String title)
title.title - the title of the headerpublic static Card create(String title, String description)
title and descriptiontitle - the title of the headerdescription - the description of the headerpublic static Card createProfile(String name, String info)
margin-bottom to 0px and @link
Color#THEME} as a backgroundname - the title of the header of the profileinfo - the description of the header of the profilecreate(String, String)public Card setTitle(String titleText)
titleText - the title of the headerpublic Card setDescription(String descriptionText)
descriptionText - the description of the headerpublic Card appendDescriptionChild(elemental2.dom.Node node)
node - the element to be addedpublic Card appendDescriptionChild(org.jboss.elemento.IsElement<?> element)
appendDescriptionChild(Node) but takes IsElementelement - the element to appendpublic Card appendChild(elemental2.dom.Node content)
appendChild in interface HasChildren<Card>appendChild in class BaseDominoElement<elemental2.dom.HTMLDivElement,Card>content - the element to addpublic Card appendChild(org.jboss.elemento.IsElement<?> element)
appendChild in interface HasChildren<Card>appendChild in class BaseDominoElement<elemental2.dom.HTMLDivElement,Card>element - IsElement to be appended to the componentpublic Card setHeaderBackground(Color headerBackground)
Color of the headerheaderBackground - a Color to set as a background to the headerpublic Card setBodyBackground(Color bodyBackground)
Color of the bodybodyBackground - a Color to set as a background to the bodypublic Card fitContent()
CardStyles.FIT_CONTENTpublic Card unFitContent()
public Card setBackground(Color background)
setBackground in interface HasBackground<Card>background - Colorpublic DominoElement<elemental2.dom.HTMLDivElement> getHeader()
public DominoElement<elemental2.dom.HTMLUListElement> getHeaderBar()
public DominoElement<elemental2.dom.HTMLDivElement> getBody()
public DominoElement<elemental2.dom.HTMLHeadingElement> getHeaderTitle()
public DominoElement<elemental2.dom.HTMLElement> getHeaderDescription()
public Card addHeaderAction(BaseIcon<?> icon, elemental2.dom.EventListener eventListener)
icon and the eventListener.icon - the header action BaseIconeventListener - A EventListener to listen to the actionpublic Card addHeaderAction(HeaderAction headerAction)
HeaderActionheaderAction - A HeaderAction to be added to the cardpublic Card setCollapsible()
HardwareIcons.keyboard_arrow_up() and adds a listener to
hide and show the body.public Card toggle()
public Card expand()
public Card collapse()
public boolean isCollapsed()
isCollapsed in interface IsCollapsible<Card>isCollapsed in class BaseDominoElement<elemental2.dom.HTMLDivElement,Card>public Card addExpandListener(Collapsible.ShowCompletedHandler listener)
listener will be called
everytime the body gets expanded.listener - the Collapsible.ShowCompletedHandler to be addedpublic Card removeExpandListener(Collapsible.ShowCompletedHandler listener)
listener - the Collapsible.ShowCompletedHandler to be removedpublic Card addCollapseListener(Collapsible.HideCompletedHandler listener)
listener will be called
everytime the body gets collapsed.listener - the Collapsible.HideCompletedHandler to addpublic Card removeCollapseListener(Collapsible.HideCompletedHandler listener)
listener - the Collapsible.HideCompletedHandler to be removedpublic Card setBodyPadding(String padding)
padding value will be the same as CSS defines it.
For example:
card.setBodyPadding("2px 1px 2px 1px")
padding - the padding to setpublic Card setBodyPaddingLeft(String padding)
padding - the padding to setpublic Card setBodyPaddingRight(String padding)
padding - the padding to setpublic Card setBodyPaddingTop(String padding)
padding - the padding to setpublic Card setBodyPaddingBottom(String padding)
padding - the padding to setpublic Card setHeaderLogo(elemental2.dom.Node node)
node - the element to be set in the logo container,if null logo container become hiddenpublic Card removeHeaderLogo()
public Card setHeaderLogo(org.jboss.elemento.IsElement<?> element)
setHeaderLogo(Node) but accepts IsElementelement - the element to be set in the logo container,if null it will hide the logo
containerpublic Card showHeader()
public Card hideHeader()
public Card setHeaderVisible(boolean headerVisible)
headerVisible - true to show the header, false otherwisepublic BaseIcon<?> getCollapseIcon()
public Style<elemental2.dom.HTMLDivElement,DominoElement<elemental2.dom.HTMLDivElement>> bodyStyle()
Style of the bodypublic Card clearBody()
public Card setBodyCollapseStrategy(CollapseStrategy strategy)
public elemental2.dom.HTMLDivElement element()
element in interface org.jboss.elemento.IsElement<elemental2.dom.HTMLDivElement>element in class BaseDominoElement<elemental2.dom.HTMLDivElement,Card>Copyright © 2019–2022 Dominokit. All rights reserved.