forked from rubyforgood/casa
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[rubyforgood#5777] Refactor with slot
- Loading branch information
1 parent
1f09e29
commit 744d82f
Showing
3 changed files
with
10 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,18 @@ | ||
# frozen_string_literal: true | ||
|
||
class Form::TitleComponent < ViewComponent::Base | ||
def initialize(title:, subtitle:, step: nil, total_steps: nil, notes: nil, autosave: false, navigable: nil) | ||
# `Form::StepNavigationComponent` is defined in another file, so we can refer to it by class name. | ||
renders_one :navigable, Form::StepNavigationComponent | ||
|
||
def initialize(title:, subtitle:, step: nil, total_steps: nil, notes: nil, autosave: false) | ||
@title = title | ||
@subtitle = subtitle | ||
@notes = notes | ||
@autosave = autosave | ||
@navigable = navigable | ||
|
||
if step && total_steps | ||
@steps_in_text = "Step #{step} of #{total_steps}" | ||
@progress = (step.to_d / total_steps.to_d) * 100 | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters