Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Setup
description: Install Node, pnpm, Swift + Wasm SDK, binaryen and project dependencies

runs:
using: composite
steps:
- name: Setup pnpm
uses: pnpm/action-setup@v6
with:
version: 9

- name: Setup Node.js
uses: actions/setup-node@v7
with:
node-version: 24
cache: "pnpm"

- uses: swift-actions/setup-swift@v3
with:
swift-version: "6.4.2"
skip-verify-signature: true

- name: Install Swift SDK for WebAssembly
shell: bash
run: swift sdk install https://download.swift.org/swift-6.4.2-release/wasm-sdk/swift-6.4.2-RELEASE/swift-6.4.2-RELEASE_wasm.artifactbundle.tar.gz --checksum 83baca83553f8c443cda7b84800912e6e709c3acd2e7ebf277794ca5836c0da5

- name: Install dependencies
shell: bash
run: swift package resolve --package-path swift && pnpm install --frozen-lockfile

- name: Install wasm-opt
uses: phi-ag/setup-binaryen@v1
with:
version: "133"
41 changes: 41 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: CI

on:
pull_request:
branches: [main]
workflow_dispatch:

jobs:
format:
runs-on: ubuntu-24.04
timeout-minutes: 5
steps:
- uses: actions/checkout@v7

- uses: pnpm/action-setup@v6
with:
version: 9

- uses: actions/setup-node@v7
with:
node-version: 24
cache: "pnpm"

- run: pnpm install --frozen-lockfile
- run: pnpm run format:check

format-swift:
runs-on: ubuntu-24.04
timeout-minutes: 5
container: "swift:6.4.2"
steps:
- uses: actions/checkout@v7
- run: swift format lint -rps .

build:
runs-on: ubuntu-24.04
timeout-minutes: 20
steps:
- uses: actions/checkout@v7
- uses: ./.github/actions/setup
- run: pnpm run build
27 changes: 1 addition & 26 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v7

- name: Setup pnpm
uses: pnpm/action-setup@v6
with:
version: 9

- name: Setup Node.js
uses: actions/setup-node@v7
with:
node-version: 24
cache: "pnpm"

- uses: swift-actions/setup-swift@v3
with:
swift-version: "6.4.2"
skip-verify-signature: true

- name: Install Swift SDK for WebAssembly
run: swift sdk install https://download.swift.org/swift-6.4.2-release/wasm-sdk/swift-6.4.2-RELEASE/swift-6.4.2-RELEASE_wasm.artifactbundle.tar.gz --checksum 83baca83553f8c443cda7b84800912e6e709c3acd2e7ebf277794ca5836c0da5

- name: Install dependencies
run: swift package resolve --package-path swift && pnpm install

- name: Install wasm-opt
uses: phi-ag/setup-binaryen@v1
with:
version: "133"
- uses: ./.github/actions/setup

- name: Build VitePress site
run: pnpm run build
Expand Down
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.build/
public/
pnpm-lock.yaml
63 changes: 63 additions & 0 deletions .swift-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"version": 1,
"indentation": {
"spaces": 4
},
"tabWidth": 4,
"fileScopedDeclarationPrivacy": {
"accessLevel": "private"
},
"spacesAroundRangeFormationOperators": false,
"indentConditionalCompilationBlocks": false,
"indentSwitchCaseLabels": false,
"lineBreakAroundMultilineExpressionChainComponents": false,
"lineBreakBeforeControlFlowKeywords": false,
"lineBreakBeforeEachArgument": true,
"lineBreakBeforeEachGenericRequirement": true,
"lineLength": 140,
"maximumBlankLines": 1,
"respectsExistingLineBreaks": true,
"prioritizeKeepingFunctionOutputTogether": true,
"multiElementCollectionTrailingCommas": true,
"rules": {
"AllPublicDeclarationsHaveDocumentation": false,
"AlwaysUseLiteralForEmptyCollectionInit": false,
"AlwaysUseLowerCamelCase": false,
"AmbiguousTrailingClosureOverload": true,
"BeginDocumentationCommentWithOneLineSummary": false,
"DoNotUseSemicolons": false,
"DontRepeatTypeInStaticProperties": true,
"FileScopedDeclarationPrivacy": true,
"FullyIndirectEnum": true,
"GroupNumericLiterals": true,
"IdentifiersMustBeASCII": true,
"NeverForceUnwrap": false,
"NeverUseForceTry": false,
"NeverUseImplicitlyUnwrappedOptionals": false,
"NoAccessLevelOnExtensionDeclaration": false,
"NoAssignmentInExpressions": true,
"NoBlockComments": true,
"NoCasesWithOnlyFallthrough": true,
"NoEmptyTrailingClosureParentheses": true,
"NoLabelsInCasePatterns": true,
"NoLeadingUnderscores": false,
"NoParensAroundConditions": true,
"NoVoidReturnOnFunctionSignature": true,
"OmitExplicitReturns": true,
"OneCasePerLine": true,
"OneVariableDeclarationPerLine": true,
"OnlyOneTrailingClosureArgument": true,
"OrderedImports": true,
"ReplaceForEachWithForLoop": true,
"ReturnVoidInsteadOfEmptyTuple": true,
"UseEarlyExits": false,
"UseExplicitNilCheckInConditions": false,
"UseLetInEveryBoundCaseVariable": false,
"UseShorthandTypeNames": true,
"UseSingleLinePropertyGetter": false,
"UseSynthesizedInitializer": false,
"UseTripleSlashForDocumentationComments": true,
"UseWhereClausesInForLoops": false,
"ValidateDocumentationComments": false
}
}
4 changes: 2 additions & 2 deletions .vitepress/theme/swift-snippets.css
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ elementary-snippet button {
transition: background-color 0.2s ease;
}

elementary-snippet button+button {
elementary-snippet button + button {
margin-left: 8px;
}

Expand Down Expand Up @@ -78,4 +78,4 @@ elementary-snippet input:focus-visible {
.dark elementary-snippet input:focus,
.dark elementary-snippet input:focus-visible {
box-shadow: 0 0 0 2px color-mix(in srgb, var(--vp-c-brand-1) 76%, transparent);
}
}
13 changes: 8 additions & 5 deletions guide/animation/animate-layout-and-css.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Animate changes to layout and CSS values

ElementaryUI comes with a ***FLIP*** animation system that enables automatic
ElementaryUI comes with a _**FLIP**_ animation system that enables automatic
animation of essentially any visible change to your view's layout or appearance.

**FLIP** (First, Last, Invert, Play) is a technique that captures the geometry or appearance of an element before and after a change, then animates the difference. A view can opt-in to FLIP handling with modifiers, and any [transaction with an animation](transactions-and-animations.md#transactions) will be animated accordingly.
Expand All @@ -16,11 +16,14 @@ Whenever this container's children are added, moved, or removed with an animatio
<elementary-snippet file="AnimateLayoutView" />

---

::: warning 🚧 🚧 🚧
FLIP features are not yet fully implemented.

Planned are:
+ animate layout changes when value changes (independent of children)
+ animate arbitrary CSS properties when value changes
+ `matchedGeometryEffect` feature by providing a stable identifier for FLIP
:::

- animate layout changes when value changes (independent of children)
- animate arbitrary CSS properties when value changes
- `matchedGeometryEffect` feature by providing a stable identifier for FLIP

:::
27 changes: 13 additions & 14 deletions guide/animation/transactions-and-animations.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# Transactions and Animations

ElementaryUI's animation system is built on the concept of **transactions** - discrete units of change that flow through your application.
Expand All @@ -8,26 +7,26 @@ If you are familiar with SwiftUI's animation system, you should feel right at ho

ElementaryUI supports three kinds of animatable views.

| Type | Description |
|------|-------------|
| [Built-in modifiers](animatable-modifiers.md) | Modifiers like `ElementaryUI.View.opacity(_:)` or `ElementaryUI.View.offset(x:y:)` are animatable. |
| Type | Description |
| --------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ |
| [Built-in modifiers](animatable-modifiers.md) | Modifiers like `ElementaryUI.View.opacity(_:)` or `ElementaryUI.View.offset(x:y:)` are animatable. |
| [Layout and CSS changes](animate-layout-and-css.md) | Modifiers like `ElementaryUI.View.animateContainerLayout(animateContainerSize:)` enable automatic FLIP animations. |
| [Custom animations](custom-animations.md) | Views that implement the `ElementaryUI.Animatable` protocol can define custom animations. |
| [Custom animations](custom-animations.md) | Views that implement the `ElementaryUI.Animatable` protocol can define custom animations. |

::: info
While these methods differ in how the animations are performed under the hood, they all participate in the same transaction-based animation system.
:::

## Transactions

Every [state change](../essentials/state-and-reactivity.md) in ElementaryUI happens within a `ElementaryUI.Transaction`. A transaction represents a single logical update that may affect multiple views throughout your hierarchy.
Every [state change](../essentials/state-and-reactivity.md) in ElementaryUI happens within a `ElementaryUI.Transaction`. A transaction represents a single logical update that may affect multiple views throughout your hierarchy.

Animatable views only describe what can be animated, but not when or how: This part is specified by setting an `ElementaryUI.Animation` for a transaction.

You can set an `ElementaryUI.Animation` in the following ways:

+ Modify state within a `ElementaryUI.withAnimation(_:_:)` block
+ Use the `ElementaryUI.View.animation(_:value:)` modifier on a view
- Modify state within a `ElementaryUI.withAnimation(_:_:)` block
- Use the `ElementaryUI.View.animation(_:value:)` modifier on a view

Here is an example of how to use `withAnimation`:

Expand All @@ -41,18 +40,18 @@ The `ElementaryUI.Animation` type is used to describe how the [animatable values

There are three types of animation:

| Type | Description |
|------|-------------|
| **Springs** | Use the built-in spring animations like `ElementaryUI.Animation.snappy`, `ElementaryUI.Animation.smooth`, and `ElementaryUI.Animation.bouncy`, or define your own `ElementaryUI.Spring`. |
| **Unit Curves** | Use the built-in animations like `ElementaryUI.Animation.linear` and `ElementaryUI.Animation.easeInOut` or define your own `ElementaryUI.UnitCurve`. |
| **Custom** | Define your own animation by implementing the `ElementaryUI.CustomAnimation` protocol. |
| Type | Description |
| --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Springs** | Use the built-in spring animations like `ElementaryUI.Animation.snappy`, `ElementaryUI.Animation.smooth`, and `ElementaryUI.Animation.bouncy`, or define your own `ElementaryUI.Spring`. |
| **Unit Curves** | Use the built-in animations like `ElementaryUI.Animation.linear` and `ElementaryUI.Animation.easeInOut` or define your own `ElementaryUI.UnitCurve`. |
| **Custom** | Define your own animation by implementing the `ElementaryUI.CustomAnimation` protocol. |

### Modifying animations

You can further control how your animations behave by using modifiers like `ElementaryUI.Animation.delay(_:)` or `ElementaryUI.Animation.speed(_:)`. These work on all types of animations.

### Interrupting and stacking animations

ElementaryUI's animation system preserves velocity when animations are interrupted, meaning new animations inherit the current momentum rather than starting from zero - this is especially noticeable with spring animations that feel natural and physics-based.
ElementaryUI's animation system preserves velocity when animations are interrupted, meaning new animations inherit the current momentum rather than starting from zero - this is especially noticeable with spring animations that feel natural and physics-based.

Additionally, animations stack seamlessly by default: the system automatically ensures smooth motion even when animations overlap or are triggered at different times.
2 changes: 1 addition & 1 deletion guide/dom-interaction/html-elements.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ div {

## Custom Elements

If you want to use ElementaryUI to create your own custom elements which can be integrated in existing web projects, see [Web Components](../topics/web-components.md).
If you want to use ElementaryUI to create your own custom elements which can be integrated in existing web projects, see [Web Components](../topics/web-components.md).
1 change: 0 additions & 1 deletion guide/essentials/lifecycle-events.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,3 @@ struct MyView {
}
}
```

2 changes: 0 additions & 2 deletions guide/essentials/list-rendering.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@ Use `ElementaryUI.ForEach` when you need a stable id for your list items (reorde

For simple cases where a stable identity does not matter, you can also just iterate a collection.


```swift
div {
for item in items {
p { item.title }
}
}
```

1 change: 0 additions & 1 deletion guide/essentials/state-and-reactivity.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,3 @@ You can use the familiar `$` syntax on `ElementaryUI.State` variables to create
<<< @/swift/Sources/Snippets/BindingCounterButton.swift#snippet

<elementary-snippet file="BindingCounterButton" />

2 changes: 1 addition & 1 deletion load-snippets.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
if (!import.meta.env.SSR) {
import("virtual:swift-wasm?js").then(i => i.init());
import("virtual:swift-wasm?js").then((i) => i.init());
}
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@
"devDependencies": {
"@elementary-swift/vite-plugin-swift-wasm": "~0.3.0",
"markdown-it": "^14.3.0",
"prettier": "^3.10.0",
"vitepress": "2.0.0-alpha.19",
"vue": "^3.5.41"
},
"scripts": {
"dev": "vitepress dev",
"build": "vitepress build",
"preview": "vitepress preview"
"preview": "vitepress preview",
"format": "prettier --write .",
"format:check": "prettier --check ."
}
}
10 changes: 10 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion privacy.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ We also use **Cloudflare Web Analytics** to obtain anonymous, aggregated statist

Cloudflare Privacy Policy: https://www.cloudflare.com/privacypolicy/

We do not sell data, we do not share data with advertisers, and we do not create user profiles.
We do not sell data, we do not share data with advertisers, and we do not create user profiles.
Loading
Loading