├── .gitignore ├── LICENSE ├── Makefile ├── Package.swift ├── README.md ├── Sources └── SwiftCss │ ├── Builders │ ├── PropertyBuilder.swift │ ├── RuleBuilder.swift │ └── SelectorBuilder.swift │ ├── Components │ ├── CSSColor+BuiltIn.swift │ ├── CSSColor.swift │ ├── CSSColorValue.swift │ ├── HTMLElement.swift │ ├── Property.swift │ ├── Pseudo.swift │ ├── Rule.swift │ ├── Selector+Modifiers.swift │ ├── Selector+Types.swift │ ├── Selector.swift │ ├── Unit.swift │ └── Variable.swift │ ├── Properties │ ├── AlignContent.swift │ ├── AlignItems.swift │ ├── AlignSelf.swift │ ├── All.swift │ ├── Animation.swift │ ├── AnimationDelay.swift │ ├── AnimationDirection.swift │ ├── AnimationDuration.swift │ ├── AnimationFillMode.swift │ ├── AnimationIterationCount.swift │ ├── AnimationName.swift │ ├── AnimationPlayState.swift │ ├── AnimationTimingFunction.swift │ ├── BackfaceVisibility.swift │ ├── Background.swift │ ├── BackgroundAttachment.swift │ ├── BackgroundBlendMode.swift │ ├── BackgroundClip.swift │ ├── BackgroundColor.swift │ ├── BackgroundImage.swift │ ├── BackgroundOrigin.swift │ ├── BackgroundPosition.swift │ ├── BackgroundRepeat.swift │ ├── BackgroundSize.swift │ ├── Border.swift │ ├── BorderBottom.swift │ ├── BorderBottomColor.swift │ ├── BorderBottomLeftRadius.swift │ ├── BorderBottomRightRadius.swift │ ├── BorderBottomStyle.swift │ ├── BorderBottomWidth.swift │ ├── BorderCollapse.swift │ ├── BorderColor.swift │ ├── BorderImage.swift │ ├── BorderImageOutset.swift │ ├── BorderImageRepeat.swift │ ├── BorderImageSlice.swift │ ├── BorderImageSource.swift │ ├── BorderImageWidth.swift │ ├── BorderLeft.swift │ ├── BorderLeftColor.swift │ ├── BorderLeftStyle.swift │ ├── BorderLeftWidth.swift │ ├── BorderRadius.swift │ ├── BorderRight.swift │ ├── BorderRightColor.swift │ ├── BorderRightStyle.swift │ ├── BorderRightWidth.swift │ ├── BorderSpacing.swift │ ├── BorderStyle.swift │ ├── BorderTop.swift │ ├── BorderTopColor.swift │ ├── BorderTopLeftRadius.swift │ ├── BorderTopRightRadius.swift │ ├── BorderTopStyle.swift │ ├── BorderTopWidth.swift │ ├── BorderWidth.swift │ ├── Bottom.swift │ ├── BoxDecorationBreak.swift │ ├── BoxShadow.swift │ ├── BoxSizing.swift │ ├── BreakAfter.swift │ ├── BreakBefore.swift │ ├── BreakInside.swift │ ├── CaptionSide.swift │ ├── CaretColor.swift │ ├── Clear.swift │ ├── Clip.swift │ ├── Color.swift │ ├── ColumnCount.swift │ ├── ColumnFill.swift │ ├── ColumnGap.swift │ ├── ColumnRule.swift │ ├── ColumnRuleColor.swift │ ├── ColumnRuleStyle.swift │ ├── ColumnRuleWidth.swift │ ├── ColumnSpan.swift │ ├── ColumnWidth.swift │ ├── Columns.swift │ ├── Content.swift │ ├── CounterIncrement.swift │ ├── CounterReset.swift │ ├── Cursor.swift │ ├── Direction.swift │ ├── Display.swift │ ├── EmptyCells.swift │ ├── Filter.swift │ ├── Flex.swift │ ├── FlexBasis.swift │ ├── FlexDirection.swift │ ├── FlexFlow.swift │ ├── FlexGrow.swift │ ├── FlexShrink.swift │ ├── FlexWrap.swift │ ├── Float.swift │ ├── Font.swift │ ├── FontFamily.swift │ ├── FontFeatureSettings.swift │ ├── FontKerning.swift │ ├── FontLanguageOverride.swift │ ├── FontSize.swift │ ├── FontSizeAdjust.swift │ ├── FontStretch.swift │ ├── FontStyle.swift │ ├── FontSynthesis.swift │ ├── FontVariant.swift │ ├── FontVariantAlternates.swift │ ├── FontVariantCaps.swift │ ├── FontVariantEastAsian.swift │ ├── FontVariantLigatures.swift │ ├── FontVariantNumeric.swift │ ├── FontVariantPosition.swift │ ├── FontWeight.swift │ ├── Gap.swift │ ├── Grid.swift │ ├── GridArea.swift │ ├── GridAutoColumns.swift │ ├── GridAutoFlow.swift │ ├── GridAutoRows.swift │ ├── GridColumn.swift │ ├── GridColumnEnd.swift │ ├── GridColumnGap.swift │ ├── GridColumnStart.swift │ ├── GridGap.swift │ ├── GridRow.swift │ ├── GridRowEnd.swift │ ├── GridRowGap.swift │ ├── GridRowStart.swift │ ├── GridTemplate.swift │ ├── GridTemplateAreas.swift │ ├── GridTemplateColumns.swift │ ├── GridTemplateRows.swift │ ├── HangingPunctuation.swift │ ├── Height.swift │ ├── Hyphens.swift │ ├── ImageRendering.swift │ ├── Isolation.swift │ ├── JustifyContent.swift │ ├── Left.swift │ ├── LetterSpacing.swift │ ├── LineBreak.swift │ ├── LineHeight.swift │ ├── ListStyle.swift │ ├── ListStyleImage.swift │ ├── ListStylePosition.swift │ ├── ListStyleType.swift │ ├── Margin.swift │ ├── MarginBottom.swift │ ├── MarginLeft.swift │ ├── MarginRight.swift │ ├── MarginTop.swift │ ├── Mask.swift │ ├── MaskType.swift │ ├── MaxHeight.swift │ ├── MaxWidth.swift │ ├── MinHeight.swift │ ├── MinWidth.swift │ ├── MixBlendMode.swift │ ├── ObjectFit.swift │ ├── ObjectPosition.swift │ ├── Opacity.swift │ ├── Order.swift │ ├── Orphans.swift │ ├── Outline.swift │ ├── OutlineColor.swift │ ├── OutlineOffset.swift │ ├── OutlineStyle.swift │ ├── OutlineWidth.swift │ ├── Overflow.swift │ ├── OverflowWrap.swift │ ├── OverflowX.swift │ ├── OverflowY.swift │ ├── Padding.swift │ ├── PaddingBottom.swift │ ├── PaddingLeft.swift │ ├── PaddingRight.swift │ ├── PaddingTop.swift │ ├── PageBreakAfter.swift │ ├── PageBreakBefore.swift │ ├── PageBreakInside.swift │ ├── Perspective.swift │ ├── PerspectiveOrigin.swift │ ├── PointerEvents.swift │ ├── Position.swift │ ├── Quotes.swift │ ├── Resize.swift │ ├── Right.swift │ ├── RowGap.swift │ ├── ScrollBehavior.swift │ ├── TabSize.swift │ ├── TableLayout.swift │ ├── TextAlign.swift │ ├── TextAlignLast.swift │ ├── TextCombineUpright.swift │ ├── TextDecoration.swift │ ├── TextDecorationColor.swift │ ├── TextDecorationLine.swift │ ├── TextDecorationStyle.swift │ ├── TextIndent.swift │ ├── TextJustify.swift │ ├── TextOrientation.swift │ ├── TextOverflow.swift │ ├── TextShadow.swift │ ├── TextTransform.swift │ ├── TextUnderlinePosition.swift │ ├── Top.swift │ ├── Transform.swift │ ├── TransformOrigin.swift │ ├── TransformStyle.swift │ ├── Transition.swift │ ├── TransitionDelay.swift │ ├── TransitionDuration.swift │ ├── TransitionProperty.swift │ ├── TransitionTimingFunction.swift │ ├── UnicodeBidi.swift │ ├── UserSelect.swift │ ├── VerticalAlign.swift │ ├── Visibility.swift │ ├── WhiteSpace.swift │ ├── Widows.swift │ ├── Width.swift │ ├── WordBreak.swift │ ├── WordSpacing.swift │ ├── WordWrap.swift │ ├── WritingMode.swift │ └── ZIndex.swift │ ├── Rules │ ├── Charset.swift │ ├── FontFace.swift │ ├── Import.swift │ ├── Keyframes.swift │ └── Media.swift │ └── Stylesheet │ ├── Stylesheet.swift │ └── StylesheetRenderer.swift └── Tests └── SwiftCssTests ├── SelectorTests.swift └── SwiftCssTests.swift /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .build 3 | .swiftpm 4 | .env 5 | .env.development 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018-2022 Tibor Bödecs 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the "Software"), to deal in the Software without 8 | restriction, including without limitation the rights to use, 9 | copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the 11 | Software is furnished to do so, subject to the following 12 | conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 19 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 21 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 22 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 24 | OTHER DEALINGS IN THE SOFTWARE. 25 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | test: 2 | swift test --enable-test-discovery --parallel 3 | -------------------------------------------------------------------------------- /Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:5.3 2 | import PackageDescription 3 | 4 | let package = Package( 5 | name: "swift-css", 6 | platforms: [ 7 | .macOS(.v10_15) 8 | ], 9 | products: [ 10 | .library(name: "SwiftCss", targets: ["SwiftCss"]), 11 | ], 12 | dependencies: [ 13 | 14 | ], 15 | targets: [ 16 | .target(name: "SwiftCss", dependencies: [ 17 | 18 | ]), 19 | .testTarget(name: "SwiftCssTests", dependencies: [ 20 | .target(name: "SwiftCss"), 21 | ]), 22 | ] 23 | ) 24 | 25 | 26 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Builders/PropertyBuilder.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PropertyBuilder.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 09.. 6 | // 7 | 8 | @resultBuilder 9 | public enum PropertyBuilder { 10 | public static func buildBlock(_ components: Property...) -> [Property] { 11 | components 12 | } 13 | 14 | public static func buildBlock(_ components: [Property]) -> [Property] { 15 | components 16 | } 17 | 18 | public static func buildBlock(_ components: [Property]...) -> [Property] { 19 | components.flatMap { $0 } 20 | } 21 | 22 | public static func buildEither(first component: [Property]) -> [Property] { 23 | component 24 | } 25 | 26 | public static func buildEither(second component: [Property]) -> [Property] { 27 | component 28 | } 29 | 30 | public static func buildOptional(_ component: [Property]?) -> [Property] { 31 | component ?? [] 32 | } 33 | 34 | public static func buildExpression(_ expression: Property) -> [Property] { 35 | [expression] 36 | } 37 | 38 | public static func buildExpression(_ expression: [Property]) -> [Property] { 39 | expression 40 | } 41 | 42 | public static func buildArray(_ components: [[Property]]) -> [Property] { 43 | components.flatMap { $0 } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Builders/RuleBuilder.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RuleBuilder.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 09.. 6 | // 7 | 8 | @resultBuilder 9 | public enum RuleBuilder { 10 | public static func buildBlock(_ components: Rule...) -> [Rule] { 11 | components 12 | } 13 | 14 | public static func buildBlock(_ components: [Rule]) -> [Rule] { 15 | components 16 | } 17 | 18 | public static func buildBlock(_ components: [Rule]...) -> [Rule] { 19 | components.flatMap { $0 } 20 | } 21 | 22 | public static func buildEither(first component: [Rule]) -> [Rule] { 23 | component 24 | } 25 | 26 | public static func buildEither(second component: [Rule]) -> [Rule] { 27 | component 28 | } 29 | 30 | public static func buildOptional(_ component: [Rule]?) -> [Rule] { 31 | component ?? [] 32 | } 33 | 34 | public static func buildExpression(_ expression: Rule) -> [Rule] { 35 | [expression] 36 | } 37 | 38 | public static func buildExpression(_ expression: [Rule]) -> [Rule] { 39 | expression 40 | } 41 | 42 | public static func buildArray(_ components: [[Rule]]) -> [Rule] { 43 | components.flatMap { $0 } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Builders/SelectorBuilder.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SelectorBuilder.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 09.. 6 | // 7 | 8 | @resultBuilder 9 | public enum SelectorBuilder { 10 | public static func buildBlock(_ components: Selector...) -> [Selector] { 11 | components 12 | } 13 | 14 | public static func buildBlock(_ components: [Selector]) -> [Selector] { 15 | components 16 | } 17 | 18 | public static func buildBlock(_ components: [Selector]...) -> [Selector] { 19 | components.flatMap { $0 } 20 | } 21 | 22 | public static func buildEither(first component: [Selector]) -> [Selector] { 23 | component 24 | } 25 | 26 | public static func buildEither(second component: [Selector]) -> [Selector] { 27 | component 28 | } 29 | 30 | public static func buildOptional(_ component: [Selector]?) -> [Selector] { 31 | component ?? [] 32 | } 33 | 34 | public static func buildExpression(_ expression: Selector) -> [Selector] { 35 | [expression] 36 | } 37 | 38 | public static func buildExpression(_ expression: [Selector]) -> [Selector] { 39 | expression 40 | } 41 | 42 | public static func buildArray(_ components: [[Selector]]) -> [Selector] { 43 | components.flatMap { $0 } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Components/CSSColorValue.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CSSColorValue.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 11.. 6 | // 7 | 8 | public enum CSSColorValue { 9 | 10 | /// Specifies the background color. 11 | case color(CSSColor) 12 | /// Specifies that the background color should be transparent. This is default 13 | case transparent 14 | /// Sets this property to its default value. 15 | case initial 16 | /// Inherits this property from its parent element. 17 | case inherit 18 | 19 | var rawValue: String { 20 | switch self { 21 | case .color(let value): 22 | return value.rawValue 23 | case .transparent: 24 | return "transparent" 25 | case .initial: 26 | return "initial" 27 | case .inherit: 28 | return "inherit" 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Components/HTMLElement.swift: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLElement.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | /// 9 | /// https://developer.mozilla.org/en-US/docs/Web/HTML/Element 10 | /// https://www.w3schools.com/TAGS/default.ASP 11 | /// 12 | public enum HTMLElement: String { 13 | /// main root, sectioning root 14 | case html, body 15 | /// content sectioning 16 | case address, article, aside, footer, header, h1, h2, h3, h4, h5, h6, main, nav, section 17 | /// text content 18 | case blockquote, dd, div, dl, dt, figcaption, figure, hr, li, ol, p, pre, ul 19 | /// inline text semantics 20 | case a, abbr, b, bdi, bdo, br, cite, code, data, dfn, em, i, kbd, mark, q, ruby, s, samp, small, span, strong, sub, sup, time, u, `var`, wbr 21 | /// image and multimedia 22 | case area, audio, img, map, track, video 23 | /// embedded content 24 | case embed, iframe, object, param, picture, portal, source 25 | /// svg and mathml 26 | case svg, math 27 | /// scripting 28 | case canvas, noscript, script 29 | /// demarcating edits 30 | case del, ins 31 | /// table content 32 | case caption, col, colgroup, table, tbody, td, tfoot, th, thead, tr 33 | /// forms 34 | case button, datalist, fieldset, form, input, label, legend, meter, optgroup, option, output, progress, select, textarea 35 | /// interactive elements 36 | case details, dialog, menu, summary 37 | /// web components 38 | case slot, template 39 | } 40 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Components/Property.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Property.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 09.. 6 | // 7 | 8 | /// https://www.w3schools.com/cssref/ 9 | public struct Property { 10 | public var name: String 11 | public var value: String 12 | var isImportant: Bool = false 13 | 14 | public init(name: String, value: String, isImportant: Bool = false) { 15 | self.name = name 16 | self.value = value 17 | self.isImportant = isImportant 18 | } 19 | 20 | public func important() -> Property { 21 | guard !isImportant else { 22 | return self 23 | } 24 | return Property(name: name, value: value, isImportant: true) 25 | } 26 | } 27 | 28 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Components/Rule.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Rule.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public protocol Rule { 9 | 10 | } 11 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Components/Selector+Modifiers.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Selector+Modifiers.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public extension Selector { 9 | 10 | func pseudo(_ pseudo: Pseudo) -> Selector { 11 | Selector(name: name, properties: properties, pseudo: pseudo.value) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Components/Selector.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Selector.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 09.. 6 | // 7 | 8 | /// https://www.w3schools.com/cssref/css_selectors.asp 9 | public struct Selector { 10 | var name: String 11 | var properties: [Property] 12 | var pseudo: String? = nil 13 | 14 | public init(name: String, properties: [Property], pseudo: String? = nil) { 15 | self.name = name 16 | self.properties = properties 17 | self.pseudo = pseudo 18 | } 19 | 20 | public init(_ name: String, @PropertyBuilder _ builder: () -> [Property]) { 21 | self.name = name 22 | self.properties = builder() 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Components/Variable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Var.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 24.. 6 | // 7 | 8 | /// Creates a new CSS variable with the given name and value 9 | public func Variable(_ name: String, _ value: String) -> Property { 10 | Property(name: "--" + name, value: value) 11 | } 12 | 13 | public extension String { 14 | var `variable`: String { 15 | "var(--" + self + ")" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/AlignContent.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AlignContent.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum AlignContentValue: String { 9 | /// Default value. Lines stretch to take up the remaining space 10 | case stretch 11 | /// Lines are packed toward the center of the flex container 12 | case center 13 | /// Lines are packed toward the start of the flex container 14 | case flexStart = "flex-start" 15 | /// Lines are packed toward the end of the flex container 16 | case flexEnd = "flex-end" 17 | /// Lines are evenly distributed in the flex container 18 | case spaceBetween = "space-between" 19 | /// Lines are evenly distributed in the flex container, with half-size spaces on either end 20 | case spaceAround = "space-around" 21 | /// Lines are evenly distributed in the flex container, with equal space around them 22 | case spaceEvenly = "space-evenly" 23 | /// Sets this property to its default value. 24 | case initial 25 | /// Inherits this property from its parent element. 26 | case inherit 27 | } 28 | 29 | public func AlignContent(_ value: String) -> Property { 30 | Property(name: "align-content", value: value) 31 | } 32 | 33 | /// Specifies the alignment between the lines inside a flexible container when the items do not use all available space 34 | public func AlignContent(_ value: AlignContentValue = .stretch) -> Property { 35 | AlignContent(value.rawValue) 36 | } 37 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/AlignItems.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AlignItems.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum AlignItemsValue: String { 9 | /// Default. Items are stretched to fit the container 10 | case stretch 11 | /// Items are positioned at the center of the container 12 | case center 13 | /// Items are positioned at the beginning of the container 14 | case flexStart = "flex-start" 15 | /// Items are positioned at the end of the container 16 | case flexEnd = "flex-end" 17 | /// Items are positioned at the baseline of the container 18 | case baseline 19 | /// Sets this property to its default value. 20 | case initial 21 | /// Inherits this property from its parent element. 22 | case inherit 23 | } 24 | 25 | public func AlignItems(_ value: String) -> Property { 26 | Property(name: "align-items", value: value) 27 | } 28 | 29 | /// Specifies the alignment for items inside a flexible container 30 | public func AlignItems(_ value: AlignItemsValue = .stretch) -> Property { 31 | AlignItems(value.rawValue) 32 | } 33 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/AlignSelf.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AlignSelf.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum AlignSelfValue: String { 9 | /// Default. The element inherits its parent container's align-items property, or "stretch" if it has no parent container 10 | case auto 11 | /// The element is positioned to fit the container 12 | case stretch 13 | /// The element is positioned at the center of the container 14 | case center 15 | /// The element is positioned at the beginning of the container 16 | case flexStart = "flex-start" 17 | /// The element is positioned at the end of the container 18 | case flexEnd = "flex-end" 19 | /// The element is positioned at the baseline of the container 20 | case baseline 21 | /// Sets this property to its default value. 22 | case initial 23 | /// Inherits this property from its parent element. 24 | case inherit 25 | } 26 | 27 | public func AlignSelf(_ value: String) -> Property { 28 | Property(name: "align-self", value: value) 29 | } 30 | 31 | /// Specifies the alignment for selected items inside a flexible container 32 | public func AlignSelf(_ value: AlignSelfValue = .auto) -> Property { 33 | AlignSelf(value.rawValue) 34 | } 35 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/All.swift: -------------------------------------------------------------------------------- 1 | // 2 | // All.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum AllValue: String { 9 | /// Changes all the properties applied to the element or the element's parent to their initial value 10 | case initial 11 | /// Changes all the properties applied to the element or the element's parent to their parent value 12 | case inherit 13 | /// Changes all the properties applied to the element or the element's parent to their parent value if they are inheritable or to their initial value if not 14 | case unset 15 | } 16 | 17 | public func All(_ value: String) -> Property { 18 | Property(name: "all", value: value) 19 | } 20 | 21 | /// Resets all properties (except unicode-bidi and direction) 22 | public func All(_ value: AllValue) -> Property { 23 | All(value.rawValue) 24 | } 25 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/AnimationDirection.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AnimationDirection.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum AnimationDirectionValue: String { 9 | /// Default value. The animation is played as normal (forwards) 10 | case normal 11 | /// The animation is played in reverse direction (backwards) 12 | case reverse 13 | /// The animation is played forwards first, then backwards 14 | case alternate 15 | /// The animation is played backwards first, then forwards 16 | case alternateReverse = "alternate-reverse" 17 | /// Sets this property to its default value. 18 | case initial 19 | /// Inherits this property from its parent element. 20 | case inherit 21 | } 22 | 23 | public func AnimationDirection(_ value: String) -> Property { 24 | Property(name: "animation-direction", value: value) 25 | } 26 | 27 | /// Specifies whether an animation should be played forwards, backwards or in alternate cycles 28 | public func AnimationDirection(_ value: AnimationDirectionValue = .normal) -> Property { 29 | AnimationDirection(value.rawValue) 30 | } 31 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/AnimationFillMode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AnimationFillMode.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum AnimationFillModeValue: String { 9 | /// Default value. Animation will not apply any styles to the element before or after it is executing 10 | case none 11 | /// The element will retain the style values that is set by the last keyframe (depends on animation-direction and animation-iteration-count) 12 | case forwards 13 | /// The element will get the style values that is set by the first keyframe (depends on animation-direction), and retain this during the animation-delay period 14 | case backwards 15 | /// The animation will follow the rules for both forwards and backwards, extending the animation properties in both directions 16 | case both 17 | /// Sets this property to its default value. 18 | case initial 19 | /// Inherits this property from its parent element. 20 | case inherit 21 | } 22 | 23 | public func AnimationFillMode(_ value: String) -> Property { 24 | Property(name: "animation-fill-mode", value: value) 25 | } 26 | 27 | /// Specifies a style for the element when the animation is not playing (before it starts, after it ends, or both) 28 | public func AnimationFillMode(_ value: AnimationFillModeValue = .none) -> Property { 29 | AnimationFillMode(value.rawValue) 30 | } 31 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/AnimationIterationCount.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AnimationIterationCount.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum AnimationIterationCountValue: ExpressibleByIntegerLiteral { 9 | 10 | /// A number that defines how many times an animation should be played. Default value is 1 11 | case number(Int) 12 | /// Specifies that the animation should be played infinite times (for ever) 13 | case infinite 14 | /// Sets this property to its default value. 15 | case initial 16 | /// Inherits this property from its parent element. 17 | case inherit 18 | 19 | public init(integerLiteral value: IntegerLiteralType) { 20 | self = .number(value) 21 | } 22 | 23 | var rawValue: String { 24 | switch self { 25 | case .number(let value): 26 | return String(value) 27 | case .infinite: 28 | return "infinite" 29 | case .initial: 30 | return "initial" 31 | case .inherit: 32 | return "inherit" 33 | } 34 | } 35 | } 36 | 37 | public func AnimationIterationCount(_ value: String) -> Property { 38 | Property(name: "animation-iteration-count", value: value) 39 | } 40 | 41 | /// Specifies the number of times an animation should be played 42 | public func AnimationIterationCount(_ value: AnimationIterationCountValue = 1) -> Property { 43 | AnimationIterationCount(value.rawValue) 44 | } 45 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/AnimationName.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AnimationName.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum AnimationNameValue: ExpressibleByStringLiteral { 9 | 10 | /// Specifies the name of the keyframe you want to bind to the selector 11 | case keyframename(String) 12 | /// Default value. Specifies that there will be no animation (can be used to override animations coming from the cascade) 13 | case none 14 | /// Sets this property to its default value. 15 | case initial 16 | /// Inherits this property from its parent element. 17 | case inherit 18 | 19 | public init(stringLiteral value: StringLiteralType) { 20 | self = .keyframename(value) 21 | } 22 | 23 | var rawValue: String { 24 | switch self { 25 | case .keyframename(let value): 26 | return value 27 | case .none: 28 | return "none" 29 | case .initial: 30 | return "initial" 31 | case .inherit: 32 | return "inherit" 33 | } 34 | } 35 | } 36 | 37 | public func AnimationName(_ value: String) -> Property { 38 | Property(name: "animation-name", value: value) 39 | } 40 | 41 | /// Specifies a name for the @keyframes animation 42 | public func AnimationName(_ value: AnimationNameValue = .none) -> Property { 43 | AnimationName(value.rawValue) 44 | } 45 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/AnimationPlayState.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AnimationPlayState.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum AnimationPlayStateValue: String { 9 | /// Specifies that the animation is paused 10 | case paused 11 | /// Default value. Specifies that the animation is running 12 | case running 13 | /// Sets this property to its default value. 14 | case initial 15 | /// Inherits this property from its parent element. 16 | case inherit 17 | } 18 | 19 | public func AnimationPlayState(_ value: String) -> Property { 20 | Property(name: "animation-play-state", value: value) 21 | } 22 | 23 | /// Specifies whether the animation is running or paused 24 | public func AnimationPlayState(_ value: AnimationPlayStateValue = .running) -> Property { 25 | AnimationPlayState(value.rawValue) 26 | } 27 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/BackfaceVisibility.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BackfaceVisibility.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum BackfaceVisibilityValue: String { 9 | /// Default value. The backside is visible 10 | case visible 11 | /// The backside is not visible 12 | case hidden 13 | /// Sets this property to its default value. 14 | case initial 15 | /// Inherits this property from its parent element. 16 | case inherit 17 | } 18 | 19 | public func BackfaceVisibility(_ value: String) -> Property { 20 | Property(name: "backface-visibility", value: value) 21 | } 22 | 23 | /// Defines whether or not the back face of an element should be visible when facing the user 24 | public func BackfaceVisibility(_ value: BackfaceVisibilityValue = .visible) -> Property { 25 | BackfaceVisibility(value.rawValue) 26 | } 27 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/BackgroundAttachment.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BackgroundAttachment.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum BackgroundAttachmentValue: String { 9 | /// The background image will scroll with the page. This is default 10 | case scroll 11 | /// The background image will not scroll with the page 12 | case fixed 13 | /// The background image will scroll with the element's contents 14 | case local 15 | /// Sets this property to its default value. 16 | case initial 17 | /// Inherits this property from its parent element. 18 | case inherit 19 | } 20 | 21 | public func BackgroundAttachment(_ value: String) -> Property { 22 | Property(name: "background-attachment", value: value) 23 | } 24 | 25 | /// Sets whether a background image scrolls with the rest of the page, or is fixed 26 | public func BackgroundAttachment(_ value: BackgroundAttachmentValue = .scroll) -> Property { 27 | BackgroundAttachment(value.rawValue) 28 | } 29 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/BackgroundBlendMode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BackgroundBlendMode.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum BackgroundBlendModeValue: String { 9 | /// This is default. Sets the blending mode to normal 10 | case normal 11 | /// Sets the blending mode to multiply 12 | case multiply 13 | /// Sets the blending mode to screen 14 | case screen 15 | /// Sets the blending mode to overlay 16 | case overlay 17 | /// Sets the blending mode to darken 18 | case darken 19 | /// Sets the blending mode to lighten 20 | case lighten 21 | /// Sets the blending mode to color-dodge 22 | case colorDodge = "color-dodge" 23 | /// Sets the blending mode to saturation 24 | case saturation 25 | /// Sets the blending mode to color 26 | case color 27 | /// Sets the blending mode to luminosity 28 | case luminosity 29 | } 30 | 31 | public func BackgroundBlendMode(_ value: String) -> Property { 32 | Property(name: "background-blend-mode", value: value) 33 | } 34 | 35 | /// Specifies the blending mode of each background layer (color/image) 36 | public func BackgroundBlendMode(_ value: BackgroundBlendModeValue = .normal) -> Property { 37 | BackgroundBlendMode(value.rawValue) 38 | } 39 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/BackgroundClip.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BackgroundClip.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum BackgroundClipValue: String { 9 | /// Default value. The background extends behind the border 10 | case borderBox = "border-box" 11 | /// The background extends to the inside edge of the border 12 | case paddingBox = "padding-box" 13 | /// The background extends to the edge of the content box 14 | case contentBox = "content-box" 15 | /// Sets this property to its default value. 16 | case initial 17 | /// Inherits this property from its parent element. 18 | case inherit 19 | } 20 | 21 | public func BackgroundClip(_ value: String) -> Property { 22 | Property(name: "background-clip", value: value) 23 | } 24 | 25 | /// Defines how far the background (color or image) should extend within an element 26 | public func BackgroundClip(_ value: BackgroundClipValue = .borderBox) -> Property { 27 | BackgroundClip(value.rawValue) 28 | } 29 | 30 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/BackgroundColor.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BackgroundColor.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public func BackgroundColor(_ value: String) -> Property { 9 | Property(name: "background-color", value: value) 10 | } 11 | 12 | /// Specifies the background color of an element 13 | public func BackgroundColor(_ value: CSSColorValue = .transparent) -> Property { 14 | BackgroundColor(value.rawValue) 15 | } 16 | 17 | /// Specifies the background color of an element 18 | public func BackgroundColor(_ value: CSSColor) -> Property { 19 | BackgroundColor(.color(value)) 20 | } 21 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/BackgroundOrigin.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BackgroundOrigin.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum BackgroundOriginValue: String { 9 | /// Default value. The background image starts from the upper left corner of the padding edge 10 | case paddingBox = "padding-box" 11 | /// The background image starts from the upper left corner of the border 12 | case borderBox = "border-box" 13 | /// The background image starts from the upper left corner of the content 14 | case contentBox = "content-box" 15 | /// Sets this property to its default value. 16 | case initial 17 | /// Inherits this property from its parent element. 18 | case inherit 19 | } 20 | 21 | public func BackgroundOrigin(_ value: String) -> Property { 22 | Property(name: "background-origin", value: value) 23 | } 24 | 25 | /// Specifies the origin position of a background image 26 | public func BackgroundOrigin(_ value: BackgroundOriginValue = .paddingBox) -> Property { 27 | BackgroundOrigin(value.rawValue) 28 | } 29 | 30 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/BackgroundRepeat.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BackgroundRepeat.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum BackgroundRepeatValue: String { 9 | /// The background image is repeated both vertically and horizontally. The last image will be clipped if it does not fit. This is default 10 | case `repeat` 11 | /// The background image is repeated only horizontally 12 | case repeatX = "repeat-x" 13 | /// The background image is repeated only vertically 14 | case repeatY = "repeat-y" 15 | /// The background-image is not repeated. The image will only be shown once 16 | case noRepeat = "no-repeat" 17 | /// The background-image is repeated as much as possible without clipping. The first and last images are pinned to either side of the element, and whitespace is distributed evenly between the images 18 | case space 19 | /// The background-image is repeated and squished or stretched to fill the space (no gaps) 20 | case round 21 | /// Sets this property to its default value. 22 | case initial 23 | /// Inherits this property from its parent element. 24 | case inherit 25 | } 26 | 27 | public func BackgroundRepeat(_ value: String) -> Property { 28 | Property(name: "background-repeat", value: value) 29 | } 30 | 31 | /// Sets if/how a background image will be repeated 32 | public func BackgroundRepeat(_ value: BackgroundRepeatValue = .repeat) -> Property { 33 | BackgroundRepeat(value.rawValue) 34 | } 35 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/BackgroundSize.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BackgroundSize.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum BackgroundSizeValue: String { 9 | /// Default value. The background image is displayed in its original size 10 | case auto 11 | /// Sets the width and height of the background image. The first value sets the width, the second value sets the height. If only one value is given, the second is set to "auto". 12 | case length 13 | /// Sets the width and height of the background image in percent of the parent element. The first value sets the width, the second value sets the height. If only one value is given, the second is set to "auto" 14 | case percentage 15 | /// Resize the background image to cover the entire container, even if it has to stretch the image or cut a little bit off one of the edges 16 | case cover 17 | /// Resize the background image to make sure the image is fully visible 18 | case contain 19 | /// Sets this property to its default value. 20 | case initial 21 | /// Inherits this property from its parent element. 22 | case inherit 23 | } 24 | 25 | public func BackgroundSize(_ value: String) -> Property { 26 | Property(name: "background-size", value: value) 27 | } 28 | 29 | /// Specifies the size of the background images 30 | public func BackgroundSize(_ value: BackgroundSizeValue = .auto) -> Property { 31 | BackgroundSize(value.rawValue) 32 | } 33 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/BorderBottom.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BorderBottom.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public func BorderBottom(_ value: String) -> Property { 9 | Property(name: "border-bottom", value: value) 10 | } 11 | 12 | /// A shorthand property for border-bottom-width, border-bottom-style and border-bottom-color 13 | public func BorderBottom(_ value: BorderLineValue) -> Property { 14 | BorderBottom(value.rawValue) 15 | } 16 | 17 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/BorderBottomColor.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BorderBottomColor.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public func BorderBottomColor(_ value: String) -> Property { 9 | Property(name: "border-bottom-color", value: value) 10 | } 11 | 12 | /// Sets the color of the bottom border 13 | public func BorderBottomColor(_ value: CSSColorValue) -> Property { 14 | BorderBottomColor(value.rawValue) 15 | } 16 | 17 | /// Sets the color of the bottom border 18 | public func BorderBottomColor(_ value: CSSColor) -> Property { 19 | BorderBottomColor(.color(value)) 20 | } 21 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/BorderBottomLeftRadius.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BorderBottomLeftRadius.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public func BorderBottomLeftRadius(_ value: String) -> Property { 9 | Property(name: "border-bottom-left-radius", value: value) 10 | } 11 | 12 | /// Defines the radius of the border of the bottom-left corner 13 | public func BorderBottomLeftRadius(_ value: BorderRadiusSingleValue) -> Property { 14 | BorderBottomLeftRadius(value.rawValue) 15 | } 16 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/BorderBottomRightRadius.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BorderBottomRightRadius.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public func BorderBottomRightRadius(_ value: String) -> Property { 9 | Property(name: "border-bottom-right-radius", value: value) 10 | } 11 | 12 | /// Defines the radius of the border of the bottom-right corner 13 | public func BorderBottomRightRadius(_ value: BorderRadiusSingleValue) -> Property { 14 | BorderBottomRightRadius(value.rawValue) 15 | } 16 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/BorderBottomStyle.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BorderBottomStyle.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public func BorderBottomStyle(_ value: String) -> Property { 9 | Property(name: "border-bottom-style", value: value) 10 | } 11 | 12 | /// Sets the style of the bottom border 13 | public func BorderBottomStyle(_ value: BorderStyleValue = .none) -> Property { 14 | BorderBottomStyle(value.rawValue) 15 | } 16 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/BorderBottomWidth.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BorderBottomWidth.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public func BorderBottomWidth(_ value: String) -> Property { 9 | Property(name: "border-bottom-width", value: value) 10 | } 11 | 12 | /// Sets the width of the bottom border 13 | public func BorderBottomWidth(_ value: BorderWidthValue = .medium) -> Property { 14 | BorderBottomWidth(value.rawValue) 15 | } 16 | 17 | /// Sets the width of the bottom border 18 | public func BorderBottomWidth(_ value: Unit) -> Property { 19 | BorderBottomWidth(.length(value)) 20 | } 21 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/BorderCollapse.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BorderCollapse.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum BorderCollapseValue: String { 9 | /// Borders are separated; each cell will display its own borders. This is default. Play it » 10 | case separate 11 | /// Borders are collapsed into a single border when possible (border-spacing and empty-cells properties have no effect) Play it » 12 | case collapse 13 | /// Sets this property to its default value. Read about initial Play it » 14 | case initial 15 | /// Inherits this property from its parent element. Read about inherit 16 | case inherit 17 | } 18 | 19 | public func BorderCollapse(_ value: String) -> Property { 20 | Property(name: "border-collapse", value: value) 21 | } 22 | 23 | /// Sets whether table borders should collapse into a single border or be separated 24 | public func BorderCollapse(_ value: BorderCollapseValue = .separate) -> Property { 25 | BorderCollapse(value.rawValue) 26 | } 27 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/BorderColor.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BorderColor.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public func BorderColor(_ value: String) -> Property { 9 | Property(name: "border-color", value: value) 10 | } 11 | 12 | /// Sets the color of the four borders 13 | public func BorderColor(_ value: CSSColorValue) -> Property { 14 | BorderColor(value.rawValue) 15 | } 16 | 17 | /// Sets the color of the four borders 18 | public func BorderColor(_ value: CSSColor) -> Property { 19 | BorderColor(.color(value)) 20 | } 21 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/BorderImageOutset.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BorderImageOutset.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum BorderImageOutsetValue { 9 | /// A length unit specifying how far from the edges the border-image will appear. Default value is 0 10 | case length(Unit) 11 | /// Represent multiples of the corresponding border-width 12 | case number(Double) 13 | /// Sets this property to its default value. 14 | case initial 15 | /// Inherits this property from its parent element. 16 | case inherit 17 | 18 | var rawValue: String { 19 | switch self { 20 | case .length(let value): 21 | return value.rawValue 22 | case .number(let value): 23 | return String(value) 24 | case .initial: 25 | return "initial" 26 | case .inherit: 27 | return "inherit" 28 | } 29 | } 30 | } 31 | 32 | public func BorderImageOutset(_ value: String) -> Property { 33 | Property(name: "border-image-outset", value: value) 34 | } 35 | 36 | /// Specifies the amount by which the border image area extends beyond the border box 37 | public func BorderImageOutset(_ value: BorderImageOutsetValue) -> Property { 38 | BorderImageOutset(value.rawValue) 39 | } 40 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/BorderImageRepeat.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BorderImageRepeat.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum BorderImageRepeatValue: String { 9 | /// Default value. The image is stretched to fill the area Play it » 10 | case stretch 11 | /// The image is tiled (repeated) to fill the area Play it » 12 | case `repeat` 13 | /// The image is tiled (repeated) to fill the area. If it does not fill the area with a whole number of tiles, the image is rescaled so it fits Play it » 14 | case round 15 | /// The image is tiled (repeated) to fill the area. If it does not fill the area with a whole number of tiles, the extra space is distributed around the tiles 16 | case space 17 | /// Sets this property to its default value. Read about initial Play it » 18 | case initial 19 | /// Inherits this property from its parent element. Read about inherit 20 | case inherit 21 | } 22 | 23 | public func BorderImageRepeat(_ value: String) -> Property { 24 | Property(name: "border-image-repeat", value: value) 25 | } 26 | 27 | /// Specifies whether the border image should be repeated, rounded or stretched 28 | public func BorderImageRepeat(_ value: BorderImageRepeatValue = .stretch) -> Property { 29 | BorderImageRepeat(value.rawValue) 30 | } 31 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/BorderImageSlice.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BorderImageSlice.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum BorderImageSliceValue { 9 | /// The number(s) represent pixels for raster images or coordinates for vector images 10 | case number(Unit) 11 | /// Causes the middle part of the image to be displayed 12 | case fill 13 | /// Sets this property to its default value. 14 | case initial 15 | /// Inherits this property from its parent element. 16 | case inherit 17 | 18 | 19 | var rawValue: String { 20 | switch self { 21 | case .number(let value): 22 | return value.rawValue 23 | case .fill: 24 | return "fill" 25 | case .initial: 26 | return "initial" 27 | case .inherit: 28 | return "inherit" 29 | } 30 | } 31 | } 32 | 33 | public func BorderImageSlice(_ value: String) -> Property { 34 | Property(name: "border-image-slice", value: value) 35 | } 36 | 37 | /// Specifies how to slice the border image 38 | public func BorderImageSlice(_ value: BorderImageSliceValue) -> Property { 39 | BorderImageSlice(value.rawValue) 40 | } 41 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/BorderImageSource.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BorderImageSource.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum BorderImageSourceValue { 9 | /// No image will be used 10 | case none 11 | /// The path to the image to be used as a border 12 | case image(String) 13 | /// Sets this property to its default value. 14 | case initial 15 | /// Inherits this property from its parent element. 16 | case inherit 17 | 18 | var rawValue: String { 19 | switch self { 20 | case .none: 21 | return "none" 22 | case .image(let value): 23 | return "url('\(value)')" 24 | case .initial: 25 | return "initial" 26 | case .inherit: 27 | return "inherit" 28 | } 29 | } 30 | } 31 | 32 | public func BorderImageSource(_ value: String) -> Property { 33 | Property(name: "border-image-source", value: value) 34 | } 35 | 36 | /// Specifies the path to the image to be used as a border 37 | public func BorderImageSource(_ value: BorderImageSourceValue) -> Property { 38 | BorderImageSource(value.rawValue) 39 | } 40 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/BorderImageWidth.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BorderImageWidth.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum BorderImageWidthValue { 9 | /// A length unit (px) specifying the size of the border-width Play it » 10 | case length(Unit) 11 | /// Default value 1. Represents multiples of the corresponding border-width Play it » 12 | case number(Double) 13 | /// If specified, the width is the intrinsic width or height of the corresponding image slice 14 | case auto 15 | /// Sets this property to its default value. 16 | case initial 17 | /// Inherits this property from its parent element. 18 | case inherit 19 | 20 | 21 | var rawValue: String { 22 | switch self { 23 | case .length(let value): 24 | return value.rawValue 25 | case .number(let value): 26 | return String(value) 27 | case .auto: 28 | return "auto" 29 | case .initial: 30 | return "initial" 31 | case .inherit: 32 | return "inherit" 33 | } 34 | } 35 | } 36 | 37 | public func BorderImageWidth(_ value: String) -> Property { 38 | Property(name: "border-image-width", value: value) 39 | } 40 | 41 | /// Specifies the width of the border image 42 | public func BorderImageWidth(_ value: BorderImageWidthValue) -> Property { 43 | BorderImageWidth(value.rawValue) 44 | } 45 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/BorderLeft.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BorderLeft.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public func BorderLeft(_ value: String) -> Property { 9 | Property(name: "border-left", value: value) 10 | } 11 | 12 | /// A shorthand property for all the border-left-* properties 13 | public func BorderLeft(_ value: BorderLineValue) -> Property { 14 | BorderLeft(value.rawValue) 15 | } 16 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/BorderLeftColor.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BorderLeftColor.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public func BorderLeftColor(_ value: String) -> Property { 9 | Property(name: "border-left-color", value: value) 10 | } 11 | 12 | /// Sets the color of the left border 13 | public func BorderLeftColor(_ value: CSSColorValue) -> Property { 14 | BorderLeftColor(value.rawValue) 15 | } 16 | 17 | /// Sets the color of the left border 18 | public func BorderLeftColor(_ value: CSSColor) -> Property { 19 | BorderLeftColor(.color(value)) 20 | } 21 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/BorderLeftStyle.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BorderLeftStyle.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public func BorderLeftStyle(_ value: String) -> Property { 9 | Property(name: "border-left-style", value: value) 10 | } 11 | 12 | /// Sets the style of the left border 13 | public func BorderLeftStyle(_ value: BorderStyleValue = .none) -> Property { 14 | BorderLeftStyle(value.rawValue) 15 | } 16 | 17 | 18 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/BorderLeftWidth.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BorderLeftWidth.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public func BorderLeftWidth(_ value: String) -> Property { 9 | Property(name: "border-left-width", value: value) 10 | } 11 | 12 | /// Sets the width of the left border 13 | public func BorderLeftWidth(_ value: BorderWidthValue = .medium) -> Property { 14 | BorderLeftWidth(value.rawValue) 15 | } 16 | 17 | public func BorderLeftWidth(_ value: Unit) -> Property { 18 | BorderLeftWidth(.length(value)) 19 | } 20 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/BorderRadius.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BorderRadius.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum BorderRadiusValue { 9 | /// Defines the shape of the corners. Default value is 0. Read about length units 10 | case length(Unit, Unit?, Unit?, Unit?) 11 | /// Sets this property to its default value. 12 | case initial 13 | /// Inherits this property from its parent element. 14 | case inherit 15 | 16 | var rawValue: String { 17 | switch self { 18 | case .length(let a, let b, let c, let d): 19 | return [ 20 | a.rawValue, 21 | b?.rawValue, 22 | c?.rawValue, 23 | d?.rawValue, 24 | ].compactMap { $0 }.joined(separator: " ") 25 | case .initial: 26 | return "initial" 27 | case .inherit: 28 | return "inherit" 29 | } 30 | } 31 | } 32 | 33 | public func BorderRadius(_ value: String) -> Property { 34 | Property(name: "border-radius", value: value) 35 | } 36 | 37 | /// A shorthand property for the four border-*-radius properties 38 | public func BorderRadius(_ value: BorderRadiusValue) -> Property { 39 | BorderRadius(value.rawValue) 40 | } 41 | 42 | // @TODO: better API for all value cases 43 | // https://www.w3schools.com/cssref/css3_pr_border-radius.asp 44 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/BorderRight.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BorderRight.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public func BorderRight(_ value: String) -> Property { 9 | Property(name: "border-right", value: value) 10 | } 11 | 12 | /// A shorthand property for all the border-right-* properties 13 | public func BorderRight(_ value: BorderLineValue) -> Property { 14 | BorderRight(value.rawValue) 15 | } 16 | 17 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/BorderRightColor.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BorderRightColor.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public func BorderRightColor(_ value: String) -> Property { 9 | Property(name: "border-right-color", value: value) 10 | } 11 | 12 | /// Sets the color of the right border 13 | public func BorderRightColor(_ value: CSSColorValue) -> Property { 14 | BorderRightColor(value.rawValue) 15 | } 16 | 17 | public func BorderRightColor(_ value: CSSColor) -> Property { 18 | BorderRightColor(.color(value)) 19 | } 20 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/BorderRightStyle.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BorderRightStyle.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public func BorderRightStyle(_ value: String) -> Property { 9 | Property(name: "border-right-style", value: value) 10 | } 11 | 12 | /// Sets the style of the right border 13 | public func BorderRightStyle(_ value: BorderStyleValue = .none) -> Property { 14 | BorderRightStyle(value.rawValue) 15 | } 16 | 17 | 18 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/BorderRightWidth.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BorderRightWidth.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public func BorderRightWidth(_ value: String) -> Property { 9 | Property(name: "border-right-width", value: value) 10 | } 11 | 12 | /// Sets the width of the right border 13 | public func BorderRightWidth(_ value: BorderWidthValue = .medium) -> Property { 14 | BorderRightWidth(value.rawValue) 15 | } 16 | 17 | public func BorderRightWidth(_ value: Unit) -> Property { 18 | BorderRightWidth(.length(value)) 19 | } 20 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/BorderSpacing.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BorderSpacing.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum BorderSpacingValue { 9 | /// Specifies the distance between the borders of adjacent cells in px, cm, etc. Negative values are not allowed. 10 | /// If one value is specified, it defines both the horizontal and vertical spacing between cells 11 | /// If two values are specified, the first sets the horizontal spacing and the second sets the vertical spacing 12 | case length(Unit, Unit?) 13 | /// Sets this property to its default value. 14 | case initial 15 | /// Inherits this property from its parent element. 16 | case inherit 17 | 18 | 19 | var rawValue: String { 20 | switch self { 21 | case .length(let horizontal, let vertical): 22 | return [ 23 | horizontal.rawValue, 24 | vertical?.rawValue, 25 | ].compactMap { $0 }.joined(separator: " ") 26 | case .initial: 27 | return "initial" 28 | case .inherit: 29 | return "inherit" 30 | } 31 | } 32 | } 33 | 34 | public func BorderSpacing(_ value: String) -> Property { 35 | Property(name: "border-spacing", value: value) 36 | } 37 | 38 | /// Sets the distance between the borders of adjacent cells 39 | public func BorderSpacing(_ value: BorderSpacingValue) -> Property { 40 | BorderSpacing(value.rawValue) 41 | } 42 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/BorderStyle.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BorderStyle.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public func BorderStyle(_ value: String) -> Property { 9 | Property(name: "border-style", value: value) 10 | } 11 | 12 | /// Sets the style of the four borders 13 | public func BorderStyle(_ value: BorderStyleValue = .none) -> Property { 14 | BorderStyle(value.rawValue) 15 | } 16 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/BorderTop.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BorderTop.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public func BorderTop(_ value: String) -> Property { 9 | Property(name: "border-top", value: value) 10 | } 11 | 12 | /// A shorthand property for border-top-width, border-top-style and border-top-color 13 | public func BorderTop(_ value: BorderLineValue) -> Property { 14 | BorderTop(value.rawValue) 15 | } 16 | 17 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/BorderTopColor.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BorderTopColor.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public func BorderTopColor(_ value: String) -> Property { 9 | Property(name: "border-top-color", value: value) 10 | } 11 | 12 | /// Sets the color of the top border 13 | public func BorderTopColor(_ value: CSSColorValue) -> Property { 14 | BorderTopColor(value.rawValue) 15 | } 16 | 17 | /// Sets the color of the top border 18 | public func BorderTopColor(_ value: CSSColor) -> Property { 19 | BorderTopColor(.color(value)) 20 | } 21 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/BorderTopLeftRadius.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BorderTopLeftRadius.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public func BorderTopLeftRadius(_ value: String) -> Property { 9 | Property(name: "border-top-left-radius", value: value) 10 | } 11 | 12 | /// Defines the radius of the border of the top-left corner 13 | public func BorderTopLeftRadius(_ value: BorderRadiusSingleValue) -> Property { 14 | BorderTopLeftRadius(value.rawValue) 15 | } 16 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/BorderTopRightRadius.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BorderTopRightRadius.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public func BorderTopRightRadius(_ value: String) -> Property { 9 | Property(name: "border-top-right-radius", value: value) 10 | } 11 | 12 | /// Defines the radius of the border of the top-right corner 13 | public func BorderTopRightRadius(_ value: BorderRadiusSingleValue) -> Property { 14 | BorderTopRightRadius(value.rawValue) 15 | } 16 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/BorderTopStyle.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BorderTopStyle.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public func BorderTopStyle(_ value: String) -> Property { 9 | Property(name: "border-top-style", value: value) 10 | } 11 | 12 | /// Sets the style of the top border 13 | public func BorderTopStyle(_ value: BorderStyleValue = .none) -> Property { 14 | BorderTopStyle(value.rawValue) 15 | } 16 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/BorderTopWidth.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BorderTopWidth.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public func BorderTopWidth(_ value: String) -> Property { 9 | Property(name: "border-top-width", value: value) 10 | } 11 | 12 | /// Sets the width of the top border 13 | public func BorderTopWidth(_ value: BorderWidthValue = .medium) -> Property { 14 | BorderTopWidth(value.rawValue) 15 | } 16 | 17 | /// Sets the width of the top border 18 | public func BorderTopWidth(_ value: Unit) -> Property { 19 | BorderTopWidth(.length(value)) 20 | } 21 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/BorderWidth.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BorderWidth.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public func BorderWidth(_ value: String) -> Property { 9 | Property(name: "border-width", value: value) 10 | } 11 | 12 | /// Sets the width of the four borders 13 | public func BorderWidth(_ value: BorderWidthValue = .medium) -> Property { 14 | BorderWidth(value.rawValue) 15 | } 16 | 17 | /// Sets the width of the four borders 18 | public func BorderWidth(_ value: Unit) -> Property { 19 | BorderWidth(.length(value)) 20 | } 21 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/Bottom.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Bottom.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum BottomValue { 9 | /// Lets the browser calculate the bottom edge position. This is default 10 | case auto 11 | /// Sets the bottom edge position in px, cm, etc. Negative values are allowed. Read about length units 12 | case length(Unit) 13 | /// Sets this property to its default value. 14 | case initial 15 | /// Inherits this property from its parent element. 16 | case inherit 17 | 18 | var rawValue: String { 19 | switch self { 20 | case .auto: 21 | return "auto" 22 | case .length(let value): 23 | return value.rawValue 24 | case .initial: 25 | return "initial" 26 | case .inherit: 27 | return "inherit" 28 | } 29 | } 30 | } 31 | 32 | public func Bottom(_ value: String) -> Property { 33 | Property(name: "bottom", value: value) 34 | } 35 | 36 | /// Sets the elements position, from the bottom of its parent element 37 | public func Bottom(_ value: BottomValue = .auto) -> Property { 38 | Bottom(value.rawValue) 39 | } 40 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/BoxDecorationBreak.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BoxDecorationBreak.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum BoxDecorationBreakValue: String { 9 | /// Default. Box decorations are applied to the element as a whole and break at the edges of the element fragments 10 | case slice 11 | /// Box decorations apply to each fragment of the element as if the fragments were individual elements. Borders wrap the four edges of each fragment of the element, and backgrounds are redrawn in full for each fragment 12 | case clone 13 | /// Sets this property to its default value. 14 | case initial 15 | /// Inherits this property from its parent element. 16 | case inherit 17 | } 18 | 19 | public func BoxDecorationBreak(_ value: String) -> Property { 20 | Property(name: "box-decoration-break", value: value) 21 | } 22 | 23 | /// Sets the behavior of the background and border of an element at page-break, or, for in-line elements, at line-break. 24 | public func BoxDecorationBreak(_ value: BoxDecorationBreakValue = .slice) -> Property { 25 | BoxDecorationBreak(value.rawValue) 26 | } 27 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/BoxSizing.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BoxSizing.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum BoxSizingValue: String { 9 | /// Default. The width and height properties (and min/max properties) includes only the content. Border and padding are not included 10 | case contentBox = "content-box" 11 | /// The width and height properties (and min/max properties) includes content, padding and border 12 | case borderBox = "border-box" 13 | /// Sets this property to its default value. 14 | case initial 15 | /// Inherits this property from its parent element. 16 | case inherit 17 | } 18 | 19 | public func BoxSizing(_ value: String) -> Property { 20 | Property(name: "box-sizing", value: value) 21 | } 22 | 23 | /// Defines how the width and height of an element are calculated: should they include padding and borders, or not 24 | public func BoxSizing(_ value: BoxSizingValue = .contentBox) -> Property { 25 | BoxSizing(value.rawValue) 26 | } 27 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/BreakInside.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BreakInside.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum BreakInsideValue: String { 9 | /// Default. Automatic page/column/region break inside the element 10 | case auto 11 | /// Avoid a page/column/region break inside the element 12 | case avoid 13 | /// Avoid a column-break inside the element 14 | case avoidColumn = "avoid-column" 15 | /// Avoid a page-break inside the element 16 | case avoidPage = "avoid-page" 17 | /// Avoid a region-break inside the element 18 | case avoidRegion = "avoid-region" 19 | /// Sets this property to its default value. 20 | case initial 21 | /// Inherits this property from its parent element. 22 | case inherit 23 | } 24 | 25 | public func BreakInside(_ value: String) -> Property { 26 | Property(name: "break-inside", value: value) 27 | } 28 | 29 | /// Specifies whether or not a page-, column-, or region-break should occur inside the specified element 30 | public func BreakInside(_ value: BreakInsideValue = .auto) -> Property { 31 | BreakInside(value.rawValue) 32 | } 33 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/CaptionSide.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CaptionSide.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum CaptionSideValue: String { 9 | /// Puts the caption above the table. This is default 10 | case top 11 | /// Puts the caption below the table 12 | case bottom 13 | /// Sets this property to its default value. 14 | case initial 15 | /// Inherits this property from its parent element. 16 | case inherit 17 | } 18 | 19 | public func CaptionSide(_ value: String) -> Property { 20 | Property(name: "caption-side", value: value) 21 | } 22 | 23 | /// Specifies the placement of a table caption 24 | public func CaptionSide(_ value: CaptionSideValue) -> Property { 25 | CaptionSide(value.rawValue) 26 | } 27 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/CaretColor.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CaretColor.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum CaretColorValue { 9 | /// Default. Browsers uses the currentColor for the caret 10 | case auto 11 | /// Specifies a color to use for the caret. All legal color values can be used (rgb, hex, named-color, etc). For more information on legal values, read our CSS Colors Tutorial 12 | case color(CSSColor) 13 | /// Sets this property to its default value. 14 | case initial 15 | /// Inherits this property from its parent element. 16 | case inherit 17 | 18 | var rawValue: String { 19 | switch self { 20 | case .auto: 21 | return "auto" 22 | case .color(let value): 23 | return value.rawValue 24 | case .initial: 25 | return "initial" 26 | case .inherit: 27 | return "inherit" 28 | } 29 | } 30 | } 31 | 32 | public func CaretColor(_ value: String) -> Property { 33 | Property(name: "caret-color", value: value) 34 | } 35 | 36 | /// Specifies the color of the cursor (caret) in inputs, textareas, or any element that is editable 37 | public func CaretColor(_ value: CaretColorValue = .auto) -> Property { 38 | CaretColor(value.rawValue) 39 | } 40 | 41 | /// Specifies the color of the cursor (caret) in inputs, textareas, or any element that is editable 42 | public func CaretColor(_ value: CSSColor) -> Property { 43 | CaretColor(.color(value)) 44 | } 45 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/Clear.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Clear.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum ClearValue: String { 9 | /// Default. The element is not pushed below left or right floated elements 10 | case none 11 | /// The element is pushed below left floated elements 12 | case left 13 | /// The element is pushed below right floated elements 14 | case right 15 | /// The element is pushed below both left and right floated elements 16 | case both 17 | /// Sets this property to its default value. 18 | case initial 19 | /// Inherits this property from its parent element. 20 | case inherit 21 | } 22 | 23 | public func Clear(_ value: String) -> Property { 24 | Property(name: "clear", value: value) 25 | } 26 | 27 | /// Specifies what should happen with the element that is next to a floating element 28 | public func Clear(_ value: ClearValue) -> Property { 29 | Clear(value.rawValue) 30 | } 31 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/Clip.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Clip.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum ClipValue { 9 | /// No clipping will be applied. This is default Play it » 10 | case auto 11 | /// Clips an element. The only valid value is: rect (top, right, bottom, left) Play it » 12 | case shape(String) 13 | /// Sets this property to its default value. Read about initial Play it » 14 | case initial 15 | /// Inherits this property from its parent element. Read about inherit 16 | case inherit 17 | 18 | var rawValue: String { 19 | switch self { 20 | case .auto: 21 | return "auto" 22 | case let .shape(value): 23 | return value 24 | case .initial: 25 | return "initial" 26 | case .inherit: 27 | return "inherit" 28 | } 29 | } 30 | } 31 | 32 | public func Clip(_ value: String) -> Property { 33 | Property(name: "clip", value: value) 34 | } 35 | 36 | /// Clips an absolutely positioned element 37 | public func Clip(_ value: ClipValue = .auto) -> Property { 38 | Clip(value.rawValue) 39 | } 40 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/Color.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Color.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum ColorValue { 9 | /// Specifies the text color. 10 | case color(CSSColor) 11 | /// Sets this property to its default value. 12 | case initial 13 | /// Inherits this property from its parent element. 14 | case inherit 15 | 16 | var rawValue: String { 17 | switch self { 18 | case .color(let value): 19 | return value.rawValue 20 | case .initial: 21 | return "initial" 22 | case .inherit: 23 | return "inherit" 24 | } 25 | } 26 | } 27 | 28 | public func Color(_ value: String) -> Property { 29 | Property(name: "color", value: value) 30 | } 31 | 32 | /// Sets the color of text 33 | public func Color(_ value: ColorValue) -> Property { 34 | Color(value.rawValue) 35 | } 36 | 37 | /// Sets the color of text 38 | public func Color(_ value: CSSColor) -> Property { 39 | Color(.color(value)) 40 | } 41 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/ColumnCount.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ColumnCount.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum ColumnCountValue: ExpressibleByIntegerLiteral { 9 | 10 | /// The optimal number of columns into which the content of the element will be flowed 11 | case number(Int) 12 | /// Default value. The number of columns will be determined by other properties, like e.g. "column-width" 13 | case auto 14 | /// Sets this property to its default value. 15 | case initial 16 | /// Inherits this property from its parent element. 17 | case inherit 18 | 19 | public init(integerLiteral value: IntegerLiteralType) { 20 | self = .number(value) 21 | } 22 | 23 | var rawValue: String { 24 | switch self { 25 | case .number(let value): 26 | return "\(value)" 27 | case .auto: 28 | return "auto" 29 | case .initial: 30 | return "initial" 31 | case .inherit: 32 | return "inherit" 33 | } 34 | } 35 | } 36 | 37 | public func ColumnCount(_ value: String) -> Property { 38 | Property(name: "column-count", value: value) 39 | } 40 | 41 | /// Specifies the number of columns an element should be divided into 42 | public func ColumnCount(_ value: ColumnCountValue = .auto) -> Property { 43 | ColumnCount(value.rawValue) 44 | } 45 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/ColumnFill.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ColumnFill.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum ColumnFillValue: String { 9 | /// Default value. Fills each column with about the same amount of content, but will not allow the columns to be taller than the height 10 | /// (so, columns might be shorter than the height as the browser distributes the content evenly horizontally) 11 | case balance 12 | /// Fills each column until it reaches the height, and do this until it runs out of content 13 | /// (so, this value will not necessarily fill all the columns nor fill them evenly) 14 | case auto 15 | /// Sets this property to its default value. 16 | case initial 17 | /// Inherits this property from its parent element. 18 | case inherit 19 | } 20 | 21 | public func ColumnFill(_ value: String) -> Property { 22 | Property(name: "column-fill", value: value) 23 | } 24 | 25 | /// Specifies how to fill columns, balanced or not 26 | public func ColumnFill(_ value: ColumnFillValue = .balance) -> Property { 27 | ColumnFill(value.rawValue) 28 | } 29 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/ColumnGap.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ColumnGap.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum ColumnGapValue { 9 | 10 | /// A specified length that will set the gap between the columns 11 | case length(Unit) 12 | /// Default value. Specifies a normal gap between the columns. W3C suggests a value of 1em 13 | case normal 14 | /// Sets this property to its default value. 15 | case initial 16 | /// Inherits this property from its parent element. 17 | case inherit 18 | 19 | var rawValue: String { 20 | switch self { 21 | case .length(let value): 22 | return value.rawValue 23 | case .normal: 24 | return "normal" 25 | case .initial: 26 | return "initial" 27 | case .inherit: 28 | return "inherit" 29 | } 30 | } 31 | } 32 | 33 | public func ColumnGap(_ value: String) -> Property { 34 | Property(name: "column-gap", value: value) 35 | } 36 | 37 | /// Specifies the gap between the columns 38 | public func ColumnGap(_ value: ColumnGapValue) -> Property { 39 | ColumnGap(value.rawValue) 40 | } 41 | 42 | /// Specifies the gap between the columns 43 | public func ColumnGap(_ value: Unit) -> Property { 44 | ColumnGap(.length(value)) 45 | } 46 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/ColumnRule.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ColumnRule.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum ColumnRuleValue { 9 | case values(ColumnRuleWidthValue, ColumnRuleStyleValue, ColumnRuleColorValue) 10 | /// Sets this property to its default value. Read about initial 11 | case initial 12 | /// Inherits this property from its parent element. Read about inherit 13 | case inherit 14 | 15 | var rawValue: String { 16 | switch self { 17 | case let .values(width, style, color): 18 | return [width.rawValue, style.rawValue, color.rawValue].joined(separator: " ") 19 | case .initial: 20 | return "initial" 21 | case .inherit: 22 | return "inherit" 23 | } 24 | } 25 | } 26 | 27 | public func ColumnRule(_ value: String) -> Property { 28 | Property(name: "column-rule", value: value) 29 | } 30 | 31 | /// A shorthand property for all the column-rule-* properties 32 | public func ColumnRule(_ value: ColumnRuleValue) -> Property { 33 | ColumnRule(value.rawValue) 34 | } 35 | 36 | /// A shorthand property for all the column-rule-* properties 37 | public func ColumnRule(_ width: ColumnRuleWidthValue, 38 | _ style: ColumnRuleStyleValue, 39 | _ color: ColumnRuleColorValue) -> Property { 40 | ColumnRule(.values(width, style, color)) 41 | } 42 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/ColumnRuleColor.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ColumnRuleColor.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum ColumnRuleColorValue { 9 | /// Specifies the color of the rule. 10 | case color(CSSColor) 11 | /// Sets this property to its default value. 12 | case initial 13 | /// Inherits this property from its parent element. 14 | case inherit 15 | 16 | var rawValue: String { 17 | switch self { 18 | case .color(let value): 19 | return value.rawValue 20 | case .initial: 21 | return "initial" 22 | case .inherit: 23 | return "inherit" 24 | } 25 | } 26 | } 27 | 28 | public func ColumnRuleColor(_ value: String) -> Property { 29 | Property(name: "column-rule-color", value: value) 30 | } 31 | 32 | /// Specifies the color of the rule between columns 33 | public func ColumnRuleColor(_ value: ColumnRuleColorValue) -> Property { 34 | ColumnRuleColor(value.rawValue) 35 | } 36 | 37 | /// Specifies the color of the rule between columns 38 | public func ColumnRuleColor(_ value: CSSColor) -> Property { 39 | ColumnRuleColor(.color(value)) 40 | } 41 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/ColumnRuleStyle.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ColumnRuleStyle.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum ColumnRuleStyleValue: String { 9 | /// Default value. Defines no rule 10 | case none 11 | /// Defines a hidden rule 12 | case hidden 13 | /// Defines a dotted rule 14 | case dotted 15 | /// Defines a dashed rule 16 | case dashed 17 | /// Defines a solid rule 18 | case solid 19 | /// Defines a double rule 20 | case double 21 | /// Specifies a 3D grooved rule. The effect depends on the width and color values 22 | case groove 23 | /// Specifies a 3D ridged rule. The effect depends on the width and color values 24 | case ridge 25 | /// Specifies a 3D inset rule. The effect depends on the width and color values 26 | case inset 27 | /// Specifies a 3D outset rule. The effect depends on the width and color values 28 | case outset 29 | /// Sets this property to its default value. 30 | case initial 31 | /// Inherits this property from its parent element. 32 | case inherit 33 | } 34 | 35 | public func ColumnRuleStyle(_ value: String) -> Property { 36 | Property(name: "column-rule-style", value: value) 37 | } 38 | 39 | /// Specifies the style of the rule between columns 40 | public func ColumnRuleStyle(_ value: ColumnRuleStyleValue = .none) -> Property { 41 | ColumnRuleStyle(value.rawValue) 42 | } 43 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/ColumnRuleWidth.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ColumnRuleWidth.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum ColumnRuleWidthValue { 9 | /// Default value. Defines a medium rule 10 | case medium 11 | /// Defines a thin rule 12 | case thin 13 | /// Defines a thick rule 14 | case thick 15 | /// Specifies the width of the rule 16 | case length(Unit) 17 | /// Sets this property to its default value. 18 | case initial 19 | /// Inherits this property from its parent element. 20 | case inherit 21 | 22 | var rawValue: String { 23 | switch self { 24 | case .medium: 25 | return "medium" 26 | case .thin: 27 | return "thin" 28 | case .thick: 29 | return "thick" 30 | case .length(let value): 31 | return value.rawValue 32 | case .initial: 33 | return "initial" 34 | case .inherit: 35 | return "inherit" 36 | } 37 | } 38 | } 39 | 40 | public func ColumnRuleWidth(_ value: String) -> Property { 41 | Property(name: "column-rule-width", value: value) 42 | } 43 | 44 | /// Specifies the width of the rule between columns 45 | public func ColumnRuleWidth(_ value: ColumnRuleWidthValue = .medium) -> Property { 46 | ColumnRuleWidth(value.rawValue) 47 | } 48 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/ColumnSpan.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ColumnSpan.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum ColumnSpanValue: String { 9 | /// Default value. The element should span across one column 10 | case none 11 | /// The element should span across all columns 12 | case all 13 | /// Sets this property to its default value. 14 | case initial 15 | /// Inherits this property from its parent element. 16 | case inherit 17 | } 18 | 19 | public func ColumnSpan(_ value: String) -> Property { 20 | Property(name: "column-span", value: value) 21 | } 22 | 23 | /// Specifies how many columns an element should span across 24 | public func ColumnSpan(_ value: ColumnSpanValue = .none) -> Property { 25 | ColumnSpan(value.rawValue) 26 | } 27 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/ColumnWidth.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ColumnWidth.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum ColumnWidthValue { 9 | /// Default value. The column width will be determined by the browser 10 | case auto 11 | /// A length that specifies the width of the columns. The number of columns will be the minimum number of columns needed to show all the content across the element. 12 | case length(Unit) 13 | /// Sets this property to its default value. 14 | case initial 15 | /// Inherits this property from its parent element. 16 | case inherit 17 | 18 | var rawValue: String { 19 | switch self { 20 | case .auto: 21 | return "auto" 22 | case .length(let value): 23 | return value.rawValue 24 | case .initial: 25 | return "initial" 26 | case .inherit: 27 | return "inherit" 28 | } 29 | } 30 | } 31 | 32 | public func ColumnWidth(_ value: String) -> Property { 33 | Property(name: "column-width", value: value) 34 | } 35 | 36 | /// Specifies the column width 37 | public func ColumnWidth(_ value: ColumnWidthValue = .auto) -> Property { 38 | ColumnWidth(value.rawValue) 39 | } 40 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/Columns.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Columns.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum ColumnsValue { 9 | /// Default value. Sets both the column-width and column-count to "auto" 10 | case auto 11 | case values(ColumnWidthValue, ColumnCountValue) 12 | /// Sets this property to its default value. Read about initial 13 | case initial 14 | /// Inherits this property from its parent element. Read about inherit 15 | case inherit 16 | 17 | var rawValue: String { 18 | switch self { 19 | case .auto: 20 | return "auto" 21 | case let .values(width, count): 22 | return [width.rawValue, count.rawValue].joined(separator: " ") 23 | case .initial: 24 | return "initial" 25 | case .inherit: 26 | return "inherit" 27 | } 28 | } 29 | } 30 | 31 | public func Columns(_ value: String) -> Property { 32 | Property(name: "columns", value: value) 33 | } 34 | 35 | /// A shorthand property for column-width and column-count 36 | public func Columns(_ value: ColumnsValue = .auto) -> Property { 37 | Columns(value.rawValue) 38 | } 39 | 40 | /// A shorthand property for column-width and column-count 41 | public func Columns(_ width: ColumnWidthValue, _ count: ColumnCountValue) -> Property { 42 | Columns(.values(width, count)) 43 | } 44 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/CounterIncrement.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CounterIncrement.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum CounterIncrementValue { 9 | /// Default value. No counters will be incremented 10 | case none 11 | /// The id defines which counter to increment. 12 | /// The number sets how much the counter will increment on each occurrence of the selector. 13 | /// The default increment is 1. 14 | /// Negative values are allowed. 15 | /// If id refers to a counter that has not been initialized by counter-reset, the default initial value is 0 16 | case id(Int) 17 | /// Sets this property to its default value. 18 | case initial 19 | /// Inherits this property from its parent element. 20 | case inherit 21 | 22 | var rawValue: String { 23 | switch self { 24 | case .none: 25 | return "none" 26 | case .id(let value): 27 | return String(value) 28 | case .initial: 29 | return "initial" 30 | case .inherit: 31 | return "inherit" 32 | } 33 | } 34 | } 35 | 36 | public func CounterIncrement(_ value: String) -> Property { 37 | Property(name: "counter-increment", value: value) 38 | } 39 | 40 | /// Increases or decreases the value of one or more CSS counters 41 | public func CounterIncrement(_ name: String, _ value: CounterIncrementValue = .none) -> Property { 42 | CounterIncrement(name + " " + value.rawValue) 43 | } 44 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/CounterReset.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CounterReset.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum CounterResetValue { 9 | /// Default value. No counters will be reset 10 | case none 11 | /// The id defines which counter to reset. 12 | /// The number sets the value the counter is reset to on each occurrence of the selector. 13 | /// The default number value is 0 14 | case id(Int) 15 | /// Sets this property to its default value. 16 | case initial 17 | /// Inherits this property from its parent element. 18 | case inherit 19 | 20 | var rawValue: String { 21 | switch self { 22 | case .none: 23 | return "none" 24 | case .id(let value): 25 | return String(value) 26 | case .initial: 27 | return "initial" 28 | case .inherit: 29 | return "inherit" 30 | } 31 | } 32 | } 33 | 34 | public func CounterReset(_ value: String) -> Property { 35 | Property(name: "counter-reset", value: value) 36 | } 37 | 38 | /// Creates or resets one or more CSS counters 39 | public func CounterReset(_ name: String, _ value: CounterResetValue = .none) -> Property { 40 | CounterReset(name + " " + value.rawValue) 41 | } 42 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/Direction.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Direction.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum DirectionValue: String { 9 | /// Text direction goes from left-to-right. This is default 10 | case ltr 11 | /// Text direction goes from right-to-left 12 | case rtl 13 | /// Sets this property to its default value. 14 | case initial 15 | /// Inherits this property from its parent element. 16 | case inherit 17 | } 18 | 19 | public func Direction(_ value: String) -> Property { 20 | Property(name: "direction", value: value) 21 | } 22 | 23 | /// Specifies the text direction/writing direction 24 | public func Direction(_ value: DirectionValue = .ltr) -> Property { 25 | Direction(value.rawValue) 26 | } 27 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/EmptyCells.swift: -------------------------------------------------------------------------------- 1 | // 2 | // EmptyCells.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum EmptyCellsValue: String { 9 | /// Display borders on empty cells. This is default 10 | case show 11 | /// Hide borders on empty cells 12 | case hide 13 | /// Sets this property to its default value. 14 | case initial 15 | /// Inherits this property from its parent element. 16 | case inherit 17 | } 18 | 19 | public func EmptyCells(_ value: String) -> Property { 20 | Property(name: "empty-cells", value: value) 21 | } 22 | 23 | /// Specifies whether or not to display borders and background on empty cells in a table 24 | public func EmptyCells(_ value: EmptyCellsValue = .show) -> Property { 25 | EmptyCells(value.rawValue) 26 | } 27 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/Flex.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Flex.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum FlexValue { 9 | case values(FlexGrowValue, FlexShrinkValue, FlexBasisValue) 10 | /// Same as 1 1 auto. 11 | case auto 12 | /// Same as 0 0 auto. 13 | case none 14 | /// Same as 0 1 auto. Read about initial 15 | case initial 16 | /// Inherits this property from its parent element. Read about inherit 17 | case inherit 18 | 19 | var rawValue: String { 20 | switch self { 21 | case let .values(grow, shrink, basis): 22 | return [grow.rawValue, shrink.rawValue, basis.rawValue].joined(separator: " ") 23 | case .auto: 24 | return "auto" 25 | case .none: 26 | return "none" 27 | case .initial: 28 | return "initial" 29 | case .inherit: 30 | return "inherit" 31 | } 32 | } 33 | } 34 | 35 | public func Flex(_ value: String) -> Property { 36 | Property(name: "flex", value: value) 37 | } 38 | 39 | /// A shorthand property for the flex-grow, flex-shrink, and the flex-basis properties 40 | public func Flex(_ value: FlexValue) -> Property { 41 | Flex(value.rawValue) 42 | } 43 | 44 | /// A shorthand property for the flex-grow, flex-shrink, and the flex-basis properties 45 | public func Flex(_ grow: FlexGrowValue, _ shrink: FlexShrinkValue, _ basis: FlexBasisValue) -> Property { 46 | Flex(.values(grow, shrink, basis)) 47 | } 48 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/FlexBasis.swift: -------------------------------------------------------------------------------- 1 | // 2 | // FlexBasis.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum FlexBasisValue { 9 | /// Default value. The length is equal to the length of the flexible item. If the item has no length specified, the length will be according to its content 10 | case auto 11 | /// A length unit, or percentage, specifying the initial length of the flexible item(s) 12 | case number(Unit) 13 | /// Sets this property to its default value. 14 | case initial 15 | /// Inherits this property from its parent element. 16 | case inherit 17 | 18 | var rawValue: String { 19 | switch self { 20 | case .auto: 21 | return "auto" 22 | case .number(let value): 23 | return value.rawValue 24 | case .initial: 25 | return "initial" 26 | case .inherit: 27 | return "inherit" 28 | } 29 | } 30 | } 31 | 32 | public func FlexBasis(_ value: String) -> Property { 33 | Property(name: "flex-basis", value: value) 34 | } 35 | 36 | /// Specifies the initial length of a flexible item 37 | public func FlexBasis(_ value: FlexBasisValue = .auto) -> Property { 38 | FlexBasis(value.rawValue) 39 | } 40 | 41 | /// Specifies the initial length of a flexible item 42 | public func FlexBasis(_ value: Unit) -> Property { 43 | FlexBasis(.number(value)) 44 | } 45 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/FlexDirection.swift: -------------------------------------------------------------------------------- 1 | // 2 | // FlexDirection.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum FlexDirectionValue: String { 9 | /// Default value. The flexible items are displayed horizontally, as a row 10 | case row 11 | /// Same as row, but in reverse order 12 | case rowReverse = "row-reverse" 13 | /// The flexible items are displayed vertically, as a column 14 | case column 15 | /// Same as column, but in reverse order 16 | case columnReverse = "column-reverse" 17 | /// Sets this property to its default value. 18 | case initial 19 | /// Inherits this property from its parent element. 20 | case inherit 21 | } 22 | 23 | public func FlexDirection(_ value: String) -> Property { 24 | Property(name: "flex-direction", value: value) 25 | } 26 | 27 | /// Specifies the direction of the flexible items 28 | public func FlexDirection(_ value: FlexDirectionValue = .row) -> Property { 29 | FlexDirection(value.rawValue) 30 | } 31 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/FlexFlow.swift: -------------------------------------------------------------------------------- 1 | // 2 | // FlexFlow.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum FlexFlowValue { 9 | case values(FlexDirectionValue, FlexWrapValue) 10 | /// Sets this property to its default value. Read about initial 11 | case initial 12 | /// Inherits this property from its parent element. Read about inherit 13 | case inherit 14 | 15 | var rawValue: String { 16 | switch self { 17 | case let .values(direction, wrap): 18 | return [direction.rawValue, wrap.rawValue].joined(separator: " ") 19 | case .initial: 20 | return "initial" 21 | case .inherit: 22 | return "inherit" 23 | } 24 | } 25 | } 26 | 27 | public func FlexFlow(_ value: String) -> Property { 28 | Property(name: "flex-flow", value: value) 29 | } 30 | 31 | /// A shorthand property for the flex-direction and the flex-wrap properties 32 | public func FlexFlow(_ value: FlexFlowValue) -> Property { 33 | FlexFlow(value.rawValue) 34 | } 35 | 36 | /// A shorthand property for the flex-direction and the flex-wrap properties 37 | public func FlexFlow(_ direction: FlexDirectionValue, _ wrap: FlexWrapValue) -> Property { 38 | FlexFlow(.values(direction, wrap)) 39 | } 40 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/FlexGrow.swift: -------------------------------------------------------------------------------- 1 | // 2 | // FlexGrow.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum FlexGrowValue { 9 | 10 | /// A number specifying how much the item will grow relative to the rest of the flexible items. Default value is 0 11 | case number(Int) 12 | /// Sets this property to its default value. 13 | case initial 14 | /// Inherits this property from its parent element. 15 | case inherit 16 | 17 | 18 | var rawValue: String { 19 | switch self { 20 | case .number(let value): 21 | return String(value) 22 | case .initial: 23 | return "initial" 24 | case .inherit: 25 | return "inherit" 26 | } 27 | } 28 | } 29 | 30 | public func FlexGrow(_ value: String) -> Property { 31 | Property(name: "flex-grow", value: value) 32 | } 33 | 34 | /// Specifies how much the item will grow relative to the rest 35 | public func FlexGrow(_ value: FlexGrowValue = .number(0)) -> Property { 36 | FlexGrow(value.rawValue) 37 | } 38 | 39 | /// Specifies how much the item will grow relative to the rest 40 | public func FlexGrow(_ value: Int = 0) -> Property { 41 | FlexGrow(.number(value)) 42 | } 43 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/FlexShrink.swift: -------------------------------------------------------------------------------- 1 | // 2 | // FlexShrink.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum FlexShrinkValue { 9 | 10 | /// A number specifying how much the item will shrink relative to the rest of the flexible items. Default value is 1 11 | case number(Int) 12 | /// Sets this property to its default value. 13 | case initial 14 | /// Inherits this property from its parent element. 15 | case inherit 16 | 17 | var rawValue: String { 18 | switch self { 19 | case .number(let value): 20 | return String(value) 21 | case .initial: 22 | return "initial" 23 | case .inherit: 24 | return "inherit" 25 | } 26 | } 27 | } 28 | 29 | public func FlexShrink(_ value: String) -> Property { 30 | Property(name: "flex-shrink", value: value) 31 | } 32 | 33 | /// Specifies how the item will shrink relative to the rest 34 | public func FlexShrink(_ value: FlexShrinkValue = .number(1)) -> Property { 35 | FlexShrink(value.rawValue) 36 | } 37 | 38 | /// Specifies how the item will shrink relative to the rest 39 | public func FlexShrink(_ value: Int = 1) -> Property { 40 | FlexShrink(.number(value)) 41 | } 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/FlexWrap.swift: -------------------------------------------------------------------------------- 1 | // 2 | // FlexWrap.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum FlexWrapValue: String { 9 | /// Default value. Specifies that the flexible items will not wrap 10 | case nowrap 11 | /// Specifies that the flexible items will wrap if necessary 12 | case wrap 13 | /// Specifies that the flexible items will wrap, if necessary, in reverse order 14 | case wrapReverse = "wrap-reverse" 15 | /// Sets this property to its default value. 16 | case initial 17 | /// Inherits this property from its parent element. 18 | case inherit 19 | } 20 | 21 | public func FlexWrap(_ value: String) -> Property { 22 | Property(name: "flex-wrap", value: value) 23 | } 24 | 25 | /// Specifies whether the flexible items should wrap or not 26 | public func FlexWrap(_ value: FlexWrapValue = .nowrap) -> Property { 27 | FlexWrap(value.rawValue) 28 | } 29 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/Float.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Float.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum FloatValue: String { 9 | /// The element does not float, (will be displayed just where it occurs in the text). This is default 10 | case none 11 | /// The element floats to the left of its container 12 | case left 13 | /// The element floats the right of its container 14 | case right 15 | /// Sets this property to its default value. 16 | case initial 17 | /// Inherits this property from its parent element. 18 | case inherit 19 | } 20 | 21 | public func Float(_ value: String) -> Property { 22 | Property(name: "float", value: value) 23 | } 24 | 25 | /// Specifies whether an element should float to the left, right, or not at all 26 | public func Float(_ value: FloatValue = .none) -> Property { 27 | Float(value.rawValue) 28 | } 29 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/FontFamily.swift: -------------------------------------------------------------------------------- 1 | // 2 | // FontFamily.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum FontFamilyValue { 9 | /// A prioritized list of font family names and/or generic family names 10 | case family(String) 11 | /// Sets this property to its default value. 12 | case initial 13 | /// Inherits this property from its parent element. 14 | case inherit 15 | 16 | var rawValue: String { 17 | switch self { 18 | case .family(let value): 19 | return value 20 | case .initial: 21 | return "initial" 22 | case .inherit: 23 | return "inherit" 24 | } 25 | } 26 | } 27 | 28 | public func FontFamily(_ value: String) -> Property { 29 | Property(name: "font-family", value: value) 30 | } 31 | 32 | /// Specifies the font family for text 33 | public func FontFamily(_ value: FontFamilyValue) -> Property { 34 | FontFamily(value.rawValue) 35 | } 36 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/FontFeatureSettings.swift: -------------------------------------------------------------------------------- 1 | // 2 | // FontFeatureSettings.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum FontFeatureSettingsValue { 9 | /// Default. Use the default settings to lay out text 10 | case normal 11 | /// Format: string [1|0|on|off] Always a string of 4 ASCII characters. 12 | case featureValue(String) 13 | 14 | var rawValue: String { 15 | switch self { 16 | case .normal: 17 | return "normal" 18 | case let .featureValue(value): 19 | return value 20 | } 21 | } 22 | } 23 | 24 | public func FontFeatureSettings(_ value: String) -> Property { 25 | Property(name: "font-feature-settings", value: value) 26 | } 27 | 28 | /// Allows control over advanced typographic features in OpenType fonts 29 | public func FontFeatureSettings(_ value: FontFeatureSettingsValue = .normal) -> Property { 30 | FontFeatureSettings(value.rawValue) 31 | } 32 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/FontKerning.swift: -------------------------------------------------------------------------------- 1 | // 2 | // FontKerning.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum FontKerningValue: String { 9 | /// Default. The browser determines whether font kerning should be applied or not 10 | case auto 11 | /// Specifies that font kerning is applied 12 | case normal 13 | /// Specifies that font kerning is not applied 14 | case none 15 | } 16 | 17 | public func FontKerning(_ value: String) -> Property { 18 | Property(name: "font-kerning", value: value) 19 | } 20 | 21 | /// Controls the usage of the kerning information (how letters are spaced) 22 | public func FontKerning(_ value: FontKerningValue = .auto) -> Property { 23 | FontKerning(value.rawValue) 24 | } 25 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/FontLanguageOverride.swift: -------------------------------------------------------------------------------- 1 | // 2 | // FontLanguageOverride.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum FontLanguageOverrideValue { 9 | case normal 10 | case value(String) 11 | case initial 12 | case inherit 13 | case unset 14 | 15 | var rawValue: String { 16 | switch self { 17 | case .normal: 18 | return "normal" 19 | case let .value(value): 20 | return value 21 | case .initial: 22 | return "initial" 23 | case .inherit: 24 | return "inherit" 25 | case .unset: 26 | return "unset" 27 | } 28 | } 29 | } 30 | 31 | public func FontLanguageOverride(_ value: String) -> Property { 32 | Property(name: "font-language-override", value: value) 33 | } 34 | 35 | /// Controls the usage of language-specific glyphs in a typeface 36 | public func FontLanguageOverride(_ value: FontLanguageOverrideValue = .normal) -> Property { 37 | FontLanguageOverride(value.rawValue) 38 | } 39 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/FontSizeAdjust.swift: -------------------------------------------------------------------------------- 1 | // 2 | // FontSizeAdjust.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum FontSizeAdjustValue { 9 | /// Defines the aspect value to use 10 | case number(Double) 11 | /// Default value. No font size adjustment 12 | case none 13 | /// Sets this property to its default value. 14 | case initial 15 | /// Inherits this property from its parent element. 16 | case inherit 17 | 18 | var rawValue: String { 19 | switch self { 20 | case .none: 21 | return "none" 22 | case .number(let value): 23 | return String(value) 24 | case .initial: 25 | return "initial" 26 | case .inherit: 27 | return "inherit" 28 | } 29 | } 30 | } 31 | 32 | public func FontSizeAdjust(_ value: String) -> Property { 33 | Property(name: "font-size-adjust", value: value) 34 | } 35 | 36 | /// Preserves the readability of text when font fallback occurs 37 | public func FontSizeAdjust(_ value: FontSizeAdjustValue = .none) -> Property { 38 | FontSizeAdjust(value.rawValue) 39 | } 40 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/FontStyle.swift: -------------------------------------------------------------------------------- 1 | // 2 | // FontStyle.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum FontStyleValue: String { 9 | /// The browser displays a normal font style. This is default 10 | case normal 11 | /// The browser displays an italic font style 12 | case italic 13 | /// The browser displays an oblique font style 14 | case oblique 15 | /// Sets this property to its default value. 16 | case initial 17 | /// Inherits this property from its parent element. 18 | case inherit 19 | } 20 | 21 | public func FontStyle(_ value: String) -> Property { 22 | Property(name: "font-style", value: value) 23 | } 24 | 25 | /// Specifies the font style for text 26 | public func FontStyle(_ value: FontStyleValue = .normal) -> Property { 27 | FontStyle(value.rawValue) 28 | } 29 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/FontSynthesis.swift: -------------------------------------------------------------------------------- 1 | // 2 | // FontSynthesis.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum FontSynthesisValue: String { 9 | case none 10 | case weight 11 | case style 12 | case weightStyle = "weight style" 13 | case inherit 14 | case initial 15 | case revert 16 | case unset 17 | } 18 | 19 | public func FontSynthesis(_ value: String) -> Property { 20 | Property(name: "font-synthesis", value: value) 21 | } 22 | 23 | /// Controls which missing typefaces (bold or italic) may be synthesized by the browser 24 | public func FontSynthesis(_ value: FontSynthesisValue = .none) -> Property { 25 | FontSynthesis(value.rawValue) 26 | } 27 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/FontVariant.swift: -------------------------------------------------------------------------------- 1 | // 2 | // FontVariant.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum FontVariantValue: String { 9 | /// The browser displays a normal font. This is default 10 | case normal 11 | /// The browser displays a small-caps font 12 | case smallCaps = "small-caps" 13 | /// Sets this property to its default value. 14 | case initial 15 | /// Inherits this property from its parent element. 16 | case inherit 17 | } 18 | 19 | public func FontVariant(_ value: String) -> Property { 20 | Property(name: "font-variant", value: value) 21 | } 22 | 23 | /// Specifies whether or not a text should be displayed in a small-caps font 24 | public func FontVariant(_ value: FontVariantValue = .normal) -> Property { 25 | FontVariant(value.rawValue) 26 | } 27 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/FontVariantCaps.swift: -------------------------------------------------------------------------------- 1 | // 2 | // FontVariantCaps.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum FontVariantCapsValue: String { 9 | /// Deactivates the use of alternate glyphs 10 | case normal 11 | /// Displays small capitals 12 | case smallCaps = "small-caps" 13 | /// Displays small capitals for both upper and lowercase letters 14 | case allSmallCaps = "all-small-caps" 15 | /// Displays petite capitals 16 | case petiteCaps = "petite-caps" 17 | /// Displays petite capitals for both upper and lowercase letters 18 | case allPetiteCaps = "all-petite-caps" 19 | /// Displays a mix of small capitals for uppercase letters with normal lowercase letters 20 | case unicase 21 | /// Displays titling capitals 22 | case titlingCaps = "titling-caps" 23 | /// Sets this property to its default value. 24 | case initial 25 | /// Inherits this property from its parent element. 26 | case inherit 27 | /// unset 28 | case unset 29 | } 30 | 31 | public func FontVariantCaps(_ value: String) -> Property { 32 | Property(name: "font-variant-caps", value: value) 33 | } 34 | 35 | /// Controls the usage of alternate glyphs for capital letters 36 | public func FontVariantCaps(_ value: FontVariantCapsValue = .normal) -> Property { 37 | FontVariantCaps(value.rawValue) 38 | } 39 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/FontVariantEastAsian.swift: -------------------------------------------------------------------------------- 1 | // 2 | // FontVariantEastAsian.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum FontVariantEastAsianValue: String { 9 | case normal 10 | case ruby 11 | case jis78 12 | case jis83 13 | case jis90 14 | case jis04 15 | case simplified 16 | case traditional 17 | case fullWidth = "full-width" 18 | case proportionalWidth = "proportional-width" 19 | case rubyFullWidthJis83 = "ruby full-width jis83" 20 | case inherit 21 | case initial 22 | case revert 23 | case unset 24 | } 25 | 26 | public func FontVariantEastAsian(_ value: String) -> Property { 27 | Property(name: "font-variant-east-asian", value: value) 28 | } 29 | 30 | /// Controls the usage of alternate glyphs for East Asian scripts (e.g Japanese and Chinese) 31 | public func FontVariantEastAsian(_ value: FontVariantEastAsianValue = .normal) -> Property { 32 | FontVariantEastAsian(value.rawValue) 33 | } 34 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/FontVariantLigatures.swift: -------------------------------------------------------------------------------- 1 | // 2 | // FontVariantLigatures.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | 9 | public enum FontVariantLigaturesValue: String { 10 | case normal 11 | case none 12 | case commonLigatures = "common-ligatures" 13 | case noCommonLigatures = "no-common-ligatures" 14 | case discretionaryLigatures = "discretionary-ligatures" 15 | case noDiscretionaryLigatures = "no-discretionary-ligatures" 16 | case historicalLigatures = "historical-ligatures" 17 | case noHistoricalLigatures = "no-historical-ligatures" 18 | case contextual 19 | case noContextual = "no-contextual" 20 | case inherit 21 | case initial 22 | case revert 23 | case unset 24 | } 25 | 26 | public func FontVariantLigatures(_ value: String) -> Property { 27 | Property(name: "font-variant-ligatures", value: value) 28 | } 29 | 30 | /// Controls which ligatures and contextual forms are used in textual content of the elements it applies to 31 | public func FontVariantLigatures(_ value: FontVariantLigaturesValue = .normal) -> Property { 32 | FontVariantLigatures(value.rawValue) 33 | } 34 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/FontVariantNumeric.swift: -------------------------------------------------------------------------------- 1 | // 2 | // FontVariantNumeric.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum FontVariantNumericValue: String { 9 | case normal 10 | case ordinal 11 | case slashedZero = "slashed-zero" 12 | case liningNums = "lining-nums" 13 | case oldstyleNums = "oldstyle-nums" 14 | case proportionalNums = "proportional-nums" 15 | case tabularNums = "tabular-nums" 16 | case diagonalFractions = "diagonal-fractions" 17 | case stackedFractions = "stacked-fractions" 18 | case oldstyleNumsStackedFractions = "oldstyle-nums stacked-fractions" 19 | case inherit 20 | case initial 21 | case revert 22 | case unset 23 | } 24 | 25 | public func FontVariantNumeric(_ value: String) -> Property { 26 | Property(name: "font-variant-numeric", value: value) 27 | } 28 | 29 | /// Controls the usage of alternate glyphs for numbers, fractions, and ordinal markers 30 | public func FontVariantNumeric(_ value: FontVariantNumericValue = .normal) -> Property { 31 | FontVariantNumeric(value.rawValue) 32 | } 33 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/FontVariantPosition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // FontVariantPosition.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum FontVariantpositionValue: String { 9 | case normal 10 | case sub 11 | case `super` 12 | case inherit 13 | case initial 14 | case revert 15 | case unset 16 | } 17 | 18 | public func FontVariantPosition(_ value: String) -> Property { 19 | Property(name: "font-variant-position", value: value) 20 | } 21 | 22 | /// Controls the usage of alternate glyphs of smaller size positioned as superscript or subscript regarding the baseline of the font 23 | public func FontVariantPosition(_ value: FontVariantpositionValue = .normal) -> Property { 24 | FontVariantPosition(value.rawValue) 25 | } 26 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/FontWeight.swift: -------------------------------------------------------------------------------- 1 | // 2 | // FontWeight.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum FontWeightValue: String { 9 | /// Defines normal characters. This is default 10 | case normal 11 | /// Defines thick characters 12 | case bold 13 | /// Defines thicker characters 14 | case bolder 15 | /// Defines lighter characters 16 | case lighter 17 | /// Defines from thin to thick characters. 400 is the same as normal, and 700 is the same as bold 18 | // @TODO: better numeric value support 19 | case w100 20 | case w200 21 | case w300 22 | case w400 23 | case w500 24 | case w600 25 | case w700 26 | case w800 27 | case w900 28 | /// Sets this property to its default value. 29 | case initial 30 | /// Inherits this property from its parent element. 31 | case inherit 32 | } 33 | 34 | public func FontWeight(_ value: String) -> Property { 35 | Property(name: "font-weight", value: value) 36 | } 37 | 38 | /// Specifies the weight of a font 39 | public func FontWeight(_ value: FontWeightValue) -> Property { 40 | FontWeight(value.rawValue) 41 | } 42 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/Gap.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Gap.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public func Gap(_ value: String) -> Property { 9 | Property(name: "gap", value: value) 10 | } 11 | 12 | /// A shorthand property for the row-gap and the column-gap properties 13 | public func Gap(_ row: RowGapValue, _ col: ColumnGapValue) -> Property { 14 | Gap([row.rawValue, col.rawValue].joined(separator: " ")) 15 | } 16 | 17 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/GridArea.swift: -------------------------------------------------------------------------------- 1 | // 2 | // GridArea.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum GridAreaValue { 9 | case name(String) 10 | case values(GridRowStartValue, GridColumnStartValue, GridRowEndValue, GridColumnEndValue) 11 | 12 | var rawValue: String { 13 | switch self { 14 | case let .name(value): 15 | return value 16 | case let .values(rowStart, colStart, rowEnd, colEnd): 17 | return [rowStart.rawValue, colStart.rawValue, rowEnd.rawValue, colEnd.rawValue].joined(separator: " / ") 18 | } 19 | } 20 | } 21 | 22 | public func GridArea(_ value: String) -> Property { 23 | Property(name: "grid-area", value: value) 24 | } 25 | 26 | /// Either specifies a name for the grid item, or this property is a shorthand property for the grid-row-start, grid-column-start, grid-row-end, and grid-column-end properties 27 | public func GridArea(_ value: GridAreaValue) -> Property { 28 | GridArea(value.rawValue) 29 | } 30 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/GridAutoColumns.swift: -------------------------------------------------------------------------------- 1 | // 2 | // GridAutoColumns.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum GridAutoColumnsValue { 9 | /// Default value. The size of the columns is determined by the size of the container 10 | case auto 11 | // @TODO: implemnet min-max & fit content 12 | // case fit-content() 13 | /// Sets the size of each column depending on the largest item in the column 14 | case maxContent 15 | /// Sets the size of each column depending on the smallest item in the column 16 | case minContent 17 | /// Sets a size range greater than or equal to min and less than or equal to max 18 | // case minmax(min.max) 19 | /// Sets the size of the columns, by using a legal length value. 20 | case length(Unit) 21 | 22 | var rawValue: String { 23 | switch self { 24 | case .auto: 25 | return "auto" 26 | case .maxContent: 27 | return "max-content" 28 | case .minContent: 29 | return "min-content" 30 | case .length(let value): 31 | return value.rawValue 32 | } 33 | } 34 | } 35 | 36 | public func GridAutoColumns(_ value: String) -> Property { 37 | Property(name: "grid-auto-columns", value: value) 38 | } 39 | 40 | /// Specifies a default column size 41 | public func GridAutoColumns(_ value: GridAutoColumnsValue = .auto) -> Property { 42 | GridAutoColumns(value.rawValue) 43 | } 44 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/GridAutoFlow.swift: -------------------------------------------------------------------------------- 1 | // 2 | // GridAutoFlow.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum GridAutoFlowValue: String { 9 | /// Default value. Places items by filling each row 10 | case row 11 | /// Places items by filling each column 12 | case column 13 | /// Place items to fill any holes in the grid 14 | case dense 15 | /// Places items by filling each row, and fill any holes in the grid 16 | case rowDense = "row dense" 17 | /// Places items by filling each column, and fill any holes in the grid 18 | case columnDense = "column dense" 19 | } 20 | 21 | public func GridAutoFlow(_ value: String) -> Property { 22 | Property(name: "grid-auto-flow", value: value) 23 | } 24 | 25 | /// Specifies how auto-placed items are inserted in the grid 26 | public func GridAutoFlow(_ value: GridAutoFlowValue) -> Property { 27 | GridAutoFlow(value.rawValue) 28 | } 29 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/GridAutoRows.swift: -------------------------------------------------------------------------------- 1 | // 2 | // GridAutoRows.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum GridAutoRowsValue { 9 | /// Default value. The size of the rows is determined by the size of the largest item in the row 10 | case auto 11 | /// Sets the size of each row to depend on the largest item in the row 12 | case maxContent 13 | /// Sets the size of each row to depend on the largest item in the row 14 | case minContent 15 | /// Sets the size of the rows, by using a legal length value. 16 | case length(Unit) 17 | 18 | var rawValue: String { 19 | switch self { 20 | case .auto: 21 | return "auto" 22 | case .maxContent: 23 | return "max-content" 24 | case .minContent: 25 | return "min-content" 26 | case .length(let value): 27 | return value.rawValue 28 | } 29 | } 30 | } 31 | 32 | 33 | /// Specifies a default row size 34 | public func GridAutoRows(_ value: String) -> Property { 35 | Property(name: "grid-auto-rows", value: value) 36 | } 37 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/GridColumn.swift: -------------------------------------------------------------------------------- 1 | // 2 | // GridColumn.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public func GridColumn(_ value: String) -> Property { 9 | Property(name: "grid-column", value: value) 10 | } 11 | 12 | /// A shorthand property for the grid-column-start and the grid-column-end properties 13 | public func GridColumn(_ start: GridColumnStartValue, _ end: GridColumnEndValue) -> Property { 14 | GridColumn(start.rawValue + " / " + end.rawValue) 15 | } 16 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/GridColumnEnd.swift: -------------------------------------------------------------------------------- 1 | // 2 | // GridColumnEnd.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum GridColumnEndValue { 9 | /// Default value. The item will span one column 10 | case auto 11 | /// Specifies the number of columns the item will span 12 | case span(Int) 13 | /// Specifies on which column to end the display of the item 14 | case columnLine(Int) 15 | 16 | var rawValue: String { 17 | switch self { 18 | case .auto: 19 | return "auto" 20 | case .span(let value): 21 | return "span \(value)" 22 | case .columnLine(let value): 23 | return String(value) 24 | } 25 | } 26 | } 27 | 28 | public func GridColumnEnd(_ value: String) -> Property { 29 | Property(name: "grid-column-end", value: value) 30 | } 31 | 32 | /// Specifies where to end the grid item 33 | public func GridColumnEnd(_ value: GridColumnEndValue) -> Property { 34 | GridColumnEnd(value.rawValue) 35 | } 36 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/GridColumnGap.swift: -------------------------------------------------------------------------------- 1 | // 2 | // GridColumnGap.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum GridColumnGapValue { 9 | /// Any legal length value, like px or %. 0 is the default value. Read about length units 10 | case length(Unit) 11 | 12 | var rawValue: String { 13 | switch self { 14 | case .length(let value): 15 | return value.rawValue 16 | } 17 | } 18 | } 19 | 20 | public func GridColumnGap(_ value: String) -> Property { 21 | Property(name: "grid-column-gap", value: value) 22 | } 23 | 24 | /// Specifies the size of the gap between columns 25 | public func GridColumnGap(_ value: GridColumnGapValue) -> Property { 26 | GridColumnGap(value.rawValue) 27 | } 28 | 29 | /// Specifies the size of the gap between columns 30 | public func GridColumnGap(_ value: Unit) -> Property { 31 | GridColumnGap(.length(value)) 32 | } 33 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/GridColumnStart.swift: -------------------------------------------------------------------------------- 1 | // 2 | // GridColumnStart.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum GridColumnStartValue { 9 | /// Default value. The item will be placed following the flow 10 | case auto 11 | /// Specifies the number of columns the item will span 12 | case span(Int) 13 | /// Specifies on which column to start the display of the item 14 | case columnLine(Int) 15 | 16 | var rawValue: String { 17 | switch self { 18 | case .auto: 19 | return "auto" 20 | case .span(let value): 21 | return "span \(value)" 22 | case .columnLine(let value): 23 | return String(value) 24 | } 25 | } 26 | } 27 | 28 | public func GridColumnStart(_ value: String) -> Property { 29 | Property(name: "grid-column-start", value: value) 30 | } 31 | 32 | /// Specifies where to start the grid item 33 | public func GridColumnStart(_ value: GridColumnStartValue = .auto) -> Property { 34 | GridColumnStart(value.rawValue) 35 | } 36 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/GridGap.swift: -------------------------------------------------------------------------------- 1 | // 2 | // GridGap.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public func GridGap(_ value: String) -> Property { 9 | Property(name: "grid-gap", value: value) 10 | } 11 | 12 | /// A shorthand property for the grid-row-gap and grid-column-gap properties 13 | public func GridGap(_ row: GridRowGapValue, _ col: GridColumnGapValue) -> Property { 14 | GridGap(row.rawValue + " " + col.rawValue) 15 | } 16 | 17 | /// A shorthand property for the grid-row-gap and grid-column-gap properties 18 | public func GridGap(_ row: Unit, _ col: Unit) -> Property { 19 | GridGap(row.rawValue + " " + col.rawValue) 20 | } 21 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/GridRow.swift: -------------------------------------------------------------------------------- 1 | // 2 | // GridRow.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public func GridRow(_ value: String) -> Property { 9 | Property(name: "grid-row", value: value) 10 | } 11 | 12 | /// A shorthand property for the grid-row-start and the grid-row-end properties 13 | public func GridRow(_ start: GridRowStartValue, _ end: GridRowEndValue) -> Property { 14 | GridRow(start.rawValue + " / " + end.rawValue) 15 | } 16 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/GridRowEnd.swift: -------------------------------------------------------------------------------- 1 | // 2 | // GridRowEnd.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum GridRowEndValue { 9 | /// Default value. The item will span one row. 10 | case auto 11 | /// Specifies the number of rows the item will span. 12 | case span(Int) 13 | /// Specifies on which row to end the display of the item. 14 | case rowLine(Int) 15 | 16 | var rawValue: String { 17 | switch self { 18 | case .auto: 19 | return "auto" 20 | case .span(let value): 21 | return "span \(value)" 22 | case .rowLine(let value): 23 | return String(value) 24 | } 25 | } 26 | } 27 | 28 | public func GridRowEnd(_ value: String) -> Property { 29 | Property(name: "grid-row-end", value: value) 30 | } 31 | 32 | /// Specifies where to end the grid item 33 | public func GridRowEnd(_ value: GridRowEndValue) -> Property { 34 | GridRowEnd(value.rawValue) 35 | } 36 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/GridRowGap.swift: -------------------------------------------------------------------------------- 1 | // 2 | // GridRowGap.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum GridRowGapValue { 9 | /// Any legal length value, like px or %. 0 is the default value. 10 | case length(Unit) 11 | 12 | var rawValue: String { 13 | switch self { 14 | case .length(let value): 15 | return value.rawValue 16 | } 17 | } 18 | } 19 | 20 | /// Specifies the size of the gap between rows 21 | public func GridRowGap(_ value: String) -> Property { 22 | Property(name: "grid-row-gap", value: value) 23 | } 24 | 25 | /// Specifies the size of the gap between rows 26 | public func GridRowGap(_ value: GridRowGapValue) -> Property { 27 | GridRowGap(value.rawValue) 28 | } 29 | 30 | /// Specifies the size of the gap between rows 31 | public func GridRowGap(_ value: Unit) -> Property { 32 | GridRowGap(.length(value)) 33 | } 34 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/GridRowStart.swift: -------------------------------------------------------------------------------- 1 | // 2 | // GridRowStart.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum GridRowStartValue { 9 | /// Default value. The item will be placed by following the flow. 10 | case auto 11 | /// Specifies on which row to end the display of the item. 12 | case rowLine(Int) 13 | 14 | var rawValue: String { 15 | switch self { 16 | case .auto: 17 | return "auto" 18 | case .rowLine(let value): 19 | return String(value) 20 | } 21 | } 22 | } 23 | 24 | public func GridRowStart(_ value: String) -> Property { 25 | Property(name: "grid-row-start", value: value) 26 | } 27 | 28 | /// Specifies where to start the grid item 29 | public func GridRowStart(_ value: GridRowStartValue = .auto) -> Property { 30 | GridRowStart(value.rawValue) 31 | } 32 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/GridTemplateAreas.swift: -------------------------------------------------------------------------------- 1 | // 2 | // GridTemplateAreas.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum GridTemplateAreasValue { 9 | /// Default value. No named grid areas 10 | case none 11 | /// A sequence that specifies how each columns and row should display 12 | case names([String]) 13 | 14 | var rawValue: String { 15 | switch self { 16 | case .none: 17 | return "none" 18 | case .names(let values): 19 | return values.map { "'" + $0 + "'" }.joined(separator: " ") 20 | } 21 | } 22 | } 23 | 24 | public func GridTemplateAreas(_ value: String) -> Property { 25 | Property(name: "grid-template-areas", value: value) 26 | } 27 | 28 | /// Specifies how to display columns and rows, using named grid items 29 | public func GridTemplateAreas(_ value: GridTemplateAreasValue = .none) -> Property { 30 | GridTemplateAreas(value.rawValue) 31 | } 32 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/GridTemplateRows.swift: -------------------------------------------------------------------------------- 1 | // 2 | // GridTemplateRows.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum GridTemplateRowsValue { 9 | /// No size is set. Rows are created if needed 10 | case none 11 | /// The size of the rows is determined by the size of the container, and on the size of the content of the items in the row 12 | case auto 13 | /// Sets the size of each row to depend on the largest item in the row 14 | case maxContent 15 | /// Sets the size of each row to depend on the smallest item in the row 16 | case minContent 17 | /// Sets the size of the rows, by using a legal length value. 18 | case length(Unit) 19 | 20 | var rawValue: String { 21 | switch self { 22 | case .none: 23 | return "none" 24 | case .auto: 25 | return "auto" 26 | case .maxContent: 27 | return "max-content" 28 | case .minContent: 29 | return "min-content" 30 | case .length(let value): 31 | return value.rawValue 32 | } 33 | } 34 | } 35 | 36 | public func GridTemplateRows(_ value: String) -> Property { 37 | Property(name: "grid-template-rows", value: value) 38 | } 39 | 40 | /// Specifies the size of the rows in a grid layout 41 | public func GridTemplateRows(_ value: GridTemplateRowsValue = .none) -> Property { 42 | GridTemplateRows(value.rawValue) 43 | } 44 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/HangingPunctuation.swift: -------------------------------------------------------------------------------- 1 | // 2 | // HangingPunctuation.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum HangingPunctuationValue: String { 9 | /// No punctuation mark may be placed outside the line box at the start or at the end of a full line of text 10 | case none 11 | /// Punctuation may hang outside the start edge of the first line 12 | case first 13 | /// Punctuation may hang outside the end edge of the last line 14 | case last 15 | /// Punctuation may hang outside the end edge of all lines if the punctuation does not otherwise fit prior to justification 16 | case allowEnd = "allow-end" 17 | /// Punctuation may hang outside the end edge of all lines. If justification is enabled on this line, then it will force the punctuation to hang 18 | case forceEnd = "force-end" 19 | /// Sets this property to its default value. 20 | case initial 21 | /// Inherits this property from its parent element. 22 | case inherit 23 | 24 | } 25 | 26 | public func HangingPunctuation(_ value: String) -> Property { 27 | Property(name: "hanging-punctuation", value: value) 28 | } 29 | 30 | /// Specifies whether a punctuation character may be placed outside the line box 31 | public func HangingPunctuation(_ value: HangingPunctuationValue = .none) -> Property { 32 | HangingPunctuation(value.rawValue) 33 | } 34 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/Height.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Height.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum HeightValue { 9 | /// The browser calculates the height. This is default 10 | case auto 11 | /// Defines the height in px, cm, etc. 12 | case length(Unit) 13 | /// Sets this property to its default value. 14 | case initial 15 | /// Inherits this property from its parent element. 16 | case inherit 17 | 18 | var rawValue: String { 19 | switch self { 20 | case .auto: 21 | return "auto" 22 | case .length(let value): 23 | return value.rawValue 24 | case .initial: 25 | return "initial" 26 | case .inherit: 27 | return "inherit" 28 | } 29 | } 30 | } 31 | 32 | public func Height(_ value: String) -> Property { 33 | Property(name: "height", value: value) 34 | } 35 | 36 | /// Sets the height of an element 37 | public func Height(_ value: HeightValue = .auto) -> Property { 38 | Height(value.rawValue) 39 | } 40 | 41 | /// Sets the height of an element 42 | public func Height(_ value: Unit) -> Property { 43 | Height(.length(value)) 44 | } 45 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/Hyphens.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Hyphens.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum HyphensValue: String { 9 | /// Words are not hyphenated 10 | case none 11 | /// Default. Words are only hyphenated at ‐ or ­ (if needed) 12 | case manual 13 | /// Words are hyphenated where the algorithm is deciding (if needed) 14 | case auto 15 | /// Sets this property to its default value. 16 | case initial 17 | /// Inherits this property from its parent element. 18 | case inherit 19 | } 20 | 21 | public func Hyphens(_ value: String) -> Property { 22 | Property(name: "hyphens", value: value) 23 | } 24 | 25 | /// Sets how to split words to improve the layout of paragraphs 26 | public func Hyphens(_ value: HyphensValue = .manual) -> Property { 27 | Hyphens(value.rawValue) 28 | } 29 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/ImageRendering.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ImageRendering.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum ImageRenderingValue: String { 9 | case auto 10 | case crispEdges = "crisp-edges" 11 | case pixelated 12 | case inherit 13 | case initial 14 | case revert 15 | case unset 16 | } 17 | 18 | public func ImageRendering(_ value: String) -> Property { 19 | Property(name: "image-rendering", value: value) 20 | } 21 | 22 | /// Gives a hint to the browser about what aspects of an image are most important to preserve when the image is scaled 23 | public func ImageRendering(_ value: ImageRenderingValue = .auto) -> Property { 24 | ImageRendering(value.rawValue) 25 | } 26 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/Isolation.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Isolation.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum IsolationValue: String { 9 | /// Default. A new stacking context is created only if one of the properties applied to the element requires it 10 | case auto 11 | /// A new stacking context must be created 12 | case isolate 13 | /// Sets this property to its default value. 14 | case initial 15 | /// Inherits this property from its parent element. 16 | case inherit 17 | } 18 | 19 | public func Isolation(_ value: String) -> Property { 20 | Property(name: "isolation", value: value) 21 | } 22 | 23 | /// Defines whether an element must create a new stacking content 24 | public func Isolation(_ value: IsolationValue = .auto) -> Property { 25 | Isolation(value.rawValue) 26 | } 27 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/JustifyContent.swift: -------------------------------------------------------------------------------- 1 | // 2 | // JustifyContent.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum JustifyContentValue: String { 9 | /// Default value. Items are positioned at the beginning of the container 10 | case flexStart = "flex-start" 11 | /// Items are positioned at the end of the container 12 | case flexEnd = "flex-end" 13 | /// Items are positioned in the center of the container 14 | case center 15 | /// Items will have space between them 16 | case spaceBetween = "space-between" 17 | /// Items will have space before, between, and after them 18 | case spaceAround = "space-around" 19 | /// Items will have equal space around them 20 | case spaceEvenly = "space-evenly" 21 | /// Sets this property to its default value. 22 | case initial 23 | /// Inherits this property from its parent element. 24 | case inherit 25 | } 26 | 27 | public func JustifyContent(_ value: String) -> Property { 28 | Property(name: "justify-content", value: value) 29 | } 30 | 31 | /// Specifies the alignment between the items inside a flexible container when the items do not use all available space 32 | public func JustifyContent(_ value: JustifyContentValue = .flexStart) -> Property { 33 | JustifyContent(value.rawValue) 34 | } 35 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/Left.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Left.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum LeftValue { 9 | /// Lets the browser calculate the left edge position. This is default 10 | case auto 11 | /// Sets the left edge position in px, cm, etc. Negative values are allowed. Read about length units 12 | case length(Unit) 13 | /// Sets this property to its default value. 14 | case initial 15 | /// Inherits this property from its parent element. 16 | case inherit 17 | 18 | var rawValue: String { 19 | switch self { 20 | case .auto: 21 | return "auto" 22 | case .length(let value): 23 | return value.rawValue 24 | case .initial: 25 | return "initial" 26 | case .inherit: 27 | return "inherit" 28 | } 29 | } 30 | } 31 | 32 | public func Left(_ value: String) -> Property { 33 | Property(name: "left", value: value) 34 | } 35 | 36 | /// Specifies the left position of a positioned element 37 | public func Left(_ value: LeftValue = .auto) -> Property { 38 | Left(value.rawValue) 39 | } 40 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/LetterSpacing.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LetterSpacing.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum LetterSpacingValue { 9 | /// No extra space between characters. This is default 10 | case normal 11 | /// Defines an extra space between characters (negative values are allowed). Read about length units 12 | case length(Unit) 13 | /// Sets this property to its default value. 14 | case initial 15 | /// Inherits this property from its parent element. 16 | case inherit 17 | 18 | var rawValue: String { 19 | switch self { 20 | case .normal: 21 | return "normal" 22 | case .length(let value): 23 | return value.rawValue 24 | case .initial: 25 | return "initial" 26 | case .inherit: 27 | return "inherit" 28 | } 29 | } 30 | } 31 | 32 | public func LetterSpacing(_ value: String) -> Property { 33 | Property(name: "letter-spacing", value: value) 34 | } 35 | 36 | /// Increases or decreases the space between characters in a text 37 | public func LetterSpacing(_ value: LetterSpacingValue) -> Property { 38 | LetterSpacing(value.rawValue) 39 | } 40 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/LineBreak.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LineBreak.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum LineBreakValue: String { 9 | case auto 10 | case loose 11 | case normal 12 | case strict 13 | case anywhere 14 | case inherit 15 | case initial 16 | case revert 17 | case unset 18 | } 19 | 20 | public func LineBreak(_ value: String) -> Property { 21 | Property(name: "line-break", value: value) 22 | } 23 | 24 | /// Specifies how/if to break lines 25 | public func LineBreak(_ value: LineBreakValue = .auto) -> Property { 26 | LineBreak(value.rawValue) 27 | } 28 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/LineHeight.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LineHeight.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum LineHeightValue { 9 | /// A normal line height. This is default 10 | case normal 11 | /// A number that will be multiplied with the current font-size to set the line height 12 | case number(Double) 13 | /// A fixed line height in px, pt, cm, etc. 14 | case length(Unit) 15 | /// Sets this property to its default value. 16 | case initial 17 | /// Inherits this property from its parent element. 18 | case inherit 19 | 20 | var rawValue: String { 21 | switch self { 22 | case .normal: 23 | return "normal" 24 | case .number(let value): 25 | return String(value) 26 | case .length(let value): 27 | return value.rawValue 28 | case .initial: 29 | return "initial" 30 | case .inherit: 31 | return "inherit" 32 | } 33 | } 34 | } 35 | 36 | public func LineHeight(_ value: String) -> Property { 37 | Property(name: "line-height", value: value) 38 | } 39 | 40 | /// Sets the line height 41 | public func LineHeight(_ value: LineHeightValue = .normal) -> Property { 42 | LineHeight(value.rawValue) 43 | } 44 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/ListStyle.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ListStyle.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum ListStyleValue { 9 | /// list-style-type Specifies the type of list-item marker. Default value is "disc" 10 | /// list-style-position Specifies where to place the list-item marker. Default value is "outside" 11 | /// list-style-image Specifies the type of list-item marker. Default value is "none" 12 | case values(ListStyleTypeValue, ListStylePositionValue, ListStyleImageValue) 13 | /// Sets this property to its default value. Read about initial 14 | case initial 15 | /// Inherits this property from its parent element. Read about inherit 16 | case inherit 17 | 18 | var rawValue: String { 19 | switch self { 20 | case let .values(type, position, image): 21 | return [type.rawValue, position.rawValue, image.rawValue].joined(separator: " ") 22 | case .initial: 23 | return "initial" 24 | case .inherit: 25 | return "inherit" 26 | } 27 | } 28 | } 29 | 30 | public func ListStyle(_ value: String) -> Property { 31 | Property(name: "list-style", value: value) 32 | } 33 | 34 | /// Sets all the properties for a list in one declaration 35 | public func ListStyle(_ value: ListStyleValue) -> Property { 36 | ListStyle(value.rawValue) 37 | } 38 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/ListStyleImage.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ListStyleImage.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum ListStyleImageValue { 9 | /// A normal line height. This is default 10 | case none 11 | /// A number that will be multiplied with the current font-size to set the line height 12 | case url(String) 13 | /// Sets this property to its default value. 14 | case initial 15 | /// Inherits this property from its parent element. 16 | case inherit 17 | 18 | var rawValue: String { 19 | switch self { 20 | case .none: 21 | return "none" 22 | case .url(let value): 23 | return "url('\(value)')" 24 | case .initial: 25 | return "initial" 26 | case .inherit: 27 | return "inherit" 28 | } 29 | } 30 | } 31 | 32 | public func ListStyleImage(_ value: String) -> Property { 33 | Property(name: "list-style-image", value: value) 34 | } 35 | 36 | /// Specifies an image as the list-item marker 37 | public func ListStyleImage(_ value: ListStyleImageValue) -> Property { 38 | ListStyleImage(value.rawValue) 39 | } 40 | 41 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/ListStylePosition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ListStylePosition.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum ListStylePositionValue: String { 9 | /// The bullet points will be inside the list item 10 | case inside 11 | /// The bullet points will be outside the list item. This is default 12 | case outside 13 | /// Sets this property to its default value. 14 | case initial 15 | /// Inherits this property from its parent element. 16 | case inherit 17 | } 18 | 19 | public func ListStylePosition(_ value: String) -> Property { 20 | Property(name: "list-style-position", value: value) 21 | } 22 | 23 | /// Specifies the position of the list-item markers (bullet points) 24 | public func ListStylePosition(_ value: ListStylePositionValue = .outside) -> Property { 25 | ListStylePosition(value.rawValue) 26 | } 27 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/MarginBottom.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MarginBottom.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | /// Sets the bottom margin of an element 9 | public func MarginBottom(_ value: String) -> Property { 10 | Property(name: "margin-bottom", value: value) 11 | } 12 | 13 | public func MarginBottom(_ value: MarginValue = .length(.zero)) -> Property { 14 | MarginBottom(value.rawValue) 15 | } 16 | 17 | public func MarginBottom(_ value: Unit = .zero) -> Property { 18 | MarginBottom(.length(value)) 19 | } 20 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/MarginLeft.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MarginLeft.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | /// Sets the left margin of an element 9 | public func MarginLeft(_ value: String) -> Property { 10 | Property(name: "margin-left", value: value) 11 | } 12 | 13 | public func MarginLeft(_ value: MarginValue = .length(.zero)) -> Property { 14 | MarginLeft(value.rawValue) 15 | } 16 | 17 | public func MarginLeft(_ value: Unit = .zero) -> Property { 18 | MarginLeft(.length(value)) 19 | } 20 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/MarginRight.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MarginRight.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | /// Sets the right margin of an element 9 | public func MarginRight(_ value: String) -> Property { 10 | Property(name: "margin-right", value: value) 11 | } 12 | 13 | public func MarginRight(_ value: MarginValue = .length(.zero)) -> Property { 14 | MarginRight(value.rawValue) 15 | } 16 | 17 | public func MarginRight(_ value: Unit = .zero) -> Property { 18 | MarginRight(.length(value)) 19 | } 20 | 21 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/MarginTop.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MarginTop.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | /// Sets the top margin of an element 9 | public func MarginTop(_ value: String) -> Property { 10 | Property(name: "margin-top", value: value) 11 | } 12 | 13 | public func MarginTop(_ value: MarginValue = .length(.zero)) -> Property { 14 | MarginTop(value.rawValue) 15 | } 16 | 17 | public func MarginTop(_ value: Unit = .zero) -> Property { 18 | MarginTop(.length(value)) 19 | } 20 | 21 | 22 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/Mask.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Mask.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | // @TODO: add proper mask support 9 | // https://developer.mozilla.org/en-US/docs/Web/CSS/mask 10 | /// Hides an element by masking or clipping the image at specific places 11 | public func Mask(_ value: String) -> Property { 12 | Property(name: "mask", value: value) 13 | } 14 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/MaskType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MaskType.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | // @TODO: add mask support 9 | // https://developer.mozilla.org/en-US/docs/Web/CSS/mask-type 10 | /// Specifies whether a mask element is used as a luminance or an alpha mask 11 | public func MaskType(_ value: String) -> Property { 12 | Property(name: "mask-type", value: value) 13 | } 14 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/MaxHeight.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MaxHeight.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum MaxHeightValue { 9 | /// No maximum height. This is default 10 | case none 11 | /// Defines the maximum height in px, cm, etc. Read about length units 12 | case length(Unit) 13 | /// Sets this property to its default value. 14 | case initial 15 | /// Inherits this property from its parent element. 16 | case inherit 17 | 18 | var rawValue: String { 19 | switch self { 20 | case .none: 21 | return "none" 22 | case .length(let value): 23 | return value.rawValue 24 | case .initial: 25 | return "initial" 26 | case .inherit: 27 | return "inherit" 28 | } 29 | } 30 | } 31 | 32 | public func MaxHeight(_ value: String) -> Property { 33 | Property(name: "max-height", value: value) 34 | } 35 | 36 | /// Sets the maximum height of an element 37 | public func MaxHeight(_ value: MaxHeightValue = .none) -> Property { 38 | MaxHeight(value.rawValue) 39 | } 40 | 41 | /// Sets the maximum height of an element 42 | public func MaxHeight(_ value: Unit) -> Property { 43 | MaxHeight(.length(value)) 44 | } 45 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/MaxWidth.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MaxWidth.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum MaxWidthValue { 9 | /// No maximum width. This is default 10 | case none 11 | /// Defines the maximum width in px, cm, etc. Read about length units 12 | case length(Unit) 13 | /// Sets this property to its default value. 14 | case initial 15 | /// Inherits this property from its parent element. 16 | case inherit 17 | 18 | var rawValue: String { 19 | switch self { 20 | case .none: 21 | return "none" 22 | case .length(let value): 23 | return value.rawValue 24 | case .initial: 25 | return "initial" 26 | case .inherit: 27 | return "inherit" 28 | } 29 | } 30 | } 31 | 32 | public func MaxWidth(_ value: String) -> Property { 33 | Property(name: "max-width", value: value) 34 | } 35 | 36 | /// Sets the maximum width of an element 37 | public func MaxWidth(_ value: MaxWidthValue = .none) -> Property { 38 | MaxWidth(value.rawValue) 39 | } 40 | 41 | /// Sets the maximum width of an element 42 | public func MaxWidth(_ value: Unit) -> Property { 43 | MaxWidth(.length(value)) 44 | } 45 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/MinHeight.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MinHeight.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum MinHeightValue { 9 | /// Default value is 0. Defines the minimum height in px, cm, etc. Read about length units 10 | case length(Unit) 11 | /// Sets this property to its default value. 12 | case initial 13 | /// Inherits this property from its parent element. 14 | case inherit 15 | 16 | var rawValue: String { 17 | switch self { 18 | case .length(let value): 19 | return value.rawValue 20 | case .initial: 21 | return "initial" 22 | case .inherit: 23 | return "inherit" 24 | } 25 | } 26 | } 27 | 28 | public func MinHeight(_ value: String) -> Property { 29 | Property(name: "min-height", value: value) 30 | } 31 | 32 | /// Sets the minimum height of an element 33 | public func MinHeight(_ value: MinHeightValue = .length(.zero)) -> Property { 34 | MinHeight(value.rawValue) 35 | } 36 | 37 | /// Sets the minimum height of an element 38 | public func MinHeight(_ value: Unit) -> Property { 39 | MinHeight(.length(value)) 40 | } 41 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/MinWidth.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MinWidth.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum MinWidthValue { 9 | /// Default value is 0. Defines the minimum width in px, cm, etc. Read about length units 10 | case length(Unit) 11 | /// Sets this property to its default value. 12 | case initial 13 | /// Inherits this property from its parent element. 14 | case inherit 15 | 16 | var rawValue: String { 17 | switch self { 18 | case .length(let value): 19 | return value.rawValue 20 | case .initial: 21 | return "initial" 22 | case .inherit: 23 | return "inherit" 24 | } 25 | } 26 | } 27 | 28 | public func MinWidth(_ value: String) -> Property { 29 | Property(name: "min-width", value: value) 30 | } 31 | 32 | /// Sets the minimum width of an element 33 | public func MinWidth(_ value: MinWidthValue = .length(.zero)) -> Property { 34 | MinWidth(value.rawValue) 35 | } 36 | 37 | /// Sets the minimum width of an element 38 | public func MinWidth(_ value: Unit) -> Property { 39 | MinWidth(.length(value)) 40 | } 41 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/ObjectFit.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ObjectFit.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum ObjectFitValue: String { 9 | /// This is default. The replaced content is sized to fill the element's content box. If necessary, the object will be stretched or squished to fit 10 | case fill 11 | /// The replaced content is scaled to maintain its aspect ratio while fitting within the element's content box 12 | case contain 13 | /// The replaced content is sized to maintain its aspect ratio while filling the element's entire content box. The object will be clipped to fit 14 | case cover 15 | /// The replaced content is not resized 16 | case none 17 | /// The content is sized as if none or contain were specified (would result in a smaller concrete object size) 18 | case scaleDown = "scale-down" 19 | /// Sets this property to its default value. 20 | case initial 21 | /// Inherits this property from its parent element. 22 | case inherit 23 | } 24 | 25 | public func ObjectFit(_ value: String) -> Property { 26 | Property(name: "object-fit", value: value) 27 | } 28 | 29 | /// Specifies how the contents of a replaced element should be fitted to the box established by its used height and width 30 | public func ObjectFit(_ value: ObjectFitValue = .fill) -> Property { 31 | ObjectFit(value.rawValue) 32 | } 33 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/ObjectPosition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ObjectPosition.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum ObjectPositionValue { 9 | 10 | /// Specifies the position of the image or video inside its content box. 11 | /// First value controls the x-axis and the second value controls the y-axis. 12 | /// Can be a string (left, center or right), or a number (in px or %). 13 | /// Negative values are allowed 14 | case position(Unit, Unit?) 15 | /// Sets this property to its default value. 16 | case initial 17 | /// Inherits this property from its parent element. 18 | case inherit 19 | 20 | 21 | var rawValue: String { 22 | switch self { 23 | case .position(let x, let y): 24 | return "\(x.rawValue) \(y?.rawValue ?? "50%")" 25 | case .initial: 26 | return "initial" 27 | case .inherit: 28 | return "inherit" 29 | } 30 | } 31 | } 32 | 33 | public func ObjectPosition(_ value: String) -> Property { 34 | Property(name: "object-position", value: value) 35 | } 36 | 37 | /// Specifies the alignment of the replaced element inside its box 38 | public func ObjectPosition(_ value: ObjectPositionValue = .position(.percent(50), .percent(50))) -> Property { 39 | ObjectPosition(value.rawValue) 40 | } 41 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/Opacity.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Opacity.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum OpacityValue { 9 | /// Specifies the opacity. From 0.0 (fully transparent) to 1.0 (fully opaque) 10 | case number(Double) 11 | /// Sets this property to its default value. 12 | case initial 13 | /// Inherits this property from its parent element. 14 | case inherit 15 | 16 | var rawValue: String { 17 | switch self { 18 | case .number(let value): 19 | return String(value) 20 | case .initial: 21 | return "initial" 22 | case .inherit: 23 | return "inherit" 24 | } 25 | } 26 | } 27 | 28 | public func Opacity(_ value: String) -> Property { 29 | Property(name: "opacity", value: value) 30 | } 31 | 32 | /// Sets the opacity level for an element 33 | public func Opacity(_ value: OpacityValue = .number(1)) -> Property { 34 | Opacity(value.rawValue) 35 | } 36 | 37 | /// Sets the opacity level for an element 38 | public func Opacity(_ value: Double = 1) -> Property { 39 | Opacity(.number(value)) 40 | } 41 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/Order.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Order.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum OrderValue { 9 | /// Default value 0. Specifies the order for the flexible item 10 | case number(Int) 11 | /// Sets this property to its default value. 12 | case initial 13 | /// Inherits this property from its parent element. 14 | case inherit 15 | 16 | var rawValue: String { 17 | switch self { 18 | case .number(let value): 19 | return String(value) 20 | case .initial: 21 | return "initial" 22 | case .inherit: 23 | return "inherit" 24 | } 25 | } 26 | } 27 | 28 | public func Order(_ value: String) -> Property { 29 | Property(name: "order", value: value) 30 | } 31 | 32 | /// Sets the order of the flexible item, relative to the rest 33 | public func Order(_ value: OrderValue = .number(1)) -> Property { 34 | Order(value.rawValue) 35 | } 36 | 37 | /// Sets the order of the flexible item, relative to the rest 38 | public func Order(_ value: Int = 1) -> Property { 39 | Order(.number(1)) 40 | } 41 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/Orphans.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Orphans.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | // @TODO: add orphans support 9 | // https://developer.mozilla.org/en-US/docs/Web/CSS/orphans 10 | /// Sets the minimum number of lines that must be left at the bottom of a page when a page break occurs inside an element 11 | public func Orphans(_ value: String) -> Property { 12 | Property(name: "orphans", value: value) 13 | } 14 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/Outline.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Outline.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum OutlineValue { 9 | /// outline-width Specifies the width of outline 10 | /// outline-style Specifies the style of the outline 11 | /// outline-color Specifies the color of the outline 12 | case values(OutlineWidthValue, OutlineStyleValue, OutlineColorValue) 13 | /// Sets this property to its default value. Read about initial 14 | case initial 15 | /// Inherits this property from its parent element. Read about inherit 16 | case inherit 17 | 18 | var rawValue: String { 19 | switch self { 20 | case let .values(width, style, color): 21 | return [width.rawValue, style.rawValue, color.rawValue].joined(separator: " ") 22 | case .initial: 23 | return "initial" 24 | case .inherit: 25 | return "inherit" 26 | } 27 | } 28 | } 29 | 30 | public func Outline(_ value: String) -> Property { 31 | Property(name: "outline", value: value) 32 | } 33 | 34 | /// A shorthand property for the outline-width, outline-style, and the outline-color properties 35 | public func Outline(_ value: OutlineValue) -> Property { 36 | Outline(value.rawValue) 37 | } 38 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/OutlineColor.swift: -------------------------------------------------------------------------------- 1 | // 2 | // OutlineColor.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum OutlineColorValue { 9 | /// Performs a color inversion. This ensures that the outline is visible, regardless of color background. This is default 10 | case invert 11 | /// Specifies the color of the outline. Look at CSS Color Values for a complete list of possible color values. 12 | case color(CSSColor) 13 | /// Sets this property to its default value. 14 | case initial 15 | /// Inherits this property from its parent element. 16 | case inherit 17 | 18 | var rawValue: String { 19 | switch self { 20 | case .invert: 21 | return "invert" 22 | case .color(let value): 23 | return value.rawValue 24 | case .initial: 25 | return "initial" 26 | case .inherit: 27 | return "inherit" 28 | } 29 | } 30 | } 31 | 32 | public func OutlineColor(_ value: String) -> Property { 33 | Property(name: "outline-color", value: value) 34 | } 35 | 36 | /// Sets the color of an outline 37 | public func OutlineColor(_ value: OutlineColorValue = .invert) -> Property { 38 | OutlineColor(value.rawValue) 39 | } 40 | 41 | public func OutlineColor(_ value: CSSColor) -> Property { 42 | OutlineColor(.color(value)) 43 | } 44 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/OutlineOffset.swift: -------------------------------------------------------------------------------- 1 | // 2 | // OutlineOffset.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum OutlineOffsetValue { 9 | /// The distance the outline is outset from the border edge. Default value is 0 10 | case length(Unit) 11 | /// Sets this property to its default value. 12 | case initial 13 | /// Inherits this property from its parent element. 14 | case inherit 15 | 16 | var rawValue: String { 17 | switch self { 18 | case .length(let value): 19 | return value.rawValue 20 | case .initial: 21 | return "initial" 22 | case .inherit: 23 | return "inherit" 24 | } 25 | } 26 | } 27 | 28 | public func OutlineOffset(_ value: String) -> Property { 29 | Property(name: "outline-offset", value: value) 30 | } 31 | 32 | /// Offsets an outline, and draws it beyond the border edge 33 | public func OutlineOffset(_ value: OutlineOffsetValue = .length(.zero)) -> Property { 34 | OutlineOffset(value.rawValue) 35 | } 36 | 37 | /// Offsets an outline, and draws it beyond the border edge 38 | public func OutlineOffset(_ value: Unit = .zero) -> Property { 39 | OutlineOffset(.length(value)) 40 | } 41 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/OutlineStyle.swift: -------------------------------------------------------------------------------- 1 | // 2 | // OutlineStyle.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum OutlineStyleValue: String { 9 | /// Specifies no outline. This is default 10 | case none 11 | /// Specifies a hidden outline 12 | case hidden 13 | /// Specifies a dotted outline 14 | case dotted 15 | /// Specifies a dashed outline 16 | case dashed 17 | /// Specifies a solid outline 18 | case solid 19 | /// Specifies a double outliner 20 | case double 21 | /// Specifies a 3D grooved outline. The effect depends on the outline-color value 22 | case groove 23 | /// Specifies a 3D ridged outline. The effect depends on the outline-color value 24 | case ridge 25 | /// Specifies a 3D inset outline. The effect depends on the outline-color value 26 | case inset 27 | /// Specifies a 3D outset outline. The effect depends on the outline-color value 28 | case outset 29 | /// Sets this property to its default value. 30 | case initial 31 | /// Inherits this property from its parent element. 32 | case inherit 33 | } 34 | 35 | public func OutlineStyle(_ value: String) -> Property { 36 | Property(name: "outline-style", value: value) 37 | } 38 | 39 | /// Sets the style of an outline 40 | public func OutlineStyle(_ value: OutlineStyleValue = .none) -> Property { 41 | OutlineStyle(value.rawValue) 42 | } 43 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/OutlineWidth.swift: -------------------------------------------------------------------------------- 1 | // 2 | // OutlineWidth.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum OutlineWidthValue { 9 | /// Specifies a medium outline. This is default 10 | case medium 11 | /// Specifies a thin outline 12 | case thin 13 | /// Specifies a thick outline 14 | case thick 15 | /// Allows you to define the thickness of the outline. Read about length units 16 | case length(Unit) 17 | /// Sets this property to its default value. 18 | case initial 19 | /// Inherits this property from its parent element. 20 | case inherit 21 | 22 | var rawValue: String { 23 | switch self { 24 | case .medium: 25 | return "medium" 26 | case .thin: 27 | return "thin" 28 | case .thick: 29 | return "thick" 30 | case .length(let value): 31 | return value.rawValue 32 | case .initial: 33 | return "initial" 34 | case .inherit: 35 | return "inherit" 36 | } 37 | } 38 | } 39 | 40 | public func OutlineWidth(_ value: String) -> Property { 41 | Property(name: "outline-width", value: value) 42 | } 43 | 44 | /// Sets the width of an outline 45 | public func OutlineWidth(_ value: OutlineWidthValue = .medium) -> Property { 46 | OutlineWidth(value.rawValue) 47 | } 48 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/Overflow.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Overflow.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum OverflowValue: String { 9 | /// The overflow is not clipped. It renders outside the element's box. This is default 10 | case visible 11 | /// The overflow is clipped, and the rest of the content will be invisible 12 | case hidden 13 | /// The overflow is clipped, but a scroll-bar is added to see the rest of the content 14 | case scroll 15 | /// If overflow is clipped, a scroll-bar should be added to see the rest of the content 16 | case auto 17 | /// Sets this property to its default value. 18 | case initial 19 | /// Inherits this property from its parent element. 20 | case inherit 21 | } 22 | 23 | public func Overflow(_ value: String) -> Property { 24 | Property(name: "overflow", value: value) 25 | } 26 | 27 | /// Specifies what happens if content overflows an element's box 28 | public func Overflow(_ value: OverflowValue = .visible) -> Property { 29 | Overflow(value.rawValue) 30 | } 31 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/OverflowWrap.swift: -------------------------------------------------------------------------------- 1 | // 2 | // OverflowWrap.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum OverflowWrapValue: String { 9 | case normal 10 | case breakWord = "break-word" 11 | case anywhere 12 | case inherit 13 | case initial 14 | case revert 15 | case unset 16 | } 17 | 18 | public func OverflowWrap(_ value: String) -> Property { 19 | Property(name: "overflow-wrap", value: value) 20 | } 21 | 22 | /// Specifies whether or not the browser may break lines within words in order to prevent overflow (when a string is too long to fit its containing box) 23 | public func OverflowWrap(_ value: OverflowWrapValue) -> Property { 24 | OverflowWrap(value.rawValue) 25 | } 26 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/OverflowX.swift: -------------------------------------------------------------------------------- 1 | // 2 | // OverflowX.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public func OverflowX(_ value: String) -> Property { 9 | Property(name: "overflow-x", value: value) 10 | } 11 | 12 | /// Specifies whether or not to clip the left/right edges of the content, if it overflows the element's content area 13 | public func OverflowX(_ value: OverflowValue = .visible) -> Property { 14 | OverflowX(value.rawValue) 15 | } 16 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/OverflowY.swift: -------------------------------------------------------------------------------- 1 | // 2 | // OverflowY.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public func OverflowY(_ value: String) -> Property { 9 | Property(name: "overflow-y", value: value) 10 | } 11 | 12 | /// Specifies whether or not to clip the top/bottom edges of the content, if it overflows the element's content area 13 | public func OverflowY(_ value: OverflowValue = .visible) -> Property { 14 | OverflowY(value.rawValue) 15 | } 16 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/PaddingBottom.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PaddingBottom.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public func PaddingBottom(_ value: String) -> Property { 9 | Property(name: "padding-bottom", value: value) 10 | } 11 | 12 | /// Sets the bottom padding of an element 13 | public func PaddingBottom(_ value: PaddingValue = .length(.zero)) -> Property { 14 | PaddingBottom(value.rawValue) 15 | } 16 | 17 | /// Sets the bottom padding of an element 18 | public func PaddingBottom(_ value: Unit = .zero) -> Property { 19 | PaddingBottom(.length(value)) 20 | } 21 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/PaddingLeft.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PaddingLeft.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public func PaddingLeft(_ value: String) -> Property { 9 | Property(name: "padding-left", value: value) 10 | } 11 | 12 | /// Sets the left padding of an element 13 | public func PaddingLeft(_ value: PaddingValue = .length(.zero)) -> Property { 14 | PaddingLeft(value.rawValue) 15 | } 16 | 17 | /// Sets the left padding of an element 18 | public func PaddingLeft(_ value: Unit = .zero) -> Property { 19 | PaddingLeft(.length(value)) 20 | } 21 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/PaddingRight.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PaddingRight.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public func PaddingRight(_ value: String) -> Property { 9 | Property(name: "padding-right", value: value) 10 | } 11 | 12 | /// Sets the right padding of an element 13 | public func PaddingRight(_ value: PaddingValue = .length(.zero)) -> Property { 14 | PaddingRight(value.rawValue) 15 | } 16 | 17 | /// Sets the right padding of an element 18 | public func PaddingRight(_ value: Unit = .zero) -> Property { 19 | PaddingRight(.length(value)) 20 | } 21 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/PaddingTop.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PaddingTop.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public func PaddingTop(_ value: String) -> Property { 9 | Property(name: "padding-top", value: value) 10 | } 11 | 12 | /// Sets the top padding of an element 13 | public func PaddingTop(_ value: PaddingValue = .length(.zero)) -> Property { 14 | PaddingTop(value.rawValue) 15 | } 16 | 17 | /// Sets the top padding of an element 18 | public func PaddingTop(_ value: Unit = .zero) -> Property { 19 | PaddingTop(.length(value)) 20 | } 21 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/PageBreakAfter.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PageBreakAfter.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum PageBreakAfterValue: String { 9 | /// Default. Automatic page-break 10 | case auto 11 | /// Always insert a page-break after the element 12 | case always 13 | /// Avoid a page-break after the element (if possible) 14 | case avoid 15 | /// Insert page-break after the element so that the next page is formatted as a left page 16 | case left 17 | /// Insert page-break after the element so that the next page is formatted as a right page 18 | case right 19 | /// Sets this property to its default value. 20 | case initial 21 | /// Inherits this property from its parent element. 22 | case inherit 23 | } 24 | 25 | public func PageBreakAfter(_ value: String) -> Property { 26 | Property(name: "page-break-after", value: value) 27 | } 28 | 29 | /// Sets the page-break behavior after an element 30 | public func PageBreakAfter(_ value: PageBreakAfterValue = .auto) -> Property { 31 | PageBreakAfter(value.rawValue) 32 | } 33 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/PageBreakBefore.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PageBreakBefore.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum PageBreakBeforeValue: String { 9 | /// Default. Automatic page-break 10 | case auto 11 | /// Always insert a page-break before the element 12 | case always 13 | /// Avoid page-break before the element (if possible) 14 | case avoid 15 | /// Insert page-break before the element so that the next page is formatted as a left page 16 | case left 17 | /// Insert page-break before the element so that the next page is formatted as a right page 18 | case right 19 | /// Sets this property to its default value. 20 | case initial 21 | /// Inherits this property from its parent element. 22 | case inherit 23 | } 24 | 25 | public func PageBreakBefore(_ value: String) -> Property { 26 | Property(name: "page-break-before", value: value) 27 | } 28 | 29 | /// Sets the page-break behavior before an element 30 | public func PageBreakBefore(_ value: PageBreakBeforeValue = .auto) -> Property { 31 | PageBreakBefore(value.rawValue) 32 | } 33 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/PageBreakInside.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PageBreakInside.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum PageBreakInsideValue: String { 9 | /// Default. Automatic page-breaks 10 | case auto 11 | /// Avoid page-break inside the element (if possible) 12 | case avoid 13 | /// Sets this property to its default value. 14 | case initial 15 | /// Inherits this property from its parent element. 16 | case inherit 17 | } 18 | 19 | public func PageBreakInside(_ value: String) -> Property { 20 | Property(name: "page-break-inside", value: value) 21 | } 22 | 23 | /// Sets the page-break behavior inside an element 24 | public func PageBreakInside(_ value: PageBreakInsideValue = .auto) -> Property { 25 | PageBreakInside(value.rawValue) 26 | } 27 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/Perspective.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Perspective.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum PerspectiveValue { 9 | /// How far the element is placed from the view 10 | case length(Unit) 11 | /// Default value. Same as 0. The perspective is not set 12 | case none 13 | /// Sets this property to its default value. 14 | case initial 15 | /// Inherits this property from its parent element. 16 | case inherit 17 | 18 | 19 | var rawValue: String { 20 | switch self { 21 | case .none: 22 | return "none" 23 | case .length(let value): 24 | return value.rawValue 25 | case .initial: 26 | return "initial" 27 | case .inherit: 28 | return "inherit" 29 | } 30 | } 31 | } 32 | 33 | public func Perspective(_ value: String) -> Property { 34 | Property(name: "perspective", value: value) 35 | } 36 | 37 | /// Gives a 3D-positioned element some perspective 38 | public func Perspective(_ value: PerspectiveValue = .none) -> Property { 39 | Perspective(value.rawValue) 40 | } 41 | 42 | /// Gives a 3D-positioned element some perspective 43 | public func Perspective(_ value: Unit = .zero) -> Property { 44 | Perspective(.length(value)) 45 | } 46 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/PointerEvents.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PointerEvents.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum PointerEventsValue: String { 9 | /// The element reacts to pointer events, like :hover and click. This is default 10 | case auto 11 | /// The element does not react to pointer events 12 | case none 13 | /// Sets this property to its default value. 14 | case initial 15 | /// Inherits this property from its parent element. 16 | case inherit 17 | } 18 | 19 | public func PointerEvents(_ value: String) -> Property { 20 | Property(name: "pointer-events", value: value) 21 | } 22 | 23 | /// Defines whether or not an element reacts to pointer events 24 | public func PointerEvents(_ value: PointerEventsValue = .auto) -> Property { 25 | PointerEvents(value.rawValue) 26 | } 27 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/Resize.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Resize.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum ResizeValue: String { 9 | /// Default value. The user cannot resize the element 10 | case none 11 | /// The user can resize both the height and width of the element 12 | case both 13 | /// The user can resize the width of the element 14 | case horizontal 15 | /// The user can resize the height of the element 16 | case vertical 17 | /// Sets this property to its default value. 18 | case initial 19 | /// Inherits this property from its parent element. 20 | case inherit 21 | } 22 | 23 | public func Resize(_ value: String) -> Property { 24 | Property(name: "resize", value: value) 25 | } 26 | 27 | /// Defines if (and how) an element is resizable by the user 28 | public func Resize(_ value: ResizeValue = .none) -> Property { 29 | Resize(value.rawValue) 30 | } 31 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/Right.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Right.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum RightValue { 9 | /// Lets the browser calculate the right edge position. This is default 10 | case auto 11 | /// Sets the bottom edge position in px, cm, etc. Negative values are allowed. Read about length units 12 | case length(Unit) 13 | /// Sets this property to its default value. 14 | case initial 15 | /// Inherits this property from its parent element. 16 | case inherit 17 | 18 | var rawValue: String { 19 | switch self { 20 | case .auto: 21 | return "auto" 22 | case .length(let value): 23 | return value.rawValue 24 | case .initial: 25 | return "initial" 26 | case .inherit: 27 | return "inherit" 28 | } 29 | } 30 | } 31 | 32 | public func Right(_ value: String) -> Property { 33 | Property(name: "right", value: value) 34 | } 35 | 36 | /// Specifies the right position of a positioned element 37 | public func Right(_ value: RightValue = .auto) -> Property { 38 | Right(value.rawValue) 39 | } 40 | 41 | /// Specifies the right position of a positioned element 42 | public func Right(_ value: Unit) -> Property { 43 | Right(.length(value)) 44 | } 45 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/RowGap.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RowGap.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum RowGapValue { 9 | /// A specified length or % that will set the gap between the rows 10 | case length(Unit) 11 | /// Default value. Specifies a normal gap between the rows 12 | case normal 13 | /// Sets this property to its default value. 14 | case initial 15 | /// Inherits this property from its parent element. 16 | case inherit 17 | 18 | var rawValue: String { 19 | switch self { 20 | case .length(let value): 21 | return value.rawValue 22 | case .normal: 23 | return "normal" 24 | case .initial: 25 | return "initial" 26 | case .inherit: 27 | return "inherit" 28 | } 29 | } 30 | } 31 | 32 | public func RowGap(_ value: String) -> Property { 33 | Property(name: "row-gap", value: value) 34 | } 35 | 36 | /// Specifies the gap between the grid rows 37 | public func RowGap(_ value: RowGapValue = .normal) -> Property { 38 | RowGap(value.rawValue) 39 | } 40 | 41 | /// Specifies the gap between the grid rows 42 | public func RowGap(_ value: Unit) -> Property { 43 | RowGap(.length(value)) 44 | } 45 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/ScrollBehavior.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ScrollBehavior.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum ScrollBehaviorValue: String { 9 | /// Allows a straight jump "scroll effect" between elements within the scrolling box. This is default 10 | case auto 11 | /// Allows a smooth animated "scroll effect" between elements within the scrolling box. 12 | case smooth 13 | /// Sets this property to its default value. 14 | case initial 15 | /// Inherits this property from its parent element. 16 | case inherit 17 | } 18 | 19 | public func ScrollBehavior(_ value: String) -> Property { 20 | Property(name: "scroll-behavior", value: value) 21 | } 22 | 23 | /// Specifies whether to smoothly animate the scroll position in a scrollable box, instead of a straight jump 24 | public func ScrollBehavior(_ value: ScrollBehaviorValue = .auto) -> Property { 25 | ScrollBehavior(value.rawValue) 26 | } 27 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/TabSize.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TabSize.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum TabSizeValue { 9 | /// The number of space-characters to be displayed for each tab-character. Default value is 8 Play it » 10 | case number(Int) 11 | /// The length of a tab-character. This property value is not supported in any of the major browsers 12 | case length(Unit) 13 | /// Sets this property to its default value. 14 | case initial 15 | /// Inherits this property from its parent element. 16 | case inherit 17 | 18 | var rawValue: String { 19 | switch self { 20 | case .number(let value): 21 | return String(value) 22 | case .length(let value): 23 | return value.rawValue 24 | case .initial: 25 | return "initial" 26 | case .inherit: 27 | return "inherit" 28 | } 29 | } 30 | } 31 | 32 | public func TabSize(_ value: String) -> Property { 33 | Property(name: "tab-size", value: value) 34 | } 35 | 36 | /// Specifies the width of a tab character 37 | public func TabSize(_ value: TabSizeValue = .number(8)) -> Property { 38 | TabSize(value.rawValue) 39 | } 40 | 41 | /// Specifies the width of a tab character 42 | public func TabSize(_ value: Int = 8) -> Property { 43 | TabSize(.number(value)) 44 | } 45 | 46 | /// Specifies the width of a tab character 47 | public func TabSize(_ value: Unit) -> Property { 48 | TabSize(.length(value)) 49 | } 50 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/TableLayout.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TableLayout.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum TableLayoutValue: String { 9 | /// Browsers use an automatic table layout algorithm. The column width is set by the widest unbreakable content in the cells. The content will dictate the layout Play it » 10 | case auto 11 | /// Sets a fixed table layout algorithm. The table and column widths are set by the widths of table and col or by the width of the first row of cells. Cells in other rows do not affect column widths. If no widths are present on the first row, the column widths are divided equally across the table, regardless of content inside the cells Play it » 12 | case fixed 13 | /// Sets this property to its default value. Read about initial Play it » 14 | case initial 15 | /// Inherits this property from its parent element. Read about inherit 16 | case inherit 17 | } 18 | 19 | public func TableLayout(_ value: String) -> Property { 20 | Property(name: "table-layout", value: value) 21 | } 22 | 23 | /// Defines the algorithm used to lay out table cells, rows, and columns 24 | public func TableLayout(_ value: TableLayoutValue = .auto) -> Property { 25 | TableLayout(value.rawValue) 26 | } 27 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/TextAlign.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TextAlign.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum TextAlignValue: String { 9 | /// Aligns the text to the left Play it » 10 | case left 11 | /// Aligns the text to the right Play it » 12 | case right 13 | /// Centers the text Play it » 14 | case center 15 | /// Stretches the lines so that each line has equal width (like in newspapers and magazines) Play it » 16 | case justify 17 | /// Sets this property to its default value. Read about initial Play it » 18 | case initial 19 | /// Inherits this property from its parent element. Read about inherit 20 | case inherit 21 | } 22 | 23 | public func TextAlign(_ value: String) -> Property { 24 | Property(name: "text-align", value: value) 25 | } 26 | 27 | /// Specifies the horizontal alignment of text 28 | public func TextAlign(_ value: TextAlignValue) -> Property { 29 | TextAlign(value.rawValue) 30 | } 31 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/TextCombineUpright.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TextCombineUpright.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum TextCombineUprightValue { 9 | case none 10 | case all 11 | case digits(Int) 12 | case inherit 13 | case initial 14 | case revert 15 | case unset 16 | 17 | var rawValue: String { 18 | switch self { 19 | case .none: 20 | return "none" 21 | case .all: 22 | return "all" 23 | case let .digits(value): 24 | return "digits \(value)" 25 | case .inherit: 26 | return "inherit" 27 | case .initial: 28 | return "initial" 29 | case .revert: 30 | return "revert" 31 | case .unset: 32 | return "unset" 33 | } 34 | } 35 | } 36 | 37 | public func TextCombineUpright(_ value: String) -> Property { 38 | Property(name: "text-combine-upright", value: value) 39 | } 40 | 41 | /// Specifies the combination of multiple characters into the space of a single character 42 | public func TextCombineUpright(_ value: TextCombineUprightValue) -> Property { 43 | TextCombineUpright(value.rawValue) 44 | } 45 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/TextDecoration.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TextDecoration.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum TextDecorationValue { 9 | /// text-decoration-line Sets the kind of text decoration to use (like underline, overline, line-through) 10 | /// text-decoration-color Sets the color of the text decoration 11 | /// text-decoration-style Sets the style of the text decoration (like solid, wavy, dotted, dashed, double) 12 | case values(TextDecorationLineValue, TextDecorationColorValue, TextDecorationStyleValue) 13 | /// Sets this property to its default value. Read about initial 14 | case initial 15 | /// Inherits this property from its parent element. Read about inherit 16 | case inherit 17 | 18 | var rawValue: String { 19 | switch self { 20 | case let .values(line, color, style): 21 | return [line.rawValue, color.rawValue, style.rawValue].joined(separator: " ") 22 | case .initial: 23 | return "initial" 24 | case .inherit: 25 | return "inherit" 26 | } 27 | } 28 | 29 | } 30 | 31 | public func TextDecoration(_ value: String) -> Property { 32 | Property(name: "text-decoration", value: value) 33 | } 34 | 35 | /// Specifies the decoration added to text 36 | public func TextDecoration(_ value: TextDecorationValue) -> Property { 37 | TextDecoration(value.rawValue) 38 | } 39 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/TextDecorationColor.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TextDecorationColor.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum TextDecorationColorValue { 9 | /// Specifies the color of the text-decoration 10 | case color(CSSColor) 11 | /// Sets this property to its default value. 12 | case initial 13 | /// Inherits this property from its parent element. 14 | case inherit 15 | 16 | var rawValue: String { 17 | switch self { 18 | case .color(let value): 19 | return value.rawValue 20 | case .initial: 21 | return "initial" 22 | case .inherit: 23 | return "inherit" 24 | } 25 | } 26 | } 27 | 28 | public func TextDecorationColor(_ value: String) -> Property { 29 | Property(name: "text-decoration-color", value: value) 30 | } 31 | 32 | /// Specifies the color of the text-decoration 33 | public func TextDecorationColor(_ value: TextDecorationColorValue) -> Property { 34 | TextDecorationColor(value.rawValue) 35 | } 36 | 37 | /// Specifies the color of the text-decoration 38 | public func TextDecorationColor(_ value: CSSColor) -> Property { 39 | TextDecorationColor(.color(value)) 40 | } 41 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/TextDecorationLine.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TextDecorationLine.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum TextDecorationLineValue: String { 9 | /// Default value. Specifies no line for the text-decoration Play it » 10 | case none 11 | /// Specifies that a line will be displayed under the text Play it » 12 | case underline 13 | /// Specifies that a line will be displayed over the text Play it » 14 | case overline 15 | /// Specifies that a line will be displayed through the text Play it » 16 | case lineThrough = "line-through" 17 | /// Sets this property to its default value. Read about initial Play it » 18 | case initial 19 | /// Inherits this property from its parent element. Read about inherit 20 | case inherit 21 | } 22 | 23 | public func TextDecorationLine(_ value: String) -> Property { 24 | Property(name: "text-decoration-line", value: value) 25 | } 26 | 27 | /// Specifies the type of line in a text-decoration 28 | public func TextDecorationLine(_ value: TextDecorationLineValue = .none) -> Property { 29 | TextDecorationLine(value.rawValue) 30 | } 31 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/TextDecorationStyle.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TextDecorationStyle.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum TextDecorationStyleValue: String { 9 | /// Default value. The line will display as a single line Play it » 10 | case solid 11 | /// The line will display as a double line Play it » 12 | case double 13 | /// The line will display as a dotted line Play it » 14 | case dotted 15 | /// The line will display as a dashed line Play it » 16 | case dashed 17 | /// The line will display as a wavy line Play it » 18 | case wavy 19 | /// Sets this property to its default value. Read about initial Play it » 20 | case initial 21 | /// Inherits this property from its parent element. Read about inherit 22 | case inherit 23 | } 24 | 25 | public func TextDecorationStyle(_ value: String) -> Property { 26 | Property(name: "text-decoration-style", value: value) 27 | } 28 | 29 | /// Specifies the style of the line in a text decoration 30 | public func TextDecorationStyle(_ value: TextDecorationStyleValue = .solid) -> Property { 31 | TextDecorationStyle(value.rawValue) 32 | } 33 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/TextIndent.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TextIndent.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum TextIndentValue { 9 | /// Defines a fixed indentation in px, pt, cm, em, etc. Default value is 0. Read about length units 10 | case length(Unit) 11 | /// Sets this property to its default value. 12 | case initial 13 | /// Inherits this property from its parent element. 14 | case inherit 15 | 16 | var rawValue: String { 17 | switch self { 18 | case .length(let value): 19 | return value.rawValue 20 | case .initial: 21 | return "initial" 22 | case .inherit: 23 | return "inherit" 24 | } 25 | } 26 | } 27 | 28 | public func TextIndent(_ value: String) -> Property { 29 | Property(name: "text-indent", value: value) 30 | } 31 | 32 | /// Specifies the indentation of the first line in a text-block 33 | public func TextIndent(_ value: TextIndentValue) -> Property { 34 | TextIndent(value.rawValue) 35 | } 36 | 37 | /// Specifies the indentation of the first line in a text-block 38 | public func TextIndent(_ value: Unit) -> Property { 39 | TextIndent(.length(value)) 40 | } 41 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/TextJustify.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TextJustify.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum TextJustifyValue: String { 9 | /// The browser determines the justification algorithm Play it » 10 | case auto 11 | /// Increases/Decreases the space between words Play it » 12 | case interWord = "inter-word" 13 | /// Increases/Decreases the space between characters Play it » 14 | case interCharacter = "inter-character" 15 | /// Disables justification methods Play it » 16 | case none 17 | /// Sets this property to its default value. Read about initial Play it » 18 | case initial 19 | /// Inherits this property from its parent element. Read about inherit 20 | case inherit 21 | } 22 | 23 | public func TextJustify(_ value: String) -> Property { 24 | Property(name: "text-justify", value: value) 25 | } 26 | 27 | /// Specifies the justification method used when text-align is "justify" 28 | public func TextJustify(_ value: TextJustifyValue = .auto) -> Property { 29 | TextJustify(value.rawValue) 30 | } 31 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/TextOrientation.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TextOrientation.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum TextOrientationValue: String { 9 | case mixed 10 | case upright 11 | case sidewaysRight = "sideways-right" 12 | case sideways 13 | case useGlyphOrientation = "use-glyph-orientation" 14 | case inherit 15 | case initial 16 | case unset 17 | } 18 | 19 | public func TextOrientation(_ value: String) -> Property { 20 | Property(name: "text-orientation", value: value) 21 | } 22 | 23 | public func TextOrientation(_ value: TextOrientationValue) -> Property { 24 | TextOrientation(value.rawValue) 25 | } 26 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/TextOverflow.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TextOverflow.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum TextOverflowValue: String { 9 | /// Default value. The text is clipped and not accessible Play it » 10 | case clip 11 | /// Render an ellipsis ("...") to represent the clipped text Play it » 12 | case ellipsis 13 | /// Render the given string to represent the clipped text 14 | case string 15 | /// Sets this property to its default value. Read about initial Play it » 16 | case initial 17 | /// Inherits this property from its parent element. Read about inherit 18 | case inherit 19 | } 20 | 21 | public func TextOverflow(_ value: String) -> Property { 22 | Property(name: "text-overflow", value: value) 23 | } 24 | 25 | /// Specifies what should happen when text overflows the containing element 26 | public func TextOverflow(_ value: TextOverflowValue = .clip) -> Property { 27 | TextOverflow(value.rawValue) 28 | } 29 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/TextTransform.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TextTransform.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum TextTransformValue: String { 9 | /// No capitalization. The text renders as it is. This is default Play it » 10 | case none 11 | /// Transforms the first character of each word to uppercase Play it » 12 | case capitalize 13 | /// Transforms all characters to uppercase Play it » 14 | case uppercase 15 | /// Transforms all characters to lowercase Play it » 16 | case lowercase 17 | /// Sets this property to its default value. Read about initial Play it » 18 | case initial 19 | /// Inherits this property from its parent element. Read about inherit 20 | case inherit 21 | } 22 | 23 | public func TextTransform(_ value: String) -> Property { 24 | Property(name: "text-transform", value: value) 25 | } 26 | 27 | /// Controls the capitalization of text 28 | public func TextTransform(_ value: TextTransformValue) -> Property { 29 | TextTransform(value.rawValue) 30 | } 31 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/TextUnderlinePosition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TextUnderlinePosition.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum TextUnderlinePositionValue: String { 9 | case auto 10 | case under 11 | case left 12 | case right 13 | case underLeft = "under left" 14 | case rightUnder = "right under" 15 | case inherit 16 | case initial 17 | case revert 18 | case unset 19 | } 20 | 21 | public func TextUnderlinePosition(_ value: String) -> Property { 22 | Property(name: "text-underline-position", value: value) 23 | } 24 | 25 | /// Specifies the position of the underline which is set using the text-decoration property 26 | public func TextUnderlinePosition(_ value: TextUnderlinePositionValue) -> Property { 27 | TextUnderlinePosition(value.rawValue) 28 | } 29 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/Top.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Top.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum TopValue { 9 | /// Lets the browser calculate the top edge position. This is default 10 | case auto 11 | /// Sets the bottom edge position in px, cm, etc. Negative values are allowed. Read about length units 12 | case length(Unit) 13 | /// Sets this property to its default value. 14 | case initial 15 | /// Inherits this property from its parent element. 16 | case inherit 17 | 18 | var rawValue: String { 19 | switch self { 20 | case .auto: 21 | return "auto" 22 | case .length(let value): 23 | return value.rawValue 24 | case .initial: 25 | return "initial" 26 | case .inherit: 27 | return "inherit" 28 | } 29 | } 30 | } 31 | public func Top(_ value: String) -> Property { 32 | Property(name: "top", value: value) 33 | } 34 | 35 | /// Specifies the top position of a positioned element 36 | public func Top(_ value: TopValue = .auto) -> Property { 37 | Top(value.rawValue) 38 | } 39 | 40 | /// Specifies the top position of a positioned element 41 | public func Top(_ value: Unit) -> Property { 42 | Top(.length(value)) 43 | } 44 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/TransformStyle.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TransformStyle.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum TransformStyleValue: String { 9 | /// Specifies that child elements will NOT preserve its 3D position. This is default 10 | case flat 11 | /// Specifies that child elements will preserve its 3D position 12 | case preserve3d = "preserve-3d" 13 | /// Sets this property to its default value. Read about initial 14 | case initial 15 | /// Inherits this property from its parent element. Read about inherit 16 | case inherit 17 | } 18 | 19 | public func TransformStyle(_ value: String) -> Property { 20 | Property(name: "transform-style", value: value) 21 | } 22 | 23 | /// Specifies how nested elements are rendered in 3D space 24 | public func TransformStyle(_ value: TransformStyleValue = .flat) -> Property { 25 | TransformStyle(value.rawValue) 26 | } 27 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/UnicodeBidi.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UnicodeBidi.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum UnicodeBidiValue: String { 9 | /// The element does not open an additional level of embedding. This is default 10 | case normal 11 | /// For inline elements, this value opens an additional level of embedding 12 | case embed 13 | /// For inline elements, this creates an override. For block elements, this creates an override for inline-level descendants not within another block element 14 | case bidiOverride = "bidi-override" 15 | /// The element is isolated from its siblings 16 | case isolate 17 | case isolateOverride = "isolate-override" 18 | case plaintext 19 | /// Sets this property to its default value. 20 | case initial 21 | /// Inherits this property from its parent element. 22 | case inherit 23 | } 24 | 25 | 26 | public func UnicodeBidi(_ value: String) -> Property { 27 | Property(name: "unicode-bidi", value: value) 28 | } 29 | 30 | /// Used together with the direction property to set or return whether the text should be overridden to support multiple languages in the same document 31 | public func UnicodeBidi(_ value: UnicodeBidiValue = .normal) -> Property { 32 | UnicodeBidi(value.rawValue) 33 | } 34 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/UserSelect.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UserSelect.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum UserSelectValue: String { 9 | /// Default. Text can be selected if the browser allows it 10 | case auto 11 | /// Prevent text selection 12 | case none 13 | /// The text can be selected by the user 14 | case text 15 | /// Text selection is made with one click instead of a double-click 16 | case all 17 | } 18 | 19 | public func UserSelect(_ value: String) -> Property { 20 | Property(name: "user-select", value: value) 21 | } 22 | 23 | /// Specifies whether the text of an element can be selected 24 | public func UserSelect(_ value: UserSelectValue = .auto) -> Property { 25 | UserSelect(value.rawValue) 26 | } 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/Visibility.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Visibility.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum VisibilityValue: String { 9 | /// Default value. The element is visible 10 | case visible 11 | /// The element is hidden (but still takes up space) 12 | case hidden 13 | /// Only for table rows (), row groups (), columns (), column groups (). 14 | /// This value removes a row or column, but it does not affect the table layout. 15 | /// The space taken up by the row or column will be available for other content. 16 | /// If collapse is used on other elements, it renders as "hidden" 17 | case collapse 18 | /// Sets this property to its default value. 19 | case initial 20 | /// Inherits this property from its parent element. 21 | case inherit 22 | } 23 | 24 | public func Visibility(_ value: String) -> Property { 25 | Property(name: "visibility", value: value) 26 | } 27 | 28 | /// Specifies whether or not an element is visible 29 | public func Visibility(_ value: VisibilityValue = .visible) -> Property { 30 | Visibility(value.rawValue) 31 | } 32 | -------------------------------------------------------------------------------- /Sources/SwiftCss/Properties/WhiteSpace.swift: -------------------------------------------------------------------------------- 1 | // 2 | // WhiteSpace.swift 3 | // SwiftCss 4 | // 5 | // Created by Tibor Bodecs on 2021. 07. 10.. 6 | // 7 | 8 | public enum WhiteSpaceValue: String { 9 | /// Sequences of whitespace will collapse into a single whitespace. Text will wrap when necessary. This is default 10 | case normal 11 | /// Sequences of whitespace will collapse into a single whitespace. Text will never wrap to the next line. The text continues on the same line until a
tag is encountered 12 | case nowrap 13 | /// Whitespace is preserved by the browser. Text will only wrap on line breaks. Acts like the
 tag in HTML    
