Skip to content

Conversation

emmadesilva
Copy link
Member

No description provided.

@emmadesilva emmadesilva added the run-visual-tests Internal label to trigger Browserstack visual testing label Nov 17, 2024
@emmadesilva
Copy link
Member Author

Claude Sonnet via Cursor

These styles are a bit bulky, especially the collapsing one. Should we bundle all these with HydePHP, or split out to an extended Torchlight stylesheet?

Based on the provided code and context, I can help analyze whether to split out the Torchlight styles. Let me break this down:

  1. Current Structure:
    The Torchlight styles are part of HydeFront's component styles, imported in the main app.css:
@import 'hydefront/components/table-of-contents.css';
@import 'hydefront/components/heading-permalinks.css';
@import 'hydefront/components/torchlight.css';
@import 'hydefront/components/blockquotes.css';
  1. Usage Analysis:
  • The Torchlight feature is optional in HydePHP, as shown in the features configuration:
    'features' => [
        // Page Modules
        Feature::HtmlPages,
        Feature::MarkdownPosts,
        Feature::BladePages,
        Feature::MarkdownPages,
        Feature::DocumentationPages,

        // Frontend Features
        Feature::Darkmode,
        Feature::DocumentationSearch,

        // Integrations
        Feature::Torchlight,
    ],
  1. Style Categories:
    The torchlight.css file contains three distinct sections:
  • Autolinking (3 lines)
  • Focusing (11 lines)
  • Collapsing (33 lines)
  1. Context from Documentation:
    Torchlight is a third-party integration that requires an API token to use:
## Torchlight

Torchlight is an amazing API for syntax highlighting, and is used by this site. I cannot recommend it highly enough,
especially for documentation sites and code-heavy blogs! As such, HydePHP has built-in support for Torchlight,
which is automatically enabled once you add an API token to your `.env` file. Nothing else needs to be done!

### Getting started

To get started you need an API token which you can get at [Torchlight.dev](https://torchlight.dev/).
It is entirely free for personal and open source projects, as seen on their [pricing page](https://torchlight.dev/#pricing).

When you have an API token, set it in the `.env` file in the root directory of your project.
Once a token is set, Hyde will automatically enable the CommonMark extension.

```env
TORCHLIGHT_TOKEN=torch_<your-api-token>
```

Recommendation:

I would recommend splitting the Torchlight styles into two files:

  1. Keep basic styles in the main torchlight.css:
/* Basic Torchlight styles */
.prose .torchlight-link,
.torchlight-link {
    text-decoration: underline;
}

/* Essential focusing styles */
.torchlight.has-focus-lines .line:not(.line-focus) {
    transition: filter 0.35s, opacity 0.35s;
    filter: blur(.095rem);
    opacity: .65;
}
 
.torchlight.has-focus-lines:hover .line:not(.line-focus) {
    filter: blur(0px);
    opacity: 1;
}
  1. Create a new torchlight-extended.css for collapsing features:
/* Collapsing feature styles */
.torchlight summary:focus {
    outline: none;
}

/* Rest of the collapsing styles... */

Rationale:

  1. The collapsing feature is more of an advanced use case and takes up the majority of the CSS
  2. Since Torchlight is an optional feature, keeping the styles modular aligns with Hyde's philosophy
  3. This approach would reduce the base CSS bundle size for users not using the collapsing features
  4. Users who need the collapsing features can opt-in by importing the extended stylesheet

Implementation suggestion:

/* Base torchlight.css */
@import 'torchlight/base.css';
@import 'torchlight/extended.css' (optional);

This aligns with Hyde's "batteries included but removable" approach seen throughout the codebase.

Copy link

codecov bot commented Nov 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (2bbd623) to head (f31b23f).
Report is 11 commits behind head on new-asset-system.

Additional details and impacted files
@@                 Coverage Diff                  @@
##             new-asset-system     #2039   +/-   ##
====================================================
  Coverage              100.00%   100.00%           
  Complexity               1906      1906           
====================================================
  Files                     195       195           
  Lines                    5080      5080           
====================================================
  Hits                     5080      5080           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@emmadesilva
Copy link
Member Author

Meh, don't think it's worth the complexity to add an extra file for a single style. Gonna merge them

@emmadesilva emmadesilva merged commit f93a7ba into new-asset-system Dec 1, 2024
12 checks passed
@emmadesilva emmadesilva deleted the support-more-torchlight-features branch December 1, 2024 12:17
@github-actions github-actions bot removed the run-visual-tests Internal label to trigger Browserstack visual testing label Dec 1, 2024
@emmadesilva emmadesilva mentioned this pull request Dec 1, 2024
17 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant