-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
531 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
.Rating { | ||
border-collapse: collapse; | ||
.star0, .star1 { | ||
width: 15px; | ||
height: 15px; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
157 changes: 157 additions & 0 deletions
157
v2/app/components/TrackCreationCard/TrackCreationCard.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
.circuit-poster { | ||
background-position: center; | ||
background-size: cover; | ||
background-repeat: no-repeat; | ||
|
||
line-height: normal; | ||
position: relative; | ||
font-family: Helvetica, arial, sans-serif; | ||
text-align: center; | ||
width: 130px; | ||
height: 130px; | ||
margin: 8px 20px; | ||
display: inline-block; | ||
&:hover { | ||
background-color: rgba(0,0,0,0.2); | ||
} | ||
|
||
@media screen and (max-width: 880px) { | ||
width: 110px; | ||
height: 110px; | ||
.circuit-name { | ||
font-size: 0.9em; | ||
} | ||
} | ||
|
||
.cup-poster { | ||
background-repeat: no-repeat; | ||
background-position: top left, top right, bottom left, bottom right; | ||
background-size: 50% 50%; | ||
background-size: calc(50% + 1px) calc(50% + 1px); | ||
} | ||
.circuit-rate { | ||
position: absolute; | ||
left: 0; | ||
bottom: 0; | ||
width: 100%; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
background-color: rgba(255,255,255, 0.6); | ||
opacity: 0.8; | ||
padding: 2px 0 3px 0; | ||
} | ||
&:hover .circuit-rate { | ||
opacity: 1; | ||
} | ||
.circuit-star { | ||
width: 15px; | ||
position: relative; | ||
} | ||
.circuit-star > div { | ||
position: absolute; | ||
left: 0; | ||
top: 1px; | ||
overflow: hidden; | ||
} | ||
.circuit-name { | ||
display: none; | ||
position: absolute; | ||
left: 10%; | ||
top: 50%; | ||
width: 80%; | ||
-webkit-transform: translateY(-50%); | ||
-moz-transform: translateY(-50%); | ||
-o-transform: translateY(-50%); | ||
-ms-transform: translateY(-50%); | ||
transform: translateY(-50%); | ||
background-color: white; | ||
color: black; | ||
opacity: 0.8; | ||
padding-top: 2px; | ||
padding-bottom: 2px; | ||
> div:first-child { | ||
word-wrap: break-word; | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
display: -webkit-box; | ||
-webkit-line-clamp: 3; | ||
line-clamp: 2; | ||
-webkit-box-orient: vertical; | ||
} | ||
} | ||
.circuit-author { | ||
margin: 1px 3px; | ||
font-size: 0.7em; | ||
opacity: 0.6; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
} | ||
.circuit-author img { | ||
height: 0.8em; | ||
margin-left: 2px; | ||
margin-right: 3px; | ||
} | ||
.circuit-author span { | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
white-space: nowrap; | ||
} | ||
.circuit-nbcomments { | ||
position: absolute; | ||
left: 0; | ||
top: 0; | ||
color: black; | ||
background-color: rgba(255,255,255, 0.6); | ||
padding: 2px 5px; | ||
border-bottom: solid 1px #AAA; | ||
border-right: solid 1px #AAA; | ||
border-bottom-right-radius: 3px; | ||
font-size: 12px; | ||
} | ||
.circuit-preview { | ||
display: none; | ||
position: absolute; | ||
right: 0; | ||
top: 0; | ||
background-color: rgba(255,255,255, 0.6); | ||
padding: 0px 5px; | ||
border-bottom: solid 1px #AAC; | ||
border-left: solid 1px #AAC; | ||
border-bottom-left-radius: 3px; | ||
cursor: zoom-in; | ||
} | ||
.circuit-preview:hover { | ||
background-color: rgba(230,230,230, 0.6); | ||
} | ||
.circuit-suppr { | ||
position: absolute; | ||
left: 40%; | ||
width: 20%; | ||
background-color: #FEE; | ||
opacity: 0.7; | ||
color: #F00; | ||
} | ||
.circuit-suppr:hover { | ||
opacity: 1; | ||
} | ||
.circuit-nbcomments img { | ||
height: 12px; | ||
position: relative; | ||
top: 2px; | ||
} | ||
.circuit-preview img { | ||
height: 12px; | ||
} | ||
&:hover .circuit-name { | ||
display: inline-block; | ||
} | ||
&:hover .circuit-preview { | ||
display: inline-block; | ||
} | ||
.circuit-star { | ||
display: inline-block; | ||
padding-top: 1px; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import styles from "./TrackCreationCard.module.scss" | ||
import useLanguage, { plural } from "../../hooks/useLanguage"; | ||
|
||
import userIcon from "../../images/icons/user.png" | ||
import commentIcon from "../../images/icons/comment.png" | ||
import previewIcon from "../../images/icons/preview.png" | ||
import Rating from "../Rating/Rating"; | ||
import { MouseEvent } from "react"; | ||
|
||
export type TrackCreation = { | ||
id: number, | ||
author: string, | ||
cicon: string, | ||
icons: string[], | ||
href: string, | ||
isCup: boolean, | ||
name: string, | ||
nbComments: number, | ||
publicationDate: number, | ||
rating: number, | ||
nbRatings: number | ||
} | ||
|
||
type Props = { | ||
creation: TrackCreation; | ||
onPreview: (creation: TrackCreation) => void; | ||
} | ||
function TrackCreationCard({ creation, onPreview }: Props) { | ||
const language = useLanguage(); | ||
|
||
function handlePreview(e: MouseEvent, creation: TrackCreation) { | ||
e.preventDefault(); | ||
onPreview(creation); | ||
} | ||
|
||
return <a href={creation.href} title={creation.name} className={styles["circuit-poster"]} | ||
style={{ backgroundImage: creation.icons ? creation.icons.map(src => `url('images/creation_icons/${src}')`).join(",") : undefined }}> | ||
<div className={styles["circuit-name"]}> | ||
<div className={styles["circuit-title"]}>{creation.name || (language ? "Untitled" : "Sans titre")}</div> | ||
{creation.author && <div className={styles["circuit-author"]}> | ||
<img src={userIcon.src} alt={language ? "Author" : "Auteur"} /> | ||
<span>{creation.author}</span> | ||
</div>} | ||
</div> | ||
<div className={styles["circuit-rate"]}> | ||
<Rating rating={creation.rating} nbRatings={creation.nbRatings} /> | ||
</div> | ||
<div className={styles["circuit-nbcomments"]} title={plural(language ? "%n comment%s" : "%n commentaire%s", creation.nbComments)}> | ||
<img src={commentIcon.src} alt={language ? "Comments" : "Commentaires"} /><span> {creation.nbComments}</span> | ||
</div> | ||
<div className={styles["circuit-preview"]} title={language ? "Preview" : "Aperçu"} onClick={(e) => handlePreview(e, creation)}> | ||
<img src={previewIcon.src} alt={language ? "Preview" : "Aperçu"} /> | ||
</div> | ||
</a> | ||
} | ||
|
||
export default TrackCreationCard; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
export function buildQuery(params: Record<string, string | number | (string | number)[]>) { | ||
return Object.entries(params) | ||
.filter(([_key, value]) => value != null) | ||
.map(([key, value]) => { | ||
if (Array.isArray(value)) { | ||
return value.map((v, i) => `${key}[${i}]=${encodeURIComponent(v)}`).join("&"); | ||
} else { | ||
return `${key}=${encodeURIComponent(value)}`; | ||
} | ||
}) | ||
.join("&"); | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.