From f381ab343109e5a1c51df8842a77a83417c93f60 Mon Sep 17 00:00:00 2001 From: MohammadMahdi Zamanian Date: Mon, 16 Jan 2023 22:22:58 +0330 Subject: [PATCH] feat(ui-kit/icon-box): new component --- ui/ui-kit/src/icon-box/icon-box.ts | 127 +++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 ui/ui-kit/src/icon-box/icon-box.ts diff --git a/ui/ui-kit/src/icon-box/icon-box.ts b/ui/ui-kit/src/icon-box/icon-box.ts new file mode 100644 index 000000000..794515568 --- /dev/null +++ b/ui/ui-kit/src/icon-box/icon-box.ts @@ -0,0 +1,127 @@ +import {AlwatrSurfaceElement, ifDefined, css, customElement, html, property} from '@alwatr/element'; + +import '@alwatr/icon'; + +declare global { + interface HTMLElementTagNameMap { + 'alwatr-icon-box': AlwatrStandardIconButton; + } +} + +/** + * Alwatr standard icon button element. + * + * @prop {String} icon + * @prop {String} href + * @prop {String} headline + * @prop {String} description + * @prop {String} urlPrefix + * @prop {Boolean} flipRtl + * + * @attr {String} icon + * @attr {String} href + * @attr {String} headline + * @attr {String} description + * @attr {String} url-prefix + * @attr {Boolean} flip-rtl + */ +@customElement('alwatr-icon-box') +export class AlwatrStandardIconButton extends AlwatrSurfaceElement { + static override styles = [ + AlwatrSurfaceElement.styles, + css` + :host { + display: flex; + transition-property: background-color, color; + } + + a { + display: flex; + flex-direction: column; + padding: calc(3 * var(--sys-spacing-track)); + gap: calc(1.5 * var(--sys-spacing-track)); + color: inherit; + text-decoration: none; + } + + .headline { + font-family: var(--sys-typescale-title-large-font-family-name); + font-weight: var(--sys-typescale-title-large-font-weight); + font-size: var(--sys-typescale-title-large-font-size); + letter-spacing: var(--sys-typescale-title-large-letter-spacing); + line-height: var(--sys-typescale-title-large-line-height); + } + + .description { + font-family: var(--sys-typescale-label-large-font-family-name); + font-weight: var(--sys-typescale-label-large-font-weight); + font-size: var(--sys-typescale-label-large-font-size); + letter-spacing: var(--sys-typescale-label-large-letter-spacing); + line-height: var(--sys-typescale-label-large-line-height); + } + + alwatr-icon { + color: var(--sys-color-primary); + width: calc(5 * var(--sys-spacing-track)); + height: calc(5 * var(--sys-spacing-track)); + margin-bottom: var(--sys-spacing-track); + transition-property: color; + } + + :host, + :host alwatr-icon { + transition-duration: var(--sys-motion-duration-small-out); + transition-timing-function: var(--sys-motion-easing-exiting); + } + `, + css` + :host(:hover) { + --_surface-color-on: var(--sys-color-on-primary-hsl); + --_surface-color-bg: var(--sys-color-primary-hsl); + } + :host(:hover) alwatr-icon { + color: var(--sys-color-on-primary); + } + + :host(:hover), + :host(:hover) alwatr-icon { + transition-duration: var(--sys-motion-duration-small-in); + transition-timing-function: var(--sys-motion-easing-incoming); + } + `, + ]; + + @property() + icon = ''; + + @property() + headline = ''; + + @property() + description = ''; + + @property() + href?: string; + + @property({attribute: 'url-prefix'}) + urlPrefix?: string; + + @property({type: Boolean, attribute: 'flip-rtl'}) + flipRtl = false; + + override connectedCallback(): void { + super.connectedCallback(); + this.setAttribute('stated', ''); + this.setAttribute('elevated', ''); + } + + override render(): unknown { + return html` + + +
${this.headline}
+
${this.description}
+
+ `; + } +}