14 |     case pre
15 |     /// Sequences of whitespace will collapse into a single whitespace. Text will wrap when necessary, and on line breaks    
16 |     case preLine = "pre-line"
17 |     /// Whitespace is preserved by the browser. Text will wrap when necessary, and on line breaks    
18 |     case preWrap = "pre-wrap"
19 |     /// Sets this property to its default value.     
20 |     case initial
21 |     /// Inherits this property from its parent element. 
22 |     case inherit
23 | }
24 | 
25 | public func WhiteSpace(_ value: String) -> Property {
26 |     Property(name: "white-space", value: value)
27 | }
28 | 
29 | /// Specifies how white-space inside an element is handled
30 | public func WhiteSpace(_ value: WhiteSpaceValue = .normal) -> Property {
31 |     WhiteSpace(value.rawValue)
32 | }
33 | 


--------------------------------------------------------------------------------
/Sources/SwiftCss/Properties/Widows.swift:
--------------------------------------------------------------------------------
 1 | //
 2 | //  Widows.swift
 3 | //  SwiftCss
 4 | //
 5 | //  Created by Tibor Bodecs on 2021. 07. 10..
 6 | //
 7 | 
 8 | public enum WidowsValue {
 9 |     /// An integer that specifies the minimum number of visible lines. Negative values are not allowed. The default value is 2
10 |     case number(Int)
11 |     /// Sets this property to its default value. 
12 |     case initial
13 |     /// Inherits this property from its parent element. 
14 |     case inherit
15 |     
16 |     var rawValue: String {
17 |         switch self {
18 |         case .number(let value):
19 |             return String(value)
20 |         case .initial:
21 |             return "initial"
22 |         case .inherit:
23 |             return "inherit"
24 |         }
25 |     }
26 | }
27 | 
28 | public func Widows(_ value: String) -> Property {
29 |     Property(name: "widows", value: value)
30 | }
31 | 
32 | /// Sets the minimum number of lines that must be left at the top of a page when a page break occurs inside an element
33 | public func Widows(_ value: WidowsValue = .number(2)) -> Property {
34 |     Widows(value.rawValue)
35 | }
36 | 


