Swiftpack.co - Package - nodes-vapor/bootstrap

Bootstrap 🍃

Swift Version Vapor Version Circle CI codebeat badge codecov Readme Score GitHub license

This package wraps Bootstrap elements into convenient Leaf-Tags.

Installation

Add Bootstrap to the package dependencies (in your Package.swift file):

dependencies: [
    ...,
    .package(url: "https://github.com/nodes-vapor/bootstrap.git", from: "4.0.0-beta")
]

as well as to your target (e.g. "App"):

targets: [
    ...
    .target(
        name: "App",
        dependencies: [... "Bootstrap" ...]
    ),
    ...
]

Getting started 🚀

First import Bootstrap and Leaf inside your configure.swift

import Bootstrap
import Leaf

Adding the Leaf tags

In order to render the Bootstrap elements, you will need to add the Bootstrap Leaf tags:

public func configure(_ config: inout Config, _ env: inout Environment, _ services: inout Services) throws {
    services.register { _ -> LeafTagConfig in
        var tags = LeafTagConfig.default()
        tags.useBootstrapLeafTags()
        return tags
    }
}

Supported tags

Alert

#bs:alert() { alert text }

Badge

#bs:badge(type?, classExtras?, attributes?) { badge text }

Button

#bs:button(type?, classExtras?, attributes?) { btn text }

Button Group

#bs:buttonGroup(isVertical, classExtras?, Aria?) { }
#bs:buttonGroup(false, "btn-group-sm") {
    #bs:button() { First Option }
    #bs:button("danger") { Second Option}
    #bs:button() { Third Option}
}

Button Toolbar

#bs:buttonToolbar(classExtras?, Aria?) { }
#bs:buttonToolbar() {
    #bs:button() { First Option }
    #bs:button("danger") { Second Option}
    #bs:button() { Third Option}
}

Input

#bs:input(type?, classExtras?, attributes?)

Breadcrumb

#bs:breadcrumb(classExtras?, attributes?) {
  #bs:breadcrumbItem(classExtras?, attributes?) { <a href="/"> Home </a> }
  #bs:breadcrumbItem(classExtras?, attributes?) { Profile }
}

Textarea

#bs:textArea(classExtras?, attributes?, value?)

Card

#bs:card(title?, classExtras?, attributes?) { <card body> }

or

#bs:card:outer(title?, classExtras?, attributes?) {
	#bs:card:header(classExtras?, attributes?) { <card header, if more than a simple string should be rendered> }
	#bs:card:body(classExtras?, attributes?) { <card contents> }
	#bs:card:footer(classExtras?, attributes?) { <card footer> }
}

🏆 Credits

This package is developed and maintained by the Vapor team at Nodes. The package owner for this project is Martin.

📄 License

This package is open-sourced software licensed under the MIT license

Github

link
Stars: 8
Help us keep the lights on

Releases

4.0.0-rc.3 - Apr 11, 2019

Added

  • Bootstrap card tags. Thanks @MrMage!

4.0.0-rc.2 - Mar 23, 2019

Fixed

  • makes sure all tags are registered (including formCheckbox, formFile, and formRadio)

4.0.0-rc.1 - Mar 6, 2019

Changed

  • depends on Sugar 4.0.0 RC

4.0.0-beta.1 - Feb 17, 2019

Changed

  • depends on Sugar 4

Removed

  • BootstrapProvider because the only thing it did was add the LeafProvider.

3.1.0 - Jan 4, 2019

Added

  • FormRadio-Tag
  • FormCheckbox-Tag
  • FormFile-Tag

Changed

  • Input-Tag no longer accepts file type. You can use FormFile-Tag from now on.