Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New hello world #1014

Merged
merged 59 commits into from
Apr 18, 2021
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
e10ef0b
Applying new design to 'Hello World' template
rafaelcamaram Apr 13, 2021
d178190
Adding Skeleton template
rafaelcamaram Apr 13, 2021
186749e
Adding changeset
rafaelcamaram Apr 13, 2021
97bbd28
add svelte-preprocess to dev config
Rich-Harris Apr 14, 2021
545b7e9
add svelte-preprocess
Rich-Harris Apr 14, 2021
e1f10c8
add templates to workspace, to make dev possible
Rich-Harris Apr 14, 2021
89cd6c5
improve accessibility of welcome image
Rich-Harris Apr 14, 2021
ce3e6ef
tweak layout
Rich-Harris Apr 14, 2021
b719226
simplify counter component a bit
Rich-Harris Apr 14, 2021
1ff610f
merge master -> new-hello-world
Rich-Harris Apr 14, 2021
c8bb743
rename HeaderNavigation to Header
Rich-Harris Apr 14, 2021
73fcbc8
simplify
Rich-Harris Apr 14, 2021
078cd05
move Header into directory
Rich-Harris Apr 14, 2021
7565e40
make header nav fluid width
Rich-Harris Apr 14, 2021
b91c735
remove unused images
Rich-Harris Apr 14, 2021
3bd4b55
inline svgs
Rich-Harris Apr 14, 2021
608a96b
dark mode style tweak
Rich-Harris Apr 14, 2021
a803774
move svelte logo to header, make it a link
Rich-Harris Apr 14, 2021
ac12e3b
tweak dark mode toggle position
Rich-Harris Apr 14, 2021
ae4113d
reuse ThemeToggler component from HN example - includes localStorage …
Rich-Harris Apr 14, 2021
724c62d
make README universal, add cfw adapter
Rich-Harris Apr 14, 2021
c7f4fe5
newlines
Rich-Harris Apr 14, 2021
ef10df0
Update packages/create-svelte/cli/index.js
Apr 14, 2021
45438ca
Update packages/create-svelte/templates/default/src/lib/Header/ThemeT…
Apr 14, 2021
5774133
use new image file
Rich-Harris Apr 14, 2021
c891d1d
Merge branch 'new-hello-world' of github.com:sveltejs/kit into new-he…
Rich-Harris Apr 14, 2021
9dca99b
remove dark/light toggle
Rich-Harris Apr 14, 2021
960a99a
ignore generated files when linting
Rich-Harris Apr 14, 2021
81475a8
more linting
Rich-Harris Apr 14, 2021
08de077
Merge branch 'master' into new-hello-world
Rich-Harris Apr 15, 2021
8835aaf
tweak some styles and wording
Rich-Harris Apr 15, 2021
20e9e68
add sveltekit:prefetch to nav links
Rich-Harris Apr 15, 2021
0688f8d
start fleshing out about page
Rich-Harris Apr 15, 2021
bacda90
merge master -> new-hello-world
Rich-Harris Apr 15, 2021
0ce375f
oops
Rich-Harris Apr 15, 2021
4258d0a
minor tweaks
Rich-Harris Apr 15, 2021
1bc4203
flesh out about page, add a skeleton todos page
Rich-Harris Apr 15, 2021
9ea4beb
non-greedy regex
Rich-Harris Apr 15, 2021
b62473d
Merge branch 'master' into new-hello-world
Rich-Harris Apr 15, 2021
2cb6790
implement TODOs page
Rich-Harris Apr 16, 2021
ff74434
make index/about prerenderable, delete unused blog page
Rich-Harris Apr 16, 2021
a0c4448
remove adapter stuff, point to docs instead
Rich-Harris Apr 16, 2021
0ccb7d2
merge master -> new-hello-world
Rich-Harris Apr 16, 2021
6b72ae9
make h1s consistent, prevent layout popping
Rich-Harris Apr 16, 2021
5fe8688
tweak pre styles
Rich-Harris Apr 16, 2021
a149e7b
tweak TODOs page
Rich-Harris Apr 16, 2021
6c75fc7
increase line-height on <p> elements
Rich-Harris Apr 16, 2021
cfa90a1
add some docs
Rich-Harris Apr 17, 2021
89e07b2
make create-svelte a bit neater
Rich-Harris Apr 17, 2021
86bf2ae
remove rollup
Rich-Harris Apr 17, 2021
4519429
fix lint script
Rich-Harris Apr 17, 2021
ed27ce5
oops
Rich-Harris Apr 17, 2021
a63ac29
goddammit, every time
Rich-Harris Apr 17, 2021
1e5fde8
use local API
Rich-Harris Apr 17, 2021
62b2fe3
typo
Rich-Harris Apr 17, 2021
f939bc5
Merge branch 'master' into api
Rich-Harris Apr 17, 2021
bf33079
various
Rich-Harris Apr 17, 2021
5d563b7
use API
Rich-Harris Apr 18, 2021
9dade4d
make skeleton app more skeletal
Rich-Harris Apr 18, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/itchy-beers-burn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'create-svelte': patch
---

Adding new Hello World templates (default with enhanced style and skeleton) to create-svelte
11 changes: 10 additions & 1 deletion packages/create-svelte/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ async function main() {
}

const options = /** @type {import('./types').Options} */ (await prompts([
{
type: 'select',
name: 'template',
message: 'Which app Svelte template?',
Rich-Harris marked this conversation as resolved.
Show resolved Hide resolved
choices: [
{ title: 'Default App (Counter + Route)', value: 'default' },
{ title: 'Skeleton App', value: 'skeleton' }
]
},
{
type: 'confirm',
name: 'typescript',
Expand All @@ -59,7 +68,7 @@ async function main() {

const name = path.basename(path.resolve(cwd));

write_template_files(`default-${options.typescript ? 'ts' : 'js'}`, name, cwd);
write_template_files(`${options.template}-${options.typescript ? 'ts' : 'js'}`, name, cwd);
write_common_files(cwd, options);

console.log(bold(green('✔ Copied project files')));
Expand Down
1 change: 1 addition & 0 deletions packages/create-svelte/cli/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export type Options = {
template: 'default' | 'skeleton';
typescript: boolean;
prettier: boolean;
eslint: boolean;
Expand Down
1 change: 1 addition & 0 deletions packages/create-svelte/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"prompts": "^2.4.0",
"rollup": "^2.41.1",
"sucrase": "^3.18.1",
"svelte-preprocess": "^4.7.0",
"tiny-glob": "^0.2.8"
},
"scripts": {
Expand Down
32 changes: 17 additions & 15 deletions packages/create-svelte/scripts/build-templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,29 +125,31 @@ async function generate_templates() {
}
}

async function generate_common() {
async function generate_shared() {
const cwd = path.resolve('shared');

const files = glob('**/*', { cwd, filesOnly: true, dot: true })
.map((file) => {
const [conditions, ...rest] = file.split('/');

const contents = fs.readFileSync(path.join(cwd, file), 'utf8');
const include = [];
const exclude = [];

const pattern = /([+-])([a-z]+)/g;
let match;
while ((match = pattern.exec(conditions))) {
const set = match[1] === '+' ? include : exclude;
set.push(match[2]);
let name = file;

if (file.startsWith('+') || file.startsWith('-')) {
const [conditions, ...rest] = file.split('/');

const pattern = /([+-])([a-z]+)/g;
let match;
while ((match = pattern.exec(conditions))) {
const set = match[1] === '+' ? include : exclude;
set.push(match[2]);
}

name = rest.join('/');
}

return {
name: rest.join('/'),
include,
exclude,
contents: fs.readFileSync(path.join(cwd, file), 'utf8')
};
return { name, include, exclude, contents };
})
.sort((a, b) => a.include.length + a.exclude.length - (b.include.length + b.exclude.length));

Expand All @@ -156,7 +158,7 @@ async function generate_common() {

async function main() {
await generate_templates();
await generate_common();
await generate_shared();
}

main();
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ By default, `npm run build` will generate a Node app that you can run with `node

- [@sveltejs/adapter-node](https://github.com/sveltejs/kit/tree/master/packages/adapter-node)
- [@sveltejs/adapter-static](https://github.com/sveltejs/kit/tree/master/packages/adapter-static)
- [@sveltejs/adapter-cloudflare-workers](https://github.com/sveltejs/kit/tree/master/packages/adapter-cloudflare-workers)
Rich-Harris marked this conversation as resolved.
Show resolved Hide resolved
- [@sveltejs/adapter-netlify](https://github.com/sveltejs/kit/tree/master/packages/adapter-netlify)
- [@sveltejs/adapter-vercel](https://github.com/sveltejs/kit/tree/master/packages/adapter-vercel)
- ...more soon
Expand Down
2 changes: 1 addition & 1 deletion packages/create-svelte/templates/default/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
node_modules
/.svelte
/build
/functions
/functions
79 changes: 77 additions & 2 deletions packages/create-svelte/templates/default/src/app.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,79 @@
:root {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell,
'Open Sans', 'Helvetica Neue', sans-serif;
font-family: Arial, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu,
Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
--pure-white: #ffffff;
--primary-color: #b9c6d2;
--secondary-color: #d0dde9;
--tertiary-color: #edf0f8;
--accent-color: #ff3e00;
--heading-color: rgba(0, 0, 0, 0.7);
--text-color: #444444;
--background-without-opacity: rgba(255, 255, 255, 0.7);
}

:root[data-theme='dark'] {
--primary-color: #1f272e;
--secondary-color: #2e3a44;
--tertiary-color: #393d45;
--heading-color: #ffffff;
--text-color: #ffffff;
--secondary-text-color: #676778;
--background-without-opacity: rgba(255, 255, 255, 0.2);
}

body {
min-height: 100vh;
margin: 0;
background-color: var(--primary-color);
background: linear-gradient(
180deg,
var(--primary-color) 0%,
var(--secondary-color) 10.45%,
var(--tertiary-color) 41.35%
);
}

body::before {
content: '';
width: 80vw;
height: 100vh;
position: absolute;
top: 0;
left: 10vw;
z-index: -1;
background: radial-gradient(
50% 50% at 50% 50%,
var(--pure-white) 0%,
rgba(255, 255, 255, 0) 100%
);
opacity: 0.05;
}

#svelte {
min-height: 100vh;
display: flex;
flex-direction: column;
}

h1,
h2,
p {
font-weight: 400;
text-align: center;
color: var(--heading-color);
}

h1 {
font-size: 2rem;
margin-bottom: 0;
}

h2 {
font-size: 1rem;
}

@media (min-width: 480px) {
h1 {
font-size: 3rem;
}
}
15 changes: 15 additions & 0 deletions packages/create-svelte/templates/default/src/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@
<meta charset="utf-8" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />

<script>
try {
if (!('theme' in localStorage)) {
localStorage.theme = window.matchMedia('(prefers-color-scheme: dark)').matches
? 'dark'
: 'light';
}

document.querySelector('html').dataset.theme = localStorage.theme;
} catch (e) {
console.error(e);
}
</script>

%svelte.head%
</head>
<body>
Expand Down
36 changes: 0 additions & 36 deletions packages/create-svelte/templates/default/src/lib/Counter.svelte

This file was deleted.

107 changes: 107 additions & 0 deletions packages/create-svelte/templates/default/src/lib/Counter/index.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
<script lang="ts">
import { spring } from 'svelte/motion';

let count = 0;

const displayed_count = spring();
$: displayed_count.set(count);
$: offset = modulo($displayed_count, 1);

function modulo(n: number, m: number) {
// handle negative numbers
return ((n % m) + m) % m;
}
</script>

<div class="counter">
<button on:click={() => (count -= 1)} aria-label="Decrease the counter by one">
<svg role="img" aria-label="Minus" viewBox="0 0 1 1">
<path d="M0,0.5 L1,0.5"></path>
</svg>
</button>

<div class="counter-viewport">
<div class="counter-digits" style="transform: translate(0, {100 * offset}%)">
<strong style="top: -100%">{Math.floor($displayed_count + 1)}</strong>
<strong>{Math.floor($displayed_count)}</strong>
</div>
</div>

<button on:click={() => (count += 1)} aria-label="Increase the counter by one">
<!-- <img src={plus} alt="Plus icon"> -->
<svg role="img" aria-label="Plus" viewBox="0 0 1 1">
<path d="M0,0.5 L1,0.5 M0.5,0 L0.5,1"></path>
</svg>
</button>
</div>

<style>
.counter {
display: flex;
border-top: 1px solid rgba(0,0,0,0.1);
border-bottom: 1px solid rgba(0,0,0,0.1);
margin: 1rem 0;
}

:global([data-theme="dark"]) .counter {
border-color: rgba(255,255,255,0.1);
}

.counter button.disabled {
opacity: 0.3;
}

.counter button {
width: 2em;
padding: 0;
display: flex;
align-items: center;
justify-content: center;
border: 0;
background-color: transparent;
color: var(--text-color);
font-size: 2rem;
}

.counter button:hover {
background-color: var(--secondary-color);
}

svg {
width: 25%;
height: 25%;
}

path {
vector-effect: non-scaling-stroke;
stroke-width: 2px;
stroke: var(--text-color);
}

.counter-viewport {
width: 8em;
height: 4em;
overflow: hidden;
text-align: center;
position: relative;
}

.counter-viewport strong {
position: absolute;
display: block;
width: 100%;
height: 100%;
font-weight: 400;
color: var(--accent-color);
font-size: 4rem;
display: flex;
align-items: center;
justify-content: center;
}

.counter-digits {
position: absolute;
width: 100%;
height: 100%;
}
</style>
Loading