GithubHelp home page GithubHelp logo

thirdfort / lorem Goto Github PK

View Code? Open in Web Editor NEW
15.0 9.0 1.0 1.13 MB

A Swift package that provides convenient Lorem Ipsum text, images, colors and other placeholders for rapidly prototyping, building and testing your iOS applications.

License: Apache License 2.0

Swift 100.00%
ios package placeholder spm swift lorem lorem-ipsum lorem-ipsum-generator loremipsum swiftui

lorem's Introduction

ios tv watchOS mac

Lorem

Introducing Lorem, a placeholder generator library for iOS to help you rapidly prototype, build and test your iOS applications.

Lorem sample

By leveraging Swift generics we're also able to provide a simple, consistent API to make it easier to discover and even find all references when you're ready to remove your placeholder data.

// When used in a context where a simple String is required
Lorem.title // return String

// But if we use the same code inside a SwiftUI View
var body: some View {
    Lorem.title // returns Text
}

Why?

Lorem placeholder content is extremely useful when prototyping or even while building your apps while live data is unavailable or just not feasible to access yet.

Its also incredibly useful when running both manual and automation test suites, as it allows for a more controlled and/or varied set of values to be tested, revealing layout and other issues that may have been missed or difficult to reproduce otherwise.

Lastly, Lorem data is more clearly placeholder data, which can help stakeholders and other team members better identify where live-data is yet to be implemented.

Features

Lorem supports various placeholder APIs, including:

  • Strings
  • Dates
  • URLs
  • Images
  • SwiftUI View's

While most features are supported across all platforms and version, some (like AsyncImage) are only available in supported environments.

In addition to text and images, Lorem also provides useful APIs for working with other types, including Color:

Lorem sample

Most APIs also have multiple convenience features to improve the experience where applicable:

// Format dates
Lorem.date(.formatted("HH:mm"))
Lorem.date(.styled(time: .shortened))

// 3 to 5 words
Lorem.title(3...5)

// returns the same grayscale image every time
Lorem.image(source: .seed(0), grayscale: true)

Usage

The most basic usage can be achieved using simple String:

Lorem.word
Lorem.sentence
Lorem.paragraph
Lorem.title
Lorem.name
Lorem.url
Lomem.email
Lorem.date

Since Lorem supports Swift Generics, you can also use it in more contexts:

let url: URL = Lorem.url
let date: Date = Lorem.date

Which also means all of the APIs are also available conveniently in SwiftUI

Lorem.title  // Text
Lorem.color  // Color
Lorem.image  // Image

Primitives are also available which allows for usage in more scenarios, including UIKit:

Lorem.url    // URL
Lorem.date   // Date
Lorem.color  // Color, UIColor, NSColor
Lorem.image  // Image, UIImage, NSImage

Advanced

Lorem provides access to its underlying placeholder data primitives, as well as a reusable composer that simplifies text generation. This enables you to easily create custom Lorem placeholders for content where the library doesn't quite meet your needs.

let keywords = Lorem.Composer(
    Lorem.word,
    countRange: 5...15,
    separator: ", ",
    terminator: ""
)

// tempora, fugit, sit, molestias, suscipit, voluptate, et, numquam, et, voluptatem, et

Additionally, Lorem provides convenient access to its data sources, so you can build placeholders with the same data used to build the API.

Lorem.Data.words
Lorem.Data.firstNames
Lorem.Data.lastNames
Lorem.Data.siteDomains
Lorem.Data.emailDomains
// etc

Installation

You can install manually (by copying the files in the Sources directory) or using Swift Package Manager (preferred)

To install using Swift Package Manager, add this to the dependencies section of your Package.swift file:

.package(url: "https://github.com/Thirdfort/Lorem.git", .upToNextMinor(from: "1.0.0"))

lorem's People

Contributors

shaps80 avatar tommy-holmes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

shaps80

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.