Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Criando componentes interativos em páginas AMP ...

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.

Criando componentes interativos em páginas AMP com <amp-bind>

Avatar for Murilo de Siqueira Ferreira

Murilo de Siqueira Ferreira

November 12, 2018
Tweet

More Decks by Murilo de Siqueira Ferreira

Other Decks in Programming

Transcript

  1. JS

  2. <amp-state id="myState"> <script type="application/json"> { myText: "Hello AMP" } </script>

    </amp-state> <span [text]="myState.myText"> Hello World </span>
  3. <amp-state id="myState"> <script type="application/json"> { "myText": "Hello AMP" } </script>

    </amp-state> <span [text]="myState.myText">Hello World</span> <button on="tap:AMP.setState({ myState: { myText: 'Hello Binding' } })">SetState</button>
  4. <amp-state id="myState"> <script type="application/json"> { "myText": "Hello world AMP" }

    </script> </amp-state> <!-- change browser history --> <button on="tap:AMP.pushState({ myState: { myText: 'Browser History' } })">SetState</button>
  5. // Returns [1, 2, 3] [3, 2, 1].sort() // Returns

    6. [1, 2, 3].reduce((x, y) => x + y) // Object to Array keys(event.speakers).map(x => event.speakers[x])
  6. String charAt charCodeAt concat indexOf lastIndexOf slice split substr substring

    toLowerCase toUpperCase Number toExponential toFixed toPrecision toString Objects keys value Array concat filter includes indexOf join lastIndexOf map reduce slice some sort splice Math abs ceil floor max min random round Global encodeURIComponent
  7. <!-- Add/Remove --> <input type="checkbox" [checked]="creditcards && creditcards._1177" [disabled]="checkeds ==

    4 && !creditcards._1177" on="change:AMP.setState({ creditcards: { _1177: event.checked, }, checkeds: (event.checked ? checkeds+1 : checkeds-1), })">
  8. <!-- Change text --> <span [text]="creditcards._1177 ? 'Remover' : 'Comparar'")

    Comparar </span> <!-- Remove all --> <button on="tap:AMP.setState({ checkeds: 0, creditcards: null })") Remover tudo </button>