Skip to content

Commit 27b29b3

Browse files
feat: updated nextjs sample and docs (#180)
* feat: updated nextjs sample and docs * fix: added link to dynamic import components * fix: update nextjs to show frameworks * add typescript language on the description * add link to sdk website * fix: updated repo to match use-in-frameworks guide * fix: updated docs and css * fix: typo * add more notes to readme --------- Co-authored-by: felixindrawan <[email protected]>
1 parent 90d38e9 commit 27b29b3

File tree

14 files changed

+687
-263
lines changed

14 files changed

+687
-263
lines changed

hello-world/next/README.md

Lines changed: 401 additions & 14 deletions
Large diffs are not rendered by default.

hello-world/next/app/layout.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ import "./globals.css";
55
const inter = Inter({ subsets: ["latin"] });
66

77
export const metadata: Metadata = {
8-
title: "Create Next App",
9-
description: "Generated by create next app",
8+
title: "Hello World for Next.js - Dynamsoft Barcode Reader Sample",
9+
description: "Dynamsoft Barcode Reader in a Next.js Application, helps read barcodes from camera or images.",
10+
keywords: "barcodes, camera, images, nextjs",
1011
};
1112

1213
export default function RootLayout({

hello-world/next/app/page.css

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,44 +4,30 @@
44
align-items: center;
55
margin-top: 20px;
66
}
7-
.title .title-logo {
8-
width: 60px;
9-
height: 60px;
10-
animation: retate 5s infinite linear;
11-
}
12-
.top-btns {
7+
.buttons-container {
138
width: 30%;
149
margin: 20px auto;
1510
}
16-
.top-btns button {
11+
.buttons-container button {
1712
display: inline-block;
1813
border: 1px solid black;
1914
padding: 5px 15px;
2015
background-color: transparent;
2116
cursor: pointer;
2217
}
23-
.top-btns button:first-child {
18+
.buttons-container button:first-child {
2419
border-top-left-radius: 10px;
2520
border-bottom-left-radius: 10px;
2621
border-right: transparent;
2722
}
28-
.top-btns button:nth-child(2) {
23+
.buttons-container button:nth-child(2) {
2924
border-top-right-radius: 10px;
3025
border-bottom-right-radius: 10px;
3126
border-left: transparent;
3227
}
3328

34-
@media screen and (max-width: 500px) {
35-
.top-btns {
36-
width: 70%;
29+
@media screen and (max-width: 800px) {
30+
.buttons-container {
31+
width: 70%;
3732
}
3833
}
39-
40-
@keyframes retate {
41-
from {
42-
transform: rotate(0deg);
43-
}
44-
to {
45-
transform: rotate(360deg);
46-
}
47-
}

hello-world/next/app/page.tsx

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,51 @@
11
"use client";
22

3-
import { useState } from 'react';
3+
import dynamic from "next/dynamic";
4+
import { useState } from "react";
45
import "./page.css";
5-
import VideoCapture from '@/component/VideoCapture';
6-
import ImageCapture from '@/component/ImageCapture';
6+
7+
const VideoCapture = dynamic(() => import("../components/VideoCapture/VideoCapture"), {
8+
ssr: false,
9+
});
10+
const ImageCapture = dynamic(() => import("../components/ImageCapture/ImageCapture"), {
11+
ssr: false,
12+
});
13+
14+
enum Modes {
15+
VIDEO_CAPTURE = "video",
16+
IMAGE_CAPTURE = "image",
17+
}
718

819
export default function Home() {
9-
const [mode, setMode] = useState("video");
20+
const [mode, setMode] = useState(Modes.VIDEO_CAPTURE);
21+
22+
const showVideoCapture = () => setMode(Modes.VIDEO_CAPTURE);
23+
const showImageCapture = () => setMode(Modes.IMAGE_CAPTURE);
24+
1025
return (
11-
<div className='App'>
12-
<div className='title'>
13-
<h2 className='title-text'>Hello World for React</h2>
26+
<div className="hello-world-page">
27+
<div className="title">
28+
<h2 className="title-text">Hello World for Next.js</h2>
1429
</div>
15-
<div className='top-btns'>
16-
<button onClick={()=>{setMode("video")}} style={{backgroundColor: mode === "video" ? "rgb(255, 174, 55)" : "#fff"}}>Video Capture</button>
17-
<button onClick={()=>{setMode("image")}} style={{backgroundColor: mode === "image" ? "rgb(255, 174, 55)" : "#fff"}}>Image Capture</button>
30+
<div className="buttons-container">
31+
<button
32+
style={{
33+
backgroundColor: mode === Modes.VIDEO_CAPTURE ? "rgb(255,174,55)" : "white",
34+
}}
35+
onClick={showVideoCapture}
36+
>
37+
Decode Video
38+
</button>
39+
<button
40+
style={{
41+
backgroundColor: mode === Modes.IMAGE_CAPTURE ? "rgb(255,174,55)" : "white",
42+
}}
43+
onClick={showImageCapture}
44+
>
45+
Decode Image
46+
</button>
1847
</div>
19-
{ mode === "video" ? <VideoCapture /> : <ImageCapture /> }
48+
<div className="container">{mode === Modes.VIDEO_CAPTURE ? <VideoCapture /> : <ImageCapture />}</div>
2049
</div>
2150
);
2251
}

hello-world/next/component/ImageCapture.css

Lines changed: 0 additions & 18 deletions
This file was deleted.

hello-world/next/component/ImageCapture.tsx

Lines changed: 0 additions & 70 deletions
This file was deleted.

hello-world/next/component/VideoCapture.css

Lines changed: 0 additions & 11 deletions
This file was deleted.

hello-world/next/component/VideoCapture.tsx

Lines changed: 0 additions & 103 deletions
This file was deleted.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
.image-capture-container {
2+
width: 100%;
3+
height: 100%;
4+
font-family: Consolas, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono,
5+
Courier New, monospace;
6+
}
7+
8+
.image-capture-container .input-container {
9+
width: 80%;
10+
height: 100%;
11+
display: flex;
12+
justify-content: center;
13+
border: 1px solid black;
14+
margin: 0 auto;
15+
}
16+
17+
.image-capture-container .results {
18+
margin-top: 20px;
19+
height: 100%;
20+
}

0 commit comments

Comments
 (0)