轮播图像
This commit is contained in:
parent
65e97a3a24
commit
d5a25a56bd
|
|
@ -11,13 +11,21 @@ import {
|
||||||
CarouselPrevious,
|
CarouselPrevious,
|
||||||
type CarouselApi,
|
type CarouselApi,
|
||||||
} from "@/ui/carousel";
|
} from "@/ui/carousel";
|
||||||
|
const imageUrls = [
|
||||||
|
|
||||||
|
"/images/carousel-1.jpg",
|
||||||
|
"/images/carousel-2.jpg",
|
||||||
|
"/images/carousel-3.jpg",
|
||||||
|
"/images/carousel-4.jpg",
|
||||||
|
"/images/carousel-5.jpg",
|
||||||
|
"/images/carousel-6.jpg",
|
||||||
|
];
|
||||||
export function CarouselDemo() {
|
export function CarouselDemo() {
|
||||||
const [api, setApi] = React.useState<CarouselApi>();
|
const [api, setApi] = React.useState<CarouselApi>();
|
||||||
const [current, setCurrent] = React.useState(0);
|
const [current, setCurrent] = React.useState(0);
|
||||||
const [count, setCount] = React.useState(0);
|
const [count, setCount] = React.useState(0);
|
||||||
|
|
||||||
const totalSlides = 6;
|
const totalSlides = imageUrls.length;
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (!api) return;
|
if (!api) return;
|
||||||
|
|
@ -46,12 +54,16 @@ export function CarouselDemo() {
|
||||||
className="w-full"
|
className="w-full"
|
||||||
>
|
>
|
||||||
<CarouselContent>
|
<CarouselContent>
|
||||||
{Array.from({ length: totalSlides }).map((_, index) => (
|
{imageUrls.map((src, index) => (
|
||||||
<CarouselItem key={index}>
|
<CarouselItem key={index}>
|
||||||
<div className="p-1">
|
<div className="p-1">
|
||||||
<Card>
|
<Card>
|
||||||
<CardContent className="flex aspect-square items-center justify-center p-6">
|
<CardContent className="flex aspect-square items-center justify-center p-6">
|
||||||
<span className="text-4xl font-semibold">{index + 1}</span>
|
<img
|
||||||
|
src={src}
|
||||||
|
alt={`Slide ${index + 1}`}
|
||||||
|
className="w-full h-full object-cover"
|
||||||
|
/>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,10 @@ import { CarouselDemo } from "@/components/untils/Carousel";
|
||||||
import type { Route } from "./+types/news";
|
import type { Route } from "./+types/news";
|
||||||
import { Header } from "@/components/header/Header";
|
import { Header } from "@/components/header/Header";
|
||||||
import { TopNav } from "@/components/header/TopNav";
|
import { TopNav } from "@/components/header/TopNav";
|
||||||
|
import NewsList from "@/components/list/NewsList";
|
||||||
|
|
||||||
|
import { C } from "node_modules/react-router/dist/development/index-react-server-client-rcoGPJhU.mjs";
|
||||||
|
import { Carousel } from "@/ui/carousel";
|
||||||
|
|
||||||
|
|
||||||
export function meta({}: Route.MetaArgs) {
|
export function meta({}: Route.MetaArgs) {
|
||||||
|
|
@ -14,8 +18,6 @@ export function meta({}: Route.MetaArgs) {
|
||||||
export default function Home() {
|
export default function Home() {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Header />
|
|
||||||
<TopNav />
|
|
||||||
<CarouselDemo />
|
<CarouselDemo />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 52 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 416 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 824 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 21 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 3.6 MiB |
Binary file not shown.
|
After Width: | Height: | Size: 549 KiB |
Loading…
Reference in New Issue