How to use the @codesandbox/common/lib/templates/icons function in @codesandbox/common

To help you get started, we’ve selected a few @codesandbox/common examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github codesandbox / codesandbox-client / packages / homepage / src / screens / home / Frameworks / index.js View on Github external
{templates.map(({ name, niceName }, i) => {
                const TIcon = getIcon(name);

                return (
                   {
                      this.setTemplate(templates[i]);
                    }}
                    as="button"
                    aria-label={`${niceName} template`}
                  >
                    
                  
                );
github codesandbox / codesandbox-client / packages / app / src / app / components / SandboxList / SandboxList.tsx View on Github external
{sandboxes.map((s, i) => {
        // TODO: investigate type mismatch between SmallSandbox and getIcon
        // @ts-ignore
        const Icon = getIcon(s.template);

        return (
          
            
              {/* We should probably use the Sandbox interface instead
                 * of SmallSandbox
                // @ts-ignore */}
              {getSandboxName(s)}
              
            
            {format(new Date(s.insertedAt), 'MMM dd, yyyy')}
            {format(new Date(s.updatedAt), 'MMM dd, yyyy')}
            
              
            
            {s.likeCount}
github codesandbox / codesandbox-client / packages / homepage / src / screens / home / Frameworks / index.js View on Github external
render() {
    const { templates } = this.props;
    const template = templates[this.state.templateIndex];
    const additionalInfo = TEMPLATE_SUPPORT[template.name] || {
      loaders: [],
      css: [],
      description: `Used for ${template.niceName} development, based on: `,
    };
    const TemplateIcon = getIcon(template.name);

    return (
      
        
          
            
              {templates.map(({ name, niceName }, i) => {
                const TIcon = getIcon(name);

                return (
                   {
github codesandbox / codesandbox-client / packages / app / src / app / components / SandboxList / index.js View on Github external
{sandboxes.map((s, i) => {
        const Icon = getIcon(s.template);
        return (
          
            
              {s.title || s.id}
              
            
            {moment(s.insertedAt).format('ll')}
            {moment(s.updatedAt).format('ll')}
            
              
            
            {s.likeCount}
            {s.viewCount}
            {s.forkCount}
            {isCurrentUser && (
github codesandbox / codesandbox-client / packages / app / src / app / components / CreateNewSandbox / CreateSandbox / SandboxCard / SandboxCard.tsx View on Github external
title,
  iconUrl,
  environment,
  official,
  color,
  focused,
  detailText,
  onClick,
  onFocus,
  onKeyPress,
  onMouseOver,
  DetailComponent,
}) => {
  const UserIcon: React.FunctionComponent =
    iconUrl && Icons[iconUrl] ? Icons[iconUrl] : getColorIcons(environment);
  const OfficialIcon: React.FunctionComponent = getColorIcons(environment);
  const parsedEnvironment = getEnvironment(environment);

  const elRef = React.useRef();

  React.useEffect(() => {
    const inputHasFocus =
      document.activeElement && document.activeElement.tagName === 'INPUT';
    if (focused && elRef.current && !inputHasFocus) {
      elRef.current.focus();
    }
  }, [focused]);

  return (
github codesandbox / codesandbox-client / packages / homepage / src / screens / explore / SandboxModal.js View on Github external
render() {
    const { sandbox } = this.state;
    const Icon = sandbox ? getIcon(sandbox.template) : Fragment;
    const template = sandbox ? getTemplate(sandbox.template) : {};

    return (
      
        
          {this.props.openPreviousSandbox && (
            
          )}
          {this.props.openNextSandbox && (
            
          )}
github codesandbox / codesandbox-client / packages / app / src / app / pages / Sandbox / Editor / Workspace / Project / SandboxConfig / TemplateConfig / Icon / index.tsx View on Github external
const {
    actions: {
      workspace: { editTemplate },
    },
    state: {
      editor: {
        currentSandbox: { customTemplate, template },
      },
    },
  } = useOvermind();
  const popover = usePopoverState();
  const [selectedIcon, setSelectedIcon] = useState(
    customTemplate.iconUrl || ''
  );

  const DefaultIcon = getIcon(template);
  const defaultColor =
    customTemplate.color || templates.default(template).color();

  const setIcon = (key: string) => {
    setSelectedIcon(key);

    popover.hide();

    editTemplate({ ...customTemplate, iconUrl: key });
  };
  const TemplateIcon = Icons[selectedIcon];

  return (
    
      Icon
github codesandbox / codesandbox-client / packages / app / src / app / pages / Sandbox / Editor / Workspace / items / NotOwnedSandboxInfo / SandboxInfo.tsx View on Github external
const TemplateIcon = ({
  iconUrl,
  environment,
}: {
  iconUrl: string;
  environment: Template;
}) => {
  const UserIcon: React.FunctionComponent =
    Icons[iconUrl] || getIcon(environment.name);

  return (
    
      
    
  );
};
github codesandbox / codesandbox-client / packages / app / src / app / components / CreateNewSandbox / CreateSandbox / SandboxCard / SandboxCard.tsx View on Github external
export const SandboxCard: React.FC = ({
  title,
  iconUrl,
  environment,
  official,
  color,
  focused,
  detailText,
  onClick,
  onFocus,
  onKeyPress,
  onMouseOver,
  DetailComponent,
}) => {
  const UserIcon: React.FunctionComponent =
    iconUrl && Icons[iconUrl] ? Icons[iconUrl] : getColorIcons(environment);
  const OfficialIcon: React.FunctionComponent = getColorIcons(environment);
  const parsedEnvironment = getEnvironment(environment);

  const elRef = React.useRef();

  React.useEffect(() => {
    const inputHasFocus =
      document.activeElement && document.activeElement.tagName === 'INPUT';
    if (focused && elRef.current && !inputHasFocus) {
      elRef.current.focus();
    }
  }, [focused]);

  return (