Sha256: 11b5051d7614afaeca65fd0a86df8b6734da1f38251c9b03d74e47fd40a3c14d

Contents?: true

Size: 963 Bytes

Versions: 9

Compression:

Stored size: 963 Bytes

Contents

import * as React from "react";
import assetUrl from "../support/asset_url";

interface IconProps {
  name: string;
  userAgent: string;
  iconExtraClassName?: string;
}

export const Icon: React.SFC<IconProps> = ({ name, userAgent, iconExtraClassName }) => {
  if (userAgent.match(/Node/)) {
    return <span className={`icon ${iconExtraClassName} ${name}`}>{name}</span>;
  }

  return (
    <svg className={`icon ${iconExtraClassName} ${name}`}>
      <use xmlnsXlink="http://www.w3.org/1999/xlink" xlinkHref={`${assetUrl("icons.svg")}#${name}`} />
    </svg>
  );
};

Icon.defaultProps = {
  iconExtraClassName: "icon--before",
};

interface IconWithoutUserAgentProps {
  name: string;
  iconExtraClassName?: string;
}

const IconWithoutUserAgent: React.SFC<IconWithoutUserAgentProps> = ({ name, iconExtraClassName }) => (
  <Icon name={name} userAgent={navigator.userAgent} iconExtraClassName={iconExtraClassName} />
);

export default IconWithoutUserAgent;

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
decidim-comments-0.9.3 app/frontend/application/icon.component.tsx
decidim-comments-0.9.2 app/frontend/application/icon.component.tsx
decidim-comments-0.9.1 app/frontend/application/icon.component.tsx
decidim-comments-0.9.0 app/frontend/application/icon.component.tsx
decidim-comments-0.8.4 app/frontend/application/icon.component.tsx
decidim-comments-0.8.3 app/frontend/application/icon.component.tsx
decidim-comments-0.8.2 app/frontend/application/icon.component.tsx
decidim-comments-0.8.1 app/frontend/application/icon.component.tsx
decidim-comments-0.8.0 app/frontend/application/icon.component.tsx