This repository has been archived by the owner on Aug 6, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2
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
9 changed files
with
76 additions
and
2,566 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import Image from "next/image"; | ||
import React, { useState, useEffect, useContext } from "react"; | ||
import { userInfoContext } from "../../context/userInfoContext"; | ||
import useSWR from "swr"; | ||
import BlurImage from "./BlurImage" | ||
import SkeletonImage from "./SkeltonImage" | ||
|
||
const fetcher = (url) => fetch(url).then((r) => r.json()); | ||
|
||
export default function OtherImages() { | ||
var ctx = useContext(userInfoContext); | ||
var access_limit = "" | ||
if (ctx.UserInfo !== null) { | ||
access_limit = "?" + new URLSearchParams(ctx.UserInfo.access_limit).toString() | ||
} | ||
|
||
const shuffle = ([...array]) => { | ||
for (let i = array.length - 1; i >= 0; i--) { | ||
const j = Math.floor(Math.random() * (i + 1)); | ||
[array[i], array[j]] = [array[j], array[i]]; | ||
} | ||
return array; | ||
} | ||
|
||
const { data, error } = useSWR( | ||
"../api/images/list" + access_limit, | ||
fetcher | ||
); | ||
if (!data) | ||
return ( | ||
<div> | ||
<div className="mx-auto max-w-2xl py-16 px-4 sm:py-24 sm:px-6 lg:max-w-7xl lg:px-8"> | ||
<div className="grid grid-cols-2 gap-y-10 gap-x-6 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 xl:gap-x-8"> | ||
{Array.apply(0, Array(10)).map(function (x, i) { | ||
return <SkeletonImage key={i} />; | ||
})} | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
var images = shuffle(data.slice(0, data.length)); | ||
images = images.slice(0, 10) | ||
|
||
return ( | ||
<div> | ||
<div className="mx-auto max-w-7xl p-6 sm:px-12"> | ||
<div className="mt-6 text-2xl font-semibold"> | ||
その他の作品 | ||
</div> | ||
</div> | ||
<div className="mx-auto max-w-2xl px-4 sm:px-6 lg:max-w-7xl lg:px-8"> | ||
<div className="grid grid-cols-2 gap-y-10 gap-x-6 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 xl:gap-x-8"> | ||
{images.reverse().map((image) => ( | ||
<BlurImage key={image.id} image={image} /> | ||
))} | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
fcd2553
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.
Successfully deployed to the following URLs:
ai-art – ./
ai-art.vercel.app
ai-art-fkunn1326.vercel.app
www.aipic.app
ai-art-git-main-fkunn1326.vercel.app
aipic.vercel.app
aipic.app