Zeplin component preview for your SwiftUI views

Overview

ZeplinPreviewSwiftUI

A Zeplin component preview for your SwiftUI views. You can use Zeplin components instead of real views within your app until you implement them.

The Purpose

To speed up prototype development and test design choices before full-featured implementation. This is basically a clone of figma-preview-swiftui, project is heavily inspired by flutter_figma_preview and jetpack-compose-figma-preview.

Requirements

ZeplinPreviewSwiftUI uses SwiftUI features of macOS 11, iOS 14, tvOS 14, watchOS 7.

Setup

Add ZeplinPreviewSwiftUI to your project via Swift Package Manager.

Create personal access token in account settings.

zeplin-access-token

Then pass this Zeplin access token via Environment.

") } } } ">
struct ZeplinPreviewApp: App {
    var body: some Scene {
        WindowGroup {
            ContentView()
                .environment(\.zeplinAccessToken, "")
        }
    }
}

Usage

If you're using single Zeplin project for all designs, you can also pass it via Environment, so you won't need to specify it for each individual component. Project id could be taken from Zeplin App link (not web link) – typically, it goes after pid=.

") .environment(\.zeplinProjectId, "") } } } ">
struct ZeplinPreviewApp: App {
    var body: some Scene {
        WindowGroup {
            ContentView()
                .environment(\.zeplinAccessToken, "")
                .environment(\.zeplinProjectId, "")
        }
    }
}

When you need to insert your Zeplin component, you can use two ways. Either you can specify component ID and optionally project ID directly.

", componentId: "") } } ">
struct ContentView: View {
    var body: some View {
        ZeplinView(projectId: "", componentId: "")
    }
}

Alternatively, you can simply pass Zeplin App link for the component.

struct ContentView: View {
    var body: some View {
        ZeplinView(link: "zpl://components?pid=NNNNNNN&coids=MMMMMMM")
    }
}

ZeplinView will maintain its aspectRatio, but you'll need to control its frame when needed.

Project and component lists to get component IDs

When you need to get component IDs for the elements, you can use ZeplinProjectsList view (it comes with NavigationView, so you could put somewhere in developer menu of your app on early stages, or use separate app to browse components). Also, there is ZeplinComponentsList which shows components for a specific project (you can use Environment, or pass project ID directly to the view). Please note that only components published in Styleguide will be listed.

struct ContentView: View {
    var body: some View {
        ZeplinProjectsList()
    }
}

Reuse and contribution

You could use ZeplinPreviewSwiftUI in any way you want. If you would like to contribute to the projects – contact me. Any ideas, suggestions, pull requests are welcome.

Anyway, ping me at @edeniska. :)

See also

If you use Figma for designs – check figma-preview-swiftui.

Roadmap

At the moment, there are couple of ideas of features to be added:

  • ability to overlay view with Zeplin representation to check the pixel-perfect differences
  • add UIKit version

License

ZeplinPreviewSwiftUI is available under the MIT license. See the LICENSE file for more info.

You might also like...
UIPheonix is a super easy, flexible, dynamic and highly scalable UI framework + concept for building reusable component/control-driven apps for macOS, iOS and tvOS
UIPheonix is a super easy, flexible, dynamic and highly scalable UI framework + concept for building reusable component/control-driven apps for macOS, iOS and tvOS

UIPheonix is a super easy, flexible, dynamic and highly scalable UI framework + concept for building reusable component/control-driven apps for macOS, iOS and tvOS

A panel component similar to the iOS Airpod battery panel or the Share Wi-Fi password panel.
A panel component similar to the iOS Airpod battery panel or the Share Wi-Fi password panel.

A SwiftUI panel component similar to the iOS Airpod battery panel or the Share Wi-Fi password panel.

Customizable CheckBox / RadioButton component for iOS
Customizable CheckBox / RadioButton component for iOS

GDCheckbox An easy to use CheckBox/Radio button component for iOS, with Attributes inspector support. Requirements Xcode 10+ Swift 5 iOS 9+ Installati

TSnackBarView is a simple and flexible UI component fully written in Swift
TSnackBarView is a simple and flexible UI component fully written in Swift

TSnackBarView is a simple and flexible UI component fully written in Swift. TSnackBarView helps you to show snackbar easily with 3 styles: normal, successful and error

TDetailBoxView is a simple and flexible UI component fully written in Swift
TDetailBoxView is a simple and flexible UI component fully written in Swift

TDetailBoxView is a simple and flexible UI component fully written in Swift. TDetailBoxView is developed to help users quickly display the detail screen without having to develop from scratch.

TSwitchLabel is a simple and flexible UI component fully written in Swift.
TSwitchLabel is a simple and flexible UI component fully written in Swift.

TSwitchLabel is a simple and flexible UI component fully written in Swift. TSwitchLabel is developed for you to easily use when you need to design a UI with Label and Switch in the fastest way without having to spend time on develop from scratch.

Placeholder views based on content, loading, error or empty states
Placeholder views based on content, loading, error or empty states

StatefulViewController A protocol to enable UIViewControllers or UIViews to present placeholder views based on content, loading, error or empty states

Compose views using enums swiftly: `let label: UILabel = [.text("Hello"), .textColor(.red)]`

ViewComposer Style views using an enum array with its attributes: let label: UILabel = [.text("Hello World"), .textColor(.red)] Table of Contents Inst

A paging scroll view for SwiftUI, using internal SwiftUI components
A paging scroll view for SwiftUI, using internal SwiftUI components

PagingView A paging scroll view for SwiftUI, using internal SwiftUI components. This is basically the same as TabView in the paging mode with the inde

Owner
Danis Tazetdinov
Danis Tazetdinov
Highly customizable Action Sheet Controller with Assets Preview written in Swift

PPAssetsActionController Play with me ▶️ ?? If you want to play with me, just tap here and enjoy! ?? ?? Show me ?? Try me ?? The easiest way to try me

Pavel Pantus 72 Feb 4, 2022
Easily use UIKit views in your SwiftUI applications. Create Xcode Previews for UIView elements

SwiftUIKitView Easily use UIKit views in SwiftUI. Convert UIView to SwiftUI View Create Xcode Previews from UIView elements SwiftUI functional updatin

Antoine van der Lee 682 Dec 29, 2022
⬆️ A SwiftUI view component sliding in from bottom

⬆️ A SwiftUI view component sliding in from bottom

Tieda 595 Dec 28, 2022
A multi-platform SwiftUI component for tabular data

SwiftTabler A multi-platform SwiftUI component for tabular data. NOTE this component is BRAND NEW and under active development. If you need stability,

OpenAlloc 45 Jan 3, 2023
A SwiftUI Views for wrapping HStack elements into multiple lines

SwiftUI WrappingStack A SwiftUI Views for wrapping HStack elements into multiple lines. List of supported views WrappingHStack - provides HStack that

Denis 50 Jan 6, 2023
Create SwiftUI Views with any data

Create SwiftUI Views with any data

Zach Eriksen 20 Jun 27, 2022
Runtime introspection and unit testing of SwiftUI views

ViewInspector is a library for unit testing SwiftUI views. It allows for traversing a view hierarchy at runtime providing direct access to the underlying View structs.

Alexey Naumov 1.5k Jan 2, 2023
AGCircularPicker is helpful component for creating a controller aimed to manage any calculated parameter

We are pleased to offer you our new free lightweight plugin named AGCircularPicker. AGCircularPicker is helpful for creating a controller aimed to man

Agilie Team 617 Dec 19, 2022
UI Component. This is a copy swipe-panel from app: Apple Maps, Stocks. Swift version

ContainerController UI Component. This is a copy swipe-panel from app: https://www.apple.com/ios/maps/ Preview Requirements Installation CocoaPods Swi

Rustam 419 Dec 12, 2022
An easy to use UI component to help display a signal bar with an added customizable fill animation

TZSignalStrengthView for iOS Introduction TZSignalStrengthView is an easy to use UI component to help display a signal bar with an added customizable

TrianglZ LLC 22 May 14, 2022