1
1
import { useState } from 'react' ;
2
2
import { ScrollingProvider , Section } from 'react-scroll-section' ;
3
+ import randomColor from 'randomcolor' ;
3
4
import ModeToggle , { Mode } from './ModeToggle' ;
4
5
import { DynamicMenu , StaticMenu } from './Menu' ;
5
6
import { Footer , Menu , SectionContainer } from './Builders' ;
6
7
import logo from './logo.svg' ;
7
8
8
9
function App ( ) {
9
10
const [ mode , setMode ] = useState < Mode > ( 'dynamic' ) ;
11
+ const [ sections , setSections ] = useState < string [ ] > ( [ ] ) ;
10
12
11
13
return (
12
14
< ScrollingProvider >
13
- < Menu > { mode === 'static' ? < StaticMenu /> : < DynamicMenu /> } </ Menu >
15
+ < Menu >
16
+ { mode === 'static' ? (
17
+ < StaticMenu />
18
+ ) : (
19
+ < DynamicMenu
20
+ onAdd = { ( ) =>
21
+ setSections ( ( prev ) => [ ...prev , `Section ${ sections . length + 1 } ` ] )
22
+ }
23
+ />
24
+ ) }
25
+ </ Menu >
14
26
15
27
< Section id = "home" >
16
28
< SectionContainer >
@@ -22,29 +34,47 @@ function App() {
22
34
</ Section >
23
35
24
36
< Section id = "about" >
25
- < SectionContainer background = "accent2" >
37
+ < SectionContainer background = { randomColor ( { seed : 'about' } ) } >
26
38
< span role = "img" aria-label = "hands up" >
27
39
🙋♂️
28
40
</ span >
29
41
</ SectionContainer >
30
42
</ Section >
31
43
32
44
< Section id = "projects" >
33
- < SectionContainer background = "accent3" >
45
+ < SectionContainer background = { randomColor ( { seed : 'projects' } ) } >
34
46
< span role = "img" aria-label = "computer" >
35
47
💻
36
48
</ span >
37
49
</ SectionContainer >
38
50
</ Section >
39
51
40
52
< Section id = "contact" >
41
- < SectionContainer >
53
+ < SectionContainer background = { randomColor ( { seed : 'contact' } ) } >
42
54
< span role = "img" aria-label = "letter" >
43
55
💌
44
56
</ span >
45
57
</ SectionContainer >
46
58
</ Section >
47
59
60
+ { sections . map ( ( name ) => (
61
+ < Section key = { name } id = { name } >
62
+ < SectionContainer background = { randomColor ( { seed : name } ) } >
63
+ < span >
64
+ { name } { ' ' }
65
+ < sup
66
+ aria-label = "Remove section"
67
+ onClick = { ( ) =>
68
+ setSections ( ( prev ) => prev . filter ( ( id ) => id !== name ) )
69
+ }
70
+ >
71
+ x
72
+ </ sup >
73
+ </ span >
74
+ </ SectionContainer >
75
+ </ Section >
76
+ ) ) }
77
+
48
78
< Footer >
49
79
< ModeToggle mode = { mode } onChange = { setMode } />
50
80
< a href = "https://www.netlify.com" >
0 commit comments