From 0320a8da4845c5f2549a211b39b230637f7952aa Mon Sep 17 00:00:00 2001 From: Dave Verwer Date: Tue, 1 Jun 2021 16:53:46 +0100 Subject: [PATCH] Added an attribute to represent the button types. (#69) * Added `HTMLButtonType`. * Added a test for button type. --- Sources/Plot/API/HTMLAttributes.swift | 8 ++++++++ Sources/Plot/API/HTMLButtonType.swift | 15 +++++++++++++++ Tests/PlotTests/HTMLTests.swift | 8 ++++++-- 3 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 Sources/Plot/API/HTMLButtonType.swift diff --git a/Sources/Plot/API/HTMLAttributes.swift b/Sources/Plot/API/HTMLAttributes.swift index 82e8faa..db87b87 100644 --- a/Sources/Plot/API/HTMLAttributes.swift +++ b/Sources/Plot/API/HTMLAttributes.swift @@ -311,6 +311,14 @@ public extension Attribute where Context == HTML.InputContext { } } +public extension Node where Context == HTML.ButtonContext { + /// Assign a button type to the element. + /// - parameter type: The button type to assign. + static func type(_ type: HTMLButtonType) -> Node { + .attribute(named: "type", value: type.rawValue) + } +} + public extension Node where Context == HTML.TextAreaContext { /// Specify the number of columns that the text area should contain. /// - parameter columns: The number of columns to specify. diff --git a/Sources/Plot/API/HTMLButtonType.swift b/Sources/Plot/API/HTMLButtonType.swift new file mode 100644 index 0000000..f1634c0 --- /dev/null +++ b/Sources/Plot/API/HTMLButtonType.swift @@ -0,0 +1,15 @@ +/** +* Plot +* Copyright (c) John Sundell 2019 +* MIT license, see LICENSE file for details +*/ + +import Foundation + +/// Enum that defines various button types that can be used with the +/// ` + \ + \ + \ + """) }