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

Adding fn/cva helper function #9

Merged
merged 1 commit into from
Sep 10, 2024
Merged

Adding fn/cva helper function #9

merged 1 commit into from
Sep 10, 2024

Conversation

rojtjo
Copy link
Contributor

@rojtjo rojtjo commented Sep 10, 2024

In simple projects my definitions often just live in my view files and it always bugged me to type the FQCN when using cva.
These changes add the fn\cva helper which accepts the same parameters as the FeatureNinja\Cva\ClassVarianceAuthority::new method.

$button = fn\cva(
    ['font-semibold', 'border', 'rounded'],
    [
        'variants' => [
            'intent' => [
                'primary' => ['bg-blue-500', 'text-white', 'border-transparent', 'hover:bg-blue-600'],
                'secondary' => 'bg-white text-gray-800 border-gray-400 hover:bg-gray-100',
            ],
            'size' => [
                'small' => ['text-sm', 'py-1', 'px-2'],
                'medium' => 'text-base py-2 px-4',
            ],
        ],
        'compoundVariants' => [
            [
                'intent' => 'primary',
                'size' => 'medium',
                'class' => 'uppercase',
            ],
        ],
        'defaultVariants' => [
            'intent' => 'primary',
            'size' => 'medium',
        ],
    ],
);

@rojtjo rojtjo merged commit bca3c1c into main Sep 10, 2024
18 checks passed
@rojtjo rojtjo deleted the feature/helper branch September 10, 2024 21:25
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