generated from goitacademy/react-homework-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
3,543 additions
and
1,440 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,48 @@ | ||
export const App = () => { | ||
return ( | ||
<div | ||
style={{ | ||
height: '100vh', | ||
display: 'flex', | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
fontSize: 40, | ||
color: '#010101' | ||
}} | ||
> | ||
React homework template | ||
</div> | ||
); | ||
}; | ||
import React, { Component } from 'react' | ||
import Searchbar from './Searchbar/Searchbar' | ||
import Modal from './Modal/Modal' | ||
// import styled from 'styled-components' | ||
// import styled from '@emotion/styled' | ||
|
||
|
||
// export default | ||
class App extends Component { | ||
|
||
|
||
state = { showModal: false, }; | ||
|
||
// Открытие и закрытие модального окна | ||
toggleModal = () => { | ||
this.setState(({ showModal })=> ({ | ||
showModal: !showModal, | ||
})); | ||
}; | ||
|
||
|
||
render() { | ||
const { showModal } = this.state; | ||
|
||
|
||
|
||
|
||
return ( | ||
<> | ||
<Searchbar/> | ||
<button type='button' onClick={this.toggleModal}>Open modal</button> | ||
{/* <ImageGallery /> | ||
<ImageGalleryItem /> | ||
<Loader />*/} | ||
{/* <Button /> */} | ||
|
||
{showModal && <Modal onClose={this.toggleModal} > <h2>Modal Hallo</h2> | ||
<p>Lorem, ipsum dolor sit amet consectetur adipisicing elit. Reprehenderit, molestias assumenda aliquid incidunt corrupti a pariatur ratione rerum numquam alias omnis in non totam voluptatum quas voluptatem! Non, aspernatur? Suscipit!</p> | ||
<button type='button' onClick={this.toggleModal}>Close modal</button> | ||
</Modal> } | ||
|
||
</> | ||
) | ||
} | ||
} | ||
export default App | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { Component } from 'react' | ||
import css from './Modal.module.css' | ||
import {createPortal} from 'react-dom'; | ||
|
||
const modalRoot= document.querySelector('#modal-root'); | ||
export default class Modal extends Component { | ||
|
||
componentWillUnmount() { | ||
console.log('modal WillUnmount '); | ||
document.removeEventListener('keydown', this.handleKeyEsc) | ||
} | ||
componentDidMount() { | ||
console.log(' modal DidMount'); | ||
// /?????????????????????????????? | ||
window.addEventListener('keydown', this.handleKeyEsc); | ||
|
||
}; | ||
// /?????????????????????????????? | ||
|
||
|
||
|
||
|
||
handleKeyEsc = (e) => { | ||
if (e.key === 'Escape') this.props.onClose() | ||
console.log('Esc'); | ||
} | ||
|
||
// const { children, toggleModal } = this.props | ||
render() { | ||
return createPortal( | ||
<div className={css.modalBackdrop}> | ||
<div className={css.modalContent}>{this.props.children} </div> | ||
</div>, | ||
modalRoot, | ||
); | ||
} | ||
|
||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
// const Modal = ({ children}) => { | ||
// return ( | ||
// <div | ||
// className='modal fade show' | ||
// style={{ display: 'block', backdropFilter: 'blur(5px)' }} | ||
// // onClick={toggleModal} | ||
// > | ||
// <div className='modal-dialog'> | ||
// <div className='modal-content'> | ||
// <div className='modal-header'> | ||
// <h5 className='modal-title'> Modal</h5> | ||
// <button | ||
// type='button' | ||
// className='btn-close' | ||
// aria-label='Close' | ||
// // onClick={toggleModal} | ||
// ></button> | ||
// </div> | ||
// <div className='modal-body'>{children}</div> | ||
// </div> | ||
// </div> | ||
// </div> | ||
// ) | ||
// } | ||
|
||
// export default Modal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
.modalBackdrop{ | ||
position: fixed; | ||
top: 25%; | ||
left: 25%; | ||
width:50% ; | ||
height: 50%; | ||
background-color: rgb(195, 195, 222); | ||
border-radius: 5px; | ||
border: 0.5px solid ; | ||
border-color: brown; | ||
/* z-index: 999; */ | ||
} | ||
|
||
.modalContent { | ||
position: absolute; | ||
top:50%; | ||
left: 50%; | ||
transform: translate(-50%, -50%); | ||
background-color: white; | ||
/* max-width: 600px; | ||
min-height: 300px; | ||
border-radius: 5px; */ | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import React, { Component } from 'react' | ||
|
||
export default class Searchbar extends Component { | ||
|
||
|
||
|
||
|
||
render() { | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
return ( | ||
<div> | ||
<header class="searchbar"> | ||
<form class="form"> | ||
<button type="submit" class="button"> | ||
<span class="button-label">Search</span> | ||
</button> | ||
|
||
<input | ||
class="input" | ||
type="text" | ||
autocomplete="off" | ||
autofocus | ||
placeholder="Search images and photos" | ||
/> | ||
</form> | ||
|
||
{/* <button type='button' onClick={this.toggleModal}>Open modal</button> */} | ||
</header> | ||
</div> | ||
) | ||
} | ||
} | ||
|
||
|
||
// 38614458-d50fcc5469c58311283d9e834 | ||
|
||
// https://pixabay.com/api/?key=38614458-d50fcc5469c58311283d9e834&q=yellow+flowers&image_type=photo&pretty=true |
Oops, something went wrong.