|
1 | | -//// |
2 | | -//// Header.swift |
3 | | -//// SwiftHtml |
4 | | -//// |
5 | | -//// Created by Tibor Bodecs on 2021. 07. 19.. |
6 | | -//// |
7 | | -// |
8 | | -///// The` <header>` element represents a container for introductory content or a set of navigational links. |
9 | | -///// |
10 | | -///// A` <header>` element typically contains: |
11 | | -///// |
12 | | -///// - one or more heading elements (`<h1>` - `<h6>`) |
13 | | -///// - logo or icon |
14 | | -///// - authorship information |
15 | | -///// **Note:** You can have several` <header>` elements in one HTML document. However,` <header>` cannot be placed within a` <footer>`,` <address>` or another` <header>` element. |
16 | | -//open class Header: Tag { |
17 | | -// |
18 | | -//} |
| 1 | +/// The` <header>` element represents a container for introductory content or a set of navigational links. |
| 2 | +/// |
| 3 | +/// A` <header>` element typically contains: |
| 4 | +/// |
| 5 | +/// - one or more heading elements (`<h1>` - `<h6>`) |
| 6 | +/// - logo or icon |
| 7 | +/// - authorship information |
| 8 | +/// **Note:** You can have several` <header>` elements in one HTML document. However,` <header>` cannot be placed within a` <footer>`,` <address>` or another` <header>` element. |
| 9 | +public struct Header: |
| 10 | + HTMLStandardTag, |
| 11 | + /// attribute modifiers |
| 12 | + GlobalAttributeModifier |
| 13 | +{ |
| 14 | + |
| 15 | + /// The attribute storage for the tag. |
| 16 | + public var attributes: AttributeStore |
| 17 | + |
| 18 | + /// The child elements contained within the tag. |
| 19 | + public var children: [Element] |
| 20 | + |
| 21 | + /// The content model category for the tag. |
| 22 | + public var categories: ContentModel { |
| 23 | + [ |
| 24 | + .flow, |
| 25 | + .palpable, |
| 26 | + ] |
| 27 | + } |
| 28 | + |
| 29 | + init( |
| 30 | + attributes: AttributeStore = .init(), |
| 31 | + children: [Element] |
| 32 | + ) { |
| 33 | + self.attributes = attributes |
| 34 | + self.children = children |
| 35 | + } |
| 36 | + |
| 37 | + public init( |
| 38 | + _ contents: String |
| 39 | + ) { |
| 40 | + self.init( |
| 41 | + children: [ |
| 42 | + Text(contents) |
| 43 | + ] |
| 44 | + ) |
| 45 | + } |
| 46 | + |
| 47 | + public init( |
| 48 | + @Builder<Element> _ block: () -> [Element] |
| 49 | + ) { |
| 50 | + self.init(children: block()) |
| 51 | + } |
| 52 | +} |
0 commit comments