Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2.x] Refactor HydeFront styles to TailwindCSS #2024

Merged
merged 110 commits into from
Nov 17, 2024
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
1b72c55
Create HydeFront-v4-plan.md
caendesilva Nov 15, 2024
2722124
Update HydeFront-v4-plan.md
caendesilva Nov 15, 2024
1fbae95
Remove x-cloak style from app CSS as we have it in the head HTML
caendesilva Nov 15, 2024
7fa3711
Track changes made
caendesilva Nov 15, 2024
7704dca
Revert "Track changes made"
caendesilva Nov 15, 2024
65943c4
Replace `x-uncloak-md` class with pure Tailwind
caendesilva Nov 15, 2024
bb3324e
Remove now empty `alpine.scss` file
caendesilva Nov 15, 2024
1ee06c4
Replace the sidebar toggle styles with pure Tailwind
caendesilva Nov 15, 2024
68e9fa7
Remove now empty `sidebar-toggle.scss` file
caendesilva Nov 15, 2024
0e43590
Tweak sidebar toggle styles to blend in better
caendesilva Nov 15, 2024
92c4d11
Recreate improved sidebar toggle button
caendesilva Nov 15, 2024
712cf95
Define table of contents styles with Tailwind
caendesilva Nov 15, 2024
48bdd88
Define heading permalink styles with Tailwind
caendesilva Nov 16, 2024
c6dc8bd
Update code comments
caendesilva Nov 16, 2024
4575d7f
Merge branch 'new-asset-system' into refactor-hydefront-styles-to-tai…
caendesilva Nov 16, 2024
c9db18c
Begin recreating the HydeSearch plugin with Alpine
caendesilva Nov 16, 2024
4772fd1
Delete now unused `search.scss` file
caendesilva Nov 16, 2024
1db8107
Add top margin
caendesilva Nov 16, 2024
c6a2c77
Hide horizontal overflow
caendesilva Nov 16, 2024
b903795
Tweak colors
caendesilva Nov 16, 2024
531c4a0
Remove the debounce
caendesilva Nov 16, 2024
8089425
Use indigo styles
caendesilva Nov 16, 2024
4d739f2
Remove prose style
caendesilva Nov 16, 2024
96bc412
Fix spacing issue
caendesilva Nov 16, 2024
cabd5a4
Tweak styles
caendesilva Nov 16, 2024
fe4cdb9
Tweak margin
caendesilva Nov 16, 2024
cf17e40
Increase contrast
caendesilva Nov 16, 2024
835fcea
Revert "Tweak margin"
caendesilva Nov 16, 2024
fc9e2c0
Compile assets
caendesilva Nov 16, 2024
0e46a13
Update RELEASE_NOTES.md
caendesilva Nov 16, 2024
cf0dc9b
Merge HydeSearch Blade views into single component
caendesilva Nov 16, 2024
dbf8cde
Remove noscript tag from search plugin
caendesilva Nov 16, 2024
0c591b2
Format Blade
caendesilva Nov 16, 2024
7c811e0
Manually reformat Blade
caendesilva Nov 16, 2024
cf42f2a
Cleanup Blade
caendesilva Nov 16, 2024
84d6537
Simplify modal layout styles
caendesilva Nov 16, 2024
73e9067
Hide search footer when there are results
caendesilva Nov 16, 2024
93bd9b9
Tweak margins
caendesilva Nov 16, 2024
5cefc0b
Add padding and negative margin to get nicer focus states
caendesilva Nov 16, 2024
fa1037b
Move font weight rule to heading
caendesilva Nov 16, 2024
ffee3b3
Update and clean up the search feature documentation
caendesilva Nov 16, 2024
8ebf91d
Tweak full page search styles
caendesilva Nov 16, 2024
b592ae0
Fix not prose styles
caendesilva Nov 16, 2024
cc796dd
Rename search widget component to search modal
caendesilva Nov 16, 2024
5782c86
Fix Blade formatting
caendesilva Nov 16, 2024
1f4e3d4
Merge pull request #2029 from hydephp/recreate-the-hydesearch-plugin-…
caendesilva Nov 16, 2024
4cf461c
Extract file for the main HydeSearch script
caendesilva Nov 16, 2024
6cf331c
Support overloading the script file
caendesilva Nov 16, 2024
4007f9d
Remove export default
caendesilva Nov 16, 2024
e27580b
Fix formatting
caendesilva Nov 16, 2024
53c9ffb
Update RELEASE_NOTES.md
caendesilva Nov 16, 2024
716c3c0
Move markup to template so Tailwind can find it
caendesilva Nov 16, 2024
cf4d641
Rename file to HydeSearch
caendesilva Nov 16, 2024
8b6ab34
Update RELEASE_NOTES.md
caendesilva Nov 16, 2024
f814d4f
Merge pull request #2031 from hydephp/recreate-the-hydesearch-plugin-…
caendesilva Nov 16, 2024
1241a39
Update app.css
caendesilva Nov 16, 2024
4ea7de9
Merge branch 'new-asset-system' into refactor-hydefront-styles-to-tai…
caendesilva Nov 16, 2024
8c0bddf
Add documentation page smooth scrolling using Tailwind
caendesilva Nov 17, 2024
8c7a56b
Remove now empty `hyde-docs.scss` file
caendesilva Nov 17, 2024
540ee94
Merge branch 'new-asset-system' into refactor-hydefront-styles-to-tai…
caendesilva Nov 17, 2024
db829ce
Sync app stylesheets
caendesilva Nov 17, 2024
7370623
Remove the `.torchlight-enabled` CSS class
caendesilva Nov 17, 2024
9f6aec4
Move opinionated styles to Tailwind config
caendesilva Nov 17, 2024
c315434
Update Markdown codeblocks to match Torchlight background color
caendesilva Nov 17, 2024
2342078
Match base pre element styles to Torchlight base
caendesilva Nov 17, 2024
fcf8c69
Define Torchlight styles in the Tailwind source file
caendesilva Nov 17, 2024
baaf8de
Normalize padding between normal and Torchlight code blocks
caendesilva Nov 17, 2024
db08205
Refactor code block file path labels to Tailwind
caendesilva Nov 17, 2024
71b5b71
Update RELEASE_NOTES.md
caendesilva Nov 17, 2024
7806047
Add parameter to dynamically set position for label
caendesilva Nov 17, 2024
3d54a65
Scope styles to only inline code spans
caendesilva Nov 17, 2024
77af72a
Adjust positioning for Torchlight label
caendesilva Nov 17, 2024
3a92381
Refactor to use the class directive
caendesilva Nov 17, 2024
250b3e1
Merge pull request #2036 from hydephp/normalize-code-block-styles-and…
caendesilva Nov 17, 2024
b238280
Refactor colored blockquotes styles to Tailwind
caendesilva Nov 17, 2024
2900eb5
Delete hyde.scss
caendesilva Nov 17, 2024
14f38ce
Delete hyde.css
caendesilva Nov 17, 2024
e961109
Remove HydeFront main file
caendesilva Nov 17, 2024
3be04e5
Remove HydeFront build scripts
caendesilva Nov 17, 2024
9926df8
Remove HydeFront dev dependencies
caendesilva Nov 17, 2024
68436ac
Remove references to removed hyde.css file
caendesilva Nov 17, 2024
6a0b638
Deprecate helper method which may become obsolete
caendesilva Nov 17, 2024
0bd07ed
Update script for removed hyde.css file
caendesilva Nov 17, 2024
14387ab
Rebuild Tailwind assets without HydeFront
caendesilva Nov 17, 2024
cea9e1f
Simplify script as the build file no longer needs to be verified
caendesilva Nov 17, 2024
6d2090f
Remove removed option usage
caendesilva Nov 17, 2024
ae435af
Update tests for removed hyde.css file
caendesilva Nov 17, 2024
6e5bed4
Remove removed build steps from internal documentation
caendesilva Nov 17, 2024
2034b01
Update RELEASE_NOTES.md
caendesilva Nov 17, 2024
9f44330
Remove HydeFront assets build step
caendesilva Nov 17, 2024
a12b565
Remove HydeFront workflows as there is no longer anything to build
caendesilva Nov 17, 2024
3c42843
Merge pull request #2037 from hydephp/remove-the-hyde-css-file-from-h…
caendesilva Nov 17, 2024
6239753
Remove linting workflow with no effect from the subpackage
caendesilva Nov 17, 2024
79ae75f
Remove badge for removed workflow
caendesilva Nov 17, 2024
4aee3cd
Delete HydeFront-v4-plan.md
caendesilva Nov 17, 2024
13f2c70
Extract HydeFront partials
caendesilva Nov 17, 2024
16fa89c
Add component styles in the components layer to ensure proper precedence
caendesilva Nov 17, 2024
93e0b54
Update managing-assets.md
caendesilva Nov 17, 2024
f1cc135
Update managing-assets.md
caendesilva Nov 17, 2024
0d12c51
Revert "Add component styles in the components layer to ensure proper…
caendesilva Nov 17, 2024
7d631f3
Normalize formatting
caendesilva Nov 17, 2024
13be44b
Tweak Tailwind setup for more stable cascade
caendesilva Nov 17, 2024
8838fe0
Simplify styling setup to not need cascade at all
caendesilva Nov 17, 2024
9304b31
Remove style rule with no effect
caendesilva Nov 17, 2024
eabe05b
Tweak positioning for changed styles
caendesilva Nov 17, 2024
353987e
Update RELEASE_NOTES.md
caendesilva Nov 17, 2024
649bbe9
Improve wording
caendesilva Nov 17, 2024
fbd70d9
Merge pull request #2038 from hydephp/extract-hydefront-partials-for-…
caendesilva Nov 17, 2024
6ac8c27
Update RELEASE_NOTES.md
caendesilva Nov 17, 2024
7e65fd6
Update RELEASE_NOTES.md
caendesilva Nov 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 117 additions & 0 deletions HydeFront-v4-plan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# HydeFront v4 Development Plan

## Abstract

We are updating how HydeFront is handled for v2. Instead of declaring styles directly in HydeFront alongside Tailwind, we will refactor those styles into Tailwind.

HydeFront will serve two main purposes:

1. It will continue to include the precompiled `app.css` file bundled with new apps, available through the HydeFront CDN.
2. It will act as a component library, allowing users to include granular styles from `app.css`, which we will preconfigure.

For example, users can include our Tailwind styles granularly using just the `app.css` file from the HydeFront package. This file will be compiled alongside Tailwind. If users prefer customization, they can remove the import and add the specific styles they want.

## Refactoring Plan

### 1. Restructure HydeFront Package
- Create a new directory structure in HydeFront:
```
hydefront/
├── dist/
│ └── app.css # Pre-compiled styles for CDN
├── components/ # New component-based structure
│ ├── base/ # Base styles
│ ├── docs/ # Documentation styles
│ ├── markdown/ # Markdown styles
│ └── utilities/ # Utility styles
└── package.json
```

### 2. Convert SCSS to Tailwind Components
- Convert existing SCSS styles from `hyde.scss` (reference: `packages/hydefront/hyde.scss`) into Tailwind components
- Create separate files for each component category that can be imported individually
- Example component structure:
```javascript
// components/docs.js
module.exports = {
'.docs-sidebar': {
'@apply ...': {},
}
}
```

### 3. Update Build Process
- Modify the Vite configuration (reference: `vite.config.js`) to handle component-based builds
- Update the build scripts in package.json to:
- Build individual components
- Generate the complete app.css for CDN distribution
- Add new script for component-based builds

### 4. Update Framework Integration
Key files to modify:

```blade
// packages/framework/resources/views/layouts/styles.blade.php
{{-- Prevent Alpine.js flashes --}}
<style>[x-cloak] {display: none!important}</style>

{{-- The compiled Tailwind/App styles --}}
@if(Vite::running())
{{ Vite::assets(['resources/assets/app.css']) }}
@else
@if(config('hyde.load_app_styles_from_cdn', false))
<link rel="stylesheet" href="{{ HydeFront::cdnLink('app.css') }}">
@elseif(Asset::exists('app.css'))
<link rel="stylesheet" href="{{ Asset::get('app.css') }}">
@endif


{{-- Dynamic TailwindCSS Play CDN --}}
@if(config('hyde.use_play_cdn', false))
<script src="https://cdn.tailwindcss.com?plugins=typography"></script>
<script>tailwind.config = { {!! HydeFront::injectTailwindConfig() !!} }</script>
<script>console.warn('The HydePHP TailwindCSS Play CDN is enabled. This is for development purposes only and should not be used in production.', 'See https://hydephp.com/docs/1.x/managing-assets');</script>
@endif
@endif

{{-- Add any extra styles to include after the others --}}
@stack('styles')
```


### 5. Documentation Updates
- Update the asset management documentation
- Create new documentation for component-based usage
- Update the HydeFront README (reference: `packages/hydefront/README.md`)

### 6. Migration Path
1. Create a new major version branch
2. Keep existing functionality working while adding new component system
3. Provide migration guide for users moving from v1 to v2
4. Update the Hyde starter template to use new component system

### 7. Configuration Updates
- Update the Hyde configuration (reference: `config/hyde.php`) to support component-based imports
- Add new configuration options for granular style inclusion

### 8. Testing Strategy
1. Create tests for individual components
2. Test CDN distribution
3. Test backward compatibility layer
4. Test integration with Hyde framework

### 9. Implementation Phases
1. **Phase 1**: Create new component structure
2. **Phase 2**: Convert existing styles
3. **Phase 3**: Update build system
4. **Phase 4**: Update framework integration
5. **Phase 5**: Documentation and migration guide
6. **Phase 6**: Testing and refinement

### 10. Breaking Changes to Document
- New import syntax for granular components
- Changes to configuration structure
- Updates to asset compilation process
- CDN usage changes

This plan maintains backward compatibility through the CDN while providing a more flexible component-based approach for customization. The changes align with modern frontend practices while keeping Hyde's simplicity.
2 changes: 1 addition & 1 deletion _media/app.css

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
<button id="sidebar-toggle" title="Toggle sidebar" aria-label="Toggle sidebar navigation menu" @click="sidebarOpen = ! sidebarOpen" :class="{'active' : sidebarOpen}">
<span class="icon-bar dark:bg-white h-0" role="presentation"></span>
<span class="icon-bar dark:bg-white h-0" role="presentation"></span>
<span class="icon-bar dark:bg-white h-0" role="presentation"></span>
<span class="icon-bar dark:bg-white h-0" role="presentation"></span>
<button
id="sidebar-toggle"
title="Toggle sidebar"
aria-label="Toggle sidebar navigation menu"
@click="sidebarOpen = !sidebarOpen"
class="flex items-center justify-center w-8 h-8 px-2 py-1 hover:text-gray-700 dark:text-gray-200 opacity-75 hover:opacity-100"
>
<div class="relative w-5 h-4">
<div class="absolute top-0 w-5 h-0.5 bg-current transition-all duration-300 ease-in-out" :class="sidebarOpen ? 'opacity-0' : ''"></div>
<div class="absolute inset-0 my-auto w-5 h-0.5 bg-current transition-all duration-300 ease-in-out origin-center" :class="sidebarOpen ? 'rotate-45' : ''"></div>
<div class="absolute inset-0 my-auto w-5 h-0.5 bg-current transition-all duration-300 ease-in-out origin-center" :class="sidebarOpen ? '-rotate-45' : ''"></div>
<div class="absolute bottom-0 w-5 h-0.5 bg-current transition-all duration-300 ease-in-out" :class="sidebarOpen ? 'opacity-0' : ''"></div>
</div>
</button>
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@
</button>
</div>

<div id="main-navigation-links" class="w-full x-uncloak-md md:flex flex-grow md:flex-grow-0 md:items-center md:w-auto px-6 -mx-4 border-t mt-3 pt-3 md:border-none md:mt-0 md:py-0 border-gray-200 dark:border-gray-700"
:class="navigationOpen ? '' : 'hidden'" x-cloak>
<div id="main-navigation-links"
class="w-full hidden md:flex flex-grow md:flex-grow-0 md:items-center md:w-auto px-6 -mx-4 border-t mt-3 pt-3 md:border-none md:mt-0 md:py-0 border-gray-200 dark:border-gray-700"
:class="navigationOpen ? '!block' : ''">
<ul aria-label="Navigation links" class="md:flex-grow md:flex justify-end">
@foreach ($navigation->getItems() as $item)
<li class="md:mx-2">
Expand Down
2 changes: 1 addition & 1 deletion packages/hydefront/dist/hyde.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/hydefront/dist/hyde.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion packages/hydefront/hyde.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@
@use 'sass/markdown/torchlight';
@use 'sass/markdown/blockquotes';
@use 'sass/markdown/codeblocks';
@use 'sass/utilities/alpine';
@use 'sass/patches/typography';
56 changes: 0 additions & 56 deletions packages/hydefront/sass/docs/sidebar-toggle.scss

This file was deleted.

38 changes: 0 additions & 38 deletions packages/hydefront/sass/docs/table-of-contents.scss

This file was deleted.

2 changes: 0 additions & 2 deletions packages/hydefront/sass/hyde-docs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
*/

@use 'docs/search';
@use 'docs/sidebar-toggle';
@use 'docs/table-of-contents';
@use 'docs/heading-permalinks';

html {
Expand Down
3 changes: 0 additions & 3 deletions packages/hydefront/sass/utilities/alpine.scss

This file was deleted.

24 changes: 23 additions & 1 deletion resources/assets/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,26 @@
@tailwind components;
@tailwind utilities;

[x-cloak] { display: none !important; }
.table-of-contents {
@apply pb-3;
}

.table-of-contents > li {
@apply my-[0.35rem];
}

.table-of-contents ul {
@apply pl-2;
}

.table-of-contents a {
@apply block -ml-8 pl-8 opacity-80 hover:opacity-100 hover:bg-gray-200/20 transition-all duration-300 relative;
}

.table-of-contents a::before {
@apply content-['#'] text-[75%] opacity-50 mr-1 transition-opacity duration-300;
}

.table-of-contents a:hover::before {
@apply opacity-100;
}
caendesilva marked this conversation as resolved.
Show resolved Hide resolved