Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[VarDumper] Allow to use a light theme out of the box #27261

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

Merged
merged 1 commit into from
Oct 10, 2018
Merged

[VarDumper] Allow to use a light theme out of the box #27261

merged 1 commit into from
Oct 10, 2018

Conversation

ogizanagi
Copy link
Contributor

Q A
Branch? master
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets N/A
License MIT
Doc PR N/A

Wouldn't it be nice to provide this light theme out of the box? (the one we use in the profiler)

capture d ecran 2018-05-14 a 16 50 55

@linaori
Copy link
Contributor

linaori commented May 15, 2018

Depends on where it's used I guess. When it's in the WDT, I'd prefer to keep it dark, but it doesn't seem possible like this (or am I wrong?).

@ogizanagi
Copy link
Contributor Author

@iltar : It'll not be used anywhere in core (appart perhaps if we want to use it for the html output of the server:dump command). It's up to you to use it or let the default theme.
Or perhaps you meant you cannot use both dark and light theme in the same page through this feature?
That's true, but it's the same for any style set with HtmlDumper::setStyles. For such needs, you'll still have to use css.

Point of this is to expose the light theme if you want to exclusively use it instead of the dark theme for your own html dumper usages and also reference this color scheme directly in it rather than having to search it in the profiler css.

@@ -61,6 +80,7 @@ public function __construct($output = null, string $charset = null, int $flags =
AbstractDumper::__construct($output, $charset, $flags);
$this->dumpId = 'sf-dump-'.mt_rand();
$this->displayOptions['fileLinkFormat'] = ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format');
$this->styles = static::$themes['dark'] ?? self::$themes['dark'];
Copy link
Member

Choose a reason for hiding this comment

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

this will break the CliDumper, which was overriding the styles property, as you now have the HTML styles overriding the CLI ones here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The HtmlDumper extends the CliDumper, not the inverse. So I'm not sure how this could break the CliDumper? HtmlDumper was already overriding the CliDumper::$styles before these changes.

@stof
Copy link
Member

stof commented May 15, 2018

btw, the fact that tests are passing tells me we are missing tests for the color support of the CliDumper

@javiereguiluz
Copy link
Member

I love this! Also, we need it. In the profiler, we apply special styles to all profiler_dump() calls to avoid displaying them with a dark background. So if this gets merged, we can remove all these special styles defined here:

https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/profiler.css.twig#L937-L950

@@ -23,28 +23,47 @@ class HtmlDumper extends CliDumper
{
public static $defaultOutput = 'php://output';

protected static $themes = array(
Copy link
Contributor

@ro0NL ro0NL May 19, 2018

Choose a reason for hiding this comment

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

tend to believe a public registerTheme($name, $styles, $extends = 'light') is more useful then static overriding =/

edit: or declare on CliDumper along with setTheme, enabling the feat. there as well.

Copy link
Member

Choose a reason for hiding this comment

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

Not sure we want to allow people to register new themes.

@nicolas-grekas
Copy link
Member

I'm wondering: should we move this to another class, following SRP? This is a helper around "setStyles", so could be decoupled. WDYT?

@ogizanagi
Copy link
Contributor Author

@nicolas-grekas : Something like a StyleBuilder/StyleHelper::setTheme(string $theme)|addStyle(string $name, string $value)|apply(CliDumper $dumper)?
Or something more like Symfony\Component\Console\Helper\TableStyle?
Is it really worth it?

Copy link
Member

@fabpot fabpot left a comment

Choose a reason for hiding this comment

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

with minor comments

public function setTheme(string $themeName)
{
if (!isset(static::$themes[$themeName])) {
throw new \InvalidArgumentException(sprintf('Theme "%s" does not exist in class "%s"', $themeName, static::class));
Copy link
Member

Choose a reason for hiding this comment

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

missing dot at the end of the exception message.

@@ -23,28 +23,47 @@ class HtmlDumper extends CliDumper
{
public static $defaultOutput = 'php://output';

protected static $themes = array(
Copy link
Member

Choose a reason for hiding this comment

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

Not sure we want to allow people to register new themes.

@fabpot
Copy link
Member

fabpot commented Oct 8, 2018

@ogizanagi Can we finish this one so that we can merge it for 4.2?

@ogizanagi
Copy link
Contributor Author

@fabpot : Sure, sorry for the lack of answer. But do we agree to keep HtmlDumper::setTheme() as is considering @nicolas-grekas 's #27261 (comment) ? Should we also add it in CliDumper (can still do it later anyway)?

@ogizanagi
Copy link
Contributor Author

(Rebased and fixed the exception message)

@fabpot
Copy link
Member

fabpot commented Oct 10, 2018

Thank you @ogizanagi.

@fabpot fabpot merged commit c705b82 into symfony:master Oct 10, 2018
fabpot added a commit that referenced this pull request Oct 10, 2018
…(ogizanagi)

This PR was merged into the 4.2-dev branch.

Discussion
----------

[VarDumper] Allow to use a light theme out of the box

| Q             | A
| ------------- | ---
| Branch?       | master <!-- see below -->
| Bug fix?      | no
| New feature?  | yes <!-- don't forget to update src/**/CHANGELOG.md files -->
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets | N/A   <!-- #-prefixed issue number(s), if any -->
| License       | MIT
| Doc PR        | N/A

Wouldn't it be nice to provide this light theme out of the box? (the one we use in the profiler)

![capture d ecran 2018-05-14 a 16 50 55](https://user-images.githubusercontent.com/2211145/40004942-23b4138c-5797-11e8-8c57-0b38744ffdc2.png)

Commits
-------

c705b82 [VarDumper] Allow to use a light theme out of the box
@ogizanagi ogizanagi deleted the html_dumper_light_theme branch October 10, 2018 12:07
@nicolas-grekas nicolas-grekas modified the milestones: next, 4.2 Nov 1, 2018
@fabpot fabpot mentioned this pull request Nov 3, 2018
@fabpot fabpot mentioned this pull request Nov 3, 2018
fabpot added a commit that referenced this pull request Sep 10, 2023
…n (derrabus)

This PR was merged into the 6.4 branch.

Discussion
----------

[DebugBundle] Remove obsolete VarDumper feature detection

| Q             | A
| ------------- | ---
| Branch?       | 6.4
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Tickets       | N/A
| License       | MIT
| Doc PR        | N/A

This PR removes detection for features introduced with #30301 (Symfony 4.3) and #27261 (Symfony 4.2).

Commits
-------

9f9747c [DebugBundle] Remove obsolete VarDumper feature detection
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants