UNPKG

@hashicorp/design-system-components

Version:
75 lines (72 loc) 2.81 kB
import Component from '@glimmer/component'; import { htmlSafe } from '@ember/template'; import { assert } from '@ember/debug'; import { service } from '@ember/service'; import { HdsAppFooterStatusLinkStatusValues } from './types.js'; import HdsAppFooterLink from './link.js'; import { precompileTemplate } from '@ember/template-compilation'; import { setComponentTemplate } from '@ember/component'; import { g, i } from 'decorator-transforms/runtime'; /** * Copyright IBM Corp. 2021, 2025 * SPDX-License-Identifier: MPL-2.0 */ class HdsAppFooterStatusLink extends Component { static { g(this.prototype, "hdsIntl", [service]); } #hdsIntl = (i(this, "hdsIntl"), void 0); get statuses() { return HdsAppFooterStatusLinkStatusValues(this.hdsIntl); } constructor(owner, args) { super(owner, args); assert('Either @status or @text for "Hds::AppFooter::StatusLink" must have a valid value', this.args.text !== undefined || this.args.status); } get status() { let status; if (this.args.status) { status = this.args.status.toLowerCase(); assert(`@status for "Hds::AppFooter" must be one of the following: ${Object.keys(this.statuses).join(', ')} received: ${this.args.status}`, status in this.statuses); return status; } return status; } get statusIcon() { return this.args.statusIcon ?? (this.status !== undefined ? this.statuses[this.status]?.iconName : undefined); } get itemStyle() { if (this.args.statusIconColor) { return htmlSafe(`--hds-app-footer-status-icon-color: ${this.args.statusIconColor}`); } else { return undefined; } } get text() { if (!this.args.text && this.status) { return this.statuses[this.status]?.text; } return this.args.text; } get href() { return this.args.href ?? 'https://status.hashicorp.com'; } get classNames() { const classes = ['hds-app-footer__status-link']; // add a class based on status if no statusIconColor is explicitly specified if (this.status && !this.args.statusIconColor) { classes.push(`hds-app-footer__status-link--${this.status}`); } return classes.join(' '); } static { setComponentTemplate(precompileTemplate("<HdsAppFooterLink class={{this.classNames}} style={{this.itemStyle}} @current-when={{@current-when}} @models={{@models}} @model={{@model}} @query={{@query}} @replace={{@replace}} @route={{@route}} @isRouteExternal={{@isRouteExternal}} @href={{this.href}} @isHrefExternal={{@isHrefExternal}} @icon={{this.statusIcon}} @iconPosition=\"leading\" ...attributes>{{this.text}}</HdsAppFooterLink>", { strictMode: true, scope: () => ({ HdsAppFooterLink }) }), this); } } export { HdsAppFooterStatusLink as default }; //# sourceMappingURL=status-link.js.map