Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
amp-email-generator
Advanced tools
Readme
This is a set of functions that will generate valid AMP email markup
getImage({ attributes, fallback })
Ex.
const attributes = {
src: "example.com/my-image.jpg",
layout: "fixed",
height: 400,
width: 400
}
const { html, css, scripts } = getImage({ attributes, fallback: "<span>Fallback Text</span>" });
will result in
<amp-img src="example.com/my-image.jpg" layout="fixed" height="400" width="400">
<span>Fallback Text</span>
</amp-img>
getAccordion({ sections, accordionAttributes, sectionAttributes })
Ex.
const sections = [
{ header: "<h1>Hello</h1>", content: "<p>World</p>" },
{ header: "<h1>Goodbye</h1>", content: "<p>World</p>", expanded: true }
]
const { html, css, scripts } = getImage({
sections,
accordionAttributes: { animate: true },
sectionAttributes: { class: "my-section" }
});
will result in
<amp-accordion animate>
<section class="my-section">
<h1>Hello</h1>
<p>World</p>
</section>
<section expanded class="my-section">
<h1>Goodbye</h1>
<p>World</p>
</section>
</amp-accordion>
getForm({ formAttributes, fields, submitLabel, success, error })
Ex.
const fields = [
{
type: "text",
name: "test-text",
fields: [
{
label: "Test Text Input",
id: "test"
}
]
},
{
type: "radio",
name: "test-radio",
fields: [
{
label: "Test Radio A",
id: "a",
value: "a"
},
{
label: "Test Radio B",
id: "b",
value: "b"
},
{
label: "Test Radio C",
id: "c",
value: "c"
}
]
}
];
const formAttributes = {
target: "_blank",
action: "post",
"action-xhr": "example.com/xhr"
}
const { html, css, scripts } = getForm({
fields,
formAttributes,
success: "Hooray!",
error: "Oh no!",
submitLabel: "This is the submit button!"
});
will result in
<form target="_blank" action="post" action-xhr="example.com/xhr">
<label for="test-text">Test Text Input</label>
<input type="text" id="test" name="test-text">
<input type="radio" id="a" name="test-radio" value="a" >
<label for="test-radio">Test Radio A</label>
<input type="radio" id="b" name="test-radio" value="b" >
<label for="test-radio">Test Radio B</label>
<input type="radio" id="c" name="test-radio" value="c" >
<label for="test-radio">Test Radio C</label>
<input type="submit" value="Submit">
<div submit-success>
Tada!
</div>
<div submit-error>
Oh no!
</div>
</form>
FAQs
Generator functions for AMP Email components
The npm package amp-email-generator receives a total of 9 weekly downloads. As such, amp-email-generator popularity was classified as not popular.
We found that amp-email-generator demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.