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

Small changes to templates (form/centered layout) #750

Merged
merged 11 commits into from
Jul 1, 2019
Merged

Small changes to templates (form/centered layout) #750

merged 11 commits into from
Jul 1, 2019

Conversation

pkly
Copy link
Contributor

@pkly pkly commented Jun 19, 2019

Fixes: #749

Adds support for custom icons in headers inside of the Centered layout.

$app->initLayout('Centered');
$app->layout->image = '/admin/assets/img/my-icon.png';

Adds two additional tags for inserting html without re-writing the whole header section in the Centered layout.

@codecov
Copy link

codecov bot commented Jun 19, 2019

Codecov Report

Merging #750 into develop will increase coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@              Coverage Diff              @@
##             develop     #750      +/-   ##
=============================================
+ Coverage      66.05%   66.08%   +0.02%     
- Complexity      2223     2225       +2     
=============================================
  Files            118      118              
  Lines           5235     5239       +4     
=============================================
+ Hits            3458     3462       +4     
  Misses          1777     1777
Impacted Files Coverage Δ Complexity Δ
src/Layout/Centered.php 100% <100%> (ø) 3 <2> (+2) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2635175...525d378. Read the comment docs.

@codecov
Copy link

codecov bot commented Jun 19, 2019

Codecov Report

Merging #750 into develop will increase coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@              Coverage Diff              @@
##             develop     #750      +/-   ##
=============================================
+ Coverage      66.05%   66.08%   +0.02%     
- Complexity      2223     2225       +2     
=============================================
  Files            118      118              
  Lines           5235     5239       +4     
=============================================
+ Hits            3458     3462       +4     
  Misses          1777     1777
Impacted Files Coverage Δ Complexity Δ
src/Layout/Centered.php 100% <100%> (ø) 3 <2> (+2) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2635175...ddef80f. Read the comment docs.

@@ -15,6 +15,10 @@ class Centered extends Generic

public $defaultTemplate = 'layout/centered.html';

// Default atk4 logo
public $image = 'https://github.com/atk4/ui/raw/07208a0af84109f0d6e3553e242720d8aeedb784/public/logo.png';
Copy link
Member

@romaninsh romaninsh Jun 21, 2019

Choose a reason for hiding this comment

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

the $app class has a CDN string, which you can use for absolute perfection. The rest seems OK.

Copy link
Member

@DarkSide666 DarkSide666 left a comment

Choose a reason for hiding this comment

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

Looks good.

But please address @romaninsh comment. Move logo URL to App->cdn['atk-logo']

@pkly
Copy link
Contributor Author

pkly commented Jun 24, 2019

@DarkSide666 I've added the requested changes, also quickly tested them on my install, everything seems to work as expected
Also this is actually a better solution since you can just override the app and work with that instead, I didn't think of it, thanks

Copy link
Member

@romaninsh romaninsh left a comment

Choose a reason for hiding this comment

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

Almost there

public $image_alt = 'Logo';

public function init()
{
parent::init();

// If image is still unset load it when layout is initialized from the App
if ($this->image === null && $this->app && $this->app->cdn['atk-logo']) {
$this->image = $this->app->cdn['atk-logo'];
Copy link
Member

Choose a reason for hiding this comment

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

This->app->cdn[‘atk’].’logo.gif’

Copy link
Member

Choose a reason for hiding this comment

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

Dark no need to duplicate atk

Copy link
Member

@DarkSide666 DarkSide666 Jun 26, 2019

Choose a reason for hiding this comment

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

Oh right https://cdn.jsdelivr.net/gh/atk4/ui@1.7.1/public/logo.png will work too. I didn't thought about that.
Then this should simply be:

  1. remove atk-logo from App->cdn
  2. and here do like this:
if ($this->image === null && $this->app) {
    $this->image = $this->app->cdn['atk'] . '/logo.png';
}

@pkly can you do these changes for us please so we can merge this in?

Copy link
Contributor Author

@pkly pkly Jun 27, 2019

Choose a reason for hiding this comment

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

This way is rather bad though.
For example, right now I can use the code that's implemented to just add my image directly to the App and forget about it.
The way you proposed it will never work, unless my image is named "logo.png", which is probably not ideal.

Actually, I'll do something slightly different in a little bit and let you know

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@romaninsh and @DarkSide666 how about this solution? I think it's the best of both worlds 35ab1b4

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've also removed the logo url completely from App later, but forgot in that commit, but you can look over the next changes obviously.

@romaninsh
Copy link
Member

And yes we do overuse cdn in project quite frequently. I wonder if there is a doc for that.

@DarkSide666
Copy link
Member

Well, it looks good this way I guess. @romaninsh how you think?

Copy link
Member

@romaninsh romaninsh left a comment

Choose a reason for hiding this comment

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

perfect now! thanks for fixing!

@romaninsh romaninsh merged commit c771e14 into atk4:develop Jul 1, 2019
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.

Default template does not allow hints in checkboxes/toggles in form fields
3 participants