-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat ContentPreview CustomStyle #129
Conversation
- Removed the need to pass PublishingContext to custom layout. - Added defaultCardLayout method for better separation of concerns. - Ensured that context is handled internally, preventing external dependency on context. - Improved clarity and flexibility by allowing custom or default rendering within the same interface.
I love this idea! However, I wonder whether it's better if we go down the SwiftUI-style approach of having a So, there would be a What do you think? |
I agree with your idea.👍
Exampleimport Foundation
import Ignite
struct HomeEn: StaticPage {
var title = "sookim's T.W.L"
func body(context: PublishingContext) -> [BlockElement] {
Group {
NavBar(name: "sookim's T.W.L", language: .english)
let orderedAllContext = context.content(ofType: "en").sorted {
$0.date > $1.date
}
for item in orderedAllContext {
ContentPreview(for: item)
.contentPreviewStyle(MyCustomContentPreviewStyle())
.width(.max)
.margin(.vertical, 50)
.background(.white)
}
SocialFooter()
IgniteFooter()
}
}
}
struct MyCustomContentPreviewStyle: ContentPreviewStyle {
func body(content: Content, context: PublishingContext) -> BlockElement {
Card(imageName: content.image) {
Text(content.metadata["description"] as? String ?? "")
.horizontalAlignment(.leading)
.font(.title5)
.fontWeight(.medium)
.foregroundStyle(.darkEmphasis)
.margin(.bottom, .none)
} header: {
Text(content.author ?? "fa")
.horizontalAlignment(.leading)
} footer: {
let tagLinks = content.tagLinks(in: context)
if tagLinks.isEmpty == false {
Group {
tagLinks
}
.style("margin-top: -5px")
}
}
}
} |
Apologies for taking so long to review this! This is a big improvement, and I'm going to merge it now. Thank you! 🙌 |
Description
This Pull Request introduces a new customLayout property to the ContentPreview struct. The primary reason for this enhancement is to provide developers with the ability to customize the layout of the ContentPreview component. Previously, the use of ContentPreview enforced a specific format, making it challenging for users to implement their desired designs.
By allowing a customLayout option, developers can now easily override the default layout and create personalized designs that better suit their project's needs. This change aims to enhance the flexibility and usability of the ContentPreview component, ultimately improving the developer experience.
Changes Made
Example