-
Notifications
You must be signed in to change notification settings - Fork 4.1k
✨ amp-story-shopping-config data json handle get and set config data #36757
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
Changes from all commits
Commits
Show all changes
57 commits
Select commit
Hold shift + click to select a range
f34a46c
Added examples for inline and remote config loading of json files.
jshamble 087b53f
finished tests for shopping config
jshamble e490dad
removed unnescessary function call
jshamble 8e0502f
fixed merge conflict dleeting base shopping file
jshamble 593250b
removed chai import
jshamble 03879e9
removed unnesc assignment
jshamble aa5eb26
fixed prettier lint warnings
jshamble 2ec626a
added dependencies for store service
jshamble 87835e6
cleanup up code and tests to optmize code flow
jshamble 5328ecd
cleaned up config files and test files
jshamble 4993c22
added more refactoring of shopping story
jshamble dcd51d4
Updated test code with new tag id
jshamble 58aa953
fixed formatting of remote file
jshamble dbef7ff
added remote config fiel formatting fix
jshamble 5a67a03
added visual diff test
jshamble e711b93
updated visual diff test
jshamble fed6aab
updated unit tests to use public facing apis, removed dead code
jshamble c4baea7
updated unit tests to use public facing apis, removed dead code
jshamble 8e0c94b
updated unit tests to use public facing apis, removed dead code
jshamble 33d72d2
added page id
jshamble 35bacc3
added load config impl (both solutions: one exposed export public met…
jshamble f7627d4
removed export ()may need to put back if want to use public facing apit
jshamble 97f38e0
modified laodconfig to handle 404 errors
jshamble d555d92
removed unused var
jshamble 6805ccb
added dependency for request service
jshamble 606f109
Merge branch 'main' into shopDataJsonHandle
jshamble 1508aa2
added a few recotoring shareconfig menthod
jshamble 172c6a7
refactored code to use new request service.
jshamble 194effe
Merge branch 'main' into shopDataJsonHandle
jshamble 72e64a6
removed unused allow list entry
jshamble b8bf02a
added buidlcallback resolve
jshamble c0278c6
added implicit return
jshamble 988ad88
added in code refactos
jshamble 4c6283f
updated shoo[[ing state to shopping data
jshamble e2284fc
removed promise.resolve
jshamble 0821aba
recatored shopping and shared config unit test code
jshamble 152d97f
added in config refactor logic
jshamble 0ba6f8c
streamlined commens and code
jshamble 0120f15
fixed comment for circleci
jshamble 517e53d
optmized code and unit tests
jshamble 6371fd2
added shared config code
jshamble 6a75291
refactored dead code
jshamble af5fdf4
added typedefs
jshamble cf5d899
added in refactor of social share widget
jshamble 3e0c132
added shopping story test features
jshamble 0599a2d
removed unnneded export
jshamble e0bb71b
udpated product images array
jshamble fbf7464
Merge branch 'main' into shopDataJsonHandle
jshamble f53685c
removed trailign whitespace
jshamble fe86615
removed unused vars
jshamble 0184f18
removed unused config for now
jshamble fafa4a9
added back in dev asserts
jshamble d70055e
code compactification
jshamble 732f9ab
Merge branch 'main' into shopDataJsonHandle
jshamble fde3e0d
stripped dev assert
jshamble 793ccfd
fixed social share config
jshamble d86af91
Merge branch 'main' into shopDataJsonHandle
jshamble File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| { | ||
| "items": [ | ||
| { | ||
| "product-tag-id": "city-pop", | ||
| "product-title": "Plastic Love" | ||
| }, | ||
| { | ||
| "product-tag-id": "k-pop", | ||
| "product-title": "Gangnam Style" | ||
| }, | ||
| { | ||
| "product-tag-id": "eurodance", | ||
| "product-title": "Crystal King Battle" | ||
| } | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 41 additions & 11 deletions
52
extensions/amp-story-shopping/0.1/amp-story-shopping-config.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,7 @@ | ||
| amp-story-shopping-tag { | ||
| /** | ||
| * This is placeholder for the shopping tag until syling is implemented. | ||
| * Having a min-height enables the layoutCallback to be called. | ||
| */ | ||
| min-height: 20px; | ||
|
jshamble marked this conversation as resolved.
|
||
| } | ||
60 changes: 47 additions & 13 deletions
60
extensions/amp-story-shopping/0.1/amp-story-shopping-tag.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,30 +1,64 @@ | ||
| import {Layout_Enum, applyFillContent} from '#core/dom/layout'; | ||
| import {Layout_Enum} from '#core/dom/layout'; | ||
|
|
||
| const TAG = 'amp-story-shopping-tag'; | ||
| import {Services} from '#service'; | ||
|
|
||
| import {devAssert} from '#utils/log'; | ||
|
|
||
| import { | ||
| ShoppingConfigDataDef, | ||
| StateProperty, | ||
| } from '../../amp-story/1.0/amp-story-store-service'; | ||
|
|
||
| /** | ||
| * @typedef {{ | ||
| * items: !Map<string, !ShoppingConfigDataDef>, | ||
| * }} | ||
| */ | ||
| let ShoppingDataDef; | ||
|
|
||
| export class AmpStoryShoppingTag extends AMP.BaseElement { | ||
| /** @param {!AmpElement} element */ | ||
| constructor(element) { | ||
| super(element); | ||
|
|
||
| /** @private {string} */ | ||
| this.myText_ = TAG; | ||
|
|
||
| /** @private {?Element} */ | ||
| this.container_ = null; | ||
| /** @private @const {?../../amp-story/1.0/amp-story-store-service.AmpStoryStoreService} */ | ||
| this.storeService_ = null; | ||
| } | ||
|
|
||
| /** @override */ | ||
| buildCallback() { | ||
| super.buildCallback(); | ||
| this.container_ = this.element.ownerDocument.createElement('div'); | ||
| this.container_.textContent = this.myText_; | ||
| this.element.appendChild(this.container_); | ||
| applyFillContent(this.container_, /* replacedContent */ true); | ||
| return Services.storyStoreServiceForOrNull(this.win).then( | ||
| (storeService) => { | ||
| devAssert(storeService, 'Could not retrieve AmpStoryStoreService'); | ||
| this.storeService_ = storeService; | ||
|
jshamble marked this conversation as resolved.
|
||
| } | ||
| ); | ||
| } | ||
|
|
||
| /** @override */ | ||
| layoutCallback() { | ||
| this.storeService_.subscribe( | ||
|
jshamble marked this conversation as resolved.
|
||
| StateProperty.SHOPPING_DATA, | ||
| (shoppingData) => this.updateShoppingTag_(shoppingData), | ||
| true /** callToInitialize */ | ||
| ); | ||
| } | ||
|
|
||
| /** @override */ | ||
| isLayoutSupported(layout) { | ||
| return layout === Layout_Enum.CONTAINER; | ||
| } | ||
|
|
||
| /** | ||
| * @param {!ShoppingDataDef} shoppingData | ||
| * @private | ||
| */ | ||
| updateShoppingTag_(shoppingData) { | ||
| const tagData = shoppingData[this.element.getAttribute('data-tag-id')]; | ||
| if (!tagData) { | ||
| return; | ||
| } | ||
| this.mutateElement(() => { | ||
| this.element.textContent = tagData['product-title']; | ||
| }); | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.