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: Assign labels a color #59

Open
adamslc opened this issue Oct 4, 2018 · 13 comments · Fixed by #113
Open

feat: Assign labels a color #59

adamslc opened this issue Oct 4, 2018 · 13 comments · Fixed by #113
Labels
enhancement New feature or request

Comments

@adamslc
Copy link
Collaborator

adamslc commented Oct 4, 2018

It would be nice to be able to assign each label a color, and use that color every time the label is printed.

@MichaelMure
Copy link
Owner

MichaelMure commented Oct 4, 2018

My thought on this:

  • the good end game way to have properly defined colors for each label would be to have a git-bug config where admins could define various properties including what label exist and their colors, define what status exist for a bug and how you can transition from one status to another ... but we are not there yet
  • there is already in the webUI some code to assign arbitrary colors to a label (https://github.com/MichaelMure/git-bug/blob/master/webui/src/Label.js#L10-L43)

My proposal:

  1. migrate the webui color code into the core. That way, a label will have the same color in all UIs, will get simpler and the core APIs will be ready for the end game
  2. when we have the code to define the config, we will just have to plug that in the core and we will have either automatic label colors or configured labels if users care enough to define them.

@j-f1
Copy link
Contributor

j-f1 commented Oct 4, 2018

For the termui, there needs to be a fallback for the colors since some terminals only support 16 or 256 colors.

@MichaelMure
Copy link
Owner

@j-f1 good point. That should be fairly easy to reduce the color precision to 16 or 8bits. I'm a bit confused as to how one is supposed to detect the terminal capabilities. I have the same question for how to detect the terminal size btw.

@j-f1
Copy link
Contributor

j-f1 commented Oct 4, 2018

Here’s a series of checks (in JavaScript, from the supports-color module) that determine the level of color support. Please @mention me if you have any questions about what it’s doing:

if (env.COLORTERM === 'truecolor') {
  return 3;
}


if ('TERM_PROGRAM' in env) {
  const version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);


  switch (env.TERM_PROGRAM) {
    case 'iTerm.app':
      return version >= 3 ? 3 : 2;
    case 'Apple_Terminal':
      return 2;
    // No default
  }
}


if (/-256(color)?$/i.test(env.TERM)) {
  return 2;
}


if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
  return 1;
}


if ('COLORTERM' in env) {
  return 1;
}


if (env.TERM === 'dumb') {
  return min;
}

source

@MichaelMure
Copy link
Owner

@j-f1 Thanks

More info on the subject: https://gist.github.com/XVilka/8346728

I found a go implementation: https://github.com/xo/terminfo/blob/master/color.go#L49-L91

@MichaelMure
Copy link
Owner

Label's color are now defined directly in the core and used in the webUI through the graphQL API.

Next steps are:

  • display the label's color in the termui
  • make the colors configurable

@MichaelMure MichaelMure reopened this May 22, 2019
@MichaelMure
Copy link
Owner

Code used by Github's hub command to display labels: https://github.com/github/hub/blob/master/utils/color.go

image

@kondanta
Copy link

Mind if I ask the current state of this issue?

@MichaelMure
Copy link
Owner

Labels should be displayed everywhere with the correct color, but you can't choose the color yourself. That would require a proper configuration data structured stored in git and shared.

@kondanta
Copy link

Alright, I understand. Do you planning to support colour selection in near future?

@MichaelMure
Copy link
Owner

Probably not as there is some significant development with higher priority (some being required to implement that feature).

@vtexier
Copy link

vtexier commented Nov 12, 2020

My git-bug choose the same color for two labels on a total of three labels!

Capture du 2020-11-12 17-10-42

A silly idea: replace or add to colors a special character symbol.

Color blind people, and others could distinguish issues more easily...

@dllud
Copy link

dllud commented Aug 3, 2022

I second @vtexier. On the CLI and TUI, displaying a (coloured) character (e.g. the first letter of the label) would be much more useful than the current square.

I just created 2 labels on a repo and git-bug chose exactly the same colour for them.

lbedford pushed a commit to daedaleanai/git-ticket that referenced this issue Jun 12, 2024
) from ja/glamour into master

Reviewed-on: https://gitea.daedalean.ai/daedalean-github/git-ticket/pulls/59
Reviewed-by: Ian Whittington <iw@daedalean.ai>

Ref T16575
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants