Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
2689d02
Started moving page attachment
mszylkowski Dec 21, 2021
32e6bd5
Create bundle
mszylkowski Dec 21, 2021
778f895
Fixed tests
mszylkowski Dec 21, 2021
fd82574
Fixed import
mszylkowski Dec 21, 2021
6c023bb
Not use service getters to avoid bundling
mszylkowski Dec 21, 2021
1b372e9
Fix services
mszylkowski Dec 21, 2021
fbe589c
Fix shopping unit test
mszylkowski Dec 22, 2021
b2323ff
Removed dependency on localizationservice
mszylkowski Dec 22, 2021
6458e97
Fixed localization
mszylkowski Dec 22, 2021
68303bc
Fixed tests
mszylkowski Dec 22, 2021
d40ea05
Merge branch 'main' of github.com:ampproject/amphtml into removeAttac…
mszylkowski Dec 22, 2021
bc5942e
Sync service fetchers
mszylkowski Dec 22, 2021
fe949a0
Made services sync
mszylkowski Dec 23, 2021
65fafaa
Fixed tests for sync services
mszylkowski Dec 23, 2021
1cabd29
Remove unused import in test
mszylkowski Dec 23, 2021
a766496
AnalyticsService to sync
mszylkowski Dec 23, 2021
204c4ee
Import devAssert
mszylkowski Dec 23, 2021
d4cc178
Remove param to buildInline
mszylkowski Dec 23, 2021
35e1aab
Undo describes.js
mszylkowski Dec 23, 2021
f9cb0d7
Fix tests
mszylkowski Dec 23, 2021
bcbac30
Remove unused import
mszylkowski Dec 23, 2021
b8f903e
Debundle store with forms
mszylkowski Dec 23, 2021
7b39379
Merge branch 'main' of github.com:ampproject/amphtml into removeAttac…
mszylkowski Dec 23, 2021
e429bf4
Moved open-page-attachment
mszylkowski Dec 23, 2021
897e178
Merge branch 'main' of github.com:ampproject/amphtml into tryRemoveAt…
mszylkowski Dec 28, 2021
57b6b23
Hooked up active attribute
mszylkowski Dec 28, 2021
02b5ecb
Fixed page attachment parent element
mszylkowski Dec 28, 2021
29a58a7
Fix opening attachment
mszylkowski Dec 28, 2021
a745d50
Fixing tests
mszylkowski Dec 28, 2021
720b89e
Removed unused tests
mszylkowski Dec 28, 2021
07075f8
Fixed amp-story test
mszylkowski Dec 28, 2021
0272bc5
Dep-check
mszylkowski Dec 28, 2021
8b6599c
Zindex fix
mszylkowski Dec 28, 2021
48e514d
Moved scrim styles to page-attachment
mszylkowski Jan 4, 2022
3a0bd28
Fixed zindex
mszylkowski Jan 5, 2022
6b89a91
Merge branch 'main' of github.com:ampproject/amphtml into tryRemoveAt…
mszylkowski Jan 11, 2022
548a923
Merge branch 'main' of github.com:ampproject/amphtml into tryRemoveAt…
mszylkowski Jan 12, 2022
8d00119
Removed unused import
mszylkowski Jan 12, 2022
1c3dc84
Fixed duplicate imports in test
mszylkowski Jan 12, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Removed dependency on localizationservice
  • Loading branch information
