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 41 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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ package-lock.json
yarn.lock
/examples/**/.svelte
/examples/**/build
/packages/create-svelte/template/CHANGELOG.md
/packages/create-svelte/template/CHANGELOG.md
.env
5 changes: 4 additions & 1 deletion packages/create-svelte/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@
/dist

# re-enable this once we're out of prerelease
/cli/versions.js
/cli/versions.js

/templates/*/.svelte
/templates/*/build
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 Svelte app template?',
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
34 changes: 18 additions & 16 deletions packages/create-svelte/scripts/build-templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ async function generate_templates() {
// tool for the job because it just removes the types; Prettier then
// tidies up the end result
const contents = file.contents.replace(
/<script([^>]+)>([\s\S]+)<\/script>/g,
/<script([^>]+)>([\s\S]+?)<\/script>/g,
(m, attrs, typescript) => {
// Sucrase assumes 'unused' imports (which _are_ used, but only
// in the markup) are type imports, and strips them. This step
Expand Down 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
7 changes: 6 additions & 1 deletion packages/create-svelte/templates/default/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@
"devDependencies": {
"@sveltejs/adapter-node": "workspace:*",
"@sveltejs/kit": "workspace:*",
"cookie": "^0.4.1",
"dotenv": "^8.2.0",
"svelte": "^3.29.0",
"vite": "^2.1.0"
},
"type": "module"
"type": "module",
"dependencies": {
"@fontsource/fira-mono": "^4.2.2"
}
}
102 changes: 100 additions & 2 deletions packages/create-svelte/templates/default/src/app.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,102 @@
@import '@fontsource/fira-mono';

: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;
--font-mono: 'Fira Mono', monospace;
--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);
--column-width: 42rem;
--column-margin-top: 4rem;
}

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;
color: var(--heading-color);
}

p {
line-height: 1.35;
}

a {
color: var(--accent-color);
text-decoration: none;
}

a:hover {
text-decoration: underline;
}

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

h2 {
font-size: 1rem;
}

pre {
font-size: 16px;
font-family: var(--font-mono);
background-color: rgba(0, 0, 0, 0.05);
border-radius: 3px;
box-shadow: inset 2px 2px 6px rgba(0, 0, 0, 0.05);
padding: 0.5em;
overflow-x: auto;
}

input,
button {
font-size: inherit;
font-family: inherit;
}

@media (min-width: 480px) {
h1 {
font-size: 2rem;
}
}
1 change: 1 addition & 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,7 @@
<meta charset="utf-8" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />

%svelte.head%
</head>
<body>
Expand Down
18 changes: 18 additions & 0 deletions packages/create-svelte/templates/default/src/hooks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import cookie from 'cookie';
import type { GetContext, Handle } from '@sveltejs/kit';

export const getContext: GetContext = (request) => {
const cookies = cookie.parse(request.headers.cookie || '');

return {
userid: cookies.userid
};
};

// TODO https://github.com/sveltejs/kit/issues/1046
export const handle: Handle = ({ request, render }) => {
return render({
...request,
method: request.query.get('_method') || request.method
});
};
36 changes: 0 additions & 36 deletions packages/create-svelte/templates/default/src/lib/Counter.svelte

This file was deleted.

Loading