Build Interactive Phoenix LiveView UIs with Components
Learn how to make use of functional components to create complex Phoenix LiveView UIs.
https://blog.appsignal.com/2022/01/11/build-interactive-phoenix-liveview-uis-with-components.html
[Blog] Phoenix File Uploading via Javascript
Uploading files with Phoenix and Javascript? Stephanie Vizzi has created a step-by-step reference to guide you through the process: https://smartlogic.io/blog/phoenix-file-upload-via-javascript/
S3 Storage Provider for Elasticlunr (Elixir)
I just published an S3 storage provider for Elasticlunr. You can now store your indexes to an S3 bucket aside the Disk storage provider included in the base project.
The storage API is flexible, so writing to any storage provider (Google Cloud Storage, DB and so on) shouldn’t be a problem. it’s just a matter of grabbing the right provider or implementing one yourself.
ThinkingElixir 081: Elixir in a Burrito with Quinn and Digit
In episode 81 of Thinking Elixir, we talk with Digit and Quinn Wilton about the Burrito project. It wraps up Elixir to a single binary, enables cross-platform builds using Zig to help while also enabling NIFs! They share how the security focused software they create uses this to run in isolated environments where Elixir can’t be installed. A really cool project that can be used for things like one-off scripts to long running CLI applications with full OTP features and more. They share some of the challenges they had to overcome in creating Burrito and how it being OpenSource helps the company and their project.
Elasticlunr Query DSL
Like every other search engine, you can make more advanced search queries depending on your requirements. In the remaining part of this post, I will be highlighting the available query types provided by Elasticlunr.
Read more: https://atandarash.me/blog/elasticlunr-query-dsl
Note: This is a continuation of the introductory post
IntelliJ Elixir 12.1.0
Changelog
v12.1.0
Enhancements
- Add MacPorts SDK locations to README.
-
Add support for
**operator to lexer and parser. - Color settings for each sigil name. Both the interpolating (lower case) and literal (upper case) name use the same settings.
- Add support for stepped ranges
Bug Fixes
-
Decompile
{:|, …, …}as cons operator in Elixir Dbgi. -
Fix missing guards when decompiling Elixr DbgI clauses using special decompiler
Guards where missing because only
decompiler.appendSignaturewas used. -
Fix module.Reference.calculateDefaultRangeInElement
element.textOffsetinstead ofelement.textLengthwas used for end of range. -
Render
OtpErlangExternalFuncorrectly as remote captures (&Mod.fun/arity). Fixes decompilingEcto.Changeset.validate_number. -
Protect ExUnit configuration
ProducerfromElixirFilewithoutVirtualFile. -
Unquote.treeWalkUpno longer assumes that the final argument tounquoteis aCall. -
Fix Find Usages for call definitions
-
Don’t resolve primary Find Usages element.
The primary element passed to
FindUsageHandleris now already resolved, so resolving it again for call definitions finds usages ofdef,defmacro, etc. -
Since the element passed to
FindUsagesProvider#canFindUsageFor, definers can no longer be excluded, so remove that check.
-
Don’t resolve primary Find Usages element.
The primary element passed to
-
Don’t highlight
QuoteorSigilas normal text if part of documentation. Since the annotators will run in arbitrary order, theTextualannotator has to avoid annotating the same nodes as theModuleAttributeannotator or the colors can get interleaved. -
Put
ENTRANCEand Initial Visited Element in__module__.Resolver. - Keep searching when resolving type parameters if bitstring is encountered.
-
Fix
UnaliasedName.unaliasedNamefor atoms. -
Restore
ElixirAtom#getNameLost when parser was regenerated when Elixir <= 1.6 support was dropped in 679a9689cfe097018b9baa4e894d4550a84d7aac.
Meaningful config keys in Elixir projects
A quick reminder that using a meaningful key (eg. a module name instead of an arbitrary atom) to store configuration in Elixir is quite simple and often leads to more maintainable code.
https://craft.mirego.com/2022-01-06-meaningful-config-keys-in-elixir-projects
Passing Unknown Attributes into Your Component
On your LiveView page, you are using a custom component. You want to be able to pass HTML attributes into the component, but the component doesn’t know anything about the attributes being passed! You need a way to pass arbitrary attributes through and get them where you want them.
https://fly.io/phoenix-files/passing-unknown-attributes-into-component/
Elixir Wizards S7E8 Sigu Magwa on the Elixir Community in Kenya
The latest episode of the Elixir Wizards podcast released this morning! Check it out: https://smartlogic.io/podcast/elixir-wizards/s7e8-magwa/
Elixir Wizards S7E8 Sigu Magwa on the Elixir Community in Kenya
The latest episode of the Elixir Wizards podcast released this morning! Check it out: https://smartlogic.io/podcast/elixir-wizards/s7e8-magwa/
Using View as a way to simplify your system
Many applications introduce some kind of status to make it easier to share data.
However, more and more modules in your codebase need to be explicit about these assumptions. Views can eliminate the problematic SQL query. It’s also great way to introduce well-defined entities.
https://bartoszgorka.com/view-as-way-to-eliminate-problematic-queries
Restore LiveView State on Startup
You are storing some LiveView state in the browser. You want to retrieve that saved state as early as possible to improve the user experience.
The approach we used earlier waits for the LiveView to request the client to send the data. In your situation, you know you want the data, so why wait around to be asked for it? Can you have it automatically pushed from the client without being requested? Can you do it in a way that is reusable for other pages and other LiveViews and not just this one page?
This recipe improves the design and even makes it work for multiple LiveViews in the same application!
https://fly.io/phoenix-files/restore-liveview-state-on-startup/
ThinkingElixir 080: Waffle Making with Boris Kuznetsov
In episode 80 of Thinking Elixir, we talk with Boris Kuznetsov to learn about the Waffle library and how it is used to attach images, video, and audio to your Ecto records while also processing the attachments for thumbnails, encodings, and more. We learn about the history of the project having forked from Arc, which is no longer maintained. We cover the challenges of supporting and maintaining a library created as a fork. We talk about Second System Syndrome and the desire we often feel that it would be easier to just start over. All this and more!
New in Legendary: 65% reduction in Docker build times via Elixir releases
We introduced a new Dockerfile and CI config that uses Elixir releases and it cut our image build times by 60-70%!
Introduction to Elasticlunr
Elasticlunr is a small, full-text search library for use in the Elixir environment. It indexes JSON documents and provides a friendly search interface to retrieve documents.
The library is built for web applications that do not require the deployment complexities of popular search engines while taking advantage of the Beam capabilities.
Read more: https://atandarash.me/blog/introduction-to-elasticlunr
Optimizing Dockerfile for Phoenix mixed with Node, Rust & Tailwind
Heyplay is a game creation platform powered by Phoenix coupled with Node and Rust — an ultimate web development stack that deploys in seconds thanks to using Docker multi-staging to the fullest. Here’s the secret sauce plus extra hints for those into Tailwind or Umbrellas.
Read more on the Cloudless Studio blog.
How to handle map types in a Phoenix form ?
just a suggestion on how to handle map types in Phoenix forms https://blog.jasonkaniekete.fr/how-to-handle-map-type-in-a-phoenix-form/
Log all the things - blog post about features and possibilities of current Logger
This post was for a long time on “ready to publish” list, but finally I managed to do it. Here I try to describe all the features and capabilities of current Logger implementation that is backed by the Erlang logger.
https://hauleth.dev/post/log-all-the-things/
Enjoy
Fly.io Deploy Elixir Phoenix LiveView ~> 1.6 with Bulma and Tailwind CSS
This project is scaffold bulma and tailwind boilerplate code to project Elixir Phoenix ~> 1.6 that now uses esbuild.
Thanks to fly.io
Running
To start your Phoenix server:
-
Install dependencies with
mix deps.get -
Start Phoenix endpoint with
mix phx.serveror inside IEx withiex -S mix phx.server
Now you can visit localhost:4000 from your browser.
Testing
-
Enter
localhost:4000/to bulmacss and admin template. -
Enter
localhost:4000/tailwindto tailwindcss admin template.
Production
Ready to run in production? Please check our deployment guides.
NOW => How this project was made :D
-
Creating
mix phx.new phx_scaffold_bulma_tailwind –live –no-ecto - Install and configure dart_css.
- Install and configure bulma.
- Install and configure tailwind
-
Configure
mix.exs -
Configure
dev.exs
Follow complete steps:
1. Creating Phoenix 1.6 LiveView project
mix phx.new phx_scaffold_bulma_tailwind --live --no-ecto
2. Install dart_css
Follow instructions here.
3. Install bulma
npm i -D --prefix assets bulma
Import bulma.sass file into css/app.scss with:
@import "../node_modules/bulma/bulma.sass";
4. Install tailwindcss
npm i -D --prefix assets tailwindcss autoprefixer postcss postcss-loader
Create file assets/tailwind.config.js with:
module.exports = {
content: [
"../lib/**/*.html.eex",
"../lib/**/*.html.leex",
"../lib/**/*.html.heex",
],
theme: {
extend: {},
},
plugins: [],
}
Create file assets/postcss.config.js with:
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {}
}
}
Create file assets/css/tailwind.css with:
/* This file is for your main application CSS */
@tailwind base;
@tailwind components;
@tailwind utilities;
Import css/tailwind.css into assets/css/app.scss after css styles:
Here is last line of the file
@import "./tailwind.css";
Configure mix.exs into function aliases with:
# $ mix setup
#
# See the documentation for `Mix` for more info on aliases.
defp aliases do
[
setup: ["deps.get"],
"assets.deploy": [
"cmd npm --prefix assets install",
"tailwindcss --postcss --minify --input=css/tailwind.css --output=../priv/static/assets/tailwind.css",
"esbuild default --minify",
"sass default --no-source-map --style=compressed",
"phx.digest"
]
]
end
Configure dev.exs into watchers with npx instructions:
# For development, we disable any cache and enable
# debugging and code reloading.
#
# The watchers configuration can be used to run external
# watchers to your application. For example, we use it
# with esbuild to bundle .js and .css sources.
config :fvideen_platform, FvideenPlatformWeb.Endpoint,
# Binding to loopback ipv4 address prevents access from other machines.
# Change to `ip: {0, 0, 0, 0}` to allow access from other machines.
http: [ip: {127, 0, 0, 1}, port: 4000],
check_origin: false,
code_reloader: true,
debug_errors: true,
secret_key_base: "q8icUmJfcHI8LF9Ajh+WKBaIXlxER5k7Hdwu845pJO45MBjL8eg5bJ8o9cJyverv",
watchers: [
# Start the esbuild watcher by calling Esbuild.install_and_run(:default, args)
npx: [
"tailwindcss",
"--input=css/tailwind.css",
"--output=../priv/static/assets/tailwind.css",
"--postcss",
"--watch",
cd: Path.expand("../assets", __DIR__)
],
esbuild: {
Esbuild,
:install_and_run,
[:default, ~w(--sourcemap=inline --watch)]
},
sass: {
DartSass,
:install_and_run,
[:default, ~w(--embed-source-map --source-map-urls=absolute --watch)]}
]
