Skip to content
This repository was archived by the owner on Apr 20, 2024. It is now read-only.

Commit 17f7443

Browse files
Merge pull request #18 from nodes-vapor/feature/update-sugar
Feature/update sugar
2 parents 9fca155 + 87e46d1 commit 17f7443

File tree

13 files changed

+94
-103
lines changed

13 files changed

+94
-103
lines changed

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ let package = Package(
77
.library(name: "Bootstrap", targets: ["Bootstrap"])
88
],
99
dependencies: [
10-
.package(url: "https://github.com/nodes-vapor/sugar.git", from: "3.0.0-beta"),
10+
.package(url: "https://github.com/nodes-vapor/sugar.git", from: "4.0.0-beta.2"),
1111
.package(url: "https://github.com/vapor/leaf.git", from: "3.0.0-rc"),
1212
.package(url: "https://github.com/vapor/vapor.git", from: "3.0.0"),
1313
],

README.md

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,26 @@ This package wraps Bootstrap elements into convenient Leaf-Tags.
1313

1414
# Installation
1515

16-
Update your `Package.swift` file.
16+
Add `Bootstrap` to the package dependencies (in your `Package.swift` file):
17+
18+
```swift
19+
dependencies: [
20+
...,
21+
.package(url: "https://github.com/nodes-vapor/bootstrap.git", from: "4.0.0-beta")
22+
]
23+
```
24+
25+
as well as to your target (e.g. "App"):
26+
1727
```swift
18-
.package(url: "https://github.com/nodes-vapor/bootstrap.git", from: "1.0.0")
28+
targets: [
29+
...
30+
.target(
31+
name: "App",
32+
dependencies: [... "Bootstrap" ...]
33+
),
34+
...
35+
]
1936
```
2037

