shotleybuilder
From the Phoenix 1.3 User Guide: “If we already have code that assumes jQuery is available as a global variable, we’ll either need to migrate our code (which is a must-do in the long run), or leave jQuery as a non-wrapped codebase (which is acceptable as a transition hack).” https://hexdocs.pm/phoenix/static_assets.html
What does that mean? I’ve installed material-design-lite and mdl-ext. The way I have these working is to add them as globals:
npm: {
enabled: true,
styles: {
'material-design-lite': ['dist/material.min.css'],
'mdl-ext': ['lib/mdl-ext.min.css']
},
globals: {
material: 'material-design-lite',
'mdl-ext': 'mdl-ext'
}
}
And then to import them inside app.js
import "material-design-lite/material";
import "mdl-ext";
They’re just providing some classes in the html. Simple stuff. Just confused by the docs.
Trending in Questions
Hey guys,
I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly
Do you guys have any suggestions what is the best prac...
New
Hello!
Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app.
I creat...
New
I have what I’ve heard referred to as a “lookup table” in my database. This is a way of assigning codes to common values. One common lo...
New
Hello,
I’m developing a online persistent chat system (what’s app) like using elixir/dynamodb/aws for a mobile app(flutter).
The diffic...
New
What approach to take when sending live updates to “random” users Hi! I have a question, I have a little chat app, and when I create a DM...
New
Anyone here using Honeybadger?
My Honeybadger account is being overwhelmed with noise from some bots. Seeing a lot of
Bandit.HTTPError...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
Other Trending Topics
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
There are three potential reasons for members of this forum to have a look at https://vutuv.de
You are tired or annoyed of LinkedIn.
Yo...
New
Aludel - LLM Evaluation Workbench
Aludel is an embeddable Phoenix LiveView dashboard for evaluating and comparing LLM prompts across mult...
New
Latest Phoenix Threads
Latest on Elixir Forum
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixir-ls
- #ai
- #elixirconf-us
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming











Showing Posts 1 to 5- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
peerreynders
See Globals; because, reasons.
In the case of jQuery the early practice was to simply attach the
jqueryobject towindow:That is what the sample
globalsconfiguration will do automatically for you inside the JS bundle that brunch creates. However current practice is to keep everything in a JavaScript module. Then the globals are no longer necessary because jQuery is accessed explicitly through the module mechanism:See also ECMAScript 6 modules: the final syntax
However browsers are only now starting to support ES2015 modules on an experimental level. To get the benefit of modules in the browser it has been necessary to use “bundlers” like browserify - and brunch is a bundler.
Now
importstatements are also used with CSS files because CSS modules try to move beyond the CSS Block Element Modifier naming convention as a means for avoiding naming collisions. These styles are applied inside JavaScript code; but sometimes such an import is simply used to communicate to the bundler that the CSS is being used and needs to be bundled (e.g. Webpack).It is my impression that mdl never supported CSS modules - that only started to be supported in Material Components for the web - which is why there is a warning that mdl is in limited support.
Brunch can bundle CSS files - but that is simply a matter of configuration to create a bundled
app.cssfile. So I’m not even sure if you are even getting any benefit from the mdlglobalsconfiguration or theimportstatements in connection with your styles. However brunch does need to know where to find the CSS to put into the CSS bundle.The Brunch fundamentals are covered in The Brunch.io Guide.
shotleybuilder
Shoot, sooooo much to learn
I’d not come across CSS modules but the link provided by @peerreynders is most persuasive.
This also helps to put the Material Components help into context.
In phoenix there are the .eex templates which get combined as a render function inside the view (that’s my simple understanding). Can these support CSS modules? Given that we seem to be writing for the builder and not the browser.
Sorry that this forum for phx and elixir has become slightly polluted with discussion about js!
peerreynders
The idea is to pick one CSS library and framework and stick with it - in the hope of being isolated from all the nitty-gritty details. But a certain amount of CSS knowledge is required to apply the customizations needed to use these styles effectively anyway. Of course some people don’t like the bloat and possibly excessive conformity and rather write their own CSS.
Well, that’s a matter of perspective. “CSS modules” is a “CSS in JS” technique. EEx templates are rendered in Elixir - so I say no. That being said EEx templates can reference JavaScript files which can use “CSS modules” but that would only apply to the client-side rendered portion of the page.
I only mentioned “CSS Modules” because you are bound to come across examples where CSS is imported into JS. Brunch itself doesn’t support “CSS Modules”, it can run CSS preprocessors and bundle CSS files. “CSS modules” are big with React/Webpack (Webpack changes class names by default to
[hash:base64], you have to explicitly configure[local]to retain the original names).postcss-modules is a variation on the theme for templates that can be processed by JavaScript and something like
is used to scope the CSS.
However “CSS in JS” isn’t without it’s critics - for example CSS in Depth author Keith Grant has some blog posts on the matter:
Most CSS libraries/frameworks follow some methodology like OOCSS, SMACSS, BEM, ITCSS, ACSS, MaintainableCSS, etc. to deliver modular CSS. So the style of modular CSS design (you use in EEx) is dictated by the CSS library/framework you choose.
shotleybuilder
@peerreynders ‘pick [something] and stick with it’ made me laugh - I’ve trundled along with angular (mongo, mongoose, less etc), then liked meteor integrated with angular2 until they went too commercial, and now elixir. Of course, back in the day, it was Rails. And countless other libraries. So pleased I don’t configure this stuff for a living
I’ll not go down the CSS modules path with my personal phoenix app and I don’t have the need for any js libraries just now (outside the styling) so I guess the “acceptable as a transition hack” doesn’t apply to me.
NB I did experiment with Material Component but found the select component (often hard for CSS frameworks) wasn’t quite there yet. Also like polymer. But by the time these frameworks have enough help and examples for the perpetual beginner the world will have moved on.
peerreynders
Even “just” using jQuery can be a polarizing topic.