gonzalezreal / swift-markdown-ui

Display and customize Markdown text in SwiftUI
MIT License
2.53k stars 318 forks source link

Table border style now has multiple colors and selectors #327

Open fbernardo opened 4 months ago

fbernardo commented 4 months ago

It is now possible to pass multiple border styles to a table border style by passing an array with selectors and colors. Also added new convinience table border selectors for selecting the first row or every other inside border.

Here's an example:

MarkdownUI.Theme()
.table { configuration in
        configuration.label
            .markdownTableBackgroundStyle(.init(background: { row, column in
                row == 0 ? .blue : .clear
            }))
            .markdownTableBorderStyle(
                TableBorderStyle([ // <----- It is now possible to pass an array here.
                    .init(visibleBorders: .insideBordersFirstRow, color: .green),
                    .init(visibleBorders: .insideBordersExceptFirstRow, color: .red)
                ], strokeStyle: .init(lineWidth: 1))
            )
            .clipShape(RoundedRectangle(cornerRadius: 10, style: .continuous))
            .overlay(
                RoundedRectangle(cornerRadius: 10, style: .continuous)
                .strokeBorder(.black, lineWidth: 1)
            )
    }
    .tableCell { configuration in
        configuration.label
            .markdownTextStyle {
                if configuration.row == 0 {
                    ForegroundColor(.white)
                }
            }
            .padding(.vertical, 6)
            .padding(.horizontal, 6)
    }

CleanShot 2024-06-11 at 23 47 58@2x