-
Notifications
You must be signed in to change notification settings - Fork 13
✨ Add LuminareButtonRow
#29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
8f4577c
LuminareButtonCompose
omeriadon 90b715c
improve modifier logic
omeriadon bcb6263
fix formatting
omeriadon 2fcb560
fix formatting
omeriadon 9edc1f7
Rename SwiftUI Preview
omeriadon 2232586
namespace LuminareButtonCompose.PositionInList
omeriadon e12073b
fix formatting
omeriadon a0e23f6
improve LuminareButtonBuilder
omeriadon 96b5c25
add .luminareButtonComposeSpacing modifier
omeriadon f3afd29
improve ForEach
omeriadon 42f9c9c
improve button paramter type
omeriadon 169211d
fix formatting + syntax
omeriadon fdda7eb
fix the builder component type inconsistency + add comments
omeriadon 19b615b
use VariadicViews
omeriadon 41f19b6
fix comment
omeriadon 6bf80a2
Add Equatable conformance to LuminareButtonComposePosition
omeriadon b2288fe
fix comment
omeriadon 2b46a08
fix LuminareButtonCompose
omeriadon 890c80c
Add documentation for LuminareButtonCompose
omeriadon 9576225
use luminare rounding enironment value instead of explicit
omeriadon d79b898
lint
omeriadon f3698c4
lint
omeriadon 350eff8
update documentation
omeriadon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
111 changes: 111 additions & 0 deletions
111
Sources/Luminare/Components/Composes/LuminareButtonRow.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,111 @@ | ||
| // | ||
| // LuminareButtonRow.swift | ||
| // Luminare | ||
| // | ||
| // Created by Adon Omeri on 23/3/2026. | ||
| // | ||
|
|
||
| import SwiftUI | ||
|
|
||
| @resultBuilder | ||
| public struct LuminareButtonBuilder { | ||
| public static func buildExpression(_ expression: some View) -> [AnyView] { | ||
| [AnyView(expression)] | ||
| } | ||
|
|
||
| public static func buildBlock(_ components: [AnyView]...) -> [AnyView] { | ||
| components.flatMap(\.self) | ||
| } | ||
|
|
||
| public static func buildOptional(_ component: [AnyView]?) -> [AnyView] { | ||
| component ?? [] | ||
| } | ||
|
|
||
| public static func buildEither(first component: [AnyView]) -> [AnyView] { | ||
| component | ||
| } | ||
|
|
||
| public static func buildEither(second component: [AnyView]) -> [AnyView] { | ||
| component | ||
| } | ||
|
|
||
| public static func buildArray(_ components: [[AnyView]]) -> [AnyView] { | ||
| components.flatMap(\.self) | ||
| } | ||
|
|
||
| public static func buildLimitedAvailability(_ component: [AnyView]) -> [AnyView] { | ||
| component | ||
| } | ||
| } | ||
|
|
||
| public struct LuminareButtonRow: View { | ||
| @Environment(\.luminareButtonComposeSpacing) private var spacing | ||
|
|
||
| @Environment(\.luminareTopLeadingRounded) private var topLeadingRounded | ||
| @Environment(\.luminareTopTrailingRounded) private var topTrailingRounded | ||
| @Environment(\.luminareBottomLeadingRounded) private var bottomLeadingRounded | ||
| @Environment(\.luminareBottomTrailingRounded) private var bottomTrailingRounded | ||
|
|
||
| private let buttons: [AnyView] | ||
|
|
||
| public init( | ||
| @LuminareButtonBuilder _ buttons: () -> [AnyView] | ||
| ) { | ||
| self.buttons = buttons() | ||
| } | ||
|
|
||
| public var body: some View { | ||
| HStack(spacing: spacing) { | ||
| ForEach(buttons.indices, id: \.self) { index in | ||
| let button = buttons[index] | ||
| let isFirst = index == 0 | ||
| let isLast = index == buttons.count - 1 | ||
|
|
||
| button | ||
| .luminareRoundingBehavior( | ||
| topLeading: isFirst ? topLeadingRounded : false, | ||
| topTrailing: isLast ? topTrailingRounded : false, | ||
| bottomLeading: isFirst ? bottomLeadingRounded : false, | ||
| bottomTrailing: isLast ? bottomTrailingRounded : false | ||
| ) | ||
| } | ||
| } | ||
| .buttonStyle(.luminare) | ||
| } | ||
| } | ||
|
|
||
| // MARK: - Preview | ||
|
|
||
| @available(macOS 15.0, *) | ||
| #Preview( | ||
| "LuminareButtonRow", | ||
| traits: .sizeThatFitsLayout | ||
| ) { | ||
| LuminarePane { | ||
| LuminareSection { | ||
| LuminareButtonRow { | ||
| Button { | ||
| print(1) | ||
| } label: { | ||
| Text("Button 1") | ||
| } | ||
|
|
||
| Button { | ||
| print(2) | ||
| } label: { | ||
| Text("Button 2") | ||
| } | ||
|
|
||
| Button { | ||
| print(3) | ||
| } label: { | ||
| Text("Button 3") | ||
| } | ||
| } | ||
| .luminareRoundingBehavior(top: true) | ||
|
|
||
| Text("Other content ...") | ||
| .foregroundStyle(.secondary) | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
Sources/Luminare/Luminare.docc/Components/Compose/LuminareButtonRow.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| # ``Luminare/LuminareButtonRow`` | ||
|
|
||
| A horizontalrow of Luminare buttons. | ||
|
|
||
|
|
||
|
|
||
| @Row { | ||
| @Column { | ||
| ```swift | ||
| LuminareButtonRow { | ||
| Button { | ||
| print(1) | ||
| } label: { | ||
| Text("Button 1") | ||
| } | ||
|
|
||
| Button { | ||
| print(2) | ||
| } label: { | ||
| Text("Button 2") | ||
| } | ||
|
|
||
| Button { | ||
| print(3) | ||
| } label: { | ||
| Text("Button 3") | ||
| } | ||
| } | ||
| ``` | ||
| } | ||
| } | ||
|
|
||
| @Row { | ||
| @Column { | ||
|  | ||
| } | ||
| } |
Binary file added
BIN
+16.9 KB
...sources/Previews Screenshots/Compose/LuminareButtonRow/LuminareButtonRow@1x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+27.6 KB
...es/Previews Screenshots/Compose/LuminareButtonRow/LuminareButtonRow~dark@1x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.