Giter VIP home page Giter VIP logo

Comments (14)

jimbojetlag avatar jimbojetlag commented on May 23, 2024 8

@lynnjepsen please do not direct discussions to a chat channel. There are three good reasons for this:

  1. Whatever happens in those channels, are not searchable and googlable by others. Many people who have contributed to this issue, for instance, would have never been able to contribute and make suggestions.
  2. There is no structure in those chat channels, there are no such things as threads and states to track the progress of a discussion. Those texts are just ephemeral.
  3. Your team on Discord is not responsive. Many questions are never answered. My questions and concerns in this very issues would have had a single line respond, if any. Compare that with the lengthy discussions that happened here.

You could instead simply tag these issues as discussion type.

from material-components-web-react.

lynnmercier avatar lynnmercier commented on May 23, 2024 5

Hey everyone, there is clearly a lot of discussion that needs to be had over this problem. I don't think a GitHub issue is the right place to talk, because I keep looking at GitHub issues and thinking "How do I close them all!" But actually, this thread is a discussion, and not something that needs to be closed.

So I propose the following: please use our "material-theming" channel (in the web category) in our Discord server. You can chat with us directly by following this link: https://discordapp.com/invite/material-components

I'm going to close this issue now. So all future discussion about Sass, CSS-In-JS, custom properties, etc can happen in that channel.

Also, as we have discussions, I will start filing more specific GitHub issues about tasks my team is working on. For example, I'll probably file a "Build a prototype using CSS-In-JS" issue soon, to show that we're looking into that specific technical detail.

from material-components-web-react.

moog16 avatar moog16 commented on May 23, 2024 1

I agree integrating Sass with CRA has been a big hurdle for us to overcome, but we've been able to get it working between the catalog and using the getting started guide. I think its too early to be looking at CRA 2.0 since its only in alpha. As you know, a lot can change while in alpha. I do see that CRA is stating that they will support Sass compilation, but to what extent and how exactly it'll be enabled is still up in the air.

+1 to being different from other boilerplates as it removes "webpack hell" and maintenance.

from material-components-web-react.

kfranqueiro avatar kfranqueiro commented on May 23, 2024 1

We already use CSS custom properties in a few of MDC Web's packages. However, they are not a silver bullet. Here are a few problems we've already encountered in MDC Web:

  • IE 11 doesn't support CSS custom properties. Handling variables at the preprocessor level allows us to expose customizations that can work in all browsers MDC Web supports.
  • There are things we would like to use custom properties for, but can't due to current limitations in CSS. One prime example is maintaining colors and alpha values separately and composing them together, which can be done in Sass, but has no widely-supported CSS equivalent.
  • Using a preprocessor allows us to perform calculations (some of which have no CSS equivalent) based on defined variables. Thus we can expose Sass variables that are configured pre-calculation rather than making users calculate the correct value themselves; this would not be possible with CSS custom properties exposed through the built CSS.

Also, tangentially, I'm not really sure what warrants the insinuation that Sass isn't modern. It's being actively worked on full-time. As far as I can tell, PostCSS plugins would (ideally) just be a different means to the same end - we'd still effectively need to use it as a preprocessor.

from material-components-web-react.

jimbojetlag avatar jimbojetlag commented on May 23, 2024

@moog16 Would it be possible to prefix the sass import path of external dependencies with a tilde ~? That might help us to not depend on CRA for resolving this.

from material-components-web-react.

moog16 avatar moog16 commented on May 23, 2024

@jimbojetlag How would adding the ~ help? You would still need some type of sass importing tool to use those files, correct? Also I believe if the Sass dependencies don't have ~s then we will still see that same issue.

RE MDC React Guide:
I understand that modifying the package.json is not ideal, but it is fairly straightforward. And once setup it works. What other issues do you run into with this process?

from material-components-web-react.

moog16 avatar moog16 commented on May 23, 2024

I was also going to suggest using a different boilerplate other than CRA. There are a lot of Webpack/Sass lovers out there that have created these seed projects. It may not be as heavily supported as CRA (and not Facebook approved), but I'm sure there are some pretty solid ones. I was going to explore other options and link them in MDC React's docs. How does that sound?

from material-components-web-react.

jimbojetlag avatar jimbojetlag commented on May 23, 2024

@moog16 You are right about Sass dependencies as demonstrated in the below:

Currently with CRA 2.0, importing an MDC React Sass module like this:

// App.css
@import '~@material/react-top-app-bar/index.scss';

, gives this error:

Failed to compile.

./src/App.scss)
Module build failed:
@import "@material/top-app-bar/mdc-top-app-bar";
^
      File to import not found or unreadable: @material/top-app-bar/mdc-top-app-bar.
      in <...>/node_modules/@material/react-top-app-bar/index.scss (line 1, column 1)

If we add ~ prefix in the MDC React module:

// @material/react-top-app-bar/index.scss
//@import "@material/top-app-bar/mdc-top-app-bar";
@import "~@material/top-app-bar/mdc-top-app-bar";

, then the error gets propagated to the dependency, in this case an MDC Web module:

./src/App.scss)
Module build failed:
@import "@material/top-app-bar/mdc-top-app-bar";
^
      File to import not found or unreadable: @material/top-app-bar/mdc-top-app-bar.
      in <...>/node_modules/@material/react-top-app-bar/index.scss (line 1, column 1)

I cannot see a way for MDC React to stop this error propagation.

RE MDC React Guide:
I understand that modifying the package.json is not ideal, but it is fairly straightforward. And once setup it works. What other issues do you run into with this process?

The guide is based on CRA 1.x, I was trying to get MDC React work with CRA 2.x, which claims to support Sass and sooner or later will replace the current version, making the guide obsolete. I understand that CRA 2.x is still in alpha.

It may not be as heavily supported as CRA (and not Facebook approved), but I'm sure there are some pretty solid ones. I was going to explore other options and link them in MDC React's docs. How does that sound?

The difference between CRA and other boilerplates, apart from being official, is that CRA is not a boilerplate. Boilerplates are like ejected CRA, that is you as the developer will inherit the future maintenance burden of the build tools. Depending on the project size, this maintenance may not be trivial.

I think the getting stared guide should continue to be based on CRA, but we need to push CRA to have Sass support for dependencies. Like I explained at the beginning of this issue, Sass is not a first class styling tool in React and it community, yet it is the case for MDC. This may cause MDC React having a hard time.

from material-components-web-react.

mswezey23 avatar mswezey23 commented on May 23, 2024

Noting that following the getting started guide on Windows 10 leads to this sass issue as described here. I've seen half a dozen solutions, but for someone that's not an expert at webpack configurations - it only leads to confusion. Going try out https://github.com/jamesmfriedman/rmwc to see if that gets me where I want to be.

File to import not found or unreadable: @material/react-button/index.

from material-components-web-react.

moog16 avatar moog16 commented on May 23, 2024

@mswezey23 I just tried CRA with @material/react-button on windows 10 and it worked fine.

Let me know what issues you're running into and I can help :)

from material-components-web-react.

nickmccurdy avatar nickmccurdy commented on May 23, 2024

I appreciate the amount of work and technological decisions that have gone into the existing Sass styles for Material Components Web and this project, but I agree with @jimbojetlag and I'd really like to be able to customize its styles without Sass before switching from other frameworks. As far as Sass goes, in my opinion it's better to replace it with more modern CSS preprocessors like PostCSS or CSS in JS solutions like styled components for all practical purposes (especially if you're using a dynamic frontend view framework like React).

I understand that MDC may have a hard requirement on using Sass for design purposes, but I think we can drop the requirement of end users compiling and writing Sass without impacting the architecture and workflow of the existing styles, allowing users more of a choice in tooling and interop with existing React styling approaches. For example, Bootstrap 4 is written in Sass and provides CSS custom properties for customization without a build tool, which I think is the simplest and most flexible solution as long as your environment supports CSS custom properties.

from material-components-web-react.

moog16 avatar moog16 commented on May 23, 2024

I am a fan of CSS in JS and PostCss. We do have PostCSS in our build process, and am not sure how we could use PostCSS to make things easier for the end developer.

I haven't used much CSS in JS in projects. How would something like that look like? And how would you go about selecting a framework. Just based off of this list there are a ton of libraries out there.

Would you be willing to do a little bit of code in one of the components to show us?

from material-components-web-react.

nickmccurdy avatar nickmccurdy commented on May 23, 2024

Personally if I maintained a project in Sass and I didn't need dynamic styles, I would port it to modern CSS (mainly custom properties), optionally using postcss if necessary for legacy browser support. I understand the team may want to continue using Sass, but you can still create CSS custom properties in Sass so they can be changed by end users that don't use Sass (see Bootstrap 4). Then a plain old CSS build can be distributed with the package, which would solve the issue of this not working with CRA without having to wait for v2 to stabilize.

I'm pretty new to CSS in JS to be honest, but I don't think it would be possible to use it in core unless you want to completely rewrite and rearchitect all styles in MCW and MCWR. That being said, Styled Components looks like the strongest option to me, but it only works with React. Emotion has a very similar syntax that's almost completely compatible with Styled Components, but it works in any JS framework. Both support writing Sass, but I would still prefer writing CSS custom properties if I were using a CSS in JS library.

Ultimately I think just adding CSS custom properties to Sass is the best approach, since they can be set in CSS, CSS modules, Sass, Less, CSS in JS, etc. As far as prior art goes, it's worth mentioning that Material UI used to use inline styles and decided to replace it with JSS after running into scaling and flexibility issues, but I don't like either approach compared to Styled Components or plain CSS personally.

from material-components-web-react.

nickmccurdy avatar nickmccurdy commented on May 23, 2024

I think it would really help the non-Sass development workflow if we added as many custom properties as possible, allowing users to use Sass in more advanced use cases.

  • I'm aware that IE doesn't have custom properties, but often it's more useful to have basic static custom properties than fully dynamic custom properties, so I think polyfills solve the issue well (Sass doesn't have dynamic variable at all, so it's not any worse than Sass's support given the right preprocessor).
  • That color and alpha problem sounds interesting, is it solvable with math or any other new specs?
  • I'm not sure I understand, couldn't you make a custom property based on a calculation from another custom property? Is this only an issue for calculations that can't be made in standard CSS (in which case a user can reimplement it in JS to avoid using Sass)?
  • To be honest, I don't like Sass, I think it encourages antipatterns like deeply nested selectors and specificity hacks. That being said I'm mainly against using it in React projects because it has too many features that break standard CSS enough to make extension via CSS in JS difficult. I'm fine with allowing users that like Sass to continue using it, but it causes issues with common React styling practices.

from material-components-web-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.