Skip to content

Commit 90b22bb

Browse files
committed
update basic display ui
1 parent f9cc7f4 commit 90b22bb

File tree

2 files changed

+46
-34
lines changed

2 files changed

+46
-34
lines changed

website/index.css

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,32 @@
66
body {
77
@apply flex justify-center items-start m-0 p-0;
88
}
9-
code {
10-
@apply whitespace-pre-wrap;
9+
h3 {
10+
@apply my-4 font-bold;
1111
}
1212
}
1313

1414
@layer components {
1515
.panel {
16-
@apply w-[400px];
16+
@apply w-[400px] flex flex-col items-center justify-start;
1717
}
1818
.list-container {
19-
@apply box-border border w-full h-[600px] overflow-scroll flex flex-col justify-start gap-4 p-2 border-solid border-black;
19+
@apply box-border border h-[600px] overflow-scroll flex flex-col justify-start gap-4 p-2 border-solid border-black pt-6 w-80;
2020
}
2121
.item {
2222
@apply flex-none w-full h-[100px] flex justify-center items-center bg-[black] text-white rounded-lg;
2323
}
2424
.grid-table {
2525
@apply grid grid-cols-[1fr_1fr] gap-16;
2626
}
27+
.code-block {
28+
@apply p-3 rounded-lg;
29+
--tw-bg-opacity: 1;
30+
background-color: var(--fallback-n, oklch(var(--n) / var(--tw-bg-opacity)));
31+
--tw-text-opacity: 1;
32+
color: var(--fallback-nc, oklch(var(--nc) / var(--tw-text-opacity)));
33+
}
34+
.code-block code {
35+
@apply whitespace-pre-wrap;
36+
}
2737
}

website/index.tsx

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ import autoScroll, { escapeWhenUpPlugin } from "../package/index.ts";
55

66
import "./index.css";
77

8+
const Phone = ({ children }) => (
9+
<div className="mockup-phone">
10+
<div className="camera"></div>
11+
<div className="display bg-base-200">{children}</div>
12+
</div>
13+
);
14+
815
const useDynamicList = ({ max = 999 }: { max?: number } = {}) => {
916
const [list, setList] = useState<number[]>([]);
1017
const dataRef = useRef({
@@ -27,12 +34,10 @@ const useDynamicList = ({ max = 999 }: { max?: number } = {}) => {
2734
};
2835

2936
const codes = {
30-
default: `
31-
import autoScroll from "@yrobot/auto-scroll";
37+
default: `import autoScroll from "@yrobot/auto-scroll";
3238
3339
autoScroll({ selector: "#scroll-container-id" });`,
34-
escapeScrollUp: `
35-
import autoScroll, { escapeWhenUpPlugin } from "@yrobot/auto-scroll";
40+
escapeScrollUp: `import autoScroll, { escapeWhenUpPlugin } from "@yrobot/auto-scroll";
3641
3742
autoScroll({
3843
selector: "#scroll-container-id",
@@ -52,30 +57,21 @@ const DefaultDemo = () => {
5257
return (
5358
<div className="panel">
5459
<h3>Default (auto scroll always)</h3>
55-
<div className="list-container" id="default-list-container">
56-
{list.map((id) => (
57-
<div className="item" key={id}>
58-
{id}
59-
</div>
60-
))}
61-
{/* <div>
60+
<Phone>
61+
<div className="list-container" id="default-list-container">
6262
{list.map((id) => (
6363
<div className="item" key={id}>
6464
{id}
6565
</div>
6666
))}
67-
</div> */}
68-
{/* <div
69-
className="item"
70-
style={{
71-
height: list.length * 100,
72-
}}
73-
>
74-
Height Update [{list.length * 100}px]
75-
</div> */}
76-
<div className="loading">LOADING...</div>
67+
<div className="loading">LOADING...</div>
68+
</div>
69+
</Phone>
70+
<div className="code-block mt-4">
71+
<pre>
72+
<code>{codes.default}</code>
73+
</pre>
7774
</div>
78-
<code>{codes.default}</code>
7975
</div>
8076
);
8177
};
@@ -93,15 +89,21 @@ const EscapeScrollUpDemo = () => {
9389
return (
9490
<div className="panel">
9591
<h3>Stop Auto Scroll When User Scroll Up</h3>
96-
<div className="list-container" id="escape-scroll-up-list-container">
97-
{list.map((id) => (
98-
<div className="item" key={id}>
99-
{id}
100-
</div>
101-
))}
102-
<div className="loading">LOADING...</div>
92+
<Phone>
93+
<div className="list-container" id="escape-scroll-up-list-container">
94+
{list.map((id) => (
95+
<div className="item" key={id}>
96+
{id}
97+
</div>
98+
))}
99+
<div className="loading">LOADING...</div>
100+
</div>
101+
</Phone>
102+
<div className="code-block mt-4">
103+
<pre>
104+
<code>{codes.escapeScrollUp}</code>
105+
</pre>
103106
</div>
104-
<code>{codes.escapeScrollUp}</code>
105107
</div>
106108
);
107109
};

0 commit comments

Comments
 (0)