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

Create directory for themes #92

Merged
merged 6 commits into from
Jul 5, 2023
Merged

Conversation

jhff
Copy link
Contributor

@jhff jhff commented Jul 3, 2023

This change addresses issue #65 by:

  • Adding themes folder to config directory
  • Adding default theme that is created when it is not in the config directory yet
  • Changing config file to take a theme filename instead of palette. If theme is not found, default Palette is used.
  • Allowing users to add their own theme files in themes directory

Copy link
Contributor

@lodenrogue lodenrogue left a comment

Choose a reason for hiding this comment

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

I'm trying to run the code for this change but it's not creating the theme files in the theme directory.

Theme directory is created successfully though.

I'm on macOS.

@lodenrogue
Copy link
Contributor

lodenrogue commented Jul 4, 2023

I'm trying to run the code for this change but it's not creating the theme files in the theme directory.

Theme directory is created successfully though.

I'm on macOS.

So it seems the issue is if you already have a config and have used the app before it doesn't go into this option in the main->load_from_state() function.

 _ => (
    Screen::Welcome(screen::Welcome::new()),
    Config::default(),
    Command::none(),
)

Which means that Config::create_themes_dir() is never called inside the Welcome::new() method.

If we add Config::create_themes_dir() at the start of the load_from_state() function it adds the theme files in the themes directory but it doesn't update the app UI until the next time you open the app.

@jhff
Copy link
Contributor Author

jhff commented Jul 4, 2023

I'm trying to run the code for this change but it's not creating the theme files in the theme directory.
Theme directory is created successfully though.
I'm on macOS.

So it seems the issue is if you already have a config and have used the app before it doesn't go into this option in the main->load_from_state() function.

 _ => (
    Screen::Welcome(screen::Welcome::new()),
    Config::default(),
    Command::none(),
)

Which means that Config::create_themes_dir() is never called inside the Welcome::new() method.

If we add Config::create_themes_dir() at the start of the load_from_state() function it adds the theme files in the themes directory but it doesn't update the app UI until the next time you open the app.

You're right, if you already had a config file, themes files weren't being created.

Moved Config::create_themes_dir() to main() so it runs at startup. It should only do this the first time you open the app without themes. 0b3ccb4

Main issue is that a config file with palette instead of theme param, will go into default theme. Any user who already used the app might not notice that palette has been deprecated, but I don't think it makes sense to add code specifically for that use case in such an early phase.

@casperstorm
Copy link
Member

Great PR @jhff.
Personally, I wouldn't want us to create all those themes though 🤔
I would rather keep it simple and just make Halloy able to read from /themes/*.yaml - and then if: theme: "foobar.yaml" We use /themes/foobar.yaml - if theme is None, or invalid, we use the default theme.
Then, in the config.template.yaml we can instead point to our Wiki to encourage people to download and add new themes.

I think my reason behind this is that, as a user i would rather build a collection of themes i want, rather than a bunch of themes i never want to use.

@jhff
Copy link
Contributor Author

jhff commented Jul 4, 2023

Great PR @jhff. Personally, I wouldn't want us to create all those themes though 🤔 I would rather keep it simple and just make Halloy able to read from /themes/*.yaml - and then if: theme: "foobar.yaml" We use /themes/foobar.yaml - if theme is None, or invalid, we use the default theme. Then, in the config.template.yaml we can instead point to our Wiki to encourage people to download and add new themes.

I think my reason behind this is that, as a user i would rather build a collection of themes i want, rather than a bunch of themes i never want to use.

np, I'll rework this PR to remove those themes and leave the default one! It was just an initial approach with a set of hardcoded themes 🙂

@jhff
Copy link
Contributor Author

jhff commented Jul 4, 2023

Removed all themes except the default one ce6da49

Users can add their own theme files. Also expect "name" field in theme files so that we can list them in the future in the app if needed with the proper name.

@@ -0,0 +1,11 @@
name: "Halloy"
Copy link
Member

Choose a reason for hiding this comment

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

Do we need name or can the filename just be the key?

Copy link
Contributor

Choose a reason for hiding this comment

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

Name of the theme as the value is more user friendly in my opinion

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the way to go is:

  • filename -> config file theme key
  • name -> theme name to display in the app

Let's say we add the file solarized_dark.yaml for the Solarized (Dark) theme. solarized_dark is used as the key and Solarized (Dark) can be used to display in the future command bar of the app, e.g..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this PR name is not used anywhere, it's just there so users are already educated to add that instead of having to change their files in the future.

Copy link
Member

Choose a reason for hiding this comment

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

Agreed that makes sense

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should wiki be updated with name in the example themes?

Copy link
Member

Choose a reason for hiding this comment

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

I think it should yeah, @jhff.

src/main.rs Outdated
Comment on lines 52 to 56
// Create themes directory
Config::create_themes_dir();

Copy link
Member

Choose a reason for hiding this comment

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

Nit: A module namespace works better here than struct namespace... config::create...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@casperstorm
Copy link
Member

casperstorm commented Jul 5, 2023

The two last thing I have is that I would like to rename halloy (default theme) to ferra since thats the name of it, and then could you please fill out CHANGELOG with a sentence about your change?

Otherwise I am good to merge.

Copy link
Member

@casperstorm casperstorm left a comment

Choose a reason for hiding this comment

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

Lets go!

@casperstorm casperstorm merged commit 3a8c812 into squidowl:main Jul 5, 2023
1 check passed
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

Successfully merging this pull request may close these issues.

None yet

4 participants