Skip to content

Ability to detect whether a theme is light/dark programatically #46940

Closed

Description

@DanTup

This has been requested before (#7589) but I don't believe the suggest solution covers all cases (as suggested in the last comment).

I'm trying to insert images into hovers for icons like this:

I have URLs for where the icons live like this:

https://storage.googleapis.com/material-icons/external-assets/v4/icons/svg/ic_favourite_white_24px.svg
https://storage.googleapis.com/material-icons/external-assets/v4/icons/svg/ic_favourite_black_24px.svg

However without knowing whether the theme is Dark or Light, I can't tell which if the colours to insert.

Activity

  1. added
    themes
    on Mar 29, 2018
  2. added
    feature-request
    on Apr 1, 2018
  3. aeschli commented on Apr 3, 2018

    @aeschli
    Contributor

    duplicate of #32813 (not exactly, I agree, but it, in the end, it goes in the same direction).

    Did you try 'currentColor' in your svg?
    (https://css-tricks.com/cascading-svg-fill-color/)

  4. DanTup commented on Apr 3, 2018

    @DanTup
    ContributorAuthor

    Martin Aeschlimann (@aeschli) That issue is about accessing colours; I don't want to know the colour, only if Code considers it light or dark.

    I don't think currentColor helps - these SVGs are remotely hosted and I need to choose between the black or white one (I can't modify them unless I pull them all down locally).

  5. DanTup commented on Apr 18, 2018

    @DanTup
    ContributorAuthor

    Martin Aeschlimann (@aeschli) Is it possible this can be reconsidered? I don't think the "duplicate" case is going to help me, I need to know whether to use the black or white version of my image :(

  6. aeschli commented on Apr 18, 2018

    @aeschli
    Contributor

    Sorry, there are currently no plans for new API in that area.

  7. DanTup commented on Apr 18, 2018

    @DanTup
    ContributorAuthor

    Martin Aeschlimann (@aeschli) Are there any workarounds or other ways I could handle do this? It's frustrating that Code has knowledge of the theme but extensions can't make decisions based on it. On a light theme my white images aren't visible, it looks really bad.

  8. aeschli commented on Apr 18, 2018

    @aeschli
    Contributor

    Sorry, I'm not aware of any other tricks. Using images in hover is possible but not really the intended usage of hovers.

  9. DanTup commented on Apr 18, 2018

    @DanTup
    ContributorAuthor

    Martin Aeschlimann (@aeschli) The problem is the same wherever I put it. Users have asked for the icon previews in the gutter (this is where IntelliJ shows them) but it's the same issue - we don't know when to use the dark/light versions.

    Would you accept a PR that added this somewhere if I could figure out how to do it?

  10. aeschli commented on Apr 18, 2018

    @aeschli
    Contributor

    In the gutter you can provide both a light and dark version of your icon

  11. locked and limited conversation to collaborators on May 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

feature-requestthemes

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions