From c07a3fcf730ce3bb397e2009666d5f8587afcb37 Mon Sep 17 00:00:00 2001 From: Martin Feckie Date: Fri, 8 Nov 2024 13:44:51 +0800 Subject: [PATCH 1/3] Swith to using viewbox and allow optional class --- lib/qr_code/render/svg.ex | 7 ++++--- lib/qr_code/render/svg_settings.ex | 4 +++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/qr_code/render/svg.ex b/lib/qr_code/render/svg.ex index 6cc6e3f..2dfb46c 100644 --- a/lib/qr_code/render/svg.ex +++ b/lib/qr_code/render/svg.ex @@ -71,15 +71,16 @@ defmodule QRCode.Render.Svg do qrcode_color: qc, flatten: flatten, scale: scale, - structure: structure + structure: structure, + class: class } ) do {:svg, %{ xmlns: xmlns, xlink: xlink, - width: rank_matrix * scale, - height: rank_matrix * scale + viewBox: "0 0 #{rank_matrix * scale} #{rank_matrix * scale}", + class: class }, [background_rect(bg, bg_tr), body_type(body, qc, flatten), put_image(image)]} |> XmlBuilder.generate(format: format(structure)) end diff --git a/lib/qr_code/render/svg_settings.ex b/lib/qr_code/render/svg_settings.ex index 40eb6c8..a538098 100644 --- a/lib/qr_code/render/svg_settings.ex +++ b/lib/qr_code/render/svg_settings.ex @@ -21,6 +21,7 @@ defmodule QRCode.Render.SvgSettings do @type structure :: :minify | :readable @type t :: %__MODULE__{ + class: String.t(), scale: integer, image: image, background_opacity: background_opacity, @@ -36,5 +37,6 @@ defmodule QRCode.Render.SvgSettings do background_color: "#ffffff", qrcode_color: "#000000", flatten: false, - structure: :minify + structure: :minify, + class: "" end From c467df0669b8b5b60cbebc027b9df7566cffc4c1 Mon Sep 17 00:00:00 2001 From: Martin Feckie Date: Fri, 8 Nov 2024 13:46:30 +0800 Subject: [PATCH 2/3] Update readme --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 398fdde..7f86294 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,8 @@ There are several options to change the appearance of svg or png: | Option | Type | Default value | Description | |--------------------|------------------------|---------------|-------------------------------------| | scale | positive integer | 10 | changes size of rendered QR code | +| class | string | "" | add a CSS class to the svg tag | +| scale | positive integer | 10 | changes size of rendered QR code | | background_opacity | nil or 0.0 <= x <= 1.0 | nil | sets background opacity of svg | | background_color | string or {r, g, b} | "#ffffff" | sets background color of svg | | qrcode_color | string or {r, g, b} | "#000000" | sets color of QR | From ad8507e770a7cf222178790c18dfcb01441dc502 Mon Sep 17 00:00:00 2001 From: Bharanee Rathna Date: Wed, 22 Oct 2025 11:50:12 +1100 Subject: [PATCH 3/3] publish branch to blake_education org see https://3plearning.slack.com/archives/C01P3MS81M4/p1761094067432939?thread_ts=1761091325.050799&cid=C01P3MS81M4 --- mix.exs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mix.exs b/mix.exs index b08e861..8856971 100644 --- a/mix.exs +++ b/mix.exs @@ -61,13 +61,15 @@ defmodule QRCode.MixProject do defp package do [ + organization: "blake_elearning", maintainers: [ "Jindrich K. Smitka ", - "Ondrej Tucek " + "Ondrej Tucek ", + "Martin Feckie " ], licenses: ["BSD-4-Clause"], links: %{ - "GitHub" => "https://github.com/iodevs/qr_code" + "GitHub" => "https://github.com/blake-education/qr_code/tree/make-styling-easier" } ] end