Comments (6)
Hi here,
Thanks much for opening the discussion. Sounds a bit similar to #14, right?
Joining your idea of a config file. We're thinking is to implement a pre-processing phase where we would read styles defined globally (in a mj-style
tag for instance) and inline them on the elements where they should apply.
A short example is more illustrating our idea here:
<mj-body>
<mj-head>
<mj-style>
.foobar {
font-family: Arial;
}
</mj-style>
</mj-head>
<mj-section>
<mj-column>
<mj-text class="foobar">Hello world</mj-text>
<mj-text class="foobar">Hello world 2</mj-text>
</mj-column>
</mj-section>
</mj-body>
would result in
<mj-body>
<mj-head>
<mj-style>
.foobar {
font-family: Arial;
}
</mj-style>
</mj-head>
<mj-section>
<mj-column>
<mj-text class="foobar" font-family="Arial">Hello world</mj-text>
<mj-text class="foobar" font-family="Arial">Hello world</mj-text>
</mj-column>
</mj-section>
</mj-body>
This avoids to repeat the font-family
styling property for each componant with class foobar
in my example, without changing the way components deals with attributes.
In a future release, we will also add attributes validation to provide you with warnings when not supported css properties end up inlined on a tag which doesn't support it.
What do you think? Would this work in your case?
from mjml.
I'm running into the same problem @BrettJay . There doesn't look to be support for that yet. The defaults are set in the different components' files: https://github.com/mjmlio/mjml/blob/master/src/components/Text.js#L12
I'm going to dig in the source for this some more (I just started using it a few hours ago) to see if there isn't some way to extend the default and override the values. It'd be nice to have a config file (possibly a json file or something) to set a lot of these things.
Another option I'm considering is creating some sort of gulp task runner to do a find and replace corresponding to a config file. That's more hacky, but something I could get done sooner.
I'd love to contribute if someone could point me in the right direction.
from mjml.
@arnaudbreton : It's quite similar to #14 . I haven't used Radium in the past, but I'll definitely look into it. I like the idea of an mj-head section as it'd contain everything in one file. I know that Foundation for email has a CSS inliner which does something similar to this. However, the styles in this instance are applied to the mjml elements, not the HTML elements.
What's the accepted practice with regard to putting other typography elements inside mj-text? Would something like the following be an acceptable practice:
<mj-text><h1>Hello world</h1></mj-text>
If it is acceptable, it would be nice to inject styles on the h1 elements from the mj-head as well. On the contrary, you could easily create an h1 class that you apply to the mj-text element.
Another thought is that it'd be nice to change all mj-* elements to a new default. This would be helpful in cases like #41. You could probably just use the mj-* element in mj-style like a normal CSS element selector.
from mjml.
Yeah I'd like to know how we can change the ubuntu font, and use our own google hosted font? Like Lato etc? Be good if you could override like:
@default({
font: 'Lato'
font-src: 'http://url.com/etc/'
from mjml.
Great Idea! Any chance this will make it to a release anytime soon?
from mjml.
Hi everyone,
I'm closing this issue since we came up with implementations to be discussed for the cases described here:
Let's move the discussions there!
Thanks for your contribution to MJML, highly appreciated!
from mjml.
Related Issues (20)
- Image width in outlook is overflowing HOT 2
- Issues with rendering in outlook HOT 1
- DeprecationWarning: The `punycode` module is deprecated on node 21 HOT 2
- "try it live"-Function now not working any more HOT 1
- New Twitter X logo not being rendered with <mj-social-element name="x" href="#"> HOT 1
- Just the basics HOT 3
- Navbar without hamburger unnecessary css HOT 1
- `mj-font` only emits the last style sheet for the font family HOT 1
- Font sizes increase in Gmail on iPhone XS HOT 6
- Append invisible characters to <mj-preview> HOT 1
- CORS request did not succeed, missing CORS header (mjml/api) HOT 2
- `mjml2html` render in web worker throws `Uncaught ReferenceError: window is not defined`
- Support DATA variable in href or button HOT 1
- Icon with text/Column within Column HOT 1
- Dependency: html-minifier REDoS vulnerability HOT 4
- No padding on outlook HOT 8
- Helper UrlEncode does not return the expected result HOT 3
- Empty "lang" attribute on mjml element is rendered as invalid lang="und" HOT 3
- Mobile customization issue. HOT 2
- Example of how to add color variables HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mjml.