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

[9.x] Add @style Blade directive #45887

Merged
merged 3 commits into from
Feb 1, 2023
Merged

[9.x] Add @style Blade directive #45887

merged 3 commits into from
Feb 1, 2023

Conversation

intrepidws
Copy link
Contributor

Building upon the great work by @danharrin, who added the @class Blade directive in PR #38016, this PR adds support for a @style Blade directive. While my preference is always to use @class, I often find myself needing to conditionally use one-off styles in projects where I don't have access to Tailwind.

Usage is very similar to the @class blade directive, as follows:

<div>
    <span @style([
        'margin-top: 10px;',
        'font-weight: bold' => $active,
    ])>
        Dashboard
    </span>

    <svg @style([
        'font-weight: bold; text-decoration: underline;',
        'margin-top: 10px' => $active,
    ])>
        <path />
        <path />
        <path />
    </svg>
</div>

One thing to note is that when specifying the styles, it doesn't matter whether or not you end the line with a semi-colon - the logic will add it if it's missing.

If accepted, I will PR to the docs. I could also add @style support for blade components as well (similar to what PR #43140 did for the @class directive) - if that's something that's desired.

@taylorotwell
Copy link
Member

I would suggest going ahead and adding support for Blade components. I don't think we would want to merge support for this without also supporting Blade components since @class is supported on both.

@taylorotwell taylorotwell marked this pull request as draft January 31, 2023 19:39
@taylorotwell
Copy link
Member

Please mark as ready for review when done. Thanks!

@intrepidws intrepidws marked this pull request as ready for review January 31, 2023 20:46
@intrepidws
Copy link
Contributor Author

No problem, this is ready for review @taylorotwell

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.

2 participants