2.0.16 • Published 4 months ago

spenpo-landing v2.0.16

Weekly downloads
-
License
ISC
Repository
github
Last release
4 months ago

A mobile-responsive hero landing page React component

Deploy with Vercel

static implementation (renders landing page only):

import { SpenpoLanding } from 'spenpo-landing'

const App = () => (
  <SpenpoLanding
    title="engineer"
    name="spenpo"
    subtitle="building!"
    socialUrls={[
      'https://twitter.com/your_twitter',
      'https://github.com/your_github',
    ]}
    headshotSrc="/images/headshot.jpeg"
    actionDestination="https://..."
    actionStatement="click here!"
  />
)

dynamic editable implementation (allows user to toggle edit mode on and change the page content with the CMS):

import React, { useState } from 'react'
import { SpenpoLanding, SpenpoLandingCms } from 'spenpo-landing'

const App: React.FC = () => {
  const editable = useState(false)
  const [title, setTitle] = useState<string>()
  const [name, setName] = useState<string>()
  const [subtitle, setSubtitle] = useState<string>()
  const [actionStatement, setActionStatement] = useState<string>()
  const [actionDestination, setActionDestination] = useState<string>()
  const [accentColor, setAccentColor] = useState<string>()
  const [secondaryAccentColor, setSecondaryAccentColor] = useState<string>()
  const [backgroundColor, setBackgroundColor] = useState<string>()
  const [backgroundImage, setBackgroundImage] = useState<string>()
  const [headshotSrc, setHeadshotSrc] = useState<string>()
  const [socialUrls, setSocialUrls] = useState<string[]>()
  const [headshotFile, setHeadshotFile] = useState<File>()

  const cms: SpenpoLandingCms = {
    title: {
      getter: () => title,
      setter: (prop) => setTitle(prop),
    },
    name: {
      getter: () => name,
      setter: (prop) => setName(prop),
    },
    subtitle: {
      getter: () => subtitle,
      setter: (prop) => setSubtitle(prop),
    },
    actionStatement: {
      getter: () => actionStatement,
      setter: (prop) => setActionStatement(prop),
    },
    actionDestination: {
      getter: () => actionDestination,
      setter: (prop) => setActionDestination(prop),
    },
    accentColor: {
      getter: () => accentColor,
      setter: (prop) => setAccentColor(prop),
    },
    secondaryAccentColor: {
      getter: () => secondaryAccentColor,
      setter: (prop) => setSecondaryAccentColor(prop),
    },
    backgroundColor: {
      getter: () => backgroundColor,
      setter: (prop) => setBackgroundColor(prop),
    },
    backgroundImage: {
      getter: () => backgroundImage,
      setter: (prop) => setBackgroundImage(prop),
    },
    headshotSrc: {
      getter: () => headshotSrc,
      setter: (prop) => setHeadshotSrc(prop),
    },
    socialUrls: {
      getter: () => socialUrls,
      setter: (prop) => setSocialUrls(prop),
    },
    headshotFile: {
      getter: () => headshotFile,
      setter: (prop) => setHeadshotFile(prop),
    },
  }

    return (
        <SpenpoLanding
            editable={editable}
            cms={cms}
        />
    )
}

cached data fed in through props takes priority. data can be persisted outside of the component with the cacheCallback prop:

import React, { useState, useContext } from 'react'
import { SpenpoLanding, SpenpoLandingCms } from 'spenpo-landing'
import redis from '../../../utils/redis'
import { GetServerSidePropsContext } from 'next'

const App: React.FC<{ cache: SpenpoLandingCache }> = ({ cache }) => {
  const { landingCms } = useContext(ShoppingCartContext)
  const editable = useState(true)

  return (
    <SpenpoLanding
      cms={landingCms}
      cacheCallback={async (callbackCache) => {
        await fetch('/api/cache/landing', {
          body: JSON.stringify({ cache: callbackCache }),
          method: 'post',
        })
      }}
      editable={editable}
      cache={cache}
    />
  )
}

export default App

export async function getServerSideProps({ query }: GetServerSidePropsContext) {
  const cache = await redis.hgetall(String(query.cache))
  return { props: { cache } }
}

props:

proptypedescription
titlestring | undefinedtitle that appears at the top of the landing page
namestring | undefinedname that appears below title
subtitlestring | undefinedsubtitle that appears below name
actionStatementstring | undefinedcall to action that appears on the button below the subtitle. if not included, button will not appear
actionDestinationstring | undefinedrelative or absolute url to be brought up in a new tab when call to action is clicked
socialUrlsstring[] | undefinedjson array of urls to social media profiles displayed at the bottom of the landing page
backgroundColorstring | undefinedhex value of the background color of the landing
backgroundImagestring | undefinedabsolute url of the background image of the landing
accentColorstring | undefinedhex value of the main color of the landing page. accents the call to action and social media buttons
secondaryAccentColorstring | undefinedhex value of the secondary color on hover effect of call to action and social media buttons
headshotSrcstring | undefinedrelative or absolute url of the image displayed on the landing page
topComponentsReactNode | undefinedadd custom functinoality at the top of the landing page
editableboolean, Dispatch<SetStateAction> | undefineduseState pair for toggling edit mode
cmsSpenpoLandingCms | undefinedobject of getters and setters for all landing page content
cacheSpenpoLandingCache | undefinedcached prop values. prioritized over direct props and CMS defaults
cacheCallback((cache: SpenpoLandingCache) => Promise) | undefinedasync function run with each update of the CMS
2.0.16

4 months ago

2.0.15

4 months ago

2.0.13

4 months ago

2.0.14

4 months ago

2.0.11

4 months ago

2.0.12

4 months ago

2.0.7

4 months ago

2.0.9

4 months ago

2.0.10

4 months ago

2.0.8

4 months ago

2.0.5

4 months ago

2.0.4

4 months ago

2.0.6

4 months ago

2.0.3

4 months ago

2.0.2

4 months ago

2.0.1

4 months ago

2.0.0

4 months ago

1.0.20

9 months ago

1.0.19

9 months ago

1.0.18

9 months ago

1.0.17

9 months ago

1.0.16

9 months ago

1.0.15

9 months ago

1.0.14

9 months ago

1.0.13

9 months ago

1.0.12

9 months ago

1.0.11

9 months ago

1.0.10

9 months ago

1.0.9

9 months ago

1.0.8

9 months ago

1.0.7

9 months ago

1.0.6

9 months ago

1.0.5

9 months ago

1.0.4

9 months ago

1.0.3

9 months ago

1.0.2

9 months ago

1.0.1

9 months ago

1.0.0

9 months ago