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

[themes] export theme settings separately for external use #457

Open
felixroos opened this issue Feb 9, 2023 · 3 comments
Open

[themes] export theme settings separately for external use #457

felixroos opened this issue Feb 9, 2023 · 3 comments

Comments

@felixroos
Copy link
Contributor

Hello! I am just trying out the themes and they are really easy to use and look great inside the editor!
To be able to reuse the theme colors for other elements of the page, it would be great if the settings would be exported separately.
I tried to find a way to deduce the settings from the exported theme object, but the standardized keys background, foreground, caret, ... etc are gone. Also, the structure of that (huge) exported theme object seems to vary between different themes, so there is no way of knowing where a specific color is (at least I haven't found one)
This could be solved by exporting the settings object e.g.

export const defaultSettings = {
  background: "#ffffff",
  foreground: "#75baff",
  caret: "#5d00ff",
  selection: "#036dd626",
  selectionMatch: "#036dd626",
  lineHighlight: "#8a91991a",
  gutterBackground: "#fff",
  gutterForeground: "#8a919966",
};
export const abcdefInit = (options?: Partial<CreateThemeOptions>) => {
  const { theme = 'dark', settings = {}, styles = [] } = options || {};
  return createTheme({
    theme: theme,
    settings: {
      ...defaultSettings,
      ...settings,
    },
  /*
rest of theme 
*/
});

What do you think? I could also send a PR if you like.
Anyways thanks for this cool lib! Happily using it with https://strudel.tidalcycles.org/

@jaywcjlove
Copy link
Member

I didn't think there was any problem, so I added it.

@felixroos

@felixroos
Copy link
Contributor Author

thanks for the quick fix! for some reason, the new versions (4.19.8) do not contain the export yet, the code on npm still looks like this:

image

@jaywcjlove
Copy link
Member

@felixroos Upgrade v4.19.9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants