Skip to content

Commit c499549

Browse files
authored
Merge pull request #28 from dbrattli/chore/modernize-repo
chore: modernize repository with release-please and bug fixes
2 parents 66fa36f + 21bd7a1 commit c499549

15 files changed

Lines changed: 309 additions & 66 deletions

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: "github-actions"
9+
directory: "/"
10+
schedule:
11+
interval: "weekly"

.github/workflows/build-and-test.yml

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,27 @@ name: Build and Test
22

33
on:
44
push:
5-
branches: [ master ]
5+
branches: [master]
66
pull_request:
7-
branches: [ master ]
7+
branches: [master]
88

99
jobs:
1010
build:
11-
1211
runs-on: ubuntu-latest
1312

1413
steps:
15-
- uses: actions/checkout@v4
16-
- name: Setup .NET Core
17-
uses: actions/setup-dotnet@v4
18-
with:
19-
dotnet-version: 9.0.300
20-
- name: Restore tools
21-
run: dotnet tool restore
22-
- name: Install dependencies
23-
run: dotnet paket restore
24-
- name: Build
25-
run: dotnet build --configuration Release
26-
- name: Test
27-
run: dotnet test --verbosity normal
14+
- uses: actions/checkout@v4
15+
16+
- name: Setup .NET Core
17+
uses: actions/setup-dotnet@v4
18+
with:
19+
dotnet-version: 9.0.x
20+
21+
- name: Install just
22+
uses: extractions/setup-just@v2
23+
24+
- name: Restore dependencies
25+
run: just restore
26+
27+
- name: Build and test
28+
run: just check
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: conventional-pr-title
2+
3+
on:
4+
pull_request:
5+
types: [opened, edited, synchronize, reopened]
6+
branches: [master]
7+
8+
jobs:
9+
lint:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: amannn/action-semantic-pull-request@v5
13+
env:
14+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
15+
with:
16+
types: |
17+
feat
18+
fix
19+
chore
20+
docs
21+
style
22+
refactor
23+
perf
24+
test
25+
ci
26+
build
27+
revert

.github/workflows/publish.yml

Lines changed: 0 additions & 45 deletions
This file was deleted.
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
on:
2+
push:
3+
branches:
4+
- master
5+
6+
permissions:
7+
contents: write
8+
pull-requests: write
9+
10+
name: Release Please
11+
12+
jobs:
13+
release-please:
14+
runs-on: ubuntu-latest
15+
outputs:
16+
release_created: ${{ steps.release.outputs.release_created }}
17+
tag_name: ${{ steps.release.outputs.tag_name }}
18+
steps:
19+
- uses: googleapis/release-please-action@v4
20+
id: release
21+
with:
22+
token: ${{ secrets.GITHUB_TOKEN }}
23+
24+
publish:
25+
needs: release-please
26+
if: ${{ needs.release-please.outputs.release_created }}
27+
runs-on: ubuntu-latest
28+
timeout-minutes: 10
29+
steps:
30+
- name: Checkout code
31+
uses: actions/checkout@v4
32+
33+
- name: Setup .NET Core
34+
uses: actions/setup-dotnet@v4
35+
with:
36+
dotnet-version: 9.0.x
37+
38+
- name: Install just
39+
uses: extractions/setup-just@v2
40+
41+
- name: Restore dependencies
42+
run: just restore
43+
44+
- name: Pack NuGet
45+
env:
46+
TAG_NAME: ${{ needs.release-please.outputs.tag_name }}
47+
run: just pack-version ${TAG_NAME#v}
48+
49+
- name: Push Feliz.ViewEngine NuGet
50+
run: dotnet nuget push src/bin/Release/*.nupkg -s https://api.nuget.org/v3/index.json -k ${{ secrets.NUGET_API_KEY }}
51+
continue-on-error: false
52+
53+
- name: Push Feliz.Bulma.ViewEngine NuGet
54+
run: dotnet nuget push Feliz.Bulma.ViewEngine/bin/Release/*.nupkg -s https://api.nuget.org/v3/index.json -k ${{ secrets.NUGET_API_KEY }}
55+
continue-on-error: false

.release-please-manifest.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
".": "1.0.0"
3+
}

CHANGELOG.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [1.0.0](https://github.com/dbrattli/Feliz.ViewEngine/compare/v0.27.0...v1.0.0) (unreleased)
9+
10+
### Features
11+
12+
* First stable release of Feliz.ViewEngine
13+
* Minimal event handler support in ReactElement DOM (not rendered, but available for inspection)
14+
15+
### Bug Fixes
16+
17+
* Fix Bulma.input properties being ignored (fixes #16, #22)
18+
* Relax FSharp.Core dependency constraint to allow modern versions (fixes #27)
19+
* Add Html.table overload for children elements (fixes #19)
20+
21+
### Build
22+
23+
* Add release-please for automated releases
24+
* Add conventional commit enforcement for PRs
25+
* Add dependabot for GitHub Actions updates

CLAUDE.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
Feliz.ViewEngine is an F# library that renders the Feliz DSL to plain HTML or XML strings. It's designed for server-side rendering (SSR) scenarios like Giraffe web handlers, HTML email generation, or any case where HTML output is needed. The library has no dependencies and is Fable-compatible.
8+
9+
## Build Commands
10+
11+
```bash
12+
# Restore dependencies (uses Paket)
13+
dotnet restore
14+
15+
# Build all projects
16+
dotnet build
17+
18+
# Run tests
19+
dotnet test test/Tests.Feliz.ViewEngine.fsproj
20+
21+
# Build specific project
22+
dotnet build src/Feliz.ViewEngine.fsproj
23+
```
24+
25+
## Architecture
26+
27+
### Core Types (src/ViewEngine.fs)
28+
29+
The library defines its own `ReactElement` discriminated union (not Fable.React):
30+
31+
```fsharp
32+
type IReactProperty =
33+
| KeyValue of string * obj
34+
| Children of ReactElement list
35+
| Text of string
36+
37+
type ReactElement =
38+
| Element of string * IReactProperty list
39+
| VoidElement of string * IReactProperty list // self-closing like <br>, <img>
40+
| TextElement of string
41+
| Elements of ReactElement seq
42+
```
43+
44+
The `Render` module converts these to strings via `htmlView`, `xmlView`, `htmlDocument`, or `xmlDocument`.
45+
46+
### Interop Module (src/Interop.fs)
47+
48+
Provides the API bridge between Feliz DSL and the ViewEngine types. Key functions:
49+
50+
- `createElement` / `createVoidElement` - create elements with properties
51+
- `mkAttr` / `mkStyle` - create attributes and style properties
52+
- `createTextElement` / `createRawTextElement` - create text (escaped vs raw)
53+
54+
### DSL Modules
55+
56+
- `Html` (src/Html.fs) - HTML element functions (`Html.div`, `Html.p`, etc.)
57+
- `prop` (src/Properties.fs) - HTML properties (`prop.className`, `prop.style`, etc.)
58+
- `style` (src/Styles.fs) - CSS style properties
59+
- `React` (src/React.fs) - React-compatible utilities like `fragment`
60+
61+
### Feliz.Bulma.ViewEngine Extension
62+
63+
A port of Feliz.Bulma for server-side rendering, located in `Feliz.Bulma.ViewEngine/`.
64+
65+
## Client/Server Code Sharing
66+
67+
Use compiler directives to share views between client (Feliz) and server (Feliz.ViewEngine):
68+
69+
```fsharp
70+
#if FABLE_COMPILER
71+
open Feliz
72+
#else
73+
open Feliz.ViewEngine
74+
#endif
75+
```
76+
77+
## Key Differences from Feliz
78+
79+
- Event handlers are stored in the DOM tree but ignored during rendering
80+
- `Html.none` returns an empty `TextElement` (not `unbox null`)
81+
- `Html.text` uses `createTextElement` (not unboxing)
82+
- HTML is escaped by default; use `Html.rawText` for unescaped content

Feliz.Bulma.ViewEngine/ElementBuilders.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ module Label =
5858

5959
module Input =
6060
let inline propsWithType (cn:string) (typ: IReactProperty) (xs:IReactProperty list) =
61-
Html.input [ typ; Helpers.combineClasses cn xs ]
61+
Html.input [ typ; yield! Helpers.partitionClasses xs ||> (fun c p -> Helpers.combineClasses cn c :: p) ]
6262

6363
module Textarea =
6464
let inline props (cn:string) (xs:IReactProperty list) = Html.textarea [ yield! Helpers.partitionClasses xs ||> (fun c p -> Helpers.combineClasses cn c :: p) ]

justfile

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Feliz.ViewEngine build commands
2+
# Install just: https://github.com/casey/just
3+
4+
src_path := "src"
5+
test_path := "test"
6+
bulma_path := "Feliz.Bulma.ViewEngine"
7+
8+
# Default recipe - show available commands
9+
default:
10+
@just --list
11+
12+
# Clean build artifacts
13+
clean:
14+
rm -rf {{src_path}}/obj {{test_path}}/obj {{bulma_path}}/obj
15+
rm -rf {{src_path}}/bin {{test_path}}/bin {{bulma_path}}/bin
16+
17+
# Restore all dependencies
18+
restore:
19+
dotnet tool restore
20+
dotnet paket restore
21+
22+
# Build all projects
23+
build:
24+
dotnet build --configuration Release
25+
26+
# Run all tests
27+
test:
28+
dotnet test {{test_path}}
29+
30+
# Build and run tests
31+
check: build test
32+
33+
# Create NuGet packages
34+
pack:
35+
dotnet pack -c Release
36+
37+
# Create NuGet packages with specific version (used in CI)
38+
pack-version version:
39+
dotnet pack -c Release -p:PackageVersion={{version}}
40+
41+
# Full setup and test
42+
setup: restore build test

0 commit comments

Comments
 (0)