GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — `VideoSection` can be refactored · Issue #1341 · CodingTrain/thecodingtrain.com

VideoSection can be refactored #1341

New issue
Copy link
New issue
Copy link
Open
Open
VideoSection can be refactored#1341
Copy link

Description

@aryanpingle
aryanpingle
opened on Dec 23, 2023
Issue body actions

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 and 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 image
image image
image image

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.

Reacted by Loïc Bertrand

Activity

  1. aryanpingle commented on Dec 23, 2023

    @aryanpingle
    aryanpingle
    on Dec 23, 2023
    ContributorAuthor
    More actions

    Another separate issue that arises because of the code duplication is that timestamps aren't left-padded with zeroes in Challenges:

    Challenges Tracks
    image image

    I suppose we just need to add a line somewhere in challenges/VideoSection.js, but refactoring the code will help us easily fix this anyway.

    (Also I just wanna mention these are minor nitpicks, this codebase is generally excellently structured LOL)

  2. loic-brtd commented on Jan 19, 2024

    @loic-brtd
    loic-brtd
    on Jan 19, 2024
    Contributor
    More actions

    Another separate issue that arises because of the code duplication is that timestamps aren't left-padded with zeroes in Challenges

    @aryanpingle Regarding timestamps, I think they're directly taken from the JSON files, without any transformation. So the differences come from the JSON files themselves.

    content/videos/challenges/171-wave-function-collapse/index.json :

      "timestamps": [
        { "time": "0:00", "title": "Day 1! Wave Function Collapse!" },
        { "time": "2:00", "title": "Entropy in Sudoku." },
    

    content/videos/webgl/3-light-and-material/index.json :

      "timestamps": [
        { "time": "00:00", "title": "Introduction" },
        { "time": "00:45", "title": "Material is the \"skin\" of 3D object" },
    
    Reacted by Francis Turmel
  3. shiffman commented on Mar 19, 2024

    @shiffman
    shiffman
    on Mar 19, 2024
    Member
    More actions

    Thank you @aryanpingle for filing this and @loic-brtd for your response! I would love to streamline the code and data format as much as possible for the site! @fturmel and @dipamsen do you have any thoughts about this?

  4. fturmel commented on Mar 20, 2024

    @fturmel
    fturmel
    on Mar 20, 2024
    Collaborator
    More actions

    Sure, it could be worth an attempt at merging/refactoring these two components (as long as we find wind a way to not dramatically increase cyclomatic complexity because we're chasing DRY too hard).

    Are the CSS differences actual bugs though? Challenges don't have h2s, for example.

    Reacted by Dipam Sen
  5. fturmel commented on Mar 20, 2024

    @fturmel
    fturmel
    on Mar 20, 2024
    Collaborator
    More actions

    For the timestamps, I assume we want the zero padding enforced?

    The build step already computes the timestamp representation in seconds, so we could format this value with the correct padding in React.

    Or, we could update the JSON sources (it can be automated) and be stricter about the format in the content tests. Less redundant compute down the road. This might affect (positively?) the youtube description generator script as well.

    EDIT: I suppose a third option is handling the formatting cleanup at the Gatsby build step. The YouTube description generator reads from the JSON source though if that matters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402520 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.