Skip to content

Commit 0d6927d

Browse files
authored
Remove component CSS class name default (#545)
1 parent 22a71a3 commit 0d6927d

File tree

3 files changed

+9
-25
lines changed

3 files changed

+9
-25
lines changed

docs/index.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ This provides a simpler alternative to nesting partials.
4949
The recommended approach is to subclass Arbre::Component and implement a new builder method.
5050

5151
The builder_method defines the method that will be called to build this component
52-
when using the DSL. The arguments passed into the builder_method will be passed
52+
when using the DSL. The arguments passed into the builder_method will be passed
5353
into the #build method for you.
5454

5555
For example:
@@ -66,7 +66,7 @@ class Panel < Arbre::Component
6666
end
6767
```
6868

69-
By default components are `div` tags with an HTML class corresponding to the component class name. This can be overridden by redefining the `tag_name` method.
69+
By default, components are `div` tags. This can be overridden by redefining the `tag_name` method.
7070

7171
Several examples of Arbre components are [included in Active Admin](https://activeadmin.info/12-arbre-components.html)
7272

@@ -76,7 +76,7 @@ An [Arbre::Context](http://www.rubydoc.info/gems/arbre/Arbre/Context) is an obje
7676

7777
```ruby
7878
html = Arbre::Context.new do
79-
panel "Hello World", id: "my-panel" do
79+
panel "Hello World", class: "panel", id: "my-panel" do
8080
span "Inside the panel"
8181
text_node "Plain text"
8282
end

lib/arbre/component.rb

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,9 @@
11
# frozen_string_literal: true
22
module Arbre
33
class Component < Arbre::HTML::Div
4-
54
# By default components render a div
65
def tag_name
76
'div'
87
end
9-
10-
def initialize(*)
11-
super
12-
add_class default_class_name
13-
end
14-
15-
protected
16-
17-
# By default, add a css class named after the ruby class
18-
def default_class_name
19-
self.class.name.demodulize.underscore
20-
end
21-
228
end
239
end

spec/arbre/unit/component_spec.rb

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,10 @@ def build
1313
end
1414

1515
describe Arbre::Component do
16-
1716
let(:assigns) { {} }
1817
let(:helpers) { nil }
19-
20-
let(:component_class){ MockComponent }
21-
let(:component){ component_class.new }
18+
let(:component_class) { MockComponent }
19+
let(:component) { component_class.new }
2220

2321
it "should be a subclass of an html div" do
2422
expect(Arbre::Component.ancestors).to include(Arbre::HTML::Div)
@@ -28,18 +26,18 @@ def build
2826
expect(component.tag_name).to eq('div')
2927
end
3028

31-
it "should add a class by default" do
32-
expect(component.class_list).to include("mock_component")
29+
it "should not have a class list" do
30+
expect(component.class_list.to_s).to eq("")
31+
expect(component.class_list.empty?).to eq(true)
3332
end
3433

3534
it "should render the object using the builder method name" do
3635
comp = expect(arbre {
3736
mock_component
3837
}.to_s).to eq <<~HTML
39-
<div class="mock_component">
38+
<div>
4039
<h2>Hello World</h2>
4140
</div>
4241
HTML
4342
end
44-
4543
end

0 commit comments

Comments
 (0)