Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 19 additions & 23 deletions frontend/src/Components/ImagePicker/ImagePicker.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -37,35 +37,31 @@
max-height: 25em;
overflow-y: scroll;
display: flex;
flex-direction: row;
justify-content: center;
flex-direction: column;
justify-content: flex-start;
flex-wrap: wrap;
gap: 0.5em;
margin: 0 auto;
gap: 1em;
margin-top: 1em;

@include for-tablet-up {
flex-direction: row;
}
}

.image {
@include rounded;
@include shadow-light;
width: 10em;
height: 8em;
background-color: $grey-1;
background-size: cover;
background-position: center;
border: 3px solid transparent;
transition: 0.2s;
transform: scale(0.9);
cursor: pointer;
.image_box {
overflow: hidden;
flex-basis: calc(25% - 1em);
min-height: 12em;
height: 12em;
box-sizing: inherit;

&:hover {
filter: brightness(110%);
@include for-tablet-down {
flex-basis: calc(33.33% - 1em);
}
}

&.selected_image {
box-shadow: 0 0 25px 5px rgba(143, 181, 238, 0.625);
border: 3px solid $blue;
transform: scale(1);
}
.image_box_selected {
border: none;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bør nok fjernes å heller gjøre alt av selected state i ImageTile .. ?


.search_wrapper {
Expand Down
11 changes: 6 additions & 5 deletions frontend/src/Components/ImagePicker/ImagePicker.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Icon } from '@iconify/react';
import { keepPreviousData, useQuery } from '@tanstack/react-query';
import classNames from 'classnames';
import { type ReactNode, useCallback, useEffect, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { ImageTile } from '~/Components/ImageTile';
import { getImagesPaginated } from '~/api';
import { BACKEND_DOMAIN } from '~/constants';
import type { ImageDto } from '~/dto';
Expand Down Expand Up @@ -62,12 +62,13 @@ export function ImagePicker({ onSelected, selectedImage }: ImagePickerProps) {
function renderImage(image: ImageDto): ReactNode {
const isSelected = selected?.id === image.id;
return (
<button
type="button"
<ImageTile
key={image.id}
className={classNames(styles.image, isSelected && styles.selected_image)}
image={image}
className={styles.image_box}
selected={isSelected}
selectedClassName={styles.image_box_selected}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fjern linje 70

onClick={() => select(image)}
style={backgroundImageFromUrl(BACKEND_DOMAIN + image.url)}
/>
);
}
Expand Down
53 changes: 53 additions & 0 deletions frontend/src/Components/ImageTile/ImageTile.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
@use 'src/constants' as *;

@use 'src/mixins' as *;

.imageContainer {
@include rounded;
@include shadow-light;
display: flex;
flex-direction: column;
justify-content: flex-end;
overflow: hidden;
background-repeat: no-repeat;
background-position: center;
background-size: cover;
transition: 0.2s;
border: none;

&:hover {
transform: scale(1.02);
}
}

.clickable {
cursor: pointer;
padding: 0;
text-align: inherit;
}

.selected {
box-shadow: 0 0 25px 5px rgba(143, 181, 238, 0.625);
border: 3px solid $blue;
transform: scale(1);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lag denne default selected mer clean!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gjør alt av selected css shit her ..? Så trenger man ikke ha masse css props osv overalt .. ?

Copy link
Copy Markdown
Contributor

@Erichseen Erichseen Mar 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image Ser litt halv jalla ut


.imageTitle {
color: $white;
text-align: center;
min-height: 2em;
}

.text {
font-size: 1.2em;
padding: 0.2em;
background-color: $black;
text-decoration: none;
}

.tags {
font-size: 0.8em;
padding: 0.4em;
background-color: $black-t75;
text-decoration: none;
}
55 changes: 55 additions & 0 deletions frontend/src/Components/ImageTile/ImageTile.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import classNames from 'classnames';
import { BACKEND_DOMAIN } from '~/constants';
import type { ImageDto } from '~/dto';
import { backgroundImageFromUrl } from '~/utils';
import styles from './ImageTile.module.scss';

type ImageTileProps = {
image: ImageDto;
className?: string;
selected?: boolean;
selectedClassName?: string;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fjern selectedClassName

onClick?(): void;
};

function TileContent({ image }: Pick<ImageTileProps, 'image'>) {
const imageTags = image.tags.map((tag) => ` ${tag.name}`).toString();

return (
<>
<div className={styles.imageTitle}>
<p className={styles.text}>{image.title}</p>
<p className={styles.tags}>{imageTags}</p>
</div>
</>
);
}

export function ImageTile({ image, className, selected = false, selectedClassName, onClick }: ImageTileProps) {
const tileClassName = classNames(
styles.imageContainer,
className,
selected && styles.selected,
selected && selectedClassName,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fjern selectedClassName

onClick && styles.clickable,
);

if (onClick !== undefined) {
return (
<button
type="button"
className={tileClassName}
style={backgroundImageFromUrl(BACKEND_DOMAIN + image.url)}
onClick={onClick}
>
<TileContent image={image} />
</button>
);
}

return (
<div className={tileClassName} style={backgroundImageFromUrl(BACKEND_DOMAIN + image.url)}>
<TileContent image={image} />
</div>
);
}
1 change: 1 addition & 0 deletions frontend/src/Components/ImageTile/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { ImageTile } from './ImageTile';
1 change: 1 addition & 0 deletions frontend/src/Components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export { IconButton } from './IconButton';
export { Image } from './Image';
export { ImageCard } from './ImageCard';
export { ImageList } from './ImageList';
export { ImageTile } from './ImageTile';
export { ImageQuery } from './ImageQuery';
export { Input, type InputProps } from './Input';
export { InputField } from './InputField';
Expand Down

This file was deleted.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AdminImage trenger vel ikke lenger å være sin egen komponent når den ikke legger til noe lenger, bare bruk ImageTile direkte ImageAdminPage 👍

Original file line number Diff line number Diff line change
@@ -1,29 +1,11 @@
import classNames from 'classnames';
import { BACKEND_DOMAIN } from '~/constants';
import { ImageTile } from '~/Components';
import type { ImageDto } from '~/dto';
import { backgroundImageFromUrl } from '~/utils';
import styles from './AdminImage.module.scss';

type AdminImageProps = {
image: ImageDto;
className?: string;
};

export function AdminImage({ image, className }: AdminImageProps) {
const TAGS = image.tags
.map((tag) => {
return ` ${tag.name}`;
})
.toString();
return (
<div
className={classNames(styles.imageContainer, className)}
style={backgroundImageFromUrl(BACKEND_DOMAIN + image.url)}
>
<div className={styles.imageTitle}>
<p className={styles.text}>{image.title}</p>
<p className={styles.tags}>{TAGS}</p>
</div>
</div>
);
return <ImageTile image={image} className={className} />;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fint! Men kan du gjøre stylingen litt mindre "forstyrrende" til bildet som ligger bak? Enten alt eller noe av dette kan prøves:

  • Gjøre teksten litt mindre
  • Gjøre overlayet enda mer gjennomsiktig (men fortsatt lesbart med god kontrast)
  • Kanskje legge tekst under selve bildet

}
Loading