Skip to content

A highly customizable template engine for in-app documentation written in SwiftUI

License

Notifications You must be signed in to change notification settings

ipedro/swiftui-showcase

Repository files navigation

Showcase

Swift iOS GitHub License GitHub Stars GitHub Forks

Showcase is a Swift package designed to simplify the process of documenting and showcasing SwiftUI-based components. It provides a structured approach to create, organize, and present documentation for your SwiftUI projects. Showcase offers a variety of customization options and styles for presenting code samples, previews, and more.

Features

  • Structured documentation for SwiftUI components.
  • Showcase your SwiftUI views' previews.
  • Showcase libraries and chapters for organized content.
  • Link external resources or documentation.
  • Display code samples with syntax highlighting.
  • Various styles for code blocks, previews, and external links.

Requirements

  • iOS 15+
  • Xcode 13+
  • Swift 5.7+

Installation

Swift Package Manager

You can easily integrate Showcase into your Xcode project using Swift Package Manager. Follow these steps:

  1. Open your project in Xcode.
  2. Go to "File" -> "Swift Packages" -> "Add Package Dependency..."
  3. Enter the following URL when prompted: https://github.com/ipedro/swiftui-showcase
  4. Choose the version or branch you want to use.
  5. Click "Finish" to add the package to your project.

Alternatively, you can add Showcase as a dependency in your Package.swift file:

dependencies: [
    .package(url: "https://github.com/ipedro/swiftui-showcase", from: "0.3.0")
]

Also: Don't forget to add "Showcase" as a dependency of your package's target.

Usage

  1. Import the Showcase module in your SwiftUI view file:

    import Showcase
  2. Create and structure your showcase topics using Topic instances.

Showcase

The Showcase view is used to display your showcase topics. Here's an example:

import SwiftUI

struct ContentView: View {
    var body: some View {
        NavigationView {
            // Create a Showcase with a Topic, e.g., .card
            Showcase(.mockCard)
                .navigationTitle("Component Showcase")
        }
    }
}

ShowcaseList

The ShowcaseList view allows you to list chapters of showcase topics. Here's an example:

import SwiftUI

struct ContentView: View {
    var body: some View {
        NavigationView {
            // Create a list with two chapters
            ShowcaseList(
                Chapter("Section 1", .card, .accordion),
                Chapter("Section 2", .button, .text)
            )
            .navigationTitle("Component Showcase")
        }
    }
}

ShowcaseNavigationView

The ShowcaseNavigationView view provides navigation to chapters of showcase topics. Here's an example:

import SwiftUI

struct ContentView: View {
    var body: some View {
        // Create a ShowcaseNavigationView with a Chapter and optional icon
        ShowcaseNavigationStack(
            ShowcaseChapter(
                "My Chapter", 
                Chapter("Section 1", .card, .accordion),
                Chapter("Section 2", .button, .text)
            )
        )
    }
}

License

Showcase is released under the MIT License. See LICENSE for details.

Contributing

Contributions are welcome! Please see our Contribution Guidelines for more information.

Credits

Showcase is created and maintained by Pedro Almeida.

About

A highly customizable template engine for in-app documentation written in SwiftUI

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages