Skip to content

Commit 334f864

Browse files
authored
Merge pull request #35 from maclong9/main
chore: auto-generated quick fix
2 parents 7c084b3 + fb379df commit 334f864

File tree

16 files changed

+519
-5
lines changed

16 files changed

+519
-5
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,16 @@ To use WebUI, ensure you have the following installed:
7171

7272
## Usage
7373

74+
### Script
75+
76+
If you pass no template the static one will be used by default and if you pass no project name it will default to `web-ui-template`
77+
78+
```sh
79+
curl -fSls https://raw.githubusercontent.com/maclong9/web-ui/refs/heads/main/initialize.sh | sh -s -- --template [static|server] [<project-name>]
80+
```
81+
82+
### Manually
83+
7484
Add the following to your package dependencies:
7585
``` Package.swift
7686
dependencies: [

Sources/WebUI/Elements/Base/List.swift

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,24 @@ public enum ListType: String {
1414
case unordered = "ul"
1515
}
1616

17+
/// Defines styles for HTML list elements.
18+
///
19+
/// HTML supports various styles for list elements, such as disc, circle, or square.
20+
/// This enum provides a type-safe way to specify which style to use.
21+
public enum ListStyle: String {
22+
/// Creates a list with no bullets or numbers.
23+
case none = ""
24+
25+
/// Creates a list with bullets shaped like discs.
26+
case disc
27+
28+
/// Creates a list with bullets shaped like circles.
29+
case circle
30+
31+
/// Creates a list with bullets shaped like squares.
32+
case square = "[square]"
33+
}
34+
1735
/// Generates HTML list elements (`<ul>` or `<ol>`).
1836
///
1937
/// `List` can be rendered as an unordered list with bullet points when sequence is unimportant,
@@ -32,11 +50,13 @@ public enum ListType: String {
3250
/// ```
3351
public final class List: Element {
3452
let type: ListType
53+
let style: ListStyle
3554

3655
/// Creates a new HTML list element (`<ul>` or `<ol>`).
3756
///
3857
/// - Parameters:
3958
/// - type: List type (ordered or unordered), defaults to unordered.
59+
/// - style: List style (disc, circle, or square), defaults to none.
4060
/// - id: Unique identifier for the HTML element.
4161
/// - classes: An array of CSS classnames for styling the list.
4262
/// - role: ARIA role of the element for accessibility.
@@ -53,6 +73,7 @@ public final class List: Element {
5373
/// ```
5474
public init(
5575
type: ListType = .unordered,
76+
style: ListStyle = .none,
5677
id: String? = nil,
5778
classes: [String]? = nil,
5879
role: AriaRole? = nil,
@@ -61,10 +82,11 @@ public final class List: Element {
6182
@HTMLBuilder content: @escaping () -> [any HTML] = { [] }
6283
) {
6384
self.type = type
85+
self.style = style
6486
super.init(
6587
tag: type.rawValue,
6688
id: id,
67-
classes: classes,
89+
classes: (classes ?? []) + (style != .none ? ["list-\(style.rawValue)"] : []),
6890
role: role,
6991
label: label,
7092
data: data,

Sources/WebUI/Styles/Base/Typography.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,10 @@ public enum Leading: String {
199199
public enum Decoration: String {
200200
/// Simple underline beneath the text.
201201
case underline
202+
/// Line above the text.
203+
case overline
202204
/// Line through the middle of the text (strikethrough).
203-
case lineThrough
205+
case lineThrough = "line-through"
204206
/// Double line decoration.
205207
case double
206208
/// Dotted line decoration.
@@ -209,9 +211,11 @@ public enum Decoration: String {
209211
case dashed
210212
/// Wavy line decoration.
211213
case wavy
212-
214+
/// Remove line decoration
215+
case none = "no-underline"
216+
213217
/// The corresponding CSS class name for this decoration.
214-
var className: String { "decoration-\(rawValue)" }
218+
var className: String { "\(rawValue)" }
215219
}
216220

217221
/// Text wrapping options for controlling how text flows.

Tests/WebUITests/ElementTests.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,17 @@ import Testing
155155
#expect(rendered.contains("</ol>"))
156156
}
157157

158+
@Test("List Styles")
159+
func testListStyles() async throws {
160+
let disc = List(style: .disc).render()
161+
let circle = List(style: .circle).render()
162+
let square = List(style: .square).render()
163+
164+
#expect(disc.contains("list-disc"))
165+
#expect(circle.contains("list-circle"))
166+
#expect(square.contains("list-[square]"))
167+
}
168+
158169
// MARK: - Media Tests
159170

160171
@Test("Picture element with multiple sources")

Tests/WebUITests/Styles/BaseTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ import Testing
187187
func testFontWithDecorationAndWrapping() async throws {
188188
let element = Element(tag: "div").font(decoration: .underline, wrapping: .nowrap)
189189
let rendered = element.render()
190-
#expect(rendered.contains("class=\"decoration-underline text-nowrap\""))
190+
#expect(rendered.contains("class=\"underline text-nowrap\""))
191191
}
192192

193193
@Test("Font with family and modifier")
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Build and Deploy Static Site
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
permissions:
10+
contents: write
11+
12+
jobs:
13+
build:
14+
runs-on: macos-15
15+
steps:
16+
# Check out the repository code
17+
- uses: actions/checkout@v4
18+
19+
# Set up Swift
20+
- name: Setup Swift
21+
uses: swift-actions/setup-swift@v2
22+
23+
# Cache Swift build artifacts
24+
- name: Cache Swift Build
25+
uses: actions/cache@v4
26+
id: cache-swift-build
27+
with:
28+
path: .build
29+
key: ${{ runner.os }}-swift-build-${{ hashFiles('Package.swift', 'Sources/**') }}
30+
restore-keys: |
31+
${{ runner.os }}-swift-build-
32+
33+
# Build the project
34+
- name: Build
35+
run: swift build -v
36+
if: steps.cache-swift-build.outputs.cache-hit != 'true'
37+
38+
# Cache generated site output
39+
- name: Cache Generated Site
40+
uses: actions/cache@v4
41+
id: cache-site-output
42+
with:
43+
path: .output
44+
key: ${{ runner.os }}-site-output-${{ hashFiles('Sources/**') }}
45+
restore-keys: |
46+
${{ runner.os }}-site-output-
47+
48+
# Run the static site generator
49+
- name: Generate Site
50+
run: swift run Application
51+
if: steps.cache-site-output.outputs.cache-hit != 'true'
52+
53+
# Push to static branch (only on push to main)
54+
- name: Push to static branch
55+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
56+
run: |
57+
git config user.name "GitHub Actions Bot"
58+
git config user.email "actions@github.com"
59+
git checkout -B static
60+
rm -rf ./*
61+
mv .output/* .
62+
rm -rf .output .gitignore .github .build .swift-format
63+
git add .
64+
git commit -m "release: update static site content"
65+
git push origin static --force
66+
env:
67+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

examples/static/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.DS_Store
2+
.build/
3+
.output/
4+
.swiftpm/

examples/static/.swift-format

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
{
2+
"indentation" : {
3+
"spaces" : 4
4+
},
5+
"tabWidth" : 4,
6+
"fileScopedDeclarationPrivacy" : {
7+
"accessLevel" : "private"
8+
},
9+
"spacesAroundRangeFormationOperators" : false,
10+
"indentConditionalCompilationBlocks" : false,
11+
"indentSwitchCaseLabels" : false,
12+
"lineBreakAroundMultilineExpressionChainComponents" : false,
13+
"lineBreakBeforeControlFlowKeywords" : false,
14+
"lineBreakBeforeEachArgument" : true,
15+
"lineBreakBeforeEachGenericRequirement" : true,
16+
"lineLength" : 120,
17+
"maximumBlankLines" : 1,
18+
"respectsExistingLineBreaks" : true,
19+
"prioritizeKeepingFunctionOutputTogether" : true,
20+
"rules" : {
21+
"AllPublicDeclarationsHaveDocumentation" : false,
22+
"AlwaysUseLiteralForEmptyCollectionInit" : false,
23+
"AlwaysUseLowerCamelCase" : false,
24+
"AmbiguousTrailingClosureOverload" : true,
25+
"BeginDocumentationCommentWithOneLineSummary" : false,
26+
"DoNotUseSemicolons" : true,
27+
"DontRepeatTypeInStaticProperties" : true,
28+
"FileScopedDeclarationPrivacy" : true,
29+
"FullyIndirectEnum" : true,
30+
"GroupNumericLiterals" : true,
31+
"IdentifiersMustBeASCII" : true,
32+
"NeverForceUnwrap" : false,
33+
"NeverUseForceTry" : false,
34+
"NeverUseImplicitlyUnwrappedOptionals" : false,
35+
"NoAccessLevelOnExtensionDeclaration" : true,
36+
"NoAssignmentInExpressions" : true,
37+
"NoBlockComments" : true,
38+
"NoCasesWithOnlyFallthrough" : true,
39+
"NoEmptyTrailingClosureParentheses" : true,
40+
"NoLabelsInCasePatterns" : true,
41+
"NoLeadingUnderscores" : false,
42+
"NoParensAroundConditions" : true,
43+
"NoVoidReturnOnFunctionSignature" : true,
44+
"OmitExplicitReturns" : true,
45+
"OneCasePerLine" : true,
46+
"OneVariableDeclarationPerLine" : true,
47+
"OnlyOneTrailingClosureArgument" : true,
48+
"OrderedImports" : true,
49+
"ReplaceForEachWithForLoop" : true,
50+
"ReturnVoidInsteadOfEmptyTuple" : true,
51+
"UseEarlyExits" : false,
52+
"UseExplicitNilCheckInConditions" : false,
53+
"UseLetInEveryBoundCaseVariable" : false,
54+
"UseShorthandTypeNames" : true,
55+
"UseSingleLinePropertyGetter" : false,
56+
"UseSynthesizedInitializer" : false,
57+
"UseTripleSlashForDocumentationComments" : true,
58+
"UseWhereClausesInForLoops" : false,
59+
"ValidateDocumentationComments" : false
60+
}
61+
}

examples/static/Package.resolved

Lines changed: 42 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/static/Package.swift

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// swift-tools-version: 6.1
2+
3+
import PackageDescription
4+
5+
let package = Package(
6+
name: "Portfolio",
7+
platforms: [.macOS(.v15)],
8+
dependencies: [
9+
.package(url: "https://github.com/maclong9/web-ui.git", from: "1.0.0")
10+
],
11+
targets: [
12+
.executableTarget(
13+
name: "Application",
14+
dependencies: [
15+
.product(name: "WebUI", package: "web-ui")
16+
],
17+
path: "Sources",
18+
resources: [.process("Public")]
19+
)
20+
]
21+
)

0 commit comments

Comments
 (0)