-
Notifications
You must be signed in to change notification settings - Fork 1
Create events add image title in graphic page #2114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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'; | ||
|
|
@@ -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} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fjern linje 70 |
||
| onClick={() => select(image)} | ||
| style={backgroundImageFromUrl(BACKEND_DOMAIN + image.url)} | ||
| /> | ||
| ); | ||
| } | ||
|
|
||
| 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); | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lag denne default selected mer clean!
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 .. ?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| .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; | ||
| } | ||
| 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; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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> | ||
| ); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export { ImageTile } from './ImageTile'; |
This file was deleted.
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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} />; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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:
|
||
| } | ||

There was a problem hiding this comment.
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 .. ?