Skip to content

Commit 401b82b

Browse files
Dena BurdDena Burd
authored andcommitted
add title to print list
1 parent f6f5bd5 commit 401b82b

8 files changed

Lines changed: 87 additions & 51 deletions

File tree

src/App.css

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,11 @@ textarea {
211211
z-index: 1;
212212
width: 100%;
213213
opacity: 0.9;
214+
text-shadow:
215+
-0.5px -0.5px 0 #000,
216+
0.5px -0.5px 0 #000,
217+
-0.5px 0.5px 0 #000,
218+
0.5px 0.5px 0 #000;
214219
}
215220
.navbar ul {
216221
display: flex;
@@ -329,6 +334,24 @@ textarea {
329334
cursor: pointer;
330335
color: #666;
331336
}
337+
338+
.printList{
339+
list-style:circle;
340+
color: #3D1D5B;
341+
font-size: 20px;
342+
}
343+
344+
.printList li {
345+
padding:5px;
346+
}
347+
348+
.label{
349+
background-color: hsla(270, 92%, 15%, 0.95);
350+
float:left;
351+
padding:10px 20px;
352+
margin:0;
353+
}
354+
332355
/*media queries */
333356

334357
@media (max-width: 1130px) {

src/components/watchLIst/Print.js

Lines changed: 35 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,39 @@
1-
import React, { Component } from 'react';
1+
import React, { useRef, useState } from 'react';
22
import { PDFExport } from '@progress/kendo-react-pdf';
33
import PrintTemplate from './PrintTemplate';
44

5-
class Print extends Component {
6-
animeList;
5+
const Print = () => {
6+
const [title, setTitle] = useState('Watch List')
7+
const [comments, setComments] = useState('')
78

8-
state={
9-
redirect:false
10-
}
9+
const animeList = useRef(null);
10+
1111

12-
exportPDF = () => {
13-
this.animeList.save();
14-
this.setState({redirect:true})
12+
const exportPDF = () => {
13+
animeList.current.save();
1514
}
16-
17-
render() {
18-
return (
19-
<div style={{ height: '100vh', width: '100vw', paddingTop: 20}}>
20-
<div style={{ textAlign: 'center', marginBottom: 10 }}>
21-
<button
22-
className='btn btn-light'
23-
onClick={this.exportPDF}
24-
style={{ margin: 'auto' }}>
25-
download
26-
</button>
27-
</div>
28-
<PDFExport paperSize={'Letter'}
29-
fileName="animeList.pdf"
30-
title=""
31-
subject=""
32-
keywords=""
33-
ref={(r) => this.animeList = r}>
15+
16+
return (
17+
<div style={{ height: '100vh', width: '100vw'}}>
18+
<button
19+
className='btn btn-light'
20+
onClick={exportPDF}
21+
style={{ margin: '0 auto', display:'block' }}>
22+
Download
23+
</button>
24+
<form style={{ textAlign: 'center', margin: '20px auto 0 auto', width:'30%'}}>
25+
<label className='label'>Title:</label>
26+
<input value={title} type="text" onChange={(e)=>setTitle(e.target.value)} />
27+
{/* <label className='label'>Comments:</label>
28+
<input value={comments} type="text" onChange={(e)=>setComments(e.target.value)} /> */}
29+
</form>
30+
<PDFExport
31+
paperSize={'Letter'}
32+
fileName="animeList.pdf"
33+
title=""
34+
subject=""
35+
keywords=""
36+
ref={animeList}>
3437
<div
3538
style={{
3639
height: 792,
@@ -43,12 +46,12 @@ class Print extends Component {
4346
overflowY: 'hidden'
4447
}}
4548
>
46-
<PrintTemplate/>
49+
<PrintTemplate title={title} comments={comments}/>
4750
</div>
48-
</PDFExport>
49-
</div>
50-
)
51-
}
51+
</PDFExport>
52+
</div>
53+
54+
)
5255
}
5356

5457
export default Print;

src/components/watchLIst/PrintTemplate.js

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import React, {useContext, useEffect} from 'react'
22
import WatchListContext from '../../context/watchList/watchListContext'
33
import {Link} from "react-router-dom"
4+
import animaven from '../../img/animaven.png'
45

5-
const PrintTemplate = () => {
6+
const PrintTemplate = ({title, comments}) => {
67
const watchListContext = useContext(WatchListContext)
78
const {watchList, getListStorage} = watchListContext
89

@@ -11,34 +12,46 @@ const PrintTemplate = () => {
1112
// eslint-disable-next-line
1213
}, []);
1314

14-
1515
return (
1616
<div>
17-
<div className="text-dark-back p-1">
1817
<Link to='/'
1918
className='bold-header-text'
20-
style={{color:'#EAE6F4', textDecoration:'underline'}}
2119
>
22-
<h1>Animaven</h1>
20+
<img
21+
src={animaven}
22+
style={{width:'100%', margin:'0', padding:'0'}}
23+
/>
2324
</Link>
24-
25-
<h2>Watch List</h2>
26-
</div>
27-
<div className="light-container" >
25+
{title && title !== '' &&
26+
<div className="text-dark-back p-1" style={{marginTop:'-10px'}}>
27+
<h2>{title}</h2>
28+
</div>
29+
}
30+
31+
<div style={{padding:'20px 0 0 50px'}}>
2832
{watchList && watchList.length > 0 &&
29-
<ul>
33+
<ul className='printList'>
3034
{ watchList.map((item, idx) => (
3135
<div key={idx}>
3236
<li>
33-
<span className='listItem'>{item.title}</span>
37+
<span>{item.title}</span>
3438
</li>
3539
</div>
3640
))}
3741
</ul>
3842
}
43+
44+
{comments && (
45+
<>
46+
<hr style={{ margin:'30px 50px 0 0'}}/>
47+
<p style={{fontFamily:'times', color:'#505050'}}>
48+
Comments: {comments}
49+
</p>
50+
</>
51+
)}
52+
3953
</div>
4054
</div>
41-
4255
)
4356
}
4457

src/context/types.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,3 @@ export const GET_STORAGE = 'GET_STORAGE';
1010
export const REMOVE_LIST_ITEM = 'REMOVE_LIST_ITEM';
1111
export const SET_GENRE = 'SET_GENRE';
1212

13-
14-
15-
16-
17-

src/context/watchList/WatchListState.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ import {
99

1010
const WatchListState = props => {
1111
const initialState = {
12-
watchList:[]
12+
watchList:[],
13+
title:'Watch List',
14+
comments:'jjjj '
1315
}
1416

1517
const [state, dispatch] = useReducer(WatchListReducer, initialState)
@@ -27,7 +29,7 @@ const WatchListState = props => {
2729
payload:anime
2830
})
2931
}
30-
32+
3133
const getListStorage = () => {
3234
const storage = localStorage.getItem('state')
3335
// console.log('watch state get', storage)

src/img/animaven.png

277 KB
Loading

src/img/back.png

-7.65 MB
Binary file not shown.

src/img/bg3.png

-1.33 MB
Binary file not shown.

0 commit comments

Comments
 (0)