--------------------------------------------------------------------------------
/Sources/SwiftCss/Properties/Width.swift:
--------------------------------------------------------------------------------
 1 | //
 2 | //  Width.swift
 3 | //  SwiftCss
 4 | //
 5 | //  Created by Tibor Bodecs on 2021. 07. 10..
 6 | //
 7 | 
 8 | public enum WidthValue {
 9 |     /// Default value. The browser calculates the width    
10 |     case auto
11 |     /// Defines the width in px, cm, etc. Read about length units    
12 |     case length(Unit)
13 |     /// Sets this property to its default value.     
14 |     case initial
15 |     /// Inherits this property from its parent element. 
16 |     case inherit
17 |     
18 |     var rawValue: String {
19 |         switch self {
20 |         case .auto:
21 |             return "auto"
22 |         case .length(let value):
23 |             return value.rawValue
24 |         case .initial:
25 |             return "initial"
26 |         case .inherit:
27 |             return "inherit"
28 |         }
29 |     }
30 | }
31 | 
32 | public func Width(_ value: String) -> Property {
33 |     Property(name: "width", value: value)
34 | }
35 | 
36 | /// Sets the width of an element
37 | public func Width(_ value: WidthValue = .auto) -> Property {
38 |     Width(value.rawValue)
39 | }
40 | 
41 | /// Sets the width of an element
42 | public func Width(_ value: Unit) -> Property {
43 |     Width(.length(value))
44 | }
45 | 


--------------------------------------------------------------------------------
/Sources/SwiftCss/Properties/WordBreak.swift:
--------------------------------------------------------------------------------
 1 | //
 2 | //  WordBreak.swift
 3 | //  SwiftCss
 4 | //
 5 | //  Created by Tibor Bodecs on 2021. 07. 10..
 6 | //
 7 | 
 8 | public enum WordBreakValue: String {
 9 |     /// Default value. Uses default line break rules
10 |     case normal
11 |     /// To prevent overflow, word may be broken at any character
12 |     case breakAll = "break-all"
13 |     /// Word breaks should not be used for Chinese/Japanese/Korean (CJK) text. Non-CJK text behavior is the same as value "normal"
14 |     case keepAll = "keep-all"
15 |     /// To prevent overflow, word may be broken at arbitrary points
16 |     case breakWord = "break-word"
17 |     /// Sets this property to its default value. 
18 |     case initial
19 |     /// Inherits this property from its parent element. 
20 |     case inherit
21 | }
22 | 
23 | public func WordBreak(_ value: String) -> Property {
24 |     Property(name: "word-break", value: value)
25 | }
26 | 
27 | /// Specifies how words should break when reaching the end of a line
28 | public func WordBreak(_ value: WordBreakValue = .normal) -> Property {
29 |     WordBreak(value.rawValue)
30 | }
31 | 