mszylkowski committed Dec 22, 2021
commit b2323ff2244f878a47e6b529e0d25f2a916ef27f
3 changes: 0 additions & 3 deletions build-system/test-configs/dep-check-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,13 +304,10 @@ exports.rules = [
'extensions/amp-smartlinks/0.1/amp-smartlinks.js->extensions/amp-skimlinks/0.1/link-rewriter/link-rewriter-manager.js',
'extensions/amp-smartlinks/0.1/linkmate.js->extensions/amp-skimlinks/0.1/link-rewriter/two-steps-response.js',

'extensions/amp-story-page-attachment/0.1/amp-story-draggable-drawer.js->extensions/amp-story/1.0/amp-story-localization-service.js',
'extensions/amp-story-page-attachment/0.1/amp-story-draggable-drawer.js->extensions/amp-story/1.0/amp-story-store-service.js',
'extensions/amp-story-page-attachment/0.1/amp-story-draggable-drawer.js->extensions/amp-story/1.0/utils.js',
'extensions/amp-story-page-attachment/0.1/amp-story-form.js->extensions/amp-story/1.0/amp-story-localization-service.js',
'extensions/amp-story-page-attachment/0.1/amp-story-form.js->extensions/amp-story/1.0/amp-story-store-service.js',
'extensions/amp-story-page-attachment/0.1/amp-story-form.js->extensions/amp-story/1.0/loading-spinner.js',
'extensions/amp-story-page-attachment/0.1/amp-story-page-attachment.js->extensions/amp-story/1.0/amp-story-localization-service.js',
'extensions/amp-story-page-attachment/0.1/amp-story-page-attachment.js->extensions/amp-story/1.0/amp-story-open-page-attachment.js',
'extensions/amp-story-page-attachment/0.1/amp-story-page-attachment.js->extensions/amp-story/1.0/amp-story-store-service.js',
'extensions/amp-story-page-attachment/0.1/amp-story-page-attachment.js->extensions/amp-story/1.0/history.js',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {listen} from '#utils/event-helper';
import {dev} from '#utils/log';

import {CSS} from '../../../build/amp-story-draggable-drawer-header-0.1.css';
import {localize} from '../../amp-story/1.0/amp-story-localization-service';
import {
Action,
StateProperty,
Expand Down Expand Up @@ -121,38 +120,43 @@ export class DraggableDrawer extends AMP.BaseElement {

/** @override */
buildCallback() {
this.element.classList.add('amp-story-draggable-drawer-root');
return Services.localizationServiceForOrNull(this.element).then(
(localizationService) => {
this.element.classList.add('amp-story-draggable-drawer-root');

const templateEl = renderDrawerElement();
this.headerEl = renderHeaderElement();
const templateEl = renderDrawerElement();
this.headerEl = renderHeaderElement();

this.containerEl = dev().assertElement(
templateEl.querySelector('.i-amphtml-story-draggable-drawer-container')
);
this.contentEl = dev().assertElement(
this.containerEl.querySelector(
'.i-amphtml-story-draggable-drawer-content'
)
);
this.containerEl = dev().assertElement(
templateEl.querySelector(
'.i-amphtml-story-draggable-drawer-container'
)
);
this.contentEl = dev().assertElement(
this.containerEl.querySelector(
'.i-amphtml-story-draggable-drawer-content'
)
);

const spacerEl = (
<button
role="button"
class="i-amphtml-story-draggable-drawer-spacer i-amphtml-story-system-reset"
aria-label={localize(
this.element,
LocalizedStringId_Enum.AMP_STORY_CLOSE_BUTTON_LABEL
)}
></button>
);
const spacerEl = (
<button
role="button"
class="i-amphtml-story-draggable-drawer-spacer i-amphtml-story-system-reset"
aria-label={localizationService.getLocalizedString(
LocalizedStringId_Enum.AMP_STORY_CLOSE_BUTTON_LABEL
)}
></button>
);

this.containerEl.insertBefore(spacerEl, this.contentEl);
this.contentEl.appendChild(
createShadowRootWithStyle(<div />, this.headerEl, CSS)
);
this.containerEl.insertBefore(spacerEl, this.contentEl);
this.contentEl.appendChild(
createShadowRootWithStyle(<div />, this.headerEl, CSS)
);

this.element.appendChild(templateEl);
this.element.setAttribute('aria-hidden', true);
this.element.appendChild(templateEl);
this.element.setAttribute('aria-hidden', true);
}
);
}

/** @override */
Expand Down
18 changes: 11 additions & 7 deletions extensions/amp-story-page-attachment/0.1/amp-story-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import * as Preact from '#core/dom/jsx';

import {LocalizedStringId_Enum} from '#service/localization/strings';

import {localize} from '../../amp-story/1.0/amp-story-localization-service';
import {
Action,
getStoreService,
Expand Down Expand Up @@ -36,26 +35,31 @@ let FormElementChildrenDef;
const createStatusChildrenByAttribute = {
'submitting': () => toggleLoadingSpinner(renderLoadingSpinner(), true),

'submit-success': (formEl) =>
'submit-success': (localizationService) =>
createFormResultChildren(
localize(formEl, LocalizedStringId_Enum.AMP_STORY_FORM_SUBMIT_SUCCESS)
localizationService.getLocalizedString(
LocalizedStringId_Enum.AMP_STORY_FORM_SUBMIT_SUCCESS
)
),

'submit-error': (formEl) =>
'submit-error': (localizationService) =>
createFormResultChildren(
localize(formEl, LocalizedStringId_Enum.AMP_STORY_FORM_SUBMIT_ERROR)
localizationService.getLocalizedString(
LocalizedStringId_Enum.AMP_STORY_FORM_SUBMIT_ERROR
)
),
};

/**
* Add a default form attribute element for each absent response attribute.
* @param {!Element} formEl The form to which the attribute elements will be
* selected or added.
* @param {!../../../src/service/localization.LocalizationService} localizationService
* @return {Array<!Element>} The list of response attribute elements that
* belong to the given form.
* @private
*/
export function setupResponseAttributeElements(formEl) {
export function setupResponseAttributeElements(formEl, localizationService) {
return Object.keys(createStatusChildrenByAttribute).map((attr) => {
const selected = formEl.querySelector(`[${escapeCssSelectorIdent(attr)}]`);
if (selected) {
Expand All @@ -64,7 +68,7 @@ export function setupResponseAttributeElements(formEl) {
const created = (
<div>
<div class="i-amphtml-story-page-attachment-form-submission-status">
{createStatusChildrenByAttribute[attr](formEl)}
{createStatusChildrenByAttribute[attr](localizationService)}
</div>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {

import {CSS} from '../../../build/amp-story-page-attachment-0.1.css';
import {getSourceOrigin} from '../../../src/url';
import {localize} from '../../amp-story/1.0/amp-story-localization-service';
import {
AttachmentTheme,
renderOutlinkLinkIconElement,
Expand Down Expand Up @@ -82,33 +81,37 @@ export class AmpStoryPageAttachment extends DraggableDrawer {
* @override
*/
buildCallback() {
super.buildCallback();

this.maybeSetDarkThemeForElement_(this.headerEl);
this.maybeSetDarkThemeForElement_(this.element);

// Outlinks can be an amp-story-page-outlink or the legacy version,
// an amp-story-page-attachment with an href.
const isOutlink =
this.element.tagName === 'AMP-STORY-PAGE-OUTLINK' ||
this.element.hasAttribute('href');
this.type_ = isOutlink ? AttachmentType.OUTLINK : AttachmentType.INLINE;
super.buildCallback().then(() => {
this.maybeSetDarkThemeForElement_(this.headerEl);
this.maybeSetDarkThemeForElement_(this.element);

// Outlinks can be an amp-story-page-outlink or the legacy version,
// an amp-story-page-attachment with an href.
const isOutlink =
this.element.tagName === 'AMP-STORY-PAGE-OUTLINK' ||
this.element.hasAttribute('href');
this.type_ = isOutlink ? AttachmentType.OUTLINK : AttachmentType.INLINE;

if (this.type_ === AttachmentType.INLINE) {
Services.localizationServiceForOrNull(this.element).then(
(localizationService) => {
this.buildInline_(localizationService);
}
);
}

if (this.type_ === AttachmentType.INLINE) {
this.buildInline_();
}
this.win.addEventListener('pageshow', (event) => {
// On browser back, Safari does not reload the page but resumes its cached
// version. This event's parameter lets us know when this happens so we
// can cleanup the remote opening animation.
if (event.persisted) {
this.closeInternal_(false /** shouldAnimate */);
}
});

this.win.addEventListener('pageshow', (event) => {
// On browser back, Safari does not reload the page but resumes its cached
// version. This event's parameter lets us know when this happens so we
// can cleanup the remote opening animation.
if (event.persisted) {
this.closeInternal_(false /** shouldAnimate */);
}
toggle(this.element, true);
this.element.setAttribute('aria-live', 'assertive');
});

toggle(this.element, true);
this.element.setAttribute('aria-live', 'assertive');
}

/**
Expand All @@ -124,9 +127,10 @@ export class AmpStoryPageAttachment extends DraggableDrawer {

/**
* Builds inline page attachment's drawer UI.
* @param {../../../src/services/localization/LocalizationService} localizationService
* @private
*/
buildInline_() {
buildInline_(localizationService) {
const titleText =
this.element.getAttribute('title') ||
this.element.getAttribute('data-title');
Expand All @@ -135,8 +139,7 @@ export class AmpStoryPageAttachment extends DraggableDrawer {
<div class="i-amphtml-story-draggable-drawer-header-title-and-close">
<button
class="i-amphtml-story-page-attachment-close-button"
aria-label={localize(
this.element,
aria-label={localizationService.getLocalizedString(
LocalizedStringId_Enum.AMP_STORY_CLOSE_BUTTON_LABEL
)}
role="button"
Expand All @@ -150,22 +153,25 @@ export class AmpStoryPageAttachment extends DraggableDrawer {
const forms = this.element.querySelectorAll('form');
if (forms.length > 0) {
allowlistFormActions(this.win);

forms.forEach((form) => {
// Scroll each response attribute element into view, when displayed.
setupResponseAttributeElements(form).forEach((el) => {
// TODO(wg-stories): Share ResizeObserver for runtime performance.
new this.win.ResizeObserver((e) => {
if (
this.state === DrawerState.OPEN &&
e[0].contentRect.height > 0
) {
el./*OK*/ scrollIntoView({
behavior: 'smooth',
block: 'nearest',
});
}
}).observe(el);
});
setupResponseAttributeElements(form, localizationService).forEach(
(el) => {
// TODO(wg-stories): Share ResizeObserver for runtime performance.
new this.win.ResizeObserver((e) => {
if (
this.state === DrawerState.OPEN &&
e[0].contentRect.height > 0
) {
el./*OK*/ scrollIntoView({
behavior: 'smooth',
block: 'nearest',
});
}
}).observe(el);
}
);
});

// Page attachments that contain forms must display the page's publisher
Expand Down