Skip to content

Instantly share code, notes, and snippets.

@joshcp joshcp/voting.html
Created Mar 1, 2017

What would you like to do?
<!-- a simple like button -->
<form id="like-btn" class="vote parent" method="POST" target="_top" action-xhr="">
<div class="fill">
<!-- download form data and pre-populate form using amp-list -->
<amp-list layout="fill" src="">
<template type="amp-mustache">
<!-- single click form by nesting radio input inside submit button -->
<button class="votes-up" type="submit" value="make-vote">
<label class="wm-icon" for="vote-up">Vote Up</label>
<input id="vote-up" type="radio" name="vote" value="vote-up">
<input type="text" name="votes-up" value="{{votes-up}}">
<label class="wm-icon" for="vote-down">Vote Down</label>
<input id="vote-down" type="radio" name="vote" value="vote-down">
<input type="text" name="votes-down" value="{{votes-down}}">
<!-- Overlay success on top of form. Limit clicks using pointer events CSS -->
<div class="fill" submit-success>
<template type="amp-mustache">
<div class="{{items.0.changed}}">
<div class="votes-up">
<label class="wm-icon" for="vote-up"></label>
<!-- Overlay error on top of form. Don't limit clicks using pointer events CSS -->
<div class="fill" submit-error>
<template type="amp-mustache">
<span>Vote failed</span>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.