--------------------------------------------------------------------------------
/Sources/SwiftCss/Properties/WordSpacing.swift:
--------------------------------------------------------------------------------
 1 | //
 2 | //  WordSpacing.swift
 3 | //  SwiftCss
 4 | //
 5 | //  Created by Tibor Bodecs on 2021. 07. 10..
 6 | //
 7 | 
 8 | public enum WordSpacingValue {
 9 |     /// Defines normal space between words (0.25em) . This is default
10 |     case normal
11 |     /// Defines an additional space between words (in px, pt, cm, em, etc). Negative values are allowed. Read about length units    
12 |     case length(Unit)
13 |     /// Sets this property to its default value.
14 |     case initial
15 |     /// Inherits this property from its parent element.
16 |     case inherit
17 |     
18 |     var rawValue: String {
19 |         switch self {
20 |         case .normal:
21 |             return "normal"
22 |         case .length(let value):
23 |             return value.rawValue
24 |         case .initial:
25 |             return "initial"
26 |         case .inherit:
27 |             return "inherit"
28 |         }
29 |     }
30 | }
31 | 
32 | public func WordSpacing(_ value: String) -> Property {
33 |     Property(name: "word-spacing", value: value)
34 | }
35 | 
36 | /// Increases or decreases the space between words in a text
37 | public func WordSpacing(_ value: WordSpacingValue = .normal) -> Property {
38 |     WordSpacing(value.rawValue)
39 | }
40 | 
41 | /// Increases or decreases the space between words in a text
42 | public func WordSpacing(_ value: Unit) -> Property {
43 |     WordSpacing(.length(value))
44 | }
45 | 


--------------------------------------------------------------------------------
/Sources/SwiftCss/Properties/WordWrap.swift:
--------------------------------------------------------------------------------
 1 | //
 2 | //  WordWrap.swift
 3 | //  SwiftCss
 4 | //
 5 | //  Created by Tibor Bodecs on 2021. 07. 10..
 6 | //
 7 | 
 8 | public enum WordWrapValue: String {
 9 |     /// Break words only at allowed break points
10 |     case normal
11 |     /// Allows unbreakable words to be broken
12 |     case breakWord = "break-word"
13 |     /// Sets this property to its default value.
14 |     case initial
15 |     /// Inherits this property from its parent element.
16 |     case inherit
17 | }
18 | 
19 | public func WordWrap(_ value: String) -> Property {
20 |     Property(name: "word-wrap", value: value)
21 | }
22 | 
23 | /// Allows long, unbreakable words to be broken and wrap to the next line
24 | public func WordWrap(_ value: WordWrapValue = .normal) -> Property {
25 |     WordWrap(value.rawValue)
26 | }
27 | 


--------------------------------------------------------------------------------
/Sources/SwiftCss/Properties/WritingMode.swift:
--------------------------------------------------------------------------------
 1 | //
 2 | //  WritingMode.swift
 3 | //  SwiftCss
 4 | //
 5 | //  Created by Tibor Bodecs on 2021. 07. 10..
 6 | //
 7 | 
 8 | public enum WritingModeValue: String {
 9 |     /// Let the content flow horizontally from left to right, vertically from top to bottom
10 |     case horizontalTb = "horizontal-tb"
11 |     /// Let the content flow vertically from top to bottom, horizontally from right to left
12 |     case verticalRl = "vertical-rl"
13 |     /// Let the content flow vertically from top to bottom, horizontally from left to right
14 |     case verticalLr = "vertical-lr"
15 | }
16 | 
17 | 
18 | public func WritingMode(_ value: String) -> Property {
19 |     Property(name: "writing-mode", value: value)
20 | }
21 | 
22 | /// Specifies whether lines of text are laid out horizontally or vertically
23 | public func WritingMode(_ value: WritingModeValue = .horizontalTb) -> Property {
24 |     WritingMode(value.rawValue)
25 | }
26 | 


