Skip to content

Commit

Permalink
Temporarily re-add ExerciseImagePlaceholder.tsx
Browse files Browse the repository at this point in the history
This fixes a problem with the background with exercises that don't have an image
  • Loading branch information
rolandgeider committed Feb 2, 2024
1 parent cc027d2 commit afd2464
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 7 deletions.
21 changes: 21 additions & 0 deletions src/components/Exercises/Detail/ExerciseImagePlaceholder.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import PhotoIcon from "@mui/icons-material/Photo";
import { Box } from "@mui/material";
import React from "react";

export const ExerciseImagePlaceholder = (props: {
backgroundColor?: string | undefined,
iconColor?: string | undefined,
height?: number | undefined,
}) => {

const backgroundColor = props.backgroundColor || "lightgray";
const iconColor = props.iconColor || "gray";
const height = props.height || 200;

return <Box sx={{ backgroundColor: backgroundColor, height: height }}
display="flex"
alignItems="center"
justifyContent="center">
<PhotoIcon sx={{ fontSize: 80, color: iconColor }} />
</Box>;
};
4 changes: 2 additions & 2 deletions src/components/Exercises/Detail/OverviewCard.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Card, CardActionArea, CardContent, CardMedia, Chip, Typography, } from "@mui/material";
import Tooltip from "@mui/material/Tooltip";
import { ExerciseImageAvatar } from "components/Exercises/Detail/ExerciseImageAvatar";
import { ExerciseImagePlaceholder } from "components/Exercises/Detail/ExerciseImagePlaceholder";
import { Exercise } from "components/Exercises/models/exercise";
import { Language } from "components/Exercises/models/language";
import React from "react";
Expand Down Expand Up @@ -36,7 +36,7 @@ export const OverviewCard = ({ exercise, language }: OverviewCardProps) => {
sx={{ height: 200 }}
alt="" />
: <CardMedia>
<ExerciseImageAvatar image={exercise.mainImage!} />
<ExerciseImagePlaceholder />
</CardMedia>}
<CardContent>
<Tooltip title={translation.name} placement="top" arrow>
Expand Down
11 changes: 6 additions & 5 deletions src/services/image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ export const IMAGE_PATH = 'exerciseimage';
/*
* Post a new exercise image
*/
export const postExerciseImage = async (data: {
exerciseId: number,
image: File,
imageData: ImageFormData
}
export const postExerciseImage = async (
data: {
exerciseId: number,
image: File,
imageData: ImageFormData
},
): Promise<ExerciseImage> => {
const url = makeUrl(IMAGE_PATH);
const headers = makeHeader();
Expand Down

0 comments on commit afd2464

Please sign in to comment.