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

Add darkly-pureblack theme #1610

Merged
merged 8 commits into from
Jun 28, 2023
Merged

Add darkly-pureblack theme #1610

merged 8 commits into from
Jun 28, 2023

Conversation

alectrocute
Copy link
Contributor

Hi Lemdevs!

In this PR:

  • Add a darkly-pureblack theme intended for OLED displays
Screenshot 2023-06-26 at 10 36 35 AM Screenshot 2023-06-26 at 10 36 38 AM Screenshot 2023-06-26 at 10 36 47 AM Screenshot 2023-06-26 at 10 36 49 AM

Thanks!

@alectrocute
Copy link
Contributor Author

The only thing I noticed that's broken is the dropdown icon. I'd love to get some more eyeballs on this.

Copy link
Member

@dessalines dessalines left a comment

Choose a reason for hiding this comment

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

Just tested and it looks beautiful.

The dropdown's and icons all look fine to me.

@alectrocute alectrocute added this to the 0.18.1 milestone Jun 26, 2023
@jsit
Copy link
Contributor

jsit commented Jun 26, 2023

@alectrocute

The only thing I noticed that's broken is the dropdown icon. I'd love to get some more eyeballs on this.

Which dropdown icon? How is it broken?

@alectrocute
Copy link
Contributor Author

@alectrocute

The only thing I noticed that's broken is the dropdown icon. I'd love to get some more eyeballs on this.

Which dropdown icon? How is it broken?

The down carot icon, I believe it’s implemented via background-image.

@alectrocute
Copy link
Contributor Author

@alectrocute

The only thing I noticed that's broken is the dropdown icon. I'd love to get some more eyeballs on this.

Which dropdown icon? How is it broken?

The down carot icon, I believe it’s implemented via background-image.

Forgot to mention that it’s broken because the color matches the background color of the select field, rendering it invisible.

@alectrocute
Copy link
Contributor Author

Fixed it, @dessalines @jsit. The down carot icon is now subtle but visible.

Screenshot 2023-06-27 at 11 30 44 AM

@jsit
Copy link
Contributor

jsit commented Jun 27, 2023

The down carot icon, I believe it’s implemented via background-image.

Which down caret icon? The post actions dropdown? Can you attach a screenshot? I wonder if we could handle this differently so that it better adapts to different colorschemes.

@jsit
Copy link
Contributor

jsit commented Jun 27, 2023

Oh, in "select a community"?

@alectrocute
Copy link
Contributor Author

@jsit This one:

Screenshot 2023-06-27 at 11 45 03 AM

I'm pretty sure it's shared across all dropdown selects.

@jsit
Copy link
Contributor

jsit commented Jun 27, 2023

Hm, I think there might be a way around this. Hold please.

@jsit
Copy link
Contributor

jsit commented Jun 27, 2023

So, Bootstrap can change the background image on certain elements by looking for [data-bs-theme="dark"].

If you really want, you can add something like this to app.tsx:

<div id="app"
            data-bs-theme={
              user &&
              ["darkly", "darkly-red", "darkly-pureblack"].includes(
                user.local_user_view.local_user.theme
              )
                ? "dark"
                : "light"
            }
>

@jsit
Copy link
Contributor

jsit commented Jun 27, 2023

Or you could try:

<div id="app"
            data-bs-theme={
              (window.matchMedia("(prefers-color-scheme: dark)") &&  user?.local_user_view.local_user.theme == 'browser') || 
              (user &&
                ["darkly", "darkly-red", "darkly-pureblack"].includes(
                  user.local_user_view.local_user.theme
                ))
                ? "dark"
                : "light"
            }
>

But window is undefined in this context for reasons I don't understand

@SleeplessOne1917
Copy link
Member

But window is undefined in this context for reasons I don't understand

Likely because it renders on both the server and the client.

@jsit
Copy link
Contributor

jsit commented Jun 27, 2023

Check this out:

app.tsx:

export class App extends Component<any, any> {
  private isoData: IsoDataOptionalSite = setIsoData(this.context);
  private readonly mainContentRef: RefObject<HTMLElement>;
  constructor(props: any, context: any) {
    super(props, context);
    this.mainContentRef = createRef();
  }

  get isDark() {
    return (
      isBrowser() && window.matchMedia("(prefers-color-scheme: dark)").matches
    );
  }

  handleJumpToContent(event) {
    event.preventDefault();
    this.mainContentRef.current?.focus();
  }
  render() {
    const siteRes = this.isoData.site_res;
    const siteView = siteRes?.site_view;
    const user = UserService.Instance.myUserInfo;

    return (
      <>
        <Provider i18next={I18NextService.i18n}>
          <div
            id="app"
            className="lemmy-site"
            data-test={user?.local_user_view.local_user.theme}
            data-bs-theme={
              (this.isDark &&
                user?.local_user_view.local_user.theme === "browser") ||
              (user &&
                ["darkly", "darkly-red", "darkly-pureblack"].includes(
                  user.local_user_view.local_user.theme
                ))
                ? "dark"
                : "light"
            }
          >

@SleeplessOne1917
Copy link
Member

I think we could extract the logic for determining to use theme light or dark into a function. It shouldn't even need to reference the App component.

@jsit
Copy link
Contributor

jsit commented Jun 27, 2023

Oh for sure, I was just throwing it in there to demo it

@alectrocute
Copy link
Contributor Author

I say we merge this and do more fine-tuning in the 0.18.2 release instead, maybe after getting additional feedback from users.

@SleeplessOne1917 SleeplessOne1917 mentioned this pull request Jun 28, 2023
@SleeplessOne1917 SleeplessOne1917 merged commit d5c45aa into main Jun 28, 2023
2 checks 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