Skip to content

Commit 36090b8

Browse files
committed
organize plot extensions
1 parent 22a9e10 commit 36090b8

File tree

8 files changed

+41
-52
lines changed

8 files changed

+41
-52
lines changed

Sources/App/Views/Plot+Extensions.swift

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,43 @@ extension Node where Context == HTML.FormContext {
249249
.value(query)
250250
)
251251
}
252+
253+
static func emailField(email: String = "") -> Self {
254+
.input(
255+
.id("email"),
256+
.name("email"),
257+
.type(.email),
258+
.placeholder("Enter email"),
259+
.spellcheck(false),
260+
.autocomplete(false),
261+
.value(email)
262+
)
263+
}
264+
265+
static func passwordField(password: String = "", passwordFieldText: String = "Enter password") -> Self {
266+
.input(
267+
.id("password"),
268+
.name("password"),
269+
.type(.password),
270+
.placeholder(passwordFieldText),
271+
.spellcheck(false),
272+
.autocomplete(false),
273+
.value(password)
274+
)
275+
}
276+
277+
static func confirmationCodeField(code: String = "") -> Self {
278+
.input(
279+
.class("portal-form-inputs"),
280+
.id("confirmationCode"),
281+
.name("confirmationCode"),
282+
.type(.text),
283+
.placeholder("Confirmation code"),
284+
.spellcheck(false),
285+
.autocomplete(false),
286+
.value(code)
287+
)
288+
}
252289
}
253290

254291
extension Node where Context == HTML.ListContext {

Sources/App/Views/Portal/ForgotPassword+View.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ enum ForgotPassword {
3131
}
3232
}
3333

34-
// TODO: move to plot extensions
3534
extension Node where Context: HTML.BodyContext {
3635
static func forgotPasswordForm(email: String = "") -> Self {
3736
.form(

Sources/App/Views/Portal/Login+View.swift

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ enum Login {
3434
}
3535
}
3636

37-
// TODO: move to plot extensions
3837
extension Node where Context: HTML.BodyContext {
3938
static func loginForm(email: String = "", password: String = "") -> Self {
4039
.div(
@@ -73,29 +72,3 @@ extension Node where Context: HTML.BodyContext {
7372
}
7473
}
7574

76-
extension Node where Context == HTML.FormContext {
77-
static func emailField(email: String = "") -> Self {
78-
.input(
79-
.id("email"),
80-
.name("email"),
81-
.type(.email),
82-
.placeholder("Enter email"),
83-
.spellcheck(false),
84-
.autocomplete(false),
85-
.value(email)
86-
)
87-
}
88-
89-
static func passwordField(password: String = "", passwordFieldText: String = "Enter password") -> Self {
90-
.input(
91-
.id("password"),
92-
.name("password"),
93-
.type(.password),
94-
.placeholder(passwordFieldText),
95-
.spellcheck(false),
96-
.autocomplete(false),
97-
.value(password)
98-
)
99-
}
100-
}
101-

Sources/App/Views/Portal/Portal+View.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ enum PortalPage {
3232
}
3333
}
3434

35-
// TODO: move to plot extensions
3635
extension Node where Context: HTML.BodyContext {
3736
static func logoutButton() -> Self {
3837
.form(

Sources/App/Views/Portal/Reset+View.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,13 @@ enum Reset {
3131
}
3232
}
3333

34-
// TODO: move to plot extensions
3534
extension Node where Context: HTML.BodyContext {
3635
static func resetPasswordForm(email: String = "", password: String = "", code: String = "") -> Self {
3736
.form(
3837
.action(SiteURL.resetPassword.relativeURL()),
3938
.method(.post),
4039
.data(named: "turbo", value: "false"),
41-
.codeField(code: code),
40+
.confirmationCodeField(code: code),
4241
.emailField(email: email) ,
4342
.passwordField(password: password, passwordFieldText: "Enter new password"),
4443
.button(

Sources/App/Views/Portal/Signup+View.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ enum Signup {
3131
}
3232
}
3333

34-
// TODO: move to plot extensions
3534
extension Node where Context: HTML.BodyContext {
3635
static func signupForm(email: String = "", password: String = "") -> Self {
3736
.form(

Sources/App/Views/Portal/Successful+Password+Change.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,14 @@ enum SuccessfulChange {
2424
.div(
2525
.class("portal-page"),
2626
.text(self.model.successMessage),
27-
.loginButton()
27+
.loginRedirectButton()
2828
)
2929
}
3030
}
3131
}
3232

33-
// TODO: move to plot extensions
3433
extension Node where Context: HTML.BodyContext {
35-
static func loginButton() -> Self {
34+
static func loginRedirectButton() -> Self {
3635
.form(
3736
.action(SiteURL.login.relativeURL()),
3837
.button(

Sources/App/Views/Portal/Verify+View.swift

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ enum Verify {
3232
}
3333
}
3434

35-
// TODO: move to plot extensions
3635
extension Node where Context: HTML.BodyContext {
3736
static func verifyForm(email: String = "", code: String = "") -> Self {
3837
.form(
@@ -44,7 +43,7 @@ extension Node where Context: HTML.BodyContext {
4443
.type(.hidden),
4544
.value(email)
4645
),
47-
.codeField(code: code),
46+
.confirmationCodeField(code: code),
4847
.data(named: "turbo", value: "false"),
4948
.button(
5049
.text("Confirm sign up"),
@@ -53,18 +52,3 @@ extension Node where Context: HTML.BodyContext {
5352
)
5453
}
5554
}
56-
57-
extension Node where Context == HTML.FormContext {
58-
static func codeField(code: String = "") -> Self {
59-
.input(
60-
.class("portal-form-inputs"),
61-
.id("confirmationCode"),
62-
.name("confirmationCode"),
63-
.type(.text),
64-
.placeholder("Confirmation code"),
65-
.spellcheck(false),
66-
.autocomplete(false),
67-
.value(code)
68-
)
69-
}
70-
}

0 commit comments

Comments
 (0)