Compare commits
3 Commits
sem2-lab7-
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5c82bceccf | ||
|
|
eda72b4c70 | ||
| c0894969dd |
@@ -2,7 +2,7 @@ import NavBar from './components/Navbar'
|
|||||||
import Gallery from "./components/Gallery";
|
import Gallery from "./components/Gallery";
|
||||||
import Content from "./components/Content";
|
import Content from "./components/Content";
|
||||||
import CustomFooter from "./components/CustomFooter";
|
import CustomFooter from "./components/CustomFooter";
|
||||||
|
import Task from "./Task"
|
||||||
|
|
||||||
import './styles/App.css'
|
import './styles/App.css'
|
||||||
|
|
||||||
@@ -13,6 +13,7 @@ function App() {
|
|||||||
<Gallery/>
|
<Gallery/>
|
||||||
<Content/>
|
<Content/>
|
||||||
<CustomFooter/>
|
<CustomFooter/>
|
||||||
|
<Task/>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
38
labs/lab6/src/Task.tsx
Normal file
38
labs/lab6/src/Task.tsx
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
import { useState,useEffect } from "react"
|
||||||
|
import type {ReactElement} from "react"
|
||||||
|
const lines = [
|
||||||
|
"Ночь, улица, фонарь, аптека,",
|
||||||
|
"Бессмыссленный и тусклый свет.",
|
||||||
|
"Живи ещё хоть четверть века - ",
|
||||||
|
"Всё будет так. Исхода нет.",
|
||||||
|
"Умрёшь - начнёшь опять сначала",
|
||||||
|
"И повториться всё как встарь:",
|
||||||
|
"Ночь, ледяная рябь канала",
|
||||||
|
"Аптека, Улица, фонарь."
|
||||||
|
];
|
||||||
|
|
||||||
|
interface ComponentProps {
|
||||||
|
Inputinterval: number
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const Task = ({Inputinterval}:ComponentProps): ReactElement =>{
|
||||||
|
const [interval, updateInterval] = useState<number>(Inputinterval);
|
||||||
|
const [lineIdx, updateLineIdx] = useState<number>(0);
|
||||||
|
const updateLine = ():void =>{
|
||||||
|
updateLineIdx((lineIdx+1)%lines.length);
|
||||||
|
}
|
||||||
|
useEffect(()=>{
|
||||||
|
const intervalId = setInterval(updateLine,Number(interval));
|
||||||
|
return ()=>{ clearInterval(intervalId)}
|
||||||
|
})
|
||||||
|
return(
|
||||||
|
<>
|
||||||
|
<input type="number" value={interval} onChange={(event)=>{updateInterval(Number(event.target.value))}}></input>
|
||||||
|
<div className="blackDiv">
|
||||||
|
<h2 className="bigWhite">{lines[lineIdx]}</h2>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
export default Task;
|
||||||
@@ -24,8 +24,10 @@ interface ComponentProps {
|
|||||||
|
|
||||||
|
|
||||||
function BuildCard({ building,cardNum} : ComponentProps) {
|
function BuildCard({ building,cardNum} : ComponentProps) {
|
||||||
|
const reverseModifier = cardNum % 2 == 0 ? "-reverse" : "";
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card style={cardNum%2==0?{'flexDirection':'row-reverse'}:{}}sx={{ display: 'flex' }} >
|
<Card sx={{ display: 'flex', flexDirection:{xs:"column", sm:"row"+reverseModifier} }} >
|
||||||
<CardMedia
|
<CardMedia
|
||||||
component="img"
|
component="img"
|
||||||
alt={ building.title }
|
alt={ building.title }
|
||||||
|
|||||||
Reference in New Issue
Block a user