Skip to content

Commit

Permalink
Adds example in README of slots taking multiple arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
nolantait committed Jan 13, 2025
1 parent 7cc9711 commit 867eba2
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,10 @@ class Navbar
end
```

Eventually everyone makes a kind of ad-hoc system for specifying styles. It gets
more complicated when you have attributes like a data-controller. How do you
give a good experience letting people using your components to add their own
Eventually everyone makes a kind of ad-hoc system for specifying styles.

It gets more complicated when you have attributes like a data-controller. How do
you give a good experience letting people using your components to add their own
controllers while your component depends on one already?

This library is an attempt to make this kind of developer experience while
Expand Down Expand Up @@ -225,6 +226,18 @@ class List < Protos::Component
end
```

Slots can also take multiple arguments, and even inline styles:

```ruby
class ListItem < Protos::Component
def view_template
li(class: css[:item, :primary_item, "text-sm"])
end
end
```

This combines the styles together, removing any duplicates.

### Attrs and default attrs

By convention, all components spread in an `attrs` hash on their outermost
Expand Down

0 comments on commit 867eba2

Please sign in to comment.