Giter Club home page Giter Club logo

Comments (5)

javivelasco avatar javivelasco commented on June 8, 2024

Nailed it! I've been thinking about doing the exact same thing you proposed. It would be backwards compatible and solves the issue. I had this very issue with Dropdown Component in react toolbox. It uses an Input under the covers and defines the same classes for label, error, etc. This would make this lib way better than it is right now since this is the most important caveat I see by now.

Do you want to PR? It shouldn't be difficult

from react-css-themr.

javivelasco avatar javivelasco commented on June 8, 2024

I'm still thinking about this... What about namespacing with an attribute instead of mapping? Less flexible but cleaner API. For example:

/* Section.css */
.content {
    & .buttonContent{
      color: red;
    }
}

And assuming that your Button has a classname API with a content node:

import React from 'react';
import Button from './ThemedButton.js';
import theme from './section.css';

const Section = () => (
  <section className={theme.content}>
    <Button theme={theme} namespace="button" />
  </section>
);

We can even support this namespace setup from the themr factory function (even falling back to the component identifier)so a button can have by default a namespace that could be enabled using a simple prop namespace:

const ThemedButton = themr('button', style)(Button);
// Or... themr('ContextIdButton', style, { namespace: 'button' })(Button);
<ThemeButton theme={theme} namespaced />

Or using recompose under the hood as you do now. Thoughts?

from react-css-themr.

denisborovikov avatar denisborovikov commented on June 8, 2024

Namespacing looks good. Not so obvious as mapping but you don't have to list all classes manually. I like to use namespace as a second prop with the theme as you can see the namespace's name at the same place where you use it (in your parent component, not button itself.)

from react-css-themr.

javivelasco avatar javivelasco commented on June 8, 2024

Great!

from react-css-themr.

denisborovikov avatar denisborovikov commented on June 8, 2024

Here how I see it. namespace and theme props should be used together. I don't know if it makes sense to add support of the namespace with default/context styles.

from react-css-themr.

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.