All files / src/components/ui/splash Projects.tsx

0% Statements 0/25
0% Branches 0/2
0% Functions 0/10
0% Lines 0/24

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148                                                                                                                                                                                                                                                                                                       
import React from "react";
import l10n from "shared/lib/lang/l10n";
import styled from "styled-components";
import projectIcon from "ui/icons/gbsproj.png";
import { CloseIcon } from "ui/icons/Icons";
 
interface SplashProjectProps {
  project: {
    name: string;
    dir: string;
  };
  onClick: () => void;
  onRemove: () => void;
}
 
const SplashProjectRemoveButton = styled.div`
  position: absolute;
  top: 5px;
  right: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s ease-in-out;
  transition-delay: 0.2s;
  background: ${(props) => props.theme.colors.input.background};
  border: 0;
  border-radius: 4px;
  width: 25px;
  height: 25px;
 
  svg {
    fill: ${(props) => props.theme.colors.text};
    width: 10px;
    height: 10px;
    max-width: 10px;
    max-height: 10px;
  }
 
  &:hover {
    cursor: pointer;
    svg {
      fill: ${(props) => props.theme.colors.highlight};
    }
  }
`;
 
const SplashProjectWrapper = styled.button`
  position: relative;
  display: flex;
  text-align: left;
  background: ${(props) => props.theme.colors.input.background};
  color: ${(props) => props.theme.colors.text};
  border: 0;
  border-bottom: 1px solid ${(props) => props.theme.colors.input.border};
  border-radius: 0px;
  padding: 15px 30px;
  width: 100%;
 
  img {
    width: 42px;
    margin-right: 10px;
  }
 
  ${SplashProjectRemoveButton} {
    opacity: 0;
  }
 
  &:hover {
    background: ${(props) => props.theme.colors.input.hoverBackground};
    ${SplashProjectRemoveButton} {
      opacity: 1;
    }
  }
 
  &:active {
    background: ${(props) => props.theme.colors.input.activeBackground};
  }
 
  &:focus {
    background: transparent;
    box-shadow: inset 0 0 0px 2px #c92c61;
  }
 
  &:last-child {
    margin-bottom: 0;
  }
`;
 
const SplashProjectDetails = styled.span`
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
`;
 
const SplashProjectName = styled.span`
  display: block;
  font-size: 16px;
  font-weight: bold;
  margin-bottom: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
`;
 
const SplashProjectPath = styled.span`
  display: block;
  font-size: 11px;
  opacity: 0.8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
`;
 
export const SplashProjectClearButton = styled.div`
  display: flex;
  justify-content: center;
  padding: 30px;
`;
 
export const SplashProject = ({
  project,
  onClick,
  onRemove,
}: SplashProjectProps) => (
  <SplashProjectWrapper onClick={onClick}>
    <img src={projectIcon} alt="" draggable={false} />
    <SplashProjectDetails>
      <SplashProjectName>{project.name}</SplashProjectName>
      <SplashProjectPath>{project.dir}</SplashProjectPath>
    </SplashProjectDetails>
    <SplashProjectRemoveButton
      title={l10n("SPLASH_REMOVE_FROM_RECENT")}
      onClick={
        onRemove
          ? (e) => {
              e.preventDefault();
              e.stopPropagation();
              onRemove();
            }
          : undefined
      }
    >
      <CloseIcon />
    </SplashProjectRemoveButton>
  </SplashProjectWrapper>
);