Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: expose createTheme as createCartoTheme #138

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/react-ui/src/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { cartoThemeOptions } from './theme/carto-theme';
import { cartoThemeOptions, createTheme } from './theme/carto-theme';
import WrapperWidgetUI from './widgets/WrapperWidgetUI';
import CategoryWidgetUI from './widgets/CategoryWidgetUI';
import FormulaWidgetUI from './widgets/FormulaWidgetUI';
Expand All @@ -7,9 +7,10 @@ import PieWidgetUI from './widgets/PieWidgetUI';

export {
cartoThemeOptions,
createTheme as createCartoTheme,
WrapperWidgetUI,
CategoryWidgetUI,
FormulaWidgetUI,
HistogramWidgetUI,
PieWidgetUI,
PieWidgetUI
};
12 changes: 3 additions & 9 deletions packages/react-ui/src/theme/carto-theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -1175,16 +1175,10 @@ export const cartoThemeOptions = {
}
};

export function createTheme(options = {}) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we sure we can remove default options?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As described in documentation PR, the way to overwrite cartoThemeOptions is equal for both implementations in this way.

Also, passing to createTheme and object like:

const mainColor = { palette: { primary: { main: '#80000' }}}

results in an error. Do you have any other idea to handle this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if we leave the optional param, and just expose the method?

That way we could also allow overriding certain properties, so we would eventually get 3 options for the user:

  • call to createTheme without params (one line from the client)
  • call to createTheme with certain options (maybe just colors)
  • completely custom case, using just cartoThemeOptions (what is currently being used from template)

/cc @borja-munoz

const themeOptions = {
...cartoThemeOptions,
...options
};

let theme = createMuiTheme(themeOptions);

export function createTheme() {
let theme = createMuiTheme(cartoThemeOptions);
theme = responsiveFontSizes(theme, {
breakpoints: themeOptions.breakpoints.keys,
breakpoints: cartoThemeOptions.breakpoints.keys,
disableAlign: false,
factor: 2,
variants: [
Expand Down