This starter template aims for fast and easy web development with HMR, and pre-rendered HTML for optimal static hosting.
Please note: do not use or reproduce The Pudding logos or fonts without written permission.
New school: just click the Use this template
button above.
Old school:
npx degit the-pudding/svelte-starter my-project
Then in your local repo:
npm install
npm run build
To start the dev server:
npm run dev
Modify content in src
and public/assets
.
test
npm run deploy
This generates a directory called ssr
with the server-side rendered static-hostable app.
If deploying to github pages:
make github
There are a few stylesheets included by default in template.html
. Modify global.css
variables to make changes to water.css
defaults.
You can use SCSS or another CSS preprocessor by installing the module (eg. node-sass
) and including the property in the svelte-preprocess in the rollup config files.
Share
button -> advanced -> Change... -> to "Anyone with this link"config.json
, and set the filepath to where you want the file savedgid
value in the url as wellRunning npm run gdoc
at any point (even in new tab while server is running) will fetch the latest from all Docs and Sheets.
Located in src/components/helpers
.
Window.svelte
: A wrapper around svelte:window that automatically debounces resize and throttles scroll, storing innerHeight
, innerWidth
, and scrollY
as global stores.Icon.svelte
: Simple integration with Feather Icons.Slider.svelte (and Slider.Slide.svelte)
: A slider widget, especially useful for swipe/slide stories.Tap.svelte
: Edge-of-screen tapping library, designed to integrate with slider.Located in src/components/pudding
.
Footer.svelte
: Pudding recirculation and social links.Header.svelte
: Pudding logo.Located in src/actions
.
inView.js
: detect when an element enters or exits the viewport.css.js
: dynmically change the value of a CSS variable.Located in src/utils/
.
mapToArray.js
: Convenience function to convert maps (generated from d3 group and rollup) to iterable array of objects.move.js
: transform translate function shorthand.These are located in src/stores
, to include them do this (replacing name
):
import name from "../stores/name.js";
prefersReducedMotion
: returns a boolean if the user has this CSS media query enabled or not.
viewport
: returns an object { width, height }
of the viewport dimensions. It is debounced for performance.
scrollY
: returns an number window vertical scroll position. It is throttled using rAF for performance.
timer
: returns an object { timer, elapsed }. timer
has 5 methods (start, stop, toggle, set, reset) and elapsed
is a store that is the number of ms.
transformSvg.js
: this custom transition lets you apply an svg transform property with the in/out svelte transition. Parameters (with defaults):
{
target: "", // string: transform properties [required]
delay: 0, // number: ms
duration: 250, // number: in ms
easing: linear, // function: svelte easing function
relative: false, // boolean: adds target onto pre-existing transform
opacity: false // boolean: to fade in/out as well
}
Usage
<g out:transformSvg={{ target: "translate(50, 50)" }}>
Any @html tags, e.g., {@html user}
must be the child of a dom element so they can be properly hydrated.