Skip to content

Commit

Permalink
Upgrade the package (#123)
Browse files Browse the repository at this point in the history
* Fix tokenizing of a negative value

* Fix the tokenizing of an negation operator

* Fix missing border radius on the button component

* Add background opacity to the button component

* Rename javascript file of the selectfield component

* Change the listener for the dropdown component

* Fix the style for the formfield invalidation

* Add opacity properties for background and border

* Fix the stack alignment and remove the stack column component

* Add an aspect ratio to the image component

* Add a better distinction for block and inline padding

* Fix component test

* Add an edge set for the padding

* Add a view method for margins

* Fix wrong padding declaration

* Rename the group component

The name declaration group is already taken for the vector element, therefore the htmlkit component needs a new name declaration.

* Fix the margin for the modal component

The margin for the modal gets neutralised by the css reset, but the modal dialog should always be centered.

* Revise some of the image component

* Fix failing test

* Add a navigation component

* Add padding methods to the list component

* Revise some of the css

* Revise the css token handling

* Create a new file for option sets

* Add more text styling methods for the text and link component

* Extend the state methods for button and view components with a condition
  • Loading branch information
mattesmohr authored Jul 1, 2023
1 parent e919e51 commit d166ef5
Show file tree
Hide file tree
Showing 57 changed files with 2,213 additions and 699 deletions.
50 changes: 46 additions & 4 deletions Sources/HTMLKitComponents/Components/Button.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ extension Button: ButtonModifier {
return self.mutate(buttonstyle: style.rawValue)
}

public func disabled() -> Button {
return self.mutate(buttonstate: Tokens.ViewState.disabled.rawValue)
}

public func disabled(_ condition: Bool) -> Button {

if condition {
Expand Down Expand Up @@ -113,12 +117,21 @@ extension Button: ViewModifier {
return self.mutate(viewstate: Tokens.ViewState.hidden.rawValue)
}

public func hidden(_ condition: Bool) -> Button {

if condition {
return self.mutate(viewstate: Tokens.ViewState.hidden.rawValue)
}

return self
}

public func colorScheme(_ scheme: Tokens.ColorScheme) -> Button {
return self.mutate(scheme: scheme.rawValue)
}

public func padding(_ length: Tokens.BoxPadding) -> Button {
return self.mutate(padding: length.rawValue)
public func padding(insets: EdgeSet = .all, length: Tokens.PaddingLength = .small) -> Button {
return self.mutate(padding: length.rawValue, insets: insets)
}

public func borderShape(_ shape: Tokens.BorderShape) -> Button {
Expand All @@ -128,6 +141,14 @@ extension Button: ViewModifier {
public func borderColor(_ color: Tokens.BorderColor) -> Button {
return self.mutate(bordercolor: color.rawValue)
}

public func frame(width: Tokens.ColumnSize, offset: Tokens.ColumnOffset? = nil) -> Button {
return mutate(frame: width.rawValue, offset: offset?.rawValue)
}

public func margin(insets: EdgeSet, length: Tokens.MarginLength = .small) -> Button {
return self.mutate(margin: length.rawValue, insets: insets)
}
}

/// A component that initiates an action.
Expand Down Expand Up @@ -196,6 +217,10 @@ extension LinkButton: ButtonModifier {
return self.mutate(buttonstyle: style.rawValue)
}

public func disabled() -> LinkButton {
return self.mutate(buttonstate: Tokens.ViewState.disabled.rawValue)
}

public func disabled(_ condition: Bool) -> LinkButton {

if condition {
Expand Down Expand Up @@ -224,12 +249,21 @@ extension LinkButton: ViewModifier {
return self.mutate(viewstate: Tokens.ViewState.hidden.rawValue)
}

public func hidden(_ condition: Bool) -> LinkButton {

if condition {
return self.mutate(viewstate: Tokens.ViewState.hidden.rawValue)
}

return self
}

public func colorScheme(_ scheme: Tokens.ColorScheme) -> LinkButton {
return self.mutate(scheme: scheme.rawValue)
}

public func padding(_ length: Tokens.BoxPadding) -> LinkButton {
return self.mutate(padding: length.rawValue)
public func padding(insets: EdgeSet = .all, length: Tokens.PaddingLength = .small) -> LinkButton {
return self.mutate(padding: length.rawValue, insets: insets)
}

public func borderShape(_ shape: Tokens.BorderShape) -> LinkButton {
Expand All @@ -239,4 +273,12 @@ extension LinkButton: ViewModifier {
public func borderColor(_ color: Tokens.BorderColor) -> LinkButton {
return self.mutate(bordercolor: color.rawValue)
}

public func frame(width: Tokens.ColumnSize, offset: Tokens.ColumnOffset? = nil) -> LinkButton {
return mutate(frame: width.rawValue, offset: offset?.rawValue)
}

public func margin(insets: EdgeSet = .all, length: Tokens.MarginLength = .small) -> LinkButton {
return self.mutate(margin: length.rawValue, insets: insets)
}
}
25 changes: 21 additions & 4 deletions Sources/HTMLKitComponents/Components/Card.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,37 @@ extension Card: ViewModifier {
return self.mutate(viewstate: Tokens.ViewState.hidden.rawValue)
}

public func hidden(_ condition: Bool) -> Card {

if condition {
return self.mutate(viewstate: Tokens.ViewState.hidden.rawValue)
}

return self
}

public func colorScheme(_ scheme: Tokens.ColorScheme) -> Card {
return self.mutate(scheme: scheme.rawValue)
}

public func padding(_ length: Tokens.BoxPadding) -> Card {
return self.mutate(padding: length.rawValue)
public func padding(insets: EdgeSet = .all, length: Tokens.PaddingLength = .small) -> Card {
return self.mutate(padding: length.rawValue, insets: insets)
}

public func borderShape(_ shape: Tokens.BorderShape) -> Card {
return self.mutate(class: shape.rawValue)
return self.mutate(bordershape: shape.rawValue)
}

public func borderColor(_ color: Tokens.BorderColor) -> Card {
return self.mutate(class: color.rawValue)
return self.mutate(bordercolor: color.rawValue)
}

public func frame(width: Tokens.ColumnSize, offset: Tokens.ColumnOffset? = nil) -> Card {
return mutate(frame: width.rawValue, offset: offset?.rawValue)
}

public func margin(insets: EdgeSet = .all, length: Tokens.MarginLength = .small) -> Card {
return self.mutate(margin: length.rawValue, insets: insets)
}
}

25 changes: 23 additions & 2 deletions Sources/HTMLKitComponents/Components/Dropdown.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ extension Dropdown: ButtonModifier {
return self.mutate(buttonstyle: style.rawValue)
}

public func disabled() -> Dropdown {
return self.mutate(buttonstate: Tokens.ViewState.disabled.rawValue)
}

public func disabled(_ condition: Bool) -> Dropdown {

if condition {
Expand All @@ -83,8 +87,17 @@ extension Dropdown: ViewModifier {
return self.mutate(viewstate: Tokens.ViewState.hidden.rawValue)
}

public func padding(_ length: Tokens.BoxPadding) -> Dropdown {
return self.mutate(padding: length.rawValue)
public func hidden(_ condition: Bool) -> Dropdown {

if condition {
return self.mutate(viewstate: Tokens.ViewState.hidden.rawValue)
}

return self
}

public func padding(insets: EdgeSet = .all, length: Tokens.PaddingLength = .small) -> Dropdown {
return self.mutate(padding: length.rawValue, insets: insets)
}

public func borderShape(_ shape: Tokens.BorderShape) -> Dropdown {
Expand All @@ -102,4 +115,12 @@ extension Dropdown: ViewModifier {
public func colorScheme(_ scheme: Tokens.ColorScheme) -> Dropdown {
return self.mutate(scheme: scheme.rawValue)
}

public func frame(width: Tokens.ColumnSize, offset: Tokens.ColumnOffset? = nil) -> Dropdown {
return mutate(frame: width.rawValue, offset: offset?.rawValue)
}

public func margin(insets: EdgeSet = .all, length: Tokens.MarginLength = .small) -> Dropdown {
return self.mutate(margin: length.rawValue, insets: insets)
}
}
Loading

0 comments on commit d166ef5

Please sign in to comment.