From b77b45c386a2395c01be07b20fc6385037dadb35 Mon Sep 17 00:00:00 2001
From: stephann <3025661+stephannv@users.noreply.github.com>
Date: Sat, 14 Sep 2024 15:10:01 -0300
Subject: [PATCH] release: Prepare 0.8.0 release
---
CHANGELOG.md | 305 ++++++++++++++++++++++++++++++++++++---
shard.yml | 2 +-
src/blueprint/version.cr | 2 +-
3 files changed, 283 insertions(+), 26 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f18c1a9..3d2b461 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,19 +2,138 @@
All notable changes to this project will be documented on .
-## [0.7.0] - 2023-09-09
+# [0.8.0] - 2024-09-14
+
+### Overhauled docs
+The [Blueprint Docs](https://stephannv.github.io/blueprint-docs/) was revised.
+
+### Style Variants (Experimental)
+Defining a schema for variants within the component class to compile the final list of CSS classes.
+
+```crystal
+class AlertComponent
+ include Blueprint::HTML
+
+ style_builder do
+ base "alert"
+
+ variants do
+ type {
+ info "alert-info"
+ danger "alert-danger"
+ }
+
+ size {
+ xs "text-xs p-2"
+ md "text-md p-4"
+ lg "text-lg p-6"
+ }
+
+ closable {
+ yes "alert-closable"
+ }
+
+ special {
+ yes "alert-special"
+ no "alert-default"
+ }
+ end
+
+ defaults type: :info, size: :md
+ end
+
+ def blueprint
+ div(class: build_style(type: :danger, size: :lg, closable: true)) do
+ "My styled alert component"
+ end
+ end
+end
+
+puts AlertComponent.build_style(type: :info, size: :xs, special: false)
+# "alert alert-info text-xs p-2 alert-default"
+
+puts AlertComponent.new.to_s
+#
+# My styled alert component
+#
+```
+
+### Tokens (Experimental)
+Allows to build classes based on conditionals.
+
+```crystal
+class UserComponent
+ include Blueprint::HTML
+
+ def blueprint
+ h1 class: tokens(admin?: "is-admin", moderator?: "is-moderator") do
+ "Jane Doe"
+ end
+ end
+
+ def admin?
+ false
+ end
+
+ def moderator?
+ true
+ end
+end
+
+puts UserComponent.new.to_s
+
+#
+# Jane Doe
+#
+```
+
+### Add `#safe` helper
+The `#safe` method wraps the given object in a `Blueprint::SafeValue`, indicating
+to Blueprint that the content should be rendered without escaping.
+
+### BREAKING: Change `#to_html` to `#to_s`
+Instead of `MyComponent.new.to_html` you should use `MyComponent.new.to_s`.
+
+### BREAKING: Remove some utils methods
+The methods `#plain(&)` and `#comment(&)` were removed, but you still can use
+the `#plain(content : String)` and `#comment(content : String)`.
+
+### BREAKING: Remove `#unsafe_raw`
+`#unsafe_raw` was removed in favor of `#raw`.
+```crystal
+# BEFORE
+unsafe_raw ""
+
+# AFTER
+raw safe("")
+```
+
+### BREAKING: Remove `Blueprint::RawHTML`
+The `Blueprint::RawHTML` included in 0.7.0 was removed. A module focused on performance will be planned in the future.
+
+### Include Blueprint::HTML::ComponenentRegistrar by default
+You don't need to require and include `Blueprint::HTML::ComponenentRegistrar`, it
+is already included when you include `Blueprint::HTML`.
+
+
+# [0.7.0] - 2024-09-09
+
+### Allow passing comment via argument
-- Allow passing comment via argument
```crystal
comment "Cool comment here"
```
-- Allow rendering unsafe content using `unsafe_raw`
+### Allow rendering unsafe content using `unsafe_raw`
+
```crystal
unsafe_raw ""
```
-- Add `RawHtml` to priorize performance over safety
+
+### RawHTML
+
+Add `RawHtml` to priorize performance over safety
```crystal
require "blueprint/unsafe_html"
class MyHTML
@@ -26,11 +145,16 @@ class MyHTML
end
```
-- Code refactoring to improve performance
-- Fix safety when passing content to elements via argument
+### Code refactoring
+Code refactoring to improve performance
+
+### Fix escaping
+Fix safety when passing content to elements via argument
+
+# [0.6.0] - 2024-09-08
-## [0.6.0] - 2023-09-08
+### Passing content via argument
Allows passing content to elements without using blocks, eg.
@@ -40,39 +164,172 @@ Allows passing content to elements without using blocks, eg.
h1 "Hello World!"
```
-Release details:
+# [0.5.1] - 2024-09-08
-## [0.5.1] - 2023-09-08
+Fix Crystal version string requirement allowing using Blueprint with newer crystal versions.
-Fix Crystal version string requirement.
+# [0.5.0] - 2024-09-08
-Release details:
+### Performance improvements
-## [0.5.0] - 2023-09-08
+Increased speed execution by 15%.
-Performance improvements: Increased speed execution by 15%.
```
-
-
v0.5.0 364.46k ( 2.74µs) (± 0.52%) 7.95kB/op fastest
v0.4.0 317.83k ( 3.15µs) (± 0.76%) 8.99kB/op 1.15× slower
+```
+
+### Fix Array attributes
+
+Ignore nil elements from array attribute parsing
+
+```crystal
+class Example
+ include Blueprint::HTML
+
+ private def blueprint
+ h1(class: ["a", "b", nil, ["c", "d"]]) { "Example" }
+ end
+end
+
+example = Example.new
+example.to_html # => "
Example
"
+```
+
+
+# [0.4.0] - 2023-04-25
+
+### SVG support
+
+It's possible to create SVG elements:
+
+```crystal
+class Example
+ include Blueprint::HTML
+
+ private def blueprint
+ svg width: 30, height: 10 do
+ g fill: :red do
+ rect x: 0, y: 0, width: 10, height: 10
+ rect x: 20, y: 0, width: 10, height: 10
+ end
+ end
+ end
+end
+```
+
+Output:
+```html
+
+```
+
+
+# [0.3.0] - 2023-04-07
+
+### Build HTML without defining classes or structs
+It's possible build HTML without using classes or structs
+
+```crystal
+html = Blueprint::HTML.build do
+ h1 { "Hello" }
+ div do
+ h2 { "World" }
+ end
+end
+
+puts html # =>
Hello
World
```
-Release details:
-## [0.4.0] - 2023-04-25
+# [0.2.0] - 2023-04-07
+
+### Allow conditional rendering
-Release details:
+It's possible to override `#render?` method to control blueprint render.
-## [0.3.0] - 2023-04-07
+```crystal
+class Example
+ include Blueprint::HTML
+
+ private def blueprint
+ h1 { "Example" }
+ end
+
+ private def render?
+ false
+ end
+end
+
+example = Example.new
+example.to_html # => ""
+```
+
+### Handles array attributes
+
+Arrays passed as attribute values will be flattened and joined with `" "`.
+
+```crystal
+class Example
+ include Blueprint::HTML
+
+ private def blueprint
+ h1(class: ["a", "b", ["c", "d"]]) { "Example" }
+ end
+end
+
+example = Example.new
+example.to_html # => "
Example
"
+```
+
+### Adds `#envelope(&)` method
+
+By overriding the `#envelope(&)` method, you can create a wrapper around
+blueprint content. This is useful when defining layouts for pages.
+
+```crystal
+class Example
+ include Blueprint::HTML
+
+ private def blueprint
+ h1 { "Example" }
+ end
+
+ private def envelope(&)
+ html do
+ body do
+ yield
+ end
+ end
+ end
+end
+
+example = Example.new
+example.to_html # => "
Hello
"
+```
-Release details:
+### Breaking changes
+- Requires `require "blueprint/html"` instead `require "blueprint"` to use `Blueprint::HTML` module
-## [0.2.0] - 2023-04-07
-Release details:
-## [0.1.0] - 2023-03-27
+# [0.1.0] - 2023-03-27
-Release details:
+### Added
+- Basic html builder
+- Allow element attributes
+- Allow rendering blueprints
+- Allow NamedTuple attributes
+- Add `doctype` util
+- Transform attribute names
+- Handle boolean attributes
+- Escape content
+- Add `comment` util
+- Add `whitespace` util
+- Allow custom component registration
+- Allow custom element registration
diff --git a/shard.yml b/shard.yml
index 33c79c9..ff704dc 100644
--- a/shard.yml
+++ b/shard.yml
@@ -2,7 +2,7 @@ name: blueprint
description: |
Blueprint is a lib for writing reusable and testable HTML templates in plain Crystal, allowing an OOP (Oriented Object Programming) approach when building your views.
-version: 0.7.0
+version: 0.8.0
authors:
- Stephann V. <3025661+stephannv@users.noreply.github.com>
diff --git a/src/blueprint/version.cr b/src/blueprint/version.cr
index 05d9edb..bab014e 100644
--- a/src/blueprint/version.cr
+++ b/src/blueprint/version.cr
@@ -1,3 +1,3 @@
module Blueprint
- VERSION = "0.7.0"
+ VERSION = "0.8.0"
end