Skip to content

Instantly share code, notes, and snippets.

Avatar
💀
Imposter Syndrome

Nick DiMatteo ndimatteo

💀
Imposter Syndrome
View GitHub Profile
View !Beyond Dark Mode.md
@ndimatteo
ndimatteo / !Advanced Link Component.md
Last active Aug 16, 2022
Advanced Link Component for Next.js
View !Advanced Link Component.md
@ndimatteo
ndimatteo / _Sanity - Async Conditional Fields.md
Last active Jun 22, 2021
Sanity Conditional Fields (async)
View _Sanity - Async Conditional Fields.md

Async Conditional Fields for Sanity

Asynchronous multiple fields Sanity UI Easy!

Show multiple fields in an object field, based on a condition set through the "options" object. Simply return true/false from "condition" function, even asynchronously!

View gist:8273988
remote: npm ERR! install Couldn't read dependencies
remote: npm ERR! Error: ENOENT, open '/var/sites/twentyoverten.com/templates/t1/package.json'
remote: npm ERR! If you need help, you may report this log at:
remote: npm ERR! <http://github.com/isaacs/npm/issues>
remote: npm ERR! or email it to:
remote: npm ERR! <npm-@googlegroups.com>
remote:
remote: npm ERR! System Linux 3.2.0-23-virtual
remote: npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install"
remote: npm ERR! cwd /var/sites/twentyoverten.com/templates/t1
View gist:8234088
$('.add-coupon').each(function() {
$(this).click(function() {
var couponVal = $('.coupon', this).val();
$('span', this).text('Applying');
$.getJSON('/check-coupon', {
coupon: couponVal
}, function(data) {
// Invalid
if (!data.valid) {
View 4.js
app.get('/check-coupon', function(req, res, next) {
stripe.coupons.retrieve(req.body.coupon, function(err, coupon) {
if (err) return res.json({ valid: false });
res.json({ valid: true });
})
})
View style.css
/*-----Scaffolding-----*/
.header {
background: #2d2d2d;
}
.content {
background: #2d2d2d;
}