--------------------------------------------------------------------------------
/Sources/SwiftCss/Properties/ZIndex.swift:
--------------------------------------------------------------------------------
 1 | //
 2 | //  ZIndex.swift
 3 | //  SwiftCss
 4 | //
 5 | //  Created by Tibor Bodecs on 2021. 07. 10..
 6 | //
 7 | 
 8 | public enum ZIndexValue: String {
 9 |     /// Sets the stack order equal to its parents. This is default
10 |     case auto
11 |     /// Sets the stack order of the element. Negative numbers are allowed
12 |     case number
13 |     /// Sets this property to its default value.
14 |     case initial
15 |     /// Inherits this property from its parent element.
16 |     case inherit
17 | }
18 | 
19 | public func ZIndex(_ value: String) -> Property {
20 |     Property(name: "z-index", value: value)
21 | }
22 | 
23 | /// Sets the stack order of a positioned element
24 | public func ZIndex(_ value: ZIndexValue = .auto) -> Property {
25 |     ZIndex(value.rawValue)
26 | }
27 | 


--------------------------------------------------------------------------------
/Sources/SwiftCss/Rules/Charset.swift:
--------------------------------------------------------------------------------
 1 | //
 2 | //  Charset.swift
 3 | //  SwiftCss
 4 | //
 5 | //  Created by Tibor Bodecs on 2021. 07. 24..
 6 | //
 7 | 
 8 | /// Specifies the character encoding to use
 9 | public struct Charset: Rule {
10 |     var name: String
11 |     
12 |     public init(_ name: String) {
13 |         self.name = name
14 |     }
15 | }
16 | 


