Closed JeremyCaney closed 11 months ago
For the Calls to Action view component, there are several options:
ViewData
instead of the view model. This isn’t typically preferred, but would be dramatically simpler.Given that this is a relatively superficial add-on which isn’t deeply implicated in the rest of the site’s architecture or any core libraries, my inclination is to accept the breach of coding preferences, and go with the last option.
This was completed with the merging of feature/AnnouncementViewComponent
into develop
(72ae7db0). In the end, I decided to introduce a view model for the CallsToAction
view component to relay the HasAnnouncement
bit to the view, thus preventing the need to shortcut this with `ViewData (as suggested in the previous comment).
Create an ASP.NET View Component that optionally displays an announcement.
/Components/AnnouncementViewComponent.cs
/Models/AnnouncementViewModel.cs
/Views/Shared/Components/Announcement/Default.cshtml
Benefits
This approach will allow @rkossik to create announcements via the editor without developer intervention. This will also automate error-prone details due to layout shifts needed when the attaching the announcement to the footer.
Placement
The Announcement view component will be called from the following views:
/Views/Home/Home.csthtml
(for the homepage)/Views/Layout/_Layout.cshtml
(for the footer)Data
The source data will be placed within
Web:Home
Topic in the following (new) attributes:AnnouncementText
(Text
type)AnnouncementUrl
(Text
type)Challenges
In addition to the above, we need to account for the layout shift in the Calls to Action view component. By default, this is anchored to the footer. When the announcement is in place, it should anchor to the announcement instead. An open challenge is how to relay this data to the Calls to Action view component, which uses the centralized
NavigationViewModel
, making it difficult to extend.