2138
## Getting started 🚀
@@ -27,12 +44,6 @@ import Bootstrap
2744
import Leaf
2845
```
2946

30-
### Adding the provider
31-
32-
```swift
33-
try services.register(BootstrapProvider())
34-
```
35-
3647
### Adding the Leaf tags
3748

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

Sources/Bootstrap/Bootstrap.swift

Lines changed: 0 additions & 71 deletions
This file was deleted.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import Leaf
2+
3+
extension LeafTagConfig {
4+
public mutating func useBootstrapLeafTags() {
5+
use([
6+
"bs:button": ButtonTag(),
7+
"bs:buttonGroup": ButtonGroupTag(),
8+
"bs:buttonToolbar": ButtonToolbarTag(),
9+
"bs:alert": AlertTag(),
10+
"bs:input": InputTag(),
11+
"bs:badge": BadgeTag(),
12+
"bs:breadCrumb": BreadCrumbTag(),
13+
"bs:breadCrumbItem": BreadCrumbItemTag(),
14+
"bs:textArea": TextAreaTag()
15+
])
16+
}
17+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/// Bootstrap Color Definitions
2+
enum ColorKeys: String {
3+
/// Bootstrap Primary Color
4+
case primary
5+
/// Bootstrap Secondary Color
6+
case secondary
7+
/// Bootstrap Success Color
8+
case success
9+
/// Bootstrap Danger Color
10+
case danger
11+
/// Bootstrap Warning Color
12+
case warning
13+
/// Bootstrap Info Color
14+
case info
15+
/// Bootstrap Light Color
16+
case light
17+
/// Bootstrap Dark Color
18+
case dark
19+
}

Sources/Bootstrap/Tags/Alert.swift

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ public final class AlertTag: TagRenderer {
1010

1111
if tag.parameters.count > 0 {
1212
guard let param = tag.parameters[0].string else {
13-
throw tag.error(reason: "Wrong type given (expected a string): \(type(of: tag.parameters[0]))")
13+
throw tag.error(
14+
reason: "Wrong type given (expected a string): \(type(of: tag.parameters[0]))"
15+
)
1416
}
1517

1618
if param.count > 0 {
@@ -20,7 +22,9 @@ public final class AlertTag: TagRenderer {
2022

2123
if tag.parameters.count > 1 {
2224
guard let param = tag.parameters[1].string else {
23-
throw tag.error(reason: "Wrong type given (expected a string): \(type(of: tag.parameters[1]))")
25+
throw tag.error(
26+
reason: "Wrong type given (expected a string): \(type(of: tag.parameters[1]))"
27+
)
2428
}
2529

2630
if param.count > 0 {
@@ -30,7 +34,9 @@ public final class AlertTag: TagRenderer {
3034

3135
if tag.parameters.count > 2 {
3236
guard let param = tag.parameters[2].string else {
33-
throw tag.error(reason: "Wrong type given (expected a string): \(type(of: tag.parameters[2]))")
37+
throw tag.error(
38+
reason: "Wrong type given (expected a string): \(type(of: tag.parameters[2]))"
39+
)
3440
}
3541

3642
if param.count > 0 {

Sources/Bootstrap/Tags/Badge.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Leaf
2+
import Sugar
23
import TemplateKit
34

45
public final class BadgeTag: TagRenderer {
@@ -18,7 +19,7 @@ public final class BadgeTag: TagRenderer {
1819
case 0: style = param
1920
case 1: classes = param
2021
case 2: attributes = param
21-
default: ()
22+
default: break
2223
}
2324
}
2425
}

Sources/Bootstrap/Tags/Breadcrumb.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Leaf
2+
import Sugar
23
import TemplateKit
34

45
public final class BreadCrumbTag: TagRenderer {
@@ -15,7 +16,7 @@ public final class BreadCrumbTag: TagRenderer {
1516
switch index {
1617
case 0: classes = param
1718
case 1: attributes = param
18-
default: ()
19+
default: break
1920
}
2021
}
2122
}
@@ -49,7 +50,7 @@ public final class BreadCrumbItemTag: TagRenderer {
4950
switch index {
5051
case 0: classes = param
5152
case 1: attributes = param
52-
default: ()
53+
default: break
5354
}
5455
}
5556
}

Sources/Bootstrap/Tags/Button.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Leaf
2+
import Sugar
23
import TemplateKit
34

45
public final class ButtonTag: TagRenderer {
@@ -23,7 +24,7 @@ public final class ButtonTag: TagRenderer {
2324
case 0: style = param
2425
case 1: classes = param
2526
case 2: attributes = param
26-
default: ()
27+
default: break
2728
}
2829
}
2930
}

Sources/Bootstrap/Tags/ButtonGroup.swift

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,27 @@ public final class ButtonGroupTag: TagRenderer {
1515

1616
try tag.requireParameterCount(upTo: ButtonGroupTag.paramCount)
1717

18-
var group = GroupKeys.standard.rawValue
18+
var group = GroupKeys.standard
1919
var classes: String?
2020
var aria = UUID().uuidString
2121

2222
if tag.parameters.count > 0 {
2323
guard let param = tag.parameters[0].bool else {
24-
throw tag.error(reason: "Wrong type given (expected a bool): \(type(of: tag.parameters[0]))")
24+
throw tag.error(
25+
reason: "Wrong type given (expected a bool): \(type(of: tag.parameters[0]))"
26+
)
2527
}
2628

2729
if param {
28-
group = GroupKeys.vertical.rawValue
30+
group = .vertical
2931
}
3032
}
3133

3234
if tag.parameters.count > 1 {
3335
guard let param = tag.parameters[1].string else {
34-
throw tag.error(reason: "Wrong type given (expected a string): \(type(of: tag.parameters[1]))")
36+
throw tag.error(
37+
reason: "Wrong type given (expected a string): \(type(of: tag.parameters[1]))"
38+
)
3539
}
3640

3741
if param.count > 0 {
@@ -41,7 +45,9 @@ public final class ButtonGroupTag: TagRenderer {
4145

4246
if tag.parameters.count > 2 {
4347
guard let param = tag.parameters[2].string else {
44-
throw tag.error(reason: "Wrong type given (expected a string): \(type(of: tag.parameters[2]))")
48+
throw tag.error(
49+
reason: "Wrong type given (expected a string): \(type(of: tag.parameters[2]))"
50+
)
4551
}
4652

4753
if param.count > 0 {
@@ -57,7 +63,7 @@ public final class ButtonGroupTag: TagRenderer {
5763
throw tag.error(reason: "Body Data Expected")
5864
}
5965

60-
var group = "<div class='\(group)"
66+
var group = "<div class='\(group.rawValue)"
6167
if let classes = classes {
6268
group += " \(classes)"
6369
}

0 commit comments

Comments
 (0)