javivelasco / javivelasco/react-css-themr

Themr with pure functions

Open
#81 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
589
Forks
65
PR merge metrics
No merged PRs in 30d

Description

Does anyone have an example of using themr with pure function components vs. classes and how to provide a default theme and then override that theme from a parent container? I've searched through the readmes and issue log and I'm not finding anything solid as an example for this case.

Here's my thought on how it should work
```scss
/* defaultTheme.module.scss */
.button {
background-color: blue;
color: white;
}

```
```javascript
/* Button.js */
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import { themr } from 'react-css-themr';
import defaultTheme from './defaultTheme.module.scss';

const Button = ({ theme }) => {
const classes = classNames({ [theme.button]: true });
return Button;
};

Button.propTypes = {
theme: PropTypes.any
};

export default themr('Button', defaultTheme)(Button);

```
```scss
/* parentTheme.module.scss */
.button {
background-color: white;
color: blue;
}

```
```javascript
/* ParentContainer.js */
import React from 'react';
import { render } from 'react-dom';
import parentTheme from './parentTheme.module.scss';
import Button from './Button';

render(
,
document.getElementById('app');
);

```

Default theme seems to work fine and the button component displays the default styles no problem. However, nothing happens when the parent passes a theme down.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the Button.js and ParentContainer.js examples in the issue, then inspect how themr combines the defaultTheme with a theme passed through the theme prop. Reproduce the example and verify that the parent theme replaces or overrides the default button styles; document the correct usage or identify the failing behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.