Commit 17de247c authored by rbpotter's avatar rbpotter Committed by Commit Bot

Print Preview: Move icon to right for checkbox settings

Bug: None
Change-Id: Idc21640edb5cce41094bf564ae9e3383e202dc91
Reviewed-on: https://chromium-review.googlesource.com/1244545
Commit-Queue: Rebekah Potter <rbpotter@chromium.org>
Reviewed-by: default avatarDemetrios Papadopoulos <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#594777}
parent 60edb79c
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
</style> </style>
<template is="dom-repeat" items="[[options_]]"> <template is="dom-repeat" items="[[options_]]">
<print-preview-settings-section managed="[[item.managed]]" <print-preview-settings-section managed="[[item.managed]]"
hidden$="[[!item.available]]" show-policy-on-end hidden$="[[!item.available]]"
class$="[[getClass_(index, firstIndex_, lastIndex_)]]"> class$="[[getClass_(index, firstIndex_, lastIndex_)]]">
<div slot="title"> <div slot="title">
<span class="title">$i18n{optionsLabel}</span> <span class="title">$i18n{optionsLabel}</span>
......
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
margin-bottom: 16px; margin-bottom: 16px;
margin-top: 16px; margin-top: 16px;
padding: 0 20px; padding: 0 20px;
--policy-icon-padding: 4px;
--policy-icon-size: 20px;
} }
::slotted([slot=controls]), ::slotted([slot=controls]),
...@@ -34,8 +36,8 @@ ...@@ -34,8 +36,8 @@
color: var(--google-grey-900); color: var(--google-grey-900);
flex: none; flex: none;
font-size: 1em; font-size: 1em;
padding-inline-end: 5px; padding-inline-end: var(--policy-icon-padding);
width: 70px; width: calc(75px - var(--policy-icon-padding));
word-break: break-word; word-break: break-word;
} }
...@@ -44,20 +46,33 @@ ...@@ -44,20 +46,33 @@
padding-top: 10px; padding-top: 10px;
} }
:host([managed]) ::slotted([slot=title]) { :host([managed]:not([show-policy-on-end])) ::slotted([slot=title]) {
width: 50px; width: calc(75px - var(--policy-icon-size)
- var(--policy-icon-padding));
}
:host([managed][show-policy-on-end]) ::slotted([slot=controls]) {
padding-inline-end: var(--policy-icon-padding);
} }
iron-icon { iron-icon {
fill: var(--google-grey-600); fill: var(--google-grey-600);
width: 20px; flex: 0;
min-width: var(--policy-icon-size);
} }
</style> </style>
<slot name="title"></slot> <slot name="title"></slot>
<iron-icon hidden$="[[!managed]]" icon="print-preview:business" <template is="dom-if" if="[[showStartIcon_(showPolicyOnEnd, managed)]]">
alt="" aria-label="$i18n{managedOption}"> <iron-icon hidden$="[[!managed]]" icon="print-preview:business"
</iron-icon> alt="" aria-label="$i18n{managedOption}">
</iron-icon>
</template>
<slot name="controls"></slot> <slot name="controls"></slot>
<template is="dom-if" if="[[showEndIcon_(showPolicyOnEnd, managed)]]">
<iron-icon hidden$="[[!managed]]" icon="print-preview:business"
alt="" aria-label="$i18n{managedOption}">
</iron-icon>
</template>
</template> </template>
<script src="settings_section.js"></script> <script src="settings_section.js"></script>
</dom-module> </dom-module>
...@@ -12,5 +12,28 @@ Polymer({ ...@@ -12,5 +12,28 @@ Polymer({
value: false, value: false,
reflectToAttribute: true, reflectToAttribute: true,
}, },
/** @type {boolean} */
showPolicyOnEnd: {
type: Boolean,
value: false,
reflectToAttribute: true,
},
},
/**
* @return {boolean} Whether to show the policy icon before the controls.
* @private
*/
showStartIcon_: function() {
return this.managed && !this.showPolicyOnEnd;
},
/**
* @return {boolean} Whether to show the policy icon after the controls.
* @private
*/
showEndIcon_: function() {
return this.managed && this.showPolicyOnEnd;
}, },
}); });
...@@ -18,20 +18,22 @@ cr.define('base_settings_section_test', function() { ...@@ -18,20 +18,22 @@ cr.define('base_settings_section_test', function() {
settingsSection = settingsSection =
document.createElement('print-preview-settings-section'); document.createElement('print-preview-settings-section');
document.body.appendChild(settingsSection); document.body.appendChild(settingsSection);
Polymer.dom.flush();
}); });
// Test that key events that would result in invalid values are blocked. // Test that key events that would result in invalid values are blocked.
test(assert(TestNames.ManagedShowsEnterpriseIcon), function() { test(assert(TestNames.ManagedShowsEnterpriseIcon), function() {
const icon = settingsSection.$$('iron-icon'); // No icons until managed is set.
let icons = settingsSection.shadowRoot.querySelectorAll('iron-icon');
// Default initial state is that the section is not managed, so the icon assertEquals(0, icons.length);
// is hidden.
assertTrue(icon.hidden);
assertFalse(settingsSection.managed); assertFalse(settingsSection.managed);
// Simulate setting the section to managed and verify icon appears. // Simulate setting the section to managed and verify icon appears.
settingsSection.managed = true; settingsSection.managed = true;
assertFalse(icon.hidden); Polymer.dom.flush();
icons = settingsSection.shadowRoot.querySelectorAll('iron-icon');
assertEquals(1, icons.length);
assertFalse(icons[0].hidden);
}); });
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment