{"version":3,"file":"Icon.mjs","names":[],"sources":["../src/Icon.tsx"],"sourcesContent":["/**\n * Copyright (c) 2024-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { type RecipeVariantProps, cva, css } from \"@ndla/styled-system/css\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport type { StyledProps } from \"@ndla/styled-system/types\";\nimport { type ComponentPropsWithRef } from \"react\";\n\nexport const iconRecipe = cva({\n  base: {\n    display: \"inline-block\",\n    fill: \"currentcolor\",\n    verticalAlign: \"middle\",\n    lineHeight: \"1em\",\n    flexShrink: \"0\",\n  },\n  defaultVariants: {\n    size: \"medium\",\n  },\n  variants: {\n    size: {\n      small: {\n        width: \"small\",\n        height: \"small\",\n      },\n      medium: {\n        width: \"medium\",\n        height: \"medium\",\n      },\n      large: {\n        width: \"xxlarge\",\n        height: \"xxlarge\",\n      },\n    },\n  },\n});\n\nexport type IconVariantProps = RecipeVariantProps<typeof iconRecipe>;\n\ninterface BaseIconProps extends ComponentPropsWithRef<\"svg\"> {\n  title?: string;\n  description?: string;\n}\n\nexport type Props = BaseIconProps & IconVariantProps & StyledProps;\n\nconst StyledSvg = styled(\"svg\");\n\nexport const Icon = ({\n  children,\n  size,\n  title,\n  description,\n  css: cssProp,\n  \"aria-hidden\": ariaHidden,\n  ...props\n}: Props) => {\n  return (\n    <StyledSvg\n      data-icon=\"\"\n      aria-hidden={ariaHidden ?? (props[\"aria-label\"] ? undefined : true)}\n      preserveAspectRatio=\"xMidYMid meet\"\n      css={css.raw(iconRecipe.raw({ size }), cssProp)}\n      {...props}\n    >\n      {!!title && <title>{title}</title>}\n      {!!description && <desc>{description}</desc>}\n      {children}\n    </StyledSvg>\n  );\n};\n"],"mappings":";;;;;;;;;;;;AAaA,MAAa,aAAa,IAAI;CAC5B,MAAM;EACJ,SAAS;EACT,MAAM;EACN,eAAe;EACf,YAAY;EACZ,YAAY;CACd;CACA,iBAAiB,EACf,MAAM,SACR;CACA,UAAU,EACR,MAAM;EACJ,OAAO;GACL,OAAO;GACP,QAAQ;EACV;EACA,QAAQ;GACN,OAAO;GACP,QAAQ;EACV;EACA,OAAO;GACL,OAAO;GACP,QAAQ;EACV;CACF,EACF;AACF,CAAC;AAWD,MAAM,YAAY,OAAO,KAAK;AAE9B,MAAa,QAAQ,EACnB,UACA,MACA,OACA,aACA,KAAK,SACL,eAAe,YACf,GAAG,YACQ;CACX,OACE,qBAAC,WAAD;EACE,aAAU;EACV,eAAa,eAAe,MAAM,gBAAgB,KAAA,IAAY;EAC9D,qBAAoB;EACpB,KAAK,IAAI,IAAI,WAAW,IAAI,EAAE,KAAK,CAAC,GAAG,OAAO;EAC9C,GAAI;YALN;GAOG,CAAC,CAAC,SAAS,oBAAC,SAAD,EAAA,UAAQ,MAAa,CAAA;GAChC,CAAC,CAAC,eAAe,oBAAC,QAAD,EAAA,UAAO,YAAkB,CAAA;GAC1C;EACQ;;AAEf"}