Conversation
| assert_equal "d-block", EmptyComponent.new.block.primer_classes | ||
| assert_equal "d-none", EmptyComponent.new.none.primer_classes | ||
| assert_equal "d-inline", EmptyComponent.new.inline.primer_classes | ||
| assert_equal "d-inline-block", EmptyComponent.new.inline_block.primer_classes | ||
| assert_equal "d-table", EmptyComponent.new.table.primer_classes | ||
| assert_equal "d-table-cell", EmptyComponent.new.table_cell.primer_classes |
There was a problem hiding this comment.
Should probably prefix these methods with d_?
There was a problem hiding this comment.
Or, could we do d(:table_cell)?
There was a problem hiding this comment.
Or, could we do
d(:table_cell)?
We totally could. I went with methods for this first attempt at an implementation instead of arguments since it will immediately raise an error instead of requiring us to validate the arguments. Thoughts?
| end | ||
|
|
||
| def float(direction) | ||
| primer_class_list << "float-#{direction}" |
There was a problem hiding this comment.
should we have VALID_DIRECTIONS?
|
Personally I think that View Components should treat Primer classes as second class citizens (in the future these perhaps shouldn't be allowed?). Hence I'm actually more in favour of using them (for now) explicitly (i.e.: |
I think that's an interesting thought, and brings up a really good point, how much do we want to couple these components to Primer through methods? Additionally, how coupled do we want to allow people to opt-in to components being coupled to primer? The original goal of this approach is to help remove the need to use I'd also be 👍 on removing def initialize(tag_name:, primer_classes:)Assuming that would be a 1-to-1 replacement. |
Is this really a realistic scenario? |
I believe so, it looks like one of the last times we had a breaking CSS name change was in December 2019 here, primer/css#966 so there is some precedent. |
|
Closing for now, since we want to stick with a more React-like API |
Update docs
This introduces a new module,
Primer::Styleablewhich adds methods to acomponent that generate primer based class names.