UNPKG

@porsche-design-system/components-react

Version:

Porsche Design System is a component library designed to help developers create the best experience for software or services distributed by Dr. Ing. h.c. F. Porsche AG.

38 lines (35 loc) 2.8 kB
import { jsxs, Fragment, jsx } from 'react/jsx-runtime'; import { Component, createElement } from 'react'; import '../../provider.mjs'; import { splitChildren } from '../../splitChildren.mjs'; import { minifyCss } from '../../minifyCss.mjs'; import { getButtonTileCss as getComponentCss$16 } from '../../../../../../components/dist/styles/esm/styles-entry.mjs'; import { isDisabledOrLoading } from '../../../../../../components/dist/utils/esm/utils-entry.mjs'; import { PButton } from '../components/button.wrapper.mjs'; /** * @slot {"name": "header", "description": "Renders a header section above the content area." } * @slot {"name": "", "description": "Default slot for the img or picture tag." } * @slot {"name": "footer", "description": "Renders a footer section below the description." } */ class DSRButtonTile extends Component { host; hasFooterSlot = false; render() { splitChildren(this.props.children); // TODO: BreakpointCustomizable breaks stencils boolean conversion from string to boolean const parsedCompact = this.props.compact === 'true' ? true : this.props.compact === 'false' ? false : this.props.compact; const buttonProps = { variant: 'secondary', iconSource: this.props.iconSource, type: this.props.type, disabled: this.props.disabled, loading: this.props.loading, aria: this.props.aria, }; const button = (createElement(PButton, { ...buttonProps, icon: this.props.icon, key: "link-or-button", className: "link-or-button" }, this.props.label)); const buttonCompact = (createElement(PButton, { ...buttonProps, key: "link-or-button-pure", className: "link-or-button-pure", hideLabel: true, compact: true, icon: this.props.icon === 'none' ? 'arrow-right' : this.props.icon }, this.props.label)); const style = minifyCss(getComponentCss$16(isDisabledOrLoading(this.props.disabled, this.props.loading), this.props.aspectRatio, this.props.size, this.props.weight, this.props.align, parsedCompact, this.props.gradient, this.props.hasFooterSlot, this.props.disabled)); return (jsxs(Fragment, { children: [jsxs("template", { shadowroot: "open", shadowrootmode: "open", shadowrootdelegatesfocus: "true", children: [jsx("style", { dangerouslySetInnerHTML: { __html: style } }), jsxs("div", { className: "root", children: [jsx("slot", { name: "header" }), jsx("div", { className: "media", children: jsx("slot", {}) }), jsxs("div", { className: "footer", children: [jsx("p", { children: this.props.description }), jsx("slot", { name: "footer" }), typeof parsedCompact === 'boolean' ? (parsedCompact ? buttonCompact : button) : [buttonCompact, button]] })] })] }), this.props.children] })); } } export { DSRButtonTile };