diff options
| -rw-r--r-- | frontend/src/components/Summary.tsx | 73 | ||||
| -rw-r--r-- | frontend/src/css/Maps.css | 1 |
2 files changed, 42 insertions, 32 deletions
diff --git a/frontend/src/components/Summary.tsx b/frontend/src/components/Summary.tsx index 23da82c..79e989f 100644 --- a/frontend/src/components/Summary.tsx +++ b/frontend/src/components/Summary.tsx | |||
| @@ -21,13 +21,11 @@ const Summary: React.FC<SummaryProps> = ({ selectedRun, setSelectedRun, data }) | |||
| 21 | (r[idx] as HTMLElement).style.backgroundColor = "#161723" | 21 | (r[idx] as HTMLElement).style.backgroundColor = "#161723" |
| 22 | 22 | ||
| 23 | 23 | ||
| 24 | if (data && data.summary.routes.length !== 0 && data.summary.routes.length !== 0) { | 24 | if (data && data.summary.routes.length !== 0) { |
| 25 | if (category_id === 2) { idx += data.summary.routes.filter(e => e.category.id < 2).length } | 25 | idx += data.summary.routes.filter(e => e.category.id < category_id).length // lethimcook |
| 26 | if (category_id === 3) { idx += data.summary.routes.filter(e => e.category.id < 3).length } | ||
| 27 | if (category_id === 4) { idx += data.summary.routes.filter(e => e.category.id < 4).length } | ||
| 28 | setSelectedRun(idx); | 26 | setSelectedRun(idx); |
| 29 | } | 27 | } |
| 30 | } | 28 | }; |
| 31 | 29 | ||
| 32 | function _get_youtube_id(url: string): string { | 30 | function _get_youtube_id(url: string): string { |
| 33 | const urlArray = url.split(/(vi\/|v=|\/v\/|youtu\.be\/|\/embed\/)/); | 31 | const urlArray = url.split(/(vi\/|v=|\/v\/|youtu\.be\/|\/embed\/)/); |
| @@ -37,7 +35,9 @@ const Summary: React.FC<SummaryProps> = ({ selectedRun, setSelectedRun, data }) | |||
| 37 | function _category_change() { | 35 | function _category_change() { |
| 38 | const btn = document.querySelectorAll("#section3 #category span button"); | 36 | const btn = document.querySelectorAll("#section3 #category span button"); |
| 39 | btn.forEach((e) => { (e as HTMLElement).style.backgroundColor = "#2b2e46" }); | 37 | btn.forEach((e) => { (e as HTMLElement).style.backgroundColor = "#2b2e46" }); |
| 40 | (btn[selectedCategory - 1] as HTMLElement).style.backgroundColor = "#202232"; | 38 | // heavenly father forgive me for i have sinned. TODO: fix this bullshit with dynamic categories |
| 39 | const idx = selectedCategory === 1 ? 0 : data.map.is_coop ? selectedCategory - 3 : selectedCategory - 1; | ||
| 40 | (btn[idx] as HTMLElement).style.backgroundColor = "#202232"; | ||
| 41 | }; | 41 | }; |
| 42 | 42 | ||
| 43 | function _history_change() { | 43 | function _history_change() { |
| @@ -47,7 +47,7 @@ const Summary: React.FC<SummaryProps> = ({ selectedRun, setSelectedRun, data }) | |||
| 47 | }; | 47 | }; |
| 48 | 48 | ||
| 49 | React.useEffect(() => { | 49 | React.useEffect(() => { |
| 50 | _history_change(); | 50 | _history_change(); |
| 51 | }, [historySelected]); | 51 | }, [historySelected]); |
| 52 | 52 | ||
| 53 | React.useEffect(() => { | 53 | React.useEffect(() => { |
| @@ -65,15 +65,27 @@ const Summary: React.FC<SummaryProps> = ({ selectedRun, setSelectedRun, data }) | |||
| 65 | <div id='category' | 65 | <div id='category' |
| 66 | style={data.map.image === "" ? { backgroundColor: "#202232" } : {}}> | 66 | style={data.map.image === "" ? { backgroundColor: "#202232" } : {}}> |
| 67 | <img src={data.map.image} alt="" id='category-image'></img> | 67 | <img src={data.map.image} alt="" id='category-image'></img> |
| 68 | <p><span className='portal-count'>{data.summary.routes.sort((a, b) => a.category.id - b.category.id)[selectedRun].history.score_count}</span> | 68 | <p><span className='portal-count'>{data.summary.routes[selectedRun].history.score_count}</span> |
| 69 | {data.summary.routes.sort((a, b) => a.category.id - b.category.id)[selectedRun].history.score_count === 1 ? ` portal` : ` portals`}</p> | 69 | {data.summary.routes[selectedRun].history.score_count === 1 ? ` portal` : ` portals`}</p> |
| 70 | <span> | 70 | {data.map.is_coop ? // TODO: make this part dynamic |
| 71 | <button onClick={() => setSelectedCategory(1)}>CM</button> | 71 | ( |
| 72 | <button onClick={() => setSelectedCategory(2)}>NoSLA</button> | 72 | <span style={{ gridTemplateColumns: "1fr 1fr 1fr" }}> |
| 73 | {data.map.is_coop ? <button onClick={() => setSelectedCategory(3)}>SLA</button> | 73 | <button onClick={() => setSelectedCategory(1)}>CM</button> |
| 74 | : <button onClick={() => setSelectedCategory(3)}>Inbounds SLA</button>} | 74 | <button onClick={() => setSelectedCategory(4)}>Any%</button> |
| 75 | <button onClick={() => setSelectedCategory(4)}>Any%</button> | 75 | <button onClick={() => setSelectedCategory(5)}>All Courses</button> |
| 76 | </span> | 76 | </span> |
| 77 | ) | ||
| 78 | : | ||
| 79 | ( | ||
| 80 | <span style={{ gridTemplateColumns: "1fr 1fr 1fr 1fr" }}> | ||
| 81 | |||
| 82 | <button onClick={() => setSelectedCategory(1)}>CM</button> | ||
| 83 | <button onClick={() => setSelectedCategory(2)}>NoSLA</button> | ||
| 84 | <button onClick={() => setSelectedCategory(3)}>Inbounds SLA</button> | ||
| 85 | <button onClick={() => setSelectedCategory(4)}>Any%</button> | ||
| 86 | </span> | ||
| 87 | ) | ||
| 88 | } | ||
| 77 | 89 | ||
| 78 | </div> | 90 | </div> |
| 79 | 91 | ||
| @@ -91,7 +103,6 @@ const Summary: React.FC<SummaryProps> = ({ selectedRun, setSelectedRun, data }) | |||
| 91 | <div id='records'> | 103 | <div id='records'> |
| 92 | 104 | ||
| 93 | {data.summary.routes | 105 | {data.summary.routes |
| 94 | .sort((a, b) => a.history.score_count - b.history.score_count) | ||
| 95 | .filter(e => e.category.id === selectedCategory) | 106 | .filter(e => e.category.id === selectedCategory) |
| 96 | .map((r, index) => ( | 107 | .map((r, index) => ( |
| 97 | <button className='record' key={index} onClick={() => { | 108 | <button className='record' key={index} onClick={() => { |
| @@ -125,22 +136,22 @@ const Summary: React.FC<SummaryProps> = ({ selectedRun, setSelectedRun, data }) | |||
| 125 | </div> | 136 | </div> |
| 126 | 137 | ||
| 127 | 138 | ||
| 128 | </section> | 139 | </section > |
| 129 | <section id='section4' className='summary1'> | 140 | <section id='section4' className='summary1'> |
| 130 | <div id='difficulty'> | 141 | <div id='difficulty'> |
| 131 | <span>Difficulty</span> | 142 | <span>Difficulty</span> |
| 132 | {data.summary.routes.sort((a, b) => a.category.id - b.category.id)[selectedRun].rating === 0 ? (<span>N/A</span>) : null} | 143 | {data.summary.routes[selectedRun].rating === 0 && (<span>N/A</span>)} |
| 133 | {data.summary.routes.sort((a, b) => a.category.id - b.category.id)[selectedRun].rating === 1 ? (<span style={{ color: "lime" }}>Very easy</span>) : null} | 144 | {data.summary.routes[selectedRun].rating === 1 && (<span style={{ color: "lime" }}>Very easy</span>)} |
| 134 | {data.summary.routes.sort((a, b) => a.category.id - b.category.id)[selectedRun].rating === 2 ? (<span style={{ color: "green" }}>Easy</span>) : null} | 145 | {data.summary.routes[selectedRun].rating === 2 && (<span style={{ color: "green" }}>Easy</span>)} |
| 135 | {data.summary.routes.sort((a, b) => a.category.id - b.category.id)[selectedRun].rating === 3 ? (<span style={{ color: "yellow" }}>Medium</span>) : null} | 146 | {data.summary.routes[selectedRun].rating === 3 && (<span style={{ color: "yellow" }}>Medium</span>)} |
| 136 | {data.summary.routes.sort((a, b) => a.category.id - b.category.id)[selectedRun].rating === 4 ? (<span style={{ color: "orange" }}>Hard</span>) : null} | 147 | {data.summary.routes[selectedRun].rating === 4 && (<span style={{ color: "orange" }}>Hard</span>)} |
| 137 | {data.summary.routes.sort((a, b) => a.category.id - b.category.id)[selectedRun].rating === 5 ? (<span style={{ color: "red" }}>Very hard</span>) : null} | 148 | {data.summary.routes[selectedRun].rating === 5 && (<span style={{ color: "red" }}>Very hard</span>)} |
| 138 | <div> | 149 | <div> |
| 139 | {data.summary.routes.sort((a, b) => a.category.id - b.category.id)[selectedRun].rating === 1 ? (<div className='difficulty-rating' style={{ backgroundColor: "lime" }}></div>) : (<div className='difficulty-rating'></div>)} | 150 | {data.summary.routes[selectedRun].rating === 1 ? (<div className='difficulty-rating' style={{ backgroundColor: "lime" }}></div>) : (<div className='difficulty-rating'></div>)} |
| 140 | {data.summary.routes.sort((a, b) => a.category.id - b.category.id)[selectedRun].rating === 2 ? (<div className='difficulty-rating' style={{ backgroundColor: "green" }}></div>) : (<div className='difficulty-rating'></div>)} | 151 | {data.summary.routes[selectedRun].rating === 2 ? (<div className='difficulty-rating' style={{ backgroundColor: "green" }}></div>) : (<div className='difficulty-rating'></div>)} |
| 141 | {data.summary.routes.sort((a, b) => a.category.id - b.category.id)[selectedRun].rating === 3 ? (<div className='difficulty-rating' style={{ backgroundColor: "yellow" }}></div>) : (<div className='difficulty-rating'></div>)} | 152 | {data.summary.routes[selectedRun].rating === 3 ? (<div className='difficulty-rating' style={{ backgroundColor: "yellow" }}></div>) : (<div className='difficulty-rating'></div>)} |
| 142 | {data.summary.routes.sort((a, b) => a.category.id - b.category.id)[selectedRun].rating === 4 ? (<div className='difficulty-rating' style={{ backgroundColor: "orange" }}></div>) : (<div className='difficulty-rating'></div>)} | 153 | {data.summary.routes[selectedRun].rating === 4 ? (<div className='difficulty-rating' style={{ backgroundColor: "orange" }}></div>) : (<div className='difficulty-rating'></div>)} |
| 143 | {data.summary.routes.sort((a, b) => a.category.id - b.category.id)[selectedRun].rating === 5 ? (<div className='difficulty-rating' style={{ backgroundColor: "red" }}></div>) : (<div className='difficulty-rating'></div>)} | 154 | {data.summary.routes[selectedRun].rating === 5 ? (<div className='difficulty-rating' style={{ backgroundColor: "red" }}></div>) : (<div className='difficulty-rating'></div>)} |
| 144 | </div> | 155 | </div> |
| 145 | </div> | 156 | </div> |
| 146 | <div id='count'> | 157 | <div id='count'> |
| @@ -151,13 +162,13 @@ const Summary: React.FC<SummaryProps> = ({ selectedRun, setSelectedRun, data }) | |||
| 151 | 162 | ||
| 152 | <section id='section5' className='summary1'> | 163 | <section id='section5' className='summary1'> |
| 153 | <div id='description'> | 164 | <div id='description'> |
| 154 | {data.summary.routes.sort((a, b) => a.category.id - b.category.id)[selectedRun].showcase !== "" ? | 165 | {data.summary.routes[selectedRun].showcase !== "" ? |
| 155 | <iframe title='Showcase video' src={"https://www.youtube.com/embed/" + _get_youtube_id(data.summary.routes[selectedRun].showcase)}> </iframe> | 166 | <iframe title='Showcase video' src={"https://www.youtube.com/embed/" + _get_youtube_id(data.summary.routes[selectedRun].showcase)}> </iframe> |
| 156 | : ""} | 167 | : ""} |
| 157 | <h3>Route Description</h3> | 168 | <h3>Route Description</h3> |
| 158 | <span id='description-text'> | 169 | <span id='description-text'> |
| 159 | <ReactMarkdown> | 170 | <ReactMarkdown> |
| 160 | {data.summary.routes.sort((a, b) => a.category.id - b.category.id)[selectedRun].description} | 171 | {data.summary.routes[selectedRun].description} |
| 161 | </ReactMarkdown> | 172 | </ReactMarkdown> |
| 162 | </span> | 173 | </span> |
| 163 | </div> | 174 | </div> |
diff --git a/frontend/src/css/Maps.css b/frontend/src/css/Maps.css index b69f588..5f28055 100644 --- a/frontend/src/css/Maps.css +++ b/frontend/src/css/Maps.css | |||
| @@ -101,7 +101,6 @@ p>span.portal-count{font-weight: bold;font-size: 100px;vertical-align: -15%;} | |||
| 101 | background-color: #202232; | 101 | background-color: #202232; |
| 102 | 102 | ||
| 103 | display: grid; | 103 | display: grid; |
| 104 | grid-template-columns: 1fr 1fr 1fr 1fr; | ||
| 105 | gap: 2px; | 104 | gap: 2px; |
| 106 | } | 105 | } |
| 107 | #category>span>button{ | 106 | #category>span>button{ |