mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Add new (and first) component: DistributorTitle
- Simple wrapper around `<h3 />` for distributor title, used in the shop front
This commit is contained in:
7
app/components/distributor_title_component.rb
Normal file
7
app/components/distributor_title_component.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class DistributorTitleComponent < ViewComponent::Base
|
||||
def initialize(name:)
|
||||
@name = name
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1 @@
|
||||
%h3= @name
|
||||
8
spec/components/distributor_title_component_spec.rb
Normal file
8
spec/components/distributor_title_component_spec.rb
Normal file
@@ -0,0 +1,8 @@
|
||||
require "spec_helper"
|
||||
|
||||
describe "DistributorTitle tests", type: :component do
|
||||
it "displays distributor title with its name" do
|
||||
render_inline(DistributorTitleComponent.new(name: "Freddy's Farm Shop")) { }
|
||||
expect(page).to have_selector "h3", text: "Freddy's Farm Shop"
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,7 @@
|
||||
class DistributorTitleComponentStories < ViewComponent::Storybook::Stories
|
||||
story(:default) do
|
||||
controls do
|
||||
text(:name, "Freddy s Farm Shop")
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user