--------------------------------------------------------------------------------
/Sources/SwiftCss/Rules/FontFace.swift:
--------------------------------------------------------------------------------
 1 | //
 2 | //  FontFace.swift
 3 | //  SwiftCss
 4 | //
 5 | //  Created by Tibor Bodecs on 2021. 07. 24..
 6 | //
 7 | 
 8 | public struct FontFace: Rule {
 9 | 
10 |     var properties: [Property]
11 | 
12 |     public init(@PropertyBuilder _ builder: () -> [Property]) {
13 |         self.properties = builder()
14 |     }
15 |     
16 | }
17 | 


--------------------------------------------------------------------------------
/Sources/SwiftCss/Rules/Import.swift:
--------------------------------------------------------------------------------
 1 | //
 2 | //  Import.swift
 3 | //  SwiftCss
 4 | //
 5 | //  Created by Tibor Bodecs on 2021. 07. 24..
 6 | //
 7 | 
 8 | /// The @import rule allows you to import a style sheet into another style sheet.
 9 | ///
10 | /// The @import rule must be at the top of the document (but after any @charset declaration).
11 | ///
12 | /// The @import rule also supports media queries, so you can allow the import to be media-dependent.
13 | public struct Import: Rule {
14 |     var name: String
15 |     
16 |     public init(_ name: String) {
17 |         self.name = name
18 |     }
19 | }
20 | 


--------------------------------------------------------------------------------
/Sources/SwiftCss/Rules/Keyframes.swift:
--------------------------------------------------------------------------------
 1 | //
 2 | //  Keyframes.swift
 3 | //  SwiftCss
 4 | //
 5 | //  Created by Tibor Bodecs on 2021. 07. 24..
 6 | //
 7 | 
 8 | public struct Keyframes: Rule {
 9 |     
10 |     var name: String
11 |     var selectors: [Selector]
12 | 
13 |     public init(_ name: String, @SelectorBuilder _ builder: () -> [Selector]) {
14 |         self.name = name
15 |         self.selectors = builder()
16 |     }
17 | }
18 | 


--------------------------------------------------------------------------------
/Sources/SwiftCss/Rules/Media.swift:
--------------------------------------------------------------------------------
 1 | //
 2 | //  Media.swift
 3 | //  SwiftCss
 4 | //
 5 | //  Created by Tibor Bodecs on 2021. 07. 09..
 6 | //
 7 | 
 8 | public struct Media: Rule {
 9 | 
10 |     public enum Screen: String {
11 |         /// 0-599px
12 |         case xs = "screen and (max-width: 599px)"
13 |         /// 600-899px
14 |         case s = "screen and (min-width: 600px)"
15 |         /// 900-1199px
16 |         case normal = "screen and (min-width: 900px)"
17 |         /// 1200-1799px
18 |         case l = "screen and (min-width: 1200px)"
19 |         /// 1800+px
20 |         case xl = "screen and (min-width: 1800px)"
21 |         /// dark mode
22 |         case dark = "screen and (prefers-color-scheme: dark)"
23 |         /// standalone app screen
24 |         case standalone = "screen and (display-mode: standalone)"
25 |     }
26 | 
27 |     var query: String?
28 |     var selectors: [Selector]
29 | 
30 |     public init(_ query: String? = nil, @SelectorBuilder _ builder: () -> [Selector]) {
31 |         self.query = query
32 |         self.selectors = builder()
33 |     }
34 |     
35 |     public init(screen: Screen, @SelectorBuilder _ builder: () -> [Selector]) {
36 |         self.init(screen.rawValue, builder)
37 |     }    
38 | }
39 | 


--------------------------------------------------------------------------------
/Sources/SwiftCss/Stylesheet/Stylesheet.swift:
--------------------------------------------------------------------------------
 1 | //
 2 | //  Stylesheet.swift
 3 | //  SwiftCss
 4 | //
 5 | //  Created by Tibor Bodecs on 2021. 07. 09..
 6 | //
 7 | 
 8 | public struct Stylesheet {
 9 |     let rules: [Rule]
10 | 
11 |     public init(@RuleBuilder _ builder: () -> [Rule]) {
12 |         self.rules = builder()
13 |     }
14 | 
15 |     public init(_ rules: [Rule]) {
16 |         self.rules = rules
17 |     }
18 | }
19 | 


--------------------------------------------------------------------------------