Giter Site home page Giter Site logo

Style/font defaults about mjml HOT 6 CLOSED

mjmlio avatar mjmlio commented on June 29, 2024
Style/font defaults

from mjml.

Comments (6)

arnaudbreton avatar arnaudbreton commented on June 29, 2024 5

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.

patrickfweston avatar patrickfweston commented on June 29, 2024

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.

patrickfweston avatar patrickfweston commented on June 29, 2024

@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.

Chrisedmo avatar Chrisedmo commented on June 29, 2024

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.

klombomb avatar klombomb commented on June 29, 2024

Great Idea! Any chance this will make it to a release anytime soon?

from mjml.

arnaudbreton avatar arnaudbreton commented on June 29, 2024

Hi everyone,

I'm closing this issue since we came up with implementations to be discussed for the cases described here:

  • #79 for global attribute definition
  • #80 to use custom fonts

Let's move the discussions there!
Thanks for your contribution to MJML, highly appreciated!

from mjml.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.