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

Include example from article #31

Open
TeriyakiBomb opened this issue Feb 4, 2025 · 1 comment
Open

Include example from article #31

TeriyakiBomb opened this issue Feb 4, 2025 · 1 comment

Comments

@TeriyakiBomb
Copy link

It'd be great to add this example from this article to the readme, it adds useful context for real world usage:

class ButtonComponent < ViewComponent::Base
  def initialize(color: :primary)
    @color = color
  end

  def css_classes
    ClassVariants.build(
      base: "inline-flex items-center rounded border-2 border-transparent font-medium text-sm text-white hover:text-white shadow-sm focus:outline-none focus:ring-2 focus:ring-offset-2 transition-colors duration-300 p-1",
      variants: {
        color: {
          primary: "bg-grape-500 hover:bg-grape-600 text-white dark:bg-grape-400 dark:hover:bg-grape-500",
        }
      }
    ).render(color: @color)
  end
end
@adrianthedev
Copy link
Contributor

Send it in a PR @TeriyakiBomb. We'd love to feature it.

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

No branches or pull requests

2 participants