Giter Site home page Giter Site logo

Comments (10)

jsakas avatar jsakas commented on July 20, 2024 1

Any though?

Yes, I think that would be a great alternative to the jss syntax.

from tss-react.

jsakas avatar jsakas commented on July 20, 2024 1

I have started on the work but have been unable to get it to work properly with typescript typings. The classes object keeps coming back as Record<never, string> and I am unsure why. See the PR here: #13

from tss-react.

garronej avatar garronej commented on July 20, 2024

Hi @jsakas,
Sorry, it's an oversight of my part.
I wasn't encline to implement this API because it's hard to make it type safe.
Now I understand that it's a must have.
I will implement a feature to cover this use case, I can't tell you exactly when though.

from tss-react.

garronej avatar garronej commented on July 20, 2024

I think I can come up with an API like that:

const useStyles = makeStyles<{ color: "red" | "blue" }>()(
    (theme, { color }, classes) => ({
          "el1": {
              [`&:hover .${classes.el2}`]: {
                  "display": "block"
              },
          },
          "el2": {
               "display": "none"
          },
    })
);

Any though?

from tss-react.

jsakas avatar jsakas commented on July 20, 2024

I will implement a feature to cover this use case, I can't tell you exactly when though.

This seems pretty critical to anyone who is migrating from Material UI v4 to v5 but can't move to styled components syntax yet.

I'm trying to address myself on a fork but it seems like the proposed API might not be possible due to the order of operations in the library.

from tss-react.

garronej avatar garronej commented on July 20, 2024

This seems pretty critical to anyone who is migrating from Material UI v4 to v5 but can't move to styled components syntax yet.

Agreed, this needs to be done ASAP. I will try to free up time in the coming days.

I'm trying to address myself on a fork but it seems like the proposed API might not be possible due to the order of operations in the library.

To implement the proposed API I think we will need a preflight to get [ "el1", "el2" ] or maybe we could make it work with proxies...

from tss-react.

garronej avatar garronej commented on July 20, 2024

I will have a look tonight. Maybe I can get it done in a couple of hours...

from tss-react.

garronej avatar garronej commented on July 20, 2024

dollar_syntax_tss

Nice!

from tss-react.

garronej avatar garronej commented on July 20, 2024
const useStyles = makeStyles()((theme, _params, css) => {

	const child = {
		"background": "blue",
		"border": "1px solid black"
	};

	return {
		"parent": {
			"border": "1px solid black",
			"padding": 30,
			[`&:hover .${css(child)}`]: {
				"background": "red",
			}
		},
		child
	};
});
//...

<div className={classes.parent}>
	<div className={classes.child}>
		Background should turn red when mouse is hover the parent.
        </div>
</div>

from tss-react.

garronej avatar garronej commented on July 20, 2024

Hi @jsakas,
I am sorry I had to update the API for nested selector. The approach based on css was broken.
https://github.com/garronej/tss-react#selecting-children-by-class-name

from tss-react.

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.