{"version":3,"file":"AppFooter.mjs","sources":["../../../src/components/AppFooter/AppFooter.tsx"],"sourcesContent":["import clsx from 'clsx';\nimport React, { type ReactNode } from 'react';\n\nimport { assertEdsUsage } from '../../util/logging';\nimport type { NavItem, NavLink } from '../../util/utility-types';\nimport type { Emphasis } from '../../util/variant-types';\n\nimport Link from '../Link';\nimport Text from '../Text';\n\nimport styles from './AppFooter.module.css';\n\nexport type AppFooterProps = Omit<\n  React.HTMLAttributes<HTMLElement>,\n  'style' | 'title'\n> & {\n  // Component API\n  /**\n   * CSS class names that can be appended to the component.\n   */\n  className?: string;\n  /**\n   * Web location for the home page. Use this to direct where the main page of the application lives.\n   */\n  href?: string;\n  /**\n   * Sets of navigation targets in the footer. Consider using four at maximum.\n   */\n  navItems: NavLink[];\n  /**\n   * Handle the click event for a given clickable link nav item in the footer. Includes the data from the associated/clicked `NavItem` for reference\n   * (e.g., attaching events, tracking, etc.)\n   */\n  onLinkClick?: AppFooterEventHandler;\n  /**\n   * CSS properties defined for the HTML element. Includes the component's CSS Custom Properties:\n   *\n   * - `--app-footer__bg`\n   * - `--app-footer__fg`\n   */\n  style?: AppFooterCSSProperties;\n  // Design API\n  /**\n   * Text slot for specifying the copyright information (e.g., \"Copyright © ${YEAR}\")\n   */\n  copyright?: string;\n  /**\n   * Determine the amount of emphasis applied to the component, e.g., low or high.\n   *\n   * **Default is `\"high\"`**.\n   */\n  emphasis?: Emphasis;\n  /**\n   * Element used for the application's logo (can be text or an image)\n   */\n  title: ReactNode;\n};\n\nexport interface AppFooterCSSProperties extends React.CSSProperties {\n  /**\n   * Custom property to customize the background color of this component (e.g., background color)\n   */\n  '--app-footer__bg'?: string;\n\n  /**\n   * Custom property to customize the foreground color of this component (e.g., text, icon, etc.)\n   */\n  '--app-footer__fg'?: string;\n}\n\nexport type AppFooterEventHandler = (\n  event: React.SyntheticEvent,\n  navItem: NavItem, // Using abstract type to handle future cases\n) => void;\n\n/**\n * ## Usage\n *\n * A footer is a navigation component. It can hold links, buttons, company info, copyrights, forms, and many other elements.\n *\n * ### Best Practices\n *\n * * Provide 3-5 important links, along with copyright information, for the footer content.\n * * Logos should be no wider than ~300px, and no taller than ~150px.\n *\n * ## Interaction\n *\n * The links and content can guide users to other pages within the application, or to the marketing pages for the organization.\n *\n * ## Content & Accessibility\n *\n * ### Do's\n *\n * * Include links with brief text.\n * * Include at most one logo, pointing to either the home page for the organization, or the application.\n *\n * ### Don'ts\n *\n * * Don't use overly verbose text for any link; keep them to 1-3 words each.\n * * Don't use the AppFooter when working on a Single-page Application (SPA).\n * * Don't use a logo for any logged-in experience. Logos in `AppFooter` are just for\n *   landing/marketing pages.\n *\n * ## Resources\n *\n * * https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/footer\n * * https://www.nngroup.com/articles/footers/\n */\nexport const AppFooter = ({\n  className,\n  copyright,\n  emphasis = 'high',\n  href,\n  navItems,\n  onLinkClick,\n  title,\n  ...other\n}: AppFooterProps) => {\n  const componentClassName = clsx(\n    styles['app-footer'],\n    emphasis && styles[`app-footer--emphasis-${emphasis}`],\n    className,\n  );\n\n  // if title is not a string, and href does not exist, render directly\n  // if title is not a string, and href exists, wrap with unstyled anchor\n  // if title is a string, and href does not exist, render directly\n  // if title is a string and href exists, use a link component\n\n  return (\n    <footer className={componentClassName} {...other}>\n      <div className={styles['app-footer__wrapper']}>\n        {(title || copyright) && (\n          <div className={styles['app-footer__colophon']}>\n            {href ? (\n              typeof title === 'string' ? (\n                <Link\n                  context=\"standalone\"\n                  emphasis=\"low\"\n                  href={href}\n                  onClick={(ev) => {\n                    onLinkClick &&\n                      onLinkClick(ev, {\n                        name: 'EDS-footer-logo',\n                        type: 'link',\n                        href: href,\n                      } as NavLink);\n                  }}\n                  size=\"xs\"\n                  variant={emphasis === 'low' ? undefined : 'inverse'}\n                >\n                  {title}\n                </Link>\n              ) : (\n                <a\n                  aria-label=\"homepage\"\n                  className={styles['app-footer__home-link']}\n                  href={href}\n                  onClick={(ev) => {\n                    onLinkClick &&\n                      onLinkClick(ev, {\n                        name: 'EDS-footer-logo',\n                        type: 'link',\n                        href: href,\n                      } as NavLink);\n                  }}\n                >\n                  <div className={styles['app-footer__title']}>{title}</div>\n                </a>\n              )\n            ) : (\n              <div className={styles['app-footer__title']}>{title}</div>\n            )}\n            {copyright && (\n              <Text\n                as=\"div\"\n                className={styles['app-footer__copyright']}\n                preset=\"body-xs\"\n              >\n                {copyright}\n              </Text>\n            )}\n          </div>\n        )}\n        <menu className={styles['app-footer__nav-items']}>\n          {navItems?.map((navItem) => {\n            switch (navItem.type) {\n              case 'link':\n                return (\n                  <li\n                    className={styles['app-footer__nav-item']}\n                    key={navItem.name}\n                  >\n                    <Link\n                      context=\"standalone\"\n                      emphasis=\"low\"\n                      href={navItem.href}\n                      onClick={(ev) => {\n                        onLinkClick && onLinkClick(ev, navItem);\n                      }}\n                      size=\"xs\"\n                      variant={emphasis === 'low' ? undefined : 'inverse'}\n                    >\n                      {navItem.name}\n                    </Link>\n                  </li>\n                );\n              default:\n                // We only allow links in the footer for now, so don't handle other\n                // data types\n                assertEdsUsage(\n                  [true],\n                  `Problem with navItem data in footer: ${JSON.stringify(navItem)}`,\n                  'error',\n                );\n                return (\n                  <li\n                    className={styles['app-footer__nav-item']}\n                    key={`error-unknown-nav-item-type-${navItem.name}`}\n                  >\n                    <Text as=\"span\" preset=\"body-xs\">\n                      N/A\n                    </Text>\n                  </li>\n                );\n            }\n          })}\n        </menu>\n      </div>\n    </footer>\n  );\n};\n\nAppFooter.displayName = 'AppFooter';\n"],"names":["React"],"mappings":";;;;;;;AA2EA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCG;AACI,MAAM,SAAS,GAAG,CAAC,EACxB,SAAS,EACT,SAAS,EACT,QAAQ,GAAG,MAAM,EACjB,IAAI,EACJ,QAAQ,EACR,WAAW,EACX,KAAK,EACL,GAAG,KAAK,EACO,KAAI;IACnB,MAAM,kBAAkB,GAAG,IAAI,CAC7B,MAAM,CAAC,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