Skip to content

Commit

Permalink
Add amp-experiment skeleton. Guarded by an experiment flag. (#3755)
Browse files Browse the repository at this point in the history
  • Loading branch information
lannka committed Jun 24, 2016
1 parent fa51153 commit 73a6c6b
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 0 deletions.
16 changes: 16 additions & 0 deletions examples/experiment.amp.html
@@ -0,0 +1,16 @@
<!doctype html>
<html >
<head>
<meta charset="utf-8">
<title>amp-experiment</title>
<link rel="canonical" href="amps.html" >
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
<style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>
<script async src="../dist/amp.js"></script>
<script async custom-element="amp-experiment" src="../dist/v0/amp-experiment-0.1.max.js"></script>
</head>
<body>
<amp-experiment >
</amp-experiment>
</body>
</html>
43 changes: 43 additions & 0 deletions extensions/amp-experiment/0.1/amp-experiment.js
@@ -0,0 +1,43 @@
/**
* Copyright 2016 The AMP HTML Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS-IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import {dev} from '../../../src/log';
import {isExperimentOn} from '../../../src/experiments';
import {toggle} from '../../../src/style';

/** @const */
const EXPERIMENT = 'amp-experiment';

export class AmpExperiment extends AMP.BaseElement {

/** @override */
isLayoutSupported(unusedLayout) {
return true;
}

/** @override */
buildCallback() {
this.isExperimentOn_ = isExperimentOn(this.getWin(), EXPERIMENT);
if (!this.isExperimentOn_) {
dev.warn(EXPERIMENT, `Experiment ${EXPERIMENT} disabled`);
toggle(this.element, false);
return;
}
dev.info(EXPERIMENT, 'amp-experiment is on');
}
}

AMP.registerElement('amp-experiment', AmpExperiment);
15 changes: 15 additions & 0 deletions extensions/amp-experiment/0.1/test/test-amp-experiment.js
@@ -0,0 +1,15 @@
/**
* Copyright 2016 The AMP HTML Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS-IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
19 changes: 19 additions & 0 deletions extensions/amp-experiment/amp-experiment.md
@@ -0,0 +1,19 @@
<!---
Copyright 2016 The AMP HTML Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS-IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

# <a name="amp-experiment"></a> `amp-experiment`

Under development. See [issue #1411](https://github.com/ampproject/amphtml/issues/1411).
1 change: 1 addition & 0 deletions gulpfile.js
Expand Up @@ -61,6 +61,7 @@ function buildExtensions(options) {
buildExtension('amp-carousel', '0.1', true, options);
buildExtension('amp-dailymotion', '0.1', false, options);
buildExtension('amp-dynamic-css-classes', '0.1', false, options);
buildExtension('amp-experiment', '0.1', false, options);
buildExtension('amp-facebook', '0.1', false, options);
buildExtension('amp-fit-text', '0.1', true, options);
buildExtension('amp-fx-flying-carpet', '0.1', true, options);
Expand Down
6 changes: 6 additions & 0 deletions tools/experiments/experiments.js
Expand Up @@ -55,6 +55,12 @@ const EXPERIMENTS = [
name: 'Activates support for measuring incoming clicks.',
spec: 'https://github.com/ampproject/amphtml/issues/2934',
},
{
id: 'amp-experiment',
name: 'AMP Experiment',
spec: 'https://github.com/ampproject/amphtml/blob/master/' +
'extensions/amp-experiment/amp-experiment.md',
},
{
id: 'amp-fx-flying-carpet',
name: 'AMP Flying Carpet',
Expand Down

0 comments on commit 73a6c6b

Please sign in to comment.