Compare commits
4 commits
27dbd26459
...
890944ab64
| Author | SHA1 | Date | |
|---|---|---|---|
| 890944ab64 | |||
| 05f0f80600 | |||
| ce1751c871 | |||
| 21d22ab5e8 |
6 changed files with 69 additions and 33 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
import type { CardDownloadType } from '@/types/cards'
|
import type { CardDownloadType } from '@/types/cards'
|
||||||
import Mdown from './Mdown'
|
import Mdown from './Mdown'
|
||||||
|
import { useState } from 'react'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
title: string
|
title: string
|
||||||
|
|
@ -9,7 +10,41 @@ interface Props {
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function Card({ title, content, id, downloads }: Props) {
|
export default function Card({ title, content, id, downloads }: Props) {
|
||||||
|
return (
|
||||||
|
<div className="bg-[#161718] w-xl max-w-4/5 p-5 flex flex-col gap-5 rounded-xl self-center hover:shadow-xl/20 hover:shadow-white transition-shadow mb-5">
|
||||||
|
<h1 className="text-white text-2xl font-bold" id={id?.toString()}>
|
||||||
|
<Mdown>{title}</Mdown>
|
||||||
|
</h1>
|
||||||
|
<div className=" flex flex-col space-y-1 text-[#9e9b97]">
|
||||||
|
<Mdown>{content}</Mdown>
|
||||||
|
</div>
|
||||||
|
{downloads != null ? (
|
||||||
|
<details className="text-[#9e9b97]">
|
||||||
|
<summary>Téléchargments</summary>
|
||||||
|
<ol className="list-disc list-inside pl-5">
|
||||||
|
{downloads.map((e, i) => (
|
||||||
|
<Download e={e} i={i} />
|
||||||
|
))}
|
||||||
|
</ol>
|
||||||
|
</details>
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
interface DownloadProps {
|
||||||
|
e: CardDownloadType
|
||||||
|
i: number
|
||||||
|
}
|
||||||
|
|
||||||
|
function Download({ e, i }: DownloadProps) {
|
||||||
|
const [isDownloading, setIsDownloading] = useState(false)
|
||||||
|
|
||||||
function download(path: URL, fileName = 'file') {
|
function download(path: URL, fileName = 'file') {
|
||||||
|
if (isDownloading) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
setIsDownloading(true)
|
||||||
fetch(path)
|
fetch(path)
|
||||||
.then((response) => response.blob())
|
.then((response) => response.blob())
|
||||||
.then((blob) => {
|
.then((blob) => {
|
||||||
|
|
@ -24,37 +59,25 @@ export default function Card({ title, content, id, downloads }: Props) {
|
||||||
link.click()
|
link.click()
|
||||||
|
|
||||||
link.parentNode?.removeChild(link)
|
link.parentNode?.removeChild(link)
|
||||||
|
|
||||||
|
setIsDownloading(false)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="bg-[#161718] w-lg p-5 flex flex-col gap-5 rounded-xl self-center">
|
<li>
|
||||||
<h1 className="text-white text-2xl font-bold" id={id?.toString()}>
|
<a
|
||||||
<Mdown>{title}</Mdown>
|
key={i}
|
||||||
</h1>
|
className={
|
||||||
<div className=" flex flex-col space-y-1 text-[#9e9b97]">
|
isDownloading
|
||||||
<Mdown>{content}</Mdown>
|
? 'text-gray-600 underline cursor-wait'
|
||||||
</div>
|
: 'text-sky-600 underline cursor-pointer'
|
||||||
{downloads != null ? (
|
}
|
||||||
<details className="text-[#9e9b97]">
|
onClick={() => download(e.link, e.filename)}
|
||||||
<summary>Téléchargments</summary>
|
>
|
||||||
<ol className="list-disc list-inside pl-5">
|
{isDownloading ? '[Téléchargement en cours ...] ' : null}{' '}
|
||||||
{downloads.map((e, i) => (
|
{e.title}
|
||||||
<li>
|
</a>
|
||||||
<a
|
</li>
|
||||||
href={e.link.toString()}
|
|
||||||
key={i}
|
|
||||||
download={e.filename}
|
|
||||||
className="text-sky-600 underline"
|
|
||||||
onClick={() => download(e.link, e.filename)}
|
|
||||||
>
|
|
||||||
{e.title}
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
))}
|
|
||||||
</ol>
|
|
||||||
</details>
|
|
||||||
) : null}
|
|
||||||
</div>
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,9 +22,22 @@ export default function Mdown({ children }: Props) {
|
||||||
const { node, ...rest } = props
|
const { node, ...rest } = props
|
||||||
return <li className="pl-5" {...rest} />
|
return <li className="pl-5" {...rest} />
|
||||||
},
|
},
|
||||||
|
p(props) {
|
||||||
|
const { node, ...rest } = props
|
||||||
|
return <p className="text-justify" {...rest} />
|
||||||
|
},
|
||||||
|
code(props) {
|
||||||
|
const { node, ...rest } = props
|
||||||
|
return (
|
||||||
|
<code
|
||||||
|
className="bg-gray-900 border-gray-600 border rounded-sm p-1 text-sm"
|
||||||
|
{...rest}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
},
|
||||||
a(props) {
|
a(props) {
|
||||||
const { node, ...rest } = props
|
const { node, ...rest } = props
|
||||||
const classes = 'text-sky-600 underline'
|
const classes = 'text-sky-700 underline'
|
||||||
if (rest.href?.startsWith('dl:')) {
|
if (rest.href?.startsWith('dl:')) {
|
||||||
let parts = rest.href.split('/')
|
let parts = rest.href.split('/')
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ function App() {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="bg-[url(/public/bg.jpeg)] bg-cover bg-no-repeat bg-center min-h-screen">
|
<div className="bg-[url(/public/bg.jpeg)] bg-cover bg-no-repeat bg-center min-h-screen">
|
||||||
<div className="flex flex-col gap-5 pt-10">
|
<div className="flex flex-col pt-10">
|
||||||
<h1 className="text-5xl text-white text-center mb-10">
|
<h1 className="text-5xl text-white text-center mb-10">
|
||||||
{data.title}
|
{data.title}
|
||||||
</h1>
|
</h1>
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ export default function Projects() {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="bg-[url(/public/bg.jpeg)] bg-cover bg-no-repeat bg-center min-h-screen">
|
<div className="bg-[url(/public/bg.jpeg)] bg-cover bg-no-repeat bg-center min-h-screen">
|
||||||
<div className="flex flex-col gap-5 pt-10">
|
<div className="flex flex-col pt-10">
|
||||||
<h1 className="text-5xl text-white text-center mb-10">
|
<h1 className="text-5xl text-white text-center mb-10">
|
||||||
{data.title}
|
{data.title}
|
||||||
</h1>
|
</h1>
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ export default function Projects() {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="bg-[url(/public/bg.jpeg)] bg-cover bg-no-repeat bg-center min-h-screen">
|
<div className="bg-[url(/public/bg.jpeg)] bg-cover bg-no-repeat bg-center min-h-screen">
|
||||||
<div className="flex flex-col gap-5 pt-10">
|
<div className="flex flex-col pt-10">
|
||||||
<h1 className="text-5xl text-white text-center mb-10">
|
<h1 className="text-5xl text-white text-center mb-10">
|
||||||
{data.title}
|
{data.title}
|
||||||
</h1>
|
</h1>
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ export default function Projects() {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="bg-[url(/public/bg.jpeg)] bg-cover bg-no-repeat bg-center min-h-screen">
|
<div className="bg-[url(/public/bg.jpeg)] bg-cover bg-no-repeat bg-center min-h-screen">
|
||||||
<div className="flex flex-col gap-5 pt-10">
|
<div className="flex flex-col pt-10">
|
||||||
<h1 className="text-5xl text-white text-center mb-10">
|
<h1 className="text-5xl text-white text-center mb-10">
|
||||||
{data.title}
|
{data.title}
|
||||||
</h1>
|
</h1>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue