Coder Social home page Coder Social logo

Comments (6)

RonaldTreur avatar RonaldTreur commented on August 29, 2024

Added to my to-do list, thanks! Curious behavior indeed! Especially since SASS is processing the @extend-directives..

from stss.

RonaldTreur avatar RonaldTreur commented on August 29, 2024

Just checked this, but it works OK when I try. My result is this:

".center": {
    textAlign: Ti.UI.TEXT_ALIGNMENT_CENTER
},
".padded-centered": {
    textAlign: Ti.UI.TEXT_ALIGNMENT_CENTER
},
".padded": {
    left: "10dp",
    right: "10dp"
},
".padded-centered": {
    left: "10dp",
    right: "10dp"
}

I'm not sure why you lack .center rule for .padded-centered..
Perhaps you could pull the latest version and try again? Also, if someone else can reproduce this, be sure to post it here!

I'll leave this open for now, until @masterbee gives us the thumbs up.

from stss.

masterbee avatar masterbee commented on August 29, 2024

@RonaldTreur , thanks, and I just pulled and noticed the same behaviour. So all good.

As a note: I will be honest, but was expecting was to have the .center value in with the left and right and it a bit surprised that it was added as a separate selector.

wrote:

STSS File

/* Center text */
.center {
    text-align: center;
}

.padded {
    left: 10dp;
    right: 10dp;
}

.padded-centered {
    @extend .padded;
    @extend .center;
}

expected:

".center": {
    textAlign: Ti.UI.TEXT_ALIGNMENT_CENTER
},
".padded": {
    left: "10dp",
    right: "10dp"
},
".padded-centered": {
    left: "10dp",
    right: "10dp",
    textAlign: Ti.UI.TEXT_ALIGNMENT_CENTER
}

got:

".center": {
    textAlign: Ti.UI.TEXT_ALIGNMENT_CENTER
},
".padded-centered": {
    textAlign: Ti.UI.TEXT_ALIGNMENT_CENTER
},
".padded": {
    left: "10dp",
    right: "10dp"
},
".padded-centered": {
    left: "10dp",
    right: "10dp"
}

I have used SCSS quiet often and it was usually a bit smarter than that. Any thoughts? on why it would create a separate selector for the second @extend instead of just writing it out in the selector block it is extending, like the first @extend?

from stss.

RonaldTreur avatar RonaldTreur commented on August 29, 2024

@masterbee I understand you completely. SCSS is even smarter than that however ;-) It doesn't duplicate any styling, it simply adds a selector to the ones extended. It's actually due to the limitations of TSS the duplication occurs. Since multiple selectors don't work for TSS, they are split and each receives a copy of the values.

This is actually the intermediate result (after SCSS processed):

/* Center text */
.center, .padded-centered {
  textAlign: center; }

.padded, .padded-centered {
  left: 10dp;
  right: 10dp; }

This is where conversion to TSS kicks in, and the styling actually does get duplicated.

You are right in that in that case the styles could be combined, but since TSS is only used during compilation there isn't much use to such an optimization.

from stss.

RonaldTreur avatar RonaldTreur commented on August 29, 2024

Since it is working (though perhaps not always as expected ;-)) I'll close this.

from stss.

rpedroni avatar rpedroni commented on August 29, 2024

Hey guys,

I do understand why this occurs but do you guys use any workaround to be able to use @extend appropriately for tss?

Thanks!

from stss.

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.