|
| 1 | +import endent from "endent" |
| 2 | +import { ValidCNSInputs } from "../../../../../create-next-stack-types" |
| 3 | +import { getProjectNameOfPath } from "../../../../../helpers/get-project-name-of-path" |
| 4 | + |
| 5 | +export const generateLandingPageTemplate = (inputs: ValidCNSInputs): string => { |
| 6 | + return endent` |
| 7 | + import Script from "next/script"; |
| 8 | + import styles from "./LandingPageTemplate.module.css"; |
| 9 | + import { Container } from "./components/Container"; |
| 10 | + import { InlineCode } from "./components/InlineCode"; |
| 11 | + import { Link } from "./components/Link"; |
| 12 | + import { Paragraph } from "./components/Paragraph"; |
| 13 | + import { Section } from "./components/Section"; |
| 14 | + import { Subtitle } from "./components/Subtitle"; |
| 15 | + import { TechnologyGrid } from "./components/TechnologyGrid"; |
| 16 | + import { H1, H2 } from "./components/headings"; |
| 17 | + import { technologies } from "./technologies"; |
| 18 | + |
| 19 | + const LandingPageTemplate = () => { |
| 20 | + const onConfettiLoad = () => { |
| 21 | + const key = "create-next-stack-hasShownConfetti-${encodeURI( |
| 22 | + getProjectNameOfPath(inputs.args.appName) |
| 23 | + )}"; |
| 24 | + const hasShownConfetti = localStorage.getItem(key); |
| 25 | + if (hasShownConfetti != null) return; |
| 26 | + |
| 27 | + const duration = 10 * 1000; |
| 28 | + const animationEnd = Date.now() + duration; |
| 29 | + |
| 30 | + const randomInRange = (min: number, max: number) => { |
| 31 | + return Math.random() * (max - min) + min; |
| 32 | + }; |
| 33 | + |
| 34 | + (function frame() { |
| 35 | + const timeLeft = animationEnd - Date.now(); |
| 36 | + |
| 37 | + (window as any).confetti({ |
| 38 | + particleCount: 1, |
| 39 | + startVelocity: 0, |
| 40 | + ticks: Math.max(200, 500 * (timeLeft / duration)), |
| 41 | + origin: { |
| 42 | + x: Math.random(), |
| 43 | + y: Math.random() - 0.2, |
| 44 | + }, |
| 45 | + colors: [ |
| 46 | + "#26ccff", |
| 47 | + "#a25afd", |
| 48 | + "#ff5e7e", |
| 49 | + "#88ff5a", |
| 50 | + "#fcff42", |
| 51 | + "#ffa62d", |
| 52 | + "#ff36ff", |
| 53 | + ], |
| 54 | + shapes: ["square", "circle"], |
| 55 | + gravity: randomInRange(0.4, 0.6), |
| 56 | + scalar: randomInRange(0.8, 1.2), |
| 57 | + drift: randomInRange(-0.1, 0.1), |
| 58 | + }); |
| 59 | + |
| 60 | + if (timeLeft > 0) { |
| 61 | + requestAnimationFrame(frame); |
| 62 | + } |
| 63 | + })(); |
| 64 | + |
| 65 | + localStorage.setItem(key, "true"); |
| 66 | + }; |
| 67 | + |
| 68 | + return ( |
| 69 | + <div className={styles.landingPageTemplate}> |
| 70 | + <Script |
| 71 | + src="https://cdn.jsdelivr.net/npm/tsparticles-confetti@2.9.3/tsparticles.confetti.bundle.min.js" |
| 72 | + onLoad={onConfettiLoad} |
| 73 | + /> |
| 74 | + <style> |
| 75 | + {\` |
| 76 | + * { |
| 77 | + box-sizing: border-box; |
| 78 | + } |
| 79 | + |
| 80 | + html, |
| 81 | + body { |
| 82 | + padding: 0; |
| 83 | + margin: 0; |
| 84 | + font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, |
| 85 | + Oxygen, Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, |
| 86 | + sans-serif; |
| 87 | + line-height: 1.5; |
| 88 | + } |
| 89 | + \`} |
| 90 | + </style> |
| 91 | + <main> |
| 92 | + <Section> |
| 93 | + <Container center className={styles.headerSection}> |
| 94 | + <H1> |
| 95 | + <span className={styles.textGradient}>Your project is a go!</span>{" "} |
| 96 | + 🎉 |
| 97 | + </H1> |
| 98 | + <Subtitle> |
| 99 | + Get started by editing <InlineCode>pages/index.tsx</InlineCode> |
| 100 | + </Subtitle> |
| 101 | + </Container> |
| 102 | + </Section> |
| 103 | + <Section> |
| 104 | + <Container className={styles.technologyGridIntro}> |
| 105 | + <H2>Technologies</H2> |
| 106 | + <Paragraph> |
| 107 | + Below you will find an overview of your chosen technologies |
| 108 | + providing you helpful links and simple usage examples to get you |
| 109 | + started. |
| 110 | + </Paragraph> |
| 111 | + </Container> |
| 112 | + <Container wide> |
| 113 | + <TechnologyGrid |
| 114 | + technologies={technologies} |
| 115 | + className={styles.technologyGrid} |
| 116 | + /> |
| 117 | + </Container> |
| 118 | + </Section> |
| 119 | + </main> |
| 120 | + <footer> |
| 121 | + <Section> |
| 122 | + <Container center> |
| 123 | + <Paragraph> |
| 124 | + Generated by{" "} |
| 125 | + <Link href="https://github.com/akd-io/create-next-stack"> |
| 126 | + Create Next Stack |
| 127 | + </Link> |
| 128 | + </Paragraph> |
| 129 | + </Container> |
| 130 | + </Section> |
| 131 | + </footer> |
| 132 | + </div> |
| 133 | + ); |
| 134 | + }; |
| 135 | + |
| 136 | + export default LandingPageTemplate; |
| 137 | + ` |
| 138 | +} |
0 commit comments