CodingTrain / CodingTrain/thecodingtrain.com

`VideoSection` can be refactored

未關閉
#1,341 5 則留言 1 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
JavaScript
星號
283
分支
126
PR 合併指標
30 天內沒有已合併 PR

描述

I've listed some bugs below, but this is mostly a critique of the code structure which is the overarching problem.

I was trying to fix a small issue in #1339 that requires setting the background of the `VideoSection` component's `.timeline`. But there are 2 independent, yet similar implementations of `VideoSection` for Tracks and Challenges - this required changing 2 files for a feature that is common to both.

In fact, [challenges/VideoSection.js](https://github.com/CodingTrain/thecodingtrain.com/blob/main/src/components/challenges/VideoSection.js) and [tracks/VideoSection.js](https://github.com/CodingTrain/thecodingtrain.com/blob/main/src/components/tracks/VideoSection.js) are mostly the same except for a few variables and what happens when a "Track Stop" or a "Part" is clicked. Their respective CSS files are have even more similarity, differing in hardly a few lines (and these may be unintentional).

Is this important? Well yeah, because code redundancy has already caused some differences:

|Challenges|Tracks|
|:-:|:-:|
|![image](https://github.com/CodingTrain/thecodingtrain.com/assets/49340972/287e293f-f6c0-4aac-b09b-7a8f8543cd65)|![image](https://github.com/CodingTrain/thecodingtrain.com/assets/49340972/9a602b9e-917c-408d-8ae9-ea49bca8801f)|
|![image](https://github.com/CodingTrain/thecodingtrain.com/assets/49340972/b4c1f236-449a-4a89-84e0-15bd4e36eec2)|![image](https://github.com/CodingTrain/thecodingtrain.com/assets/49340972/60e064c2-4373-4876-8dac-3c9d44e6f231)|
|![image](https://github.com/CodingTrain/thecodingtrain.com/assets/49340972/318cc641-fbf8-4b3f-8567-e6d768a8309e)|![image](https://github.com/CodingTrain/thecodingtrain.com/assets/49340972/c7a7060f-6f7e-4fc1-902e-fa8fa8b23745)|

## Potential Solution

If we refactor `VideoSection` to be a Class Component instead of a Functional Component, we can inherit from a *more general* `VideoSection` that'll make the code more readable and DRY. The CSS files have practically no differences because we pass in the variant programmatically for UI changes. They can be merged, and we can use this merged file for the base `VideoSection` class.

貢獻指南

開啟貢獻指南

研究方向

先比較 src/components/challenges/VideoSection.js 和 src/components/tracks/VideoSection.js,以及它們的 CSS 檔案,以找出共用結構和刻意保留的差異。追蹤 Track Stop 和 Part 的點擊行為,接著確認重構後的共用元件和合併後的樣式保留兩種變體,並解決重複的 timeline 行為。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
javascript, react
領域
frontend
Issue 類型
重構
難度
5/5
預估耗時
一週以上
活躍度
停滯
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。