Skip to content

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

@felixroos

Description

@felixroos

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/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions