Skip to content

Commit 08ad585

Browse files
committed
workaround for phones
1 parent 22e2909 commit 08ad585

File tree

3 files changed

+45
-15
lines changed

3 files changed

+45
-15
lines changed

test/public/demo.gif

2.5 MB
Loading

test/src/index.jsx

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,17 @@ const copyToClipboard = (text) => {
2424

2525
export const App = () => {
2626
const [tasks, setTasks] = useState([]);
27+
const [isMobile, setIsMobile] = useState(false);
28+
29+
React.useEffect(() => {
30+
const checkMobile = () => {
31+
setIsMobile(window.innerWidth <= 768);
32+
};
33+
34+
checkMobile();
35+
window.addEventListener('resize', checkMobile);
36+
return () => window.removeEventListener('resize', checkMobile);
37+
}, []);
2738

2839
React.useMemo(() => {
2940
console.log('App rerender');
@@ -66,21 +77,27 @@ export const App = () => {
6677
JavaScript, so you drop it in anywhere – script tag, npm, you name it!
6778
</p>
6879

69-
<div className="task-section">
70-
<p>Try interacting with this input to see it in action:</p>
71-
<AddTaskBar
72-
onCreate={(value) => {
73-
if (!value) return;
74-
setTasks([...tasks, value]);
75-
}}
76-
/>
77-
<TaskList
78-
tasks={tasks}
79-
onDelete={(value) =>
80-
setTasks(tasks.filter((task) => task !== value))
81-
}
82-
/>
83-
</div>
80+
{isMobile ? (
81+
<div className="demo-section">
82+
<img src="/demo.gif" alt="React Scan Demo" className="demo-gif" />
83+
</div>
84+
) : (
85+
<div className="task-section">
86+
<p>Try interacting with this input to see it in action:</p>
87+
<AddTaskBar
88+
onCreate={(value) => {
89+
if (!value) return;
90+
setTasks([...tasks, value]);
91+
}}
92+
/>
93+
<TaskList
94+
tasks={tasks}
95+
onDelete={(value) =>
96+
setTasks(tasks.filter((task) => task !== value))
97+
}
98+
/>
99+
</div>
100+
)}
84101
</div>
85102

86103
<div className="sticky-footer">

test/src/styles.css

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,3 +142,16 @@ aside {
142142
.copy-button:active {
143143
background: #eee;
144144
}
145+
146+
.demo-section {
147+
width: 100%;
148+
margin: 2rem 0;
149+
display: flex;
150+
justify-content: center;
151+
}
152+
153+
.demo-gif {
154+
max-width: 100%;
155+
border-radius: 8px;
156+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
157+
}

0 commit comments

Comments
 (0)