13 votes

Thoughts on collapsible code snippets?

One thing I ended up realizing is that for e.g. code challenges in ~comp, there could be threads with a lot of code blocks that could easily take up a ton of screen real-estate. Something like the following isn't so bad:

/*
    This is a short multi-line example that doesn't
    take up much screen real-estate at all.
*/

But, what if the average comment for a particular topic has several of these with 100 lines or more? This could make navigating the comments really cumbersome as the number of comments grows. In the case of code challenges, lengthy code snippets could be very common, and collapsing the comment threads may not be the desirable course of action--in collapsing the thread for navigational convenience, you lose the ability to view and contribute to discussions. Hosting the code elsewhere risks links expiring or becoming lost or broken, and it feels like a clunky workaround to try to avoid inconveniencing other users.

With that in mind, what are your thoughts on having these code blocks display in a collapsed state by default with only a preview of the code block showing? Is there any support for this idea? If so, should this be implemented as part of Tildes itself or as a client-side extension of some sort? Are there any concerns about this?

(If there's general support for the idea, but opposition toward adding it to the Tildes code base, I may get off my lazy ass and try to hack something together.)

4 comments

  1. [4]
    Comment deleted by author
    Link
    1. [3]
      Emerald_Knight
      Link Parent
      This was my biggest concern. Desktop? Still cumbersome, but at least I have a scroll wheel with fine control over the scrolling and a quick scrolling rate. Mobile? Most likely an incredibly...

      I wonder what it would look like on mobile. . . I would prefer it to be in the site officially as I'm sure mobile users could benefit from it.

      This was my biggest concern. Desktop? Still cumbersome, but at least I have a scroll wheel with fine control over the scrolling and a quick scrolling rate. Mobile? Most likely an incredibly frustrating wall of text that takes ages to work through. Additionally, making it a client-side extension would mean adding another step that, on mobile, could take a bit of extra effort.

      If you'd like, you can always submit a PR for it instead of creating an extension all by yourself. ;)

      I might do that, but it wouldn't be until early next week. My schedule is a bit packed this weekend. If the extension is updated before then, I have no problem with that :)

      1 vote
      1. [2]
        tegla
        Link Parent
        Won't be cumbersome if you make the box resizable, no?

        Desktop? Still cumbersome, but at least I have a scroll wheel with fine control over the scrolling and a quick scrolling rate.

        Won't be cumbersome if you make the box resizable, no?

        1. Emerald_Knight
          Link Parent
          I'm not entirely sure what you're suggesting. Are you saying they would remain as they are, but would act like the comment box with the draggable corner? If so, that wouldn't really resolve the...

          I'm not entirely sure what you're suggesting. Are you saying they would remain as they are, but would act like the comment box with the draggable corner? If so, that wouldn't really resolve the problem.

  2. crius
    (edited )
    Link
    Hey, As @Bauke said, it can be easily done with some basic css/js. We'll give it a try after this weekend, you're welcome to fork out the repo and run a pull request if you're quicker :)

    Hey, As @Bauke said, it can be easily done with some basic css/js.
    We'll give it a try after this weekend, you're welcome to fork out the repo and run a pull request if you're quicker :)

    3 votes