CodingTrain / CodingTrain/thecodingtrain.com

`VideoSection` can be refactored

オープン
#1,341 コメント 5 件 リアクション 1 件 担当者 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
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。