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
Implement new pie
and pie-light
styles
#1238
Conversation
79a2d92
to
4476968
Compare
4476968
to
3933ea9
Compare
Codecov Report
@@ Coverage Diff @@
## master #1238 +/- ##
==========================================
- Coverage 97.28% 96.40% -0.89%
==========================================
Files 67 82 +15
Lines 4235 5560 +1325
==========================================
+ Hits 4120 5360 +1240
- Misses 115 200 +85
Continue to review full report at Codecov.
|
94690e3
to
d1ad5ac
Compare
5681651
to
c77621a
Compare
c77621a
to
87ac7d8
Compare
httpie/output/formatters/colors.py
Outdated
def make_styles(name, raw_styles): | ||
for mode, shade in [ | ||
('light', '700'), | ||
('universal', '600'), | ||
('dark', '500') | ||
]: | ||
yield type( | ||
name.format(mode=mode.title()), | ||
(pygments.style.Style,), | ||
{ | ||
'styles': format_style(raw_styles, shade) | ||
} | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably should use a more robust methodology in the future (for -100 -200 -300 etc). Something like this
for shade in range(100, 800, 100):
name = SHADE_NAMES.get(shade, f"pie-{shade}")
for style_type, style_map in [("Header", HEADER_COLORS), ("Body", BODY_COLORS)]:
create_styles()
though I plan to omit this for this release, and implement this after this gets merged (if there are no objections).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏻
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good stuff 💅 A few remaining tweaks.
httpie/output/formatters/colors.py
Outdated
def make_styles(name, raw_styles): | ||
for mode, shade in [ | ||
('light', '700'), | ||
('universal', '600'), | ||
('dark', '500') | ||
]: | ||
yield type( | ||
name.format(mode=mode.title()), | ||
(pygments.style.Style,), | ||
{ | ||
'styles': format_style(raw_styles, shade) | ||
} | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏻
httpie/output/formatters/colors.py
Outdated
def format_style(raw_styles, shade): | ||
def get_shade(part): | ||
if part not in COLOR_PALETTE: | ||
return part | ||
|
||
color_code = COLOR_PALETTE[part] | ||
if isinstance(color_code, dict) and shade in color_code: | ||
return color_code[shade] | ||
else: | ||
return color_code | ||
|
||
def format_value(value): | ||
return " ".join( | ||
get_shade(part) | ||
for part in value.split() | ||
) | ||
|
||
return { | ||
key: format_value(value) | ||
for key, value in raw_styles.items() | ||
} | ||
|
||
|
||
def make_styles(name, raw_styles): | ||
for mode, shade in [ | ||
('light', '700'), | ||
('universal', '600'), | ||
('dark', '500') | ||
]: | ||
yield type( | ||
name.format(mode=mode.title()), | ||
(pygments.style.Style,), | ||
{ | ||
'styles': format_style(raw_styles, shade) | ||
} | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are tied to the Pie themes, so I’d either reflect that in their names or move them to palette
.
@@ -0,0 +1,138 @@ | |||
# Copy the brand palette | |||
|
|||
COLOR_PALETTE = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PIE_COLOR_PALETTE
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this prefix? I assumed these were going to be the default colors we use after this PR (e.g on progress bars, on regular colored outputs etc.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question. I thought we’d always re-use the effective --style
even for the UI, because if I use the terminal scheme, for example, then I’d like to see those colors everywhere. In that case, giving it the PIE_
prefix would make sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I especially put this into a separate package, httpie.output.ui
, since I plan to (at least feel like) this is going to be the place where we would manage our rich UI (progress bars, themes, highlighting, console, etc.), and those probably will use this theme. If you feel strong about it, I can add the PIE_
prefix though but personally I'd find this very compelling (since the fully qualified name of this is httpie.output.ui.COLOR_PLAETTE
, so it is not something arbitrary).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. Although we should discuss this:
I thought we’d always re-use the effective
--style
even for the UI, because if I use the terminal scheme, for example, then I’d like to see those colors everywhere.
httpie/output/formatters/colors.py
Outdated
PIE_STYLES = { | ||
'pie', | ||
'pie-light', | ||
'pie-dark' | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like an enum/constants candidate (we refer to it from multiple places). Maybe it could also go to palette
.
40e853c
to
cd5de1a
Compare
Co-authored-by: Jakub Roztocil <jakub@roztocil.co>
cd5de1a
to
2287a08
Compare
Resolves #1237.
Demos: