Skip to content

Commit fbd70d9

Browse files
authored
Merge pull request #2038 from hydephp/extract-hydefront-partials-for-tailwind-components
[2.x] Extract HydeFront partials for Tailwind component templates
2 parents 4aee3cd + 649bbe9 commit fbd70d9

File tree

11 files changed

+82
-99
lines changed

11 files changed

+82
-99
lines changed

RELEASE_NOTES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ This serves two purposes:
102102
- Renamed Blade component `hyde::components.docs.search-widget` to `hyde::components.docs.search-modal` in https://github.com/hydephp/develop/pull/2029
103103
- Added support for customizing the search implementation by creating a `resources/js/HydeSearch.js` file in https://github.com/hydephp/develop/pull/2031
104104
- Normalized default Tailwind Typography Prose code block styles to match Torchlight's theme, ensuring consistent styling across Markdown and Torchlight code blocks in https://github.com/hydephp/develop/pull/2036.
105+
- Extracted CSS component partials in HydeFront in https://github.com/hydephp/develop/pull/2038
105106

106107
### Deprecated
107108

@@ -149,6 +150,7 @@ This serves two purposes:
149150
#### HydeFront
150151

151152
- Removed the `hyde.css` file in https://github.com/hydephp/develop/pull/2037 as all its styles were refactored to Tailwind in https://github.com/hydephp/develop/pull/2024
153+
- Extracted CSS component partials in https://github.com/hydephp/develop/pull/2038
152154

153155
### Upgrade Guide
154156

_media/app.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/creating-content/managing-assets.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ With Hyde, **you don't have to do it**, in fact, you can skip this entire page i
1313
But as always with Hyde, you can customize everything if you want to.
1414

1515
Hyde ships with a complete frontend using Blade views, TailwindCSS styles, and Alpine.js interactions.
16-
Some extra custom styles are made in the HydeFront package, which is pre-installed and bundled in the pre-configured Tailwind and Vite setup.
16+
Some extra component styles are organized into modular files in the HydeFront package, which is pre-installed and bundled in the pre-configured Tailwind and Vite setup.
1717

1818
To get you started quickly, all the styles are already compiled and minified into `_media/app.css`,
1919
which will be copied to the `_site/media/app.css` directory when you run `php hyde build`.
@@ -26,7 +26,7 @@ No, it is optional. All the compiled styles that you need are already installed,
2626

2727
### When Should Assets be Compiled?
2828

29-
The `_media/app.css` file that comes with Hyde contains TailwindCSS for all classes that are used in the default Blade views, as well as the HydeFront custom styles.
29+
The `_media/app.css` file that comes with Hyde contains TailwindCSS for all classes that are used in the default Blade views, as well as the HydeFront component styles.
3030
If you want to customize the Tailwind settings or add custom styles, you will need to recompile the styles yourself.
3131

3232
For example, if you customize the Blade views and add new classes or add new classes in Blade-based pages, you may need to compile the assets yourself to get the new styles.
@@ -66,6 +66,12 @@ When running the `npm run dev/prod` command, Vite will compile the `resources/as
6666

6767
The compiled assets will then be automatically copied to `_site/media` when you run `php hyde build`.
6868

69+
### Customizing HydeFront Components
70+
71+
HydeFront components are modular and can be easily customized to fit your needs.
72+
73+
You can either remove the import of the component you want to customize and replace it with your own styles, or keep the import and add overriding styles after it (since CSS cascade order matters).
74+
6975
## Telling Hyde where to find assets
7076

7177
### Customizing the Blade templates
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<small @class([
22
'relative float-right opacity-50 hover:opacity-100 transition-opacity duration-250 not-prose hidden md:block',
3-
'-top-1 right-3' => $torchlight,
3+
'-top-1 right-1' => $torchlight,
44
'top-0 right-0' => ! $torchlight,
55
])><span class="sr-only">Filepath: </span>{{ $path }}</small>

packages/framework/tests/Feature/Services/Markdown/CodeblockFilepathProcessorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ public function testProcessorExpandsFilepathDirectiveInTorchlightCodeblock()
215215
HTML;
216216

217217
$expected = <<<'HTML'
218-
<pre><code class="torchlight"><!-- Syntax highlighted by torchlight.dev --><small class="relative float-right opacity-50 hover:opacity-100 transition-opacity duration-250 not-prose hidden md:block -top-1 right-3"><span class="sr-only">Filepath: </span>foo.html</small><div class="line"><span class="line-number">1</span>&nbsp;</div></code></pre>
218+
<pre><code class="torchlight"><!-- Syntax highlighted by torchlight.dev --><small class="relative float-right opacity-50 hover:opacity-100 transition-opacity duration-250 not-prose hidden md:block -top-1 right-1"><span class="sr-only">Filepath: </span>foo.html</small><div class="line"><span class="line-number">1</span>&nbsp;</div></code></pre>
219219
HTML;
220220

221221
$this->assertSame($expected, CodeblockFilepathProcessor::postprocess($html));
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
.prose blockquote.info {
2+
@apply border-blue-500;
3+
}
4+
5+
.prose blockquote.success {
6+
@apply border-green-500;
7+
}
8+
9+
.prose blockquote.warning {
10+
@apply border-amber-500;
11+
}
12+
13+
.prose blockquote.danger {
14+
@apply border-red-600;
15+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
.prose h1, .prose h2, .prose h3, .prose h4, .prose h5, .prose h6 {
2+
@apply w-fit;
3+
}
4+
5+
.prose :is(h1,h2,h3,h4,h5,h6):hover .heading-permalink,
6+
.prose :is(h1,h2,h3,h4,h5,h6):focus .heading-permalink {
7+
@apply opacity-75 grayscale transition-opacity duration-100 ease-out;
8+
}
9+
10+
.heading-permalink {
11+
@apply opacity-0 ml-1 transition-opacity duration-300 ease-linear px-1 scroll-m-4;
12+
}
13+
14+
.heading-permalink::before {
15+
@apply content-['#'];
16+
}
17+
18+
.heading-permalink:hover, .heading-permalink:focus {
19+
@apply opacity-100 grayscale-0;
20+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
.table-of-contents {
2+
@apply pb-3;
3+
}
4+
5+
.table-of-contents > li {
6+
@apply my-[0.35rem];
7+
}
8+
9+
.table-of-contents ul {
10+
@apply pl-2;
11+
}
12+
13+
.table-of-contents a {
14+
@apply block -ml-8 pl-8 opacity-80 hover:opacity-100 hover:bg-gray-200/20 transition-all duration-300 relative;
15+
}
16+
17+
.table-of-contents a::before {
18+
@apply content-['#'] text-[75%] opacity-50 mr-1 transition-opacity duration-300;
19+
}
20+
21+
.table-of-contents a:hover::before {
22+
@apply opacity-100;
23+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
pre code.torchlight .line-number, pre code.torchlight .summary-caret {
2+
@apply mr-4;
3+
}

resources/assets/app.css

Lines changed: 6 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -5,101 +5,17 @@
55
* The HydeFront package contains some base styles to make your site look even more amazing.
66
*
77
* The compiled result of this file is shipped with HydePHP and is found at _media/app.css,
8-
* so you don't need to compile this file unless you're making changes.
8+
* so you don't need to compile this file unless you're making changes to Tailwind styles.
99
*
1010
* If you want, you can load the compiled file with minified styles for a base install from the CDN.
1111
* See https://hydephp.com/docs/1.x/managing-assets#loading-from-cdn
1212
*/
1313

14+
@import 'hydefront/components/table-of-contents.css';
15+
@import 'hydefront/components/heading-permalinks.css';
16+
@import 'hydefront/components/torchlight.css';
17+
@import 'hydefront/components/blockquotes.css';
18+
1419
@tailwind base;
1520
@tailwind components;
1621
@tailwind utilities;
17-
18-
/**
19-
* Documentation Pages - Table of Contents
20-
*/
21-
22-
.table-of-contents {
23-
@apply pb-3;
24-
}
25-
26-
.table-of-contents > li {
27-
@apply my-[0.35rem];
28-
}
29-
30-
.table-of-contents ul {
31-
@apply pl-2;
32-
}
33-
34-
.table-of-contents a {
35-
@apply block -ml-8 pl-8 opacity-80 hover:opacity-100 hover:bg-gray-200/20 transition-all duration-300 relative;
36-
}
37-
38-
.table-of-contents a::before {
39-
@apply content-['#'] text-[75%] opacity-50 mr-1 transition-opacity duration-300;
40-
}
41-
42-
.table-of-contents a:hover::before {
43-
@apply opacity-100;
44-
}
45-
46-
/**
47-
* Documentation Pages - Heading Permalinks
48-
*/
49-
50-
.prose h1, .prose h2, .prose h3, .prose h4, .prose h5, .prose h6 {
51-
@apply w-fit;
52-
}
53-
54-
.prose :is(h1,h2,h3,h4,h5,h6):hover .heading-permalink,
55-
.prose :is(h1,h2,h3,h4,h5,h6):focus .heading-permalink {
56-
@apply opacity-75 grayscale transition-opacity duration-100 ease-out;
57-
}
58-
59-
.heading-permalink {
60-
@apply opacity-0 ml-1 transition-opacity duration-300 ease-linear px-1 scroll-m-4;
61-
}
62-
63-
.heading-permalink::before {
64-
@apply content-['#'];
65-
}
66-
67-
.heading-permalink:hover, .heading-permalink:focus {
68-
@apply opacity-100 grayscale-0;
69-
}
70-
71-
/**
72-
* Torchlight
73-
*/
74-
75-
pre code.torchlight {
76-
@apply block py-4 px-0 min-w-max;
77-
}
78-
79-
pre code.torchlight .line {
80-
@apply px-4;
81-
}
82-
83-
pre code.torchlight .line-number, pre code.torchlight .summary-caret {
84-
@apply mr-4;
85-
}
86-
87-
/**
88-
* Colored Blockquotes
89-
*/
90-
91-
.prose blockquote.info {
92-
@apply border-blue-500;
93-
}
94-
95-
.prose blockquote.success {
96-
@apply border-green-500;
97-
}
98-
99-
.prose blockquote.warning {
100-
@apply border-amber-500;
101-
}
102-
103-
.prose blockquote.danger {
104-
@apply border-red-600;
105-
}

0 commit comments

Comments
 (0)