Skip to content

More examples #1

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

Open
wants to merge 40 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
a441b74
Refactor repository
rustkas Nov 27, 2021
8692f60
Update README.md
rustkas Nov 27, 2021
b9e6a7e
Update README.md
rustkas Nov 27, 2021
391b6ce
Update README.md
rustkas Nov 27, 2021
0be590e
Update README.md
rustkas Nov 27, 2021
5556376
Как устроен Компонент в Svelte?
rustkas Nov 27, 2021
e107749
Update README.md
rustkas Nov 27, 2021
b856532
Жизненный цикл Svelte компонента
rustkas Nov 27, 2021
5a53665
Merge branch 'main' of https://github.com/rustkas/svelte-todo
rustkas Nov 27, 2021
67fbf82
add dots.
rustkas Nov 27, 2021
6af1375
Update README.md
rustkas Nov 27, 2021
e48ad31
Update README.md
rustkas Nov 27, 2021
06090e9
Update README.md
rustkas Nov 27, 2021
0dfcb61
Optimize phone numbers example code
rustkas Nov 27, 2021
ce7c276
Update README.md
rustkas Nov 27, 2021
5aa7990
HTML шаблоны в Svelte
rustkas Nov 29, 2021
9442e83
Как работать с событиями в Svelte?
rustkas Nov 29, 2021
3c33737
add item
rustkas Nov 29, 2021
1420ccc
Update README.md
rustkas Nov 29, 2021
ab58a0e
Update README.md
rustkas Nov 29, 2021
cc34bf9
Привязки (Bindings)
rustkas Nov 30, 2021
2f1b810
Merge branch 'main' of https://github.com/rustkas/svelte-todo
rustkas Nov 30, 2021
d00eb09
Update README.md
rustkas Nov 30, 2021
d965988
Update README.md
rustkas Nov 30, 2021
d06f090
Update README.md
rustkas Nov 30, 2021
b39b919
Хранилище (Store)
rustkas Dec 1, 2021
dcf6657
Анимации и переходы (Motion, Transition and Animation)
rustkas Dec 2, 2021
f739881
Update README.md
rustkas Dec 2, 2021
7043507
update example list
rustkas Dec 2, 2021
3a5fe24
Действия и директива use (Actions)
rustkas Dec 3, 2021
6989651
Update README.md
rustkas Dec 3, 2021
ac76785
Слоты - Svelte slots. Context Модуль.
rustkas Dec 4, 2021
abfebca
Update README.md
rustkas Dec 4, 2021
fe18b55
API контекста (Context API)
rustkas Dec 4, 2021
7c4f27a
Merge branch 'main' of https://github.com/rustkas/svelte-todo
rustkas Dec 4, 2021
db71583
Update README.md
rustkas Dec 4, 2021
0a40e78
update projects
rustkas Dec 4, 2021
2d93cac
Merge branch 'main' of https://github.com/rustkas/svelte-todo
rustkas Dec 4, 2021
1443886
Специальные элементы (Special elements)
rustkas Dec 5, 2021
e30ad28
remove unused project
rustkas Dec 5, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@
12. [Специальные элементы (Special elements)](https://youtu.be/axGxAHwbYYg)

👉 [Плейлист со всеми частями курса](https://www.youtube.com/playlist?list=PLmfIBo6rTVR5XNcJxu8TwzEvIDUCAhGc6)

## [Приложение к обучающим YouTube-видео](examples)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
14 changes: 14 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Приложение к обучающим YouTube-видео

1. [Установка и структура проекта.](projects/video01)
2. [Компонент и его структура.](projects/video02)
3. [Жизненный цикл компонента.](projects/video03)
4. [Синтаксис HTML шаблонов.](projects/video04)
5. [События и обработка событий.](projects/video05)
6. [Привязки (Bindings).](projects/video06)
7. [Хранилище (Store).](projects/video07)
8. [Анимации и переходы (Motion, Transition and Animation).](projects/video08)
9. [Действия и директива use (Actions).](projects/video09)
10. [Слоты - Svelte slots. Context Модуль - Svelte module context.](projects/video10)
11. [API контекста (Context API). Применение CSS классов по условию.](projects/video11)
12. [Специальные элементы.](projects/video12)
25 changes: 25 additions & 0 deletions examples/projects/video01/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Что такое Svelte и как он устроен?

[![Что такое Svelte и как он устроен? video](https://img.youtube.com/vi/N4KXC7z---Y/0.jpg)](https://youtu.be/N4KXC7z---Y "Что такое Svelte и как он устроен?")

## SVELTE
Сайт проекта [Svelte](https://svelte.dev/)

## Создать новый поект, перейти в папку, установить зависимости и запустить VS Code
`npx degit sveltejs/template svelte-todo && cd svelte-todo && npm install && code .`

### npx
Удобная команда запуска.

### degit
[degit](https://github.com/Rich-Harris/degit) - команда копирования git-репозитория.

## rollup.js
[rollup.js](https://rollupjs.org/) - сборщик модулей JavaScript.

## Команда запуска приложения
`npm run dev`

## Адрес приложения
`http://localhost:5000/`

4 changes: 4 additions & 0 deletions examples/projects/video01/code/svelte-todo/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/node_modules/
/public/build/

.DS_Store
109 changes: 109 additions & 0 deletions examples/projects/video01/code/svelte-todo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
*Psst — looking for a more complete solution? Check out [SvelteKit](https://kit.svelte.dev), the official framework for building web applications of all sizes, with a beautiful development experience and flexible filesystem-based routing.*

*Looking for a shareable component template instead? You can [use SvelteKit for that as well](https://kit.svelte.dev/docs#packaging) or the older [sveltejs/component-template](https://github.com/sveltejs/component-template)*

---

# svelte app

This is a project template for [Svelte](https://svelte.dev) apps. It lives at https://github.com/sveltejs/template.

To create a new project based on this template using [degit](https://github.com/Rich-Harris/degit):

```bash
npx degit sveltejs/template svelte-app
cd svelte-app
```

*Note that you will need to have [Node.js](https://nodejs.org) installed.*


## Get started

Install the dependencies...

```bash
cd svelte-app
npm install
```

...then start [Rollup](https://rollupjs.org):

```bash
npm run dev
```

Navigate to [localhost:5000](http://localhost:5000). You should see your app running. Edit a component file in `src`, save it, and reload the page to see your changes.

By default, the server will only respond to requests from localhost. To allow connections from other computers, edit the `sirv` commands in package.json to include the option `--host 0.0.0.0`.

If you're using [Visual Studio Code](https://code.visualstudio.com/) we recommend installing the official extension [Svelte for VS Code](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode). If you are using other editors you may need to install a plugin in order to get syntax highlighting and intellisense.

## Building and running in production mode

To create an optimised version of the app:

```bash
npm run build
```

You can run the newly built app with `npm run start`. This uses [sirv](https://github.com/lukeed/sirv), which is included in your package.json's `dependencies` so that the app will work when you deploy to platforms like [Heroku](https://heroku.com).


## Single-page app mode

By default, sirv will only respond to requests that match files in `public`. This is to maximise compatibility with static fileservers, allowing you to deploy your app anywhere.

If you're building a single-page app (SPA) with multiple routes, sirv needs to be able to respond to requests for *any* path. You can make it so by editing the `"start"` command in package.json:

```js
"start": "sirv public --single"
```

## Using TypeScript

This template comes with a script to set up a TypeScript development environment, you can run it immediately after cloning the template with:

```bash
node scripts/setupTypeScript.js
```

Or remove the script via:

```bash
rm scripts/setupTypeScript.js
```

If you want to use `baseUrl` or `path` aliases within your `tsconfig`, you need to set up `@rollup/plugin-alias` to tell Rollup to resolve the aliases. For more info, see [this StackOverflow question](https://stackoverflow.com/questions/63427935/setup-tsconfig-path-in-svelte).

## Deploying to the web

### With [Vercel](https://vercel.com)

Install `vercel` if you haven't already:

```bash
npm install -g vercel
```

Then, from within your project folder:

```bash
cd public
vercel deploy --name my-project
```

### With [surge](https://surge.sh/)

Install `surge` if you haven't already:

```bash
npm install -g surge
```

Then, from within your project folder:

```bash
npm run build
surge public my-project.surge.sh
```
23 changes: 23 additions & 0 deletions examples/projects/video01/code/svelte-todo/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "svelte-app",
"version": "1.0.0",
"private": true,
"scripts": {
"build": "rollup -c",
"dev": "rollup -c -w",
"start": "sirv public --no-clear"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^17.0.0",
"@rollup/plugin-node-resolve": "^11.0.0",
"rollup": "^2.3.4",
"rollup-plugin-css-only": "^3.1.0",
"rollup-plugin-livereload": "^2.0.0",
"rollup-plugin-svelte": "^7.0.0",
"rollup-plugin-terser": "^7.0.0",
"svelte": "^3.0.0"
},
"dependencies": {
"sirv-cli": "^1.0.0"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
63 changes: 63 additions & 0 deletions examples/projects/video01/code/svelte-todo/public/global.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
html, body {
position: relative;
width: 100%;
height: 100%;
}

body {
color: #333;
margin: 0;
padding: 8px;
box-sizing: border-box;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

a {
color: rgb(0,100,200);
text-decoration: none;
}

a:hover {
text-decoration: underline;
}

a:visited {
color: rgb(0,80,160);
}

label {
display: block;
}

input, button, select, textarea {
font-family: inherit;
font-size: inherit;
-webkit-padding: 0.4em 0;
padding: 0.4em;
margin: 0 0 0.5em 0;
box-sizing: border-box;
border: 1px solid #ccc;
border-radius: 2px;
}

input:disabled {
color: #ccc;
}

button {
color: #333;
background-color: #f4f4f4;
outline: none;
}

button:disabled {
color: #999;
}

button:not(:disabled):active {
background-color: #ddd;
}

button:focus {
border-color: #666;
}
18 changes: 18 additions & 0 deletions examples/projects/video01/code/svelte-todo/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset='utf-8'>
<meta name='viewport' content='width=device-width,initial-scale=1'>

<title>Svelte app</title>

<link rel='icon' type='image/png' href='/favicon.png'>
<link rel='stylesheet' href='/global.css'>
<link rel='stylesheet' href='/build/bundle.css'>

<script defer src='/build/bundle.js'></script>
</head>

<body>
</body>
</html>
76 changes: 76 additions & 0 deletions examples/projects/video01/code/svelte-todo/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import svelte from 'rollup-plugin-svelte';
import commonjs from '@rollup/plugin-commonjs';
import resolve from '@rollup/plugin-node-resolve';
import livereload from 'rollup-plugin-livereload';
import { terser } from 'rollup-plugin-terser';
import css from 'rollup-plugin-css-only';

const production = !process.env.ROLLUP_WATCH;

function serve() {
let server;

function toExit() {
if (server) server.kill(0);
}

return {
writeBundle() {
if (server) return;
server = require('child_process').spawn('npm', ['run', 'start', '--', '--dev'], {
stdio: ['ignore', 'inherit', 'inherit'],
shell: true
});

process.on('SIGTERM', toExit);
process.on('exit', toExit);
}
};
}

export default {
input: 'src/main.js',
output: {
sourcemap: true,
format: 'iife',
name: 'app',
file: 'public/build/bundle.js'
},
plugins: [
svelte({
compilerOptions: {
// enable run-time checks when not in production
dev: !production
}
}),
// we'll extract any component CSS out into
// a separate file - better for performance
css({ output: 'bundle.css' }),

// If you have external dependencies installed from
// npm, you'll most likely need these plugins. In
// some cases you'll need additional configuration -
// consult the documentation for details:
// https://github.com/rollup/plugins/tree/master/packages/commonjs
resolve({
browser: true,
dedupe: ['svelte']
}),
commonjs(),

// In dev mode, call `npm run start` once
// the bundle has been generated
!production && serve(),

// Watch the `public` directory and refresh the
// browser on changes when not in production
!production && livereload('public'),

// If we're building for production (npm run build
// instead of npm run dev), minify
production && terser()
],
watch: {
clearScreen: false
}
};
Loading