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

Allow plugable themes #45

Open
tobiasBora opened this issue Apr 10, 2024 · 0 comments
Open

Allow plugable themes #45

tobiasBora opened this issue Apr 10, 2024 · 0 comments

Comments

@tobiasBora
Copy link

tobiasBora commented Apr 10, 2024

Hugo and many other static site generators provide multiple pre-built themes, like https://themes.gohugo.io/ that provides nearly 200 themes. This is really handy to quickly explore different styles and get started. I would be great to provide a plugin-like infrastructure that allows users to create a unified theme, so that people can start to write new themes. Once this is done, one can start to think about creating more themes and publishing them on some web pages.

I'm not sure what would be the best technical way to do this, but we can maybe let the user define an alias called mainTheme to some module (say myGreatTheme, that might either be installed via npm, or that is cloned from some repository, allowing the user to easily tweak minor theme options), maybe via https://www.npmjs.com/package/module-alias or maybe some sveltekit alias like https://medium.com/@rizqyhi/adding-new-path-alias-in-sveltekit-1127a1138e7 (to be honest I know very little about how modules work in js), so that later this library could run:

<script>
  import { Header } from 'mainTheme'; // See that we use `mainTheme` here instead of `$lib/component`
  // …
</script>

<Header someOptionalProps="foo">
  
</Header>

Ideally, you would also:

  • document a number of components that are typically needed to be present (possibly refactoring the components provided by this lib to allow greater configurability)
  • provide a fallback mechanism, so that if myGreatTheme does not provide, say, Header, then we use some default components for greater backward compatibility
  • provide a way to send to the theme with some options, like maybe mainTheme comes in a dark and light style.
  • allow the user to easily change a nested component, like maybe a given theme uses some buttons, then the theme might want to be able to allow the user to overwrite the theme of all buttons at once.

I guess that one can get inspired by how flowbite or skeleton work to provide customizable components.

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

1 participant