Skip to content

Conversation

@Roene-JustBetter
Copy link
Member

WIP - Tailwind update to version 4.

@Roene-JustBetter Roene-JustBetter marked this pull request as draft February 25, 2025 07:27
}

export default {
content: [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried using the @source in the app.css inside the Rapidez/core But I didn't managed to load styling from other vendor packages like rapidez/menu or rapidez/account.

Copy link
Member Author

@Roene-JustBetter Roene-JustBetter Mar 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have have checked the docs about using @source.
https://tailwindcss.com/docs/detecting-classes-in-source-files#which-files-are-scanned

So we have to make use of the @source: https://tailwindcss.com/docs/detecting-classes-in-source-files#explicitly-registering-sources./
So I tried this:

@source "../../vendor/rapidez/**/*.blade.php";
@source "../../vendor/rapidez/**/*.css";
@source "../../vendor/rapidez/**/*.vue";

@source '../../resources/views/**/*.blade.php';
@source '../../resources/css/**/*.css';
@source '../../resources/js/**/*.vue';

@source '../../../../config/rapidez/frontend.php';
@source '../../vendor/rapidez/core/config/rapidez/frontend.php';
@source '../../../../config/rapidez/menu.php';
@source '../../../../vendor/rapidez/menu/config/rapidez/menu.php';
@source '../../../../../vendor/laravel/framework/src/Illuminate/Pagination/resources/views/tailwind.blade.php';

But this work partly
This works correct and generated the classes from the core:

@source '../../resources/views/**/*.blade.php';
@source '../../resources/css/**/*.css';
@source '../../resources/js/**/*.vue';
Scherm­afbeelding 2025-03-06 om 13 20 11

The problem is that styling from vendor packages like account doesn't work:

@source "../../vendor/rapidez/**/*.blade.php";
@source "../../vendor/rapidez/**/*.css";
@source "../../vendor/rapidez/**/*.vue";
Scherm­afbeelding 2025-03-06 om 13 21 41

The issue is that we are using symlinks and that is not working correctly. I double checked this with @indykoning and we found this: tailwindlabs/tailwindcss#16765

Copy link
Member Author

@Roene-JustBetter Roene-JustBetter Apr 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the @source is still nog working good. I have tried this inside Rapidez (so not inside the Core):

This works:
@source "../../vendor/rapidez/account/resources/views/account/**/*.blade.php";

This doesn't work:
@source "../../vendor/rapidez/*/resources/views/account/**/*.blade.php";.

The problem is with the /*/

Looks like this is the same issue: tailwindlabs/tailwindcss#17601

--color-conversion: color-mix(in srgb, var(--conversion, #22c55e) calc(100% * 1), transparent);
--color-conversion-text: color-mix(in srgb, var(--conversion-text, #fff) calc(100% * 1), transparent);
--color-foreground-emphasis: color-mix(in srgb, var(--foreground-emphasis, #0f172a) calc(100% * 1), transparent);
--color-foreground: color-mix(in srgb, var(--foreground, #1e293b) calc(100% * 1), transparent);
Copy link
Member

@royduin royduin Feb 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per: https://tailwindcss.com/docs/colors#referencing-in-css and previously within the tailwind.config.js we can reference existing colors;

--color-foreground: color-mix(in srgb, var(--foreground, var(--color-slate-800)) calc(100% * 1), transparent);

Demo: https://play.tailwindcss.com/QB164GxvSS


Seems like we don't need the color-mix(), Tailwind is handeling that for us now

--color-foreground: var(--foreground, var(--color-slate-800));

Demo: https://play.tailwindcss.com/yslYTQCdL6?file=css


But... with this it's a bit weird to have --color-foreground and --foreground, maybe change everything to be inline with Tailwind, so prefix all colors and only use --color-foreground

Demo: https://play.tailwindcss.com/IUMpQQ8KCa?file=css


Another update; undocumented but it's still possible to scope colors to utilities:

--foreground: var(--color-slate-800);
--text-color-default: var(--foreground);

This way bg-foreground doesn't work, as it should.

Demo: https://play.tailwindcss.com/kwKsPPfh8q?file=css

Comment on lines 92 to 100
@utility text {
color: var(--text-color);
}
@utility text-emphasis {
color: var(--text-color-emphasis);
}
@utility text-muted {
color: var(--text-color-muted);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the scoped colors we don't need this, only text doesn't work by default so that one should stay. But... it doesn't support the opacity modifier (eg text/50), see: tailwindlabs/tailwindcss#16824

For the time being, the "full version" does support it: text-default/50

@indykoning
Copy link
Member

We're being blocked by the following 2 issues:

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.

4 participants