Skip to content
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

Various README improvements #52

Merged
merged 9 commits into from
Mar 8, 2022
Merged
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 46 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
# Exhibition

Exhibition is a framework and generator for displaying a SwiftUI component library.
![CI](https://github.com/mjarvis/exhibition/actions/workflows/test.yml/badge.svg)

Exhibition is a framework and generator for displaying and debugging a SwiftUI component library.

Inspired by [Storybook](https://storybook.js.org/) and [Showkase](https://github.com/airbnb/Showkase)

# Installation

### Swift Package Manager

# Usage

1. Add Exhibition to your project via Swift package manager using `https://github.com/mjarvis/Exhibition.git`
1. Add `https://github.com/mjarvis/Exhibition` to your project via Xcode.
2. Install [Sourcery](https://github.com/krzysztofzablocki/Sourcery)
3. Copy [Exhibition.swifttemplate](./Exhibition.swifttemplate) into your project
4. Modify your SwiftUI previews to use `ExhibitProvider`

# Usage

1. Modify your SwiftUI previews to use `ExhibitProvider`
```swift
import Exhibition

Expand All @@ -26,12 +29,48 @@ Inspired by [Storybook](https://storybook.js.org/) and [Showkase](https://github
title: context.parameter(name: "title", defaultValue: "Title"),
content: context.parameter(name: "content")
)
.previewLayout(.sizeThatFits)
}
}
```
5. Run `Sourcery` to generate your Exhibition: `sourcery --sources Your/Source/Path --templates Exhibition.swifttemplate --output ./Sources/Generated`
6. Show `exhibition` in a swift view
6. Show `Exhibition()` in a swift view

# Custom Layout

If you would like your exhibit to have some custom layout, there is an optional function in `ExhibitProvider` you can implement.

Here is an example of embeding the exhibit within a `List`:

```swift
static func exhibitLayout(_ content: Foo) -> some View {
List {
content
}
}
IanHoar marked this conversation as resolved.
Show resolved Hide resolved
```

You can also provide a custom `View` here to provide presentation samples:

```swift
struct CustomLayout<Content: View>: View {
let content: Content

@State var isPresented: Bool = false

var body: some View {
Button("Open") {
isPresented = true
}
.sheet(isPresented: $isPresented) {
content
}
}
}

static func exhibitLayout(_ content: Foo) -> some View {
CustomLayout(content: content)
}
IanHoar marked this conversation as resolved.
Show resolved Hide resolved
```

# Custom Parameter views

Expand All @@ -54,38 +93,3 @@ struct DoublingStringParameterView: ParameterView {
Exhibition()
.parameterView(DoublingStringParameterView.self)
```

# TODO:

- [x] Debug (#1)
- [x] Dark mode (#1)
- [x] RTL (#11)
- [ ] Text sizing
- [ ] Investigate other assistive switches

- [x] Search (#2)
- [x] Search top level
- [ ] Search nested

- [x] Sections (#5)
- [x] Collapsing
- [ ] Rows
- [ ] Icon
- [ ] Title

- [x] Exhibit
- [x] Push
- [ ] Present
- [x] Layout rules (#4)
- [x] Parameters (#3)

- [ ] Code samples (copy-able snippets)
- [ ] Code documentation (jazzy / swiftdocc)
- [ ] Metadata (JSON output)

- [ ] Layout
- [x] iPhone
- [x] iPad
- [ ] macOS
- [ ] watchOS
- [ ] tvOS