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

feat: added theme support for icons #975

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

feat: added theme support for icons #975

wants to merge 3 commits into from

Conversation

3em
Copy link
Collaborator

@3em 3em commented Feb 5, 2025

  • Added theme support for icons
  • Added ThemeProvider context to UI
  • Added icons with light mode
  • Fixed useThemeStore at design-system

image

@3em 3em requested a review from knagurski as a code owner February 5, 2025 08:34
@CLAassistant
Copy link

CLAassistant commented Feb 5, 2025

CLA assistant check
All committers have signed the CLA.

Copy link

netlify bot commented Feb 5, 2025

Deploy Preview for harness-design failed.

Name Link
🔨 Latest commit 617b6a5
🔍 Latest deploy log https://app.netlify.com/sites/harness-design/deploys/67c06b8e3c15ea00083abd38

Copy link

netlify bot commented Feb 5, 2025

Deploy Preview for harness-xd-review ready!

Name Link
🔨 Latest commit 617b6a5
🔍 Latest deploy log https://app.netlify.com/sites/harness-xd-review/deploys/67c06b8ee622b80008492eb4
😎 Deploy Preview https://deploy-preview-975--harness-xd-review.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@3em 3em force-pushed the feat-themed-icons branch from 82e535d to e0f602c Compare February 5, 2025 08:41
Copy link
Collaborator

@abhinavrastogi-harness abhinavrastogi-harness left a comment

Choose a reason for hiding this comment

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

most of the images which need a light version, are not even "icons" strictly.
i think we need to discuss and come up with a better approach for handling this.

@@ -102,15 +101,30 @@ import Italicize from '../icons/italicize.svg'
import Key from '../icons/key-icon.svg'
import Lightning from '../icons/lightning.svg'
import List from '../icons/list.svg'
import CreateWorkspaceLight from '../icons/lists-data-icons/create-workspace-light.svg'
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is not a good/scalable way to support "light" versions of icons as it just results in proliferation by doubling almost all icons.
we can probably do something similar to how we handled it earlier: https://github.com/harness/uicore/blob/main/packages/icons/src/Icon.tsx
basically we added an inverse prop on the Icon component, which looks for a specific file name pattern for the selected icon. if it's available the inverted one is returned, if not, the default one is returned.

Copy link
Collaborator Author

@3em 3em Feb 6, 2025

Choose a reason for hiding this comment

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

@abhinavrastogi-harness Got it. So in our case, I think we should also check if there is an icon with the -light postfix, and use it; otherwise, we fallback to the default one.
But in fact, in the example, icons for inverse are added in the same way, just with a fallback. Correct?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@abhinavrastogi-harness I have made the changes to the PR, you can review it

@3em 3em force-pushed the feat-themed-icons branch 4 times, most recently from da15041 to 7875dad Compare February 14, 2025 08:14
@3em 3em force-pushed the feat-themed-icons branch 2 times, most recently from ce7b0d7 to 3b63c4f Compare February 26, 2025 12:08
Copy link
Collaborator

@knagurski knagurski left a comment

Choose a reason for hiding this comment

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

I think we can pretty drastically cut down on this changeset by requiring that consuming apps wrap their entire app in the ThemeProvider. We can then look for the theme directly from the Icon component and not need to alter any other view or component or require the consumer pass additional props.

Regarding different SVGs for light vs dark icons, I'm not really convinced. From experience, the majority of icons should just be invertible to get the same effect without additional weight. It might be better to add a CSS invert filter when the theme is light. In some cases this won't be ideal, so we can add in selective overrides; the flow in that case would be that we get the normal icon name, check if the theme is light, if so check if there is a light version, if so use it, otherwise use the normal icon with the invert filter.

Worth noting that work is also underway to tokenise the strokes/fills etc of icons, so in the future we'll be able to set the colouring/thickness/etc of SVG icons to whatever we need it to be for the theme from tokens studio. We're not there yet so the override/invert is probably a good stopgap.

@3em 3em force-pushed the feat-themed-icons branch from 1f4bc13 to 4d8877d Compare February 27, 2025 11:01
@3em 3em force-pushed the feat-themed-icons branch from 4d8877d to 1c44c11 Compare February 27, 2025 11:09
@3em 3em force-pushed the feat-themed-icons branch from 97d852c to 617b6a5 Compare February 27, 2025 13:41
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.

4 participants