Skip to content

Instantly share code, notes, and snippets.

import React, { useState } from "react";
import CenterBanner from "./centered-banner";
import BottomBanner from "./bottom-banner";
import TopBanner from "./top-banner";
export default function Banner({
banner: {
headline,
text,
@media (max-width: 640px) {
.banner_bottom {
height: unset !important;
}
.banner_top {
height: unset !important;
}
}
export default function TopBanner({
headline,
text,
buttonText,
buttonLink,
height,
maxHeight,
backgroundColor,
closeButtonClicked,
buttonBackgroundColor,
@media (max-width: 425px) {
.banner_centered {
width: 100% !important;
max-width: 100% !important;
height: 100% !important;
max-height: 100% !important;
}
}
export default function BottomBanner({
headline,
text,
buttonText,
buttonLink,
height,
maxHeight,
backgroundColor,
closeButtonClicked,
buttonBackgroundColor,
export default function CenterBanner({
headline,
text,
buttonText,
buttonLink,
width,
maxWidth,
height,
maxHeight,
backgroundColor,
@orlyohreally
orlyohreally / api.js
Created January 2, 2021 21:18
Implementation of getRecipesData function
const defaultPageSize = 2;
export async function getRecipesData(page = 1, pageSize = defaultPageSize) {
const response = await butter.page.list("recipe", {
page_size: pageSize,
page: page,
locale: "en",
});
return {
@orlyohreally
orlyohreally / [page].js
Last active January 2, 2021 21:16
getStaticProps function to fetch data to the page
import { getRecipesData } from "@/lib/api";
// ...
export async function getStaticProps({ params }) {
const page = parseInt(params.page, 10);
const { recipes, prevPage, nextPage } = await getRecipesData(page);
return {
props: { recipes, prevPage, nextPage },
@orlyohreally
orlyohreally / authors.js
Last active December 19, 2020 19:58
Pre-save hook for author model
function getUTCDateNoTime(date) {
return new Date(
Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0)
);
}
AuthorSchema.pre("save", function (next) {
this.dateOfBirth = getUTCDateNoTime(this.dateOfBirth);
this.dateOfDeath = this.dateOfDeath
? getUTCDateNoTime(this.dateOfDeath)
@orlyohreally
orlyohreally / utils.js
Created October 15, 2020 09:10
Utility function that would be helpful for the project
export function getUTCDateNoTime(date) {
return new Date(
Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0)
);
}