From 72a69cf9e699087b53e10f8e326c4c31f9cebf35 Mon Sep 17 00:00:00 2001 From: Deepak Lalwani Date: Mon, 14 Feb 2022 23:55:33 +0530 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Bento=20amp-gist=20(#37333)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ✨ Add Bento gist component * Add unit test cases for the amp-gist component * Add support for data-file attribute * Add npm property to amp-gist in bundles config * Add file attribute to type definition * Remove debug code * Add test case and storybook example for file attribute * Update amp-gist validator test files * Add readme.md file for bento amp-gist component * Remove dict --- .../compile/bundles.config.extensions.json | 9 + extensions/amp-gist/1.0/README.md | 187 ++++++++++++++++++ extensions/amp-gist/1.0/amp-gist.css | 17 ++ extensions/amp-gist/1.0/amp-gist.js | 40 ++++ extensions/amp-gist/1.0/base-element.js | 20 ++ extensions/amp-gist/1.0/component.js | 66 +++++++ extensions/amp-gist/1.0/component.type.js | 15 ++ .../amp-gist/1.0/storybook/Basic.amp.js | 33 ++++ extensions/amp-gist/1.0/storybook/Basic.js | 26 +++ extensions/amp-gist/1.0/test/test-amp-gist.js | 63 ++++++ .../amp-gist/1.0/test/test-component.js | 46 +++++ .../amp-gist/1.0/test/validator-amp-gist.html | 47 +++++ .../amp-gist/1.0/test/validator-amp-gist.out | 54 +++++ 13 files changed, 623 insertions(+) create mode 100644 extensions/amp-gist/1.0/README.md create mode 100644 extensions/amp-gist/1.0/amp-gist.css create mode 100644 extensions/amp-gist/1.0/amp-gist.js create mode 100644 extensions/amp-gist/1.0/base-element.js create mode 100644 extensions/amp-gist/1.0/component.js create mode 100644 extensions/amp-gist/1.0/component.type.js create mode 100644 extensions/amp-gist/1.0/storybook/Basic.amp.js create mode 100644 extensions/amp-gist/1.0/storybook/Basic.js create mode 100644 extensions/amp-gist/1.0/test/test-amp-gist.js create mode 100644 extensions/amp-gist/1.0/test/test-component.js create mode 100644 extensions/amp-gist/1.0/test/validator-amp-gist.html create mode 100644 extensions/amp-gist/1.0/test/validator-amp-gist.out diff --git a/build-system/compile/bundles.config.extensions.json b/build-system/compile/bundles.config.extensions.json index 114bb142f3f7..09e7ae84cc33 100644 --- a/build-system/compile/bundles.config.extensions.json +++ b/build-system/compile/bundles.config.extensions.json @@ -482,6 +482,15 @@ "version": "0.1", "latestVersion": "0.1" }, + { + "name": "amp-gist", + "version": "1.0", + "options": { + "hasCss": true, + "bento": true, + "npm": true + } + }, { "name": "amp-google-document-embed", "version": "0.1", diff --git a/extensions/amp-gist/1.0/README.md b/extensions/amp-gist/1.0/README.md new file mode 100644 index 000000000000..17c6c703da91 --- /dev/null +++ b/extensions/amp-gist/1.0/README.md @@ -0,0 +1,187 @@ +# Bento Gist + +Creates an iframe and displays a [GitHub Gist](https://docs.github.com/en/github/writing-on-github/creating-gists). + +## Web Component + +You must include each Bento component's required CSS library to guarantee proper loading and before adding custom styles. Or use the light-weight pre-upgrade styles available inline. See [Layout and style](#layout-and-style). + +### Import via npm + +```sh +npm install @bentoproject/gist +``` + +```javascript +import {defineElement as defineBentoGist} from '@bentoproject/gist'; +defineBentoGist(); +``` + +### Include via ` + + + + +``` + +### Example + + + +```html + + + + + + + + + + + + + + +``` + +### Layout and style + +Each Bento component has a small CSS library you must include to guarantee proper loading without [content shifts](https://web.dev/cls/). Because of order-based specificity, you must manually ensure that stylesheets are included before any custom styles. + +```html + +``` + +Alternatively, you may also make the light-weight pre-upgrade styles available inline: + +```html + +``` + +#### Container type + +The `bento-gist` component has a defined layout size type. To ensure the component renders correctly, be sure to apply a size to the component and its immediate children (slides) via a desired CSS layout (such as one defined with `height`, `width`, `aspect-ratio`, or other such properties): + +```css +bento-gist { + height: 100px; + width: 100%; +} +``` + +### Attributes + +##### data-gistid + +The ID of the gist to embed. + +##### data-file (optional) + +If specified, display only one file in a gist. + +#### title (optional) + +Define a `title` attribute for the component to propagate to the underlying `