first commit
This commit is contained in:
commit
108c69eb49
48
README.md
Normal file
48
README.md
Normal file
@ -0,0 +1,48 @@
|
||||
# Svelte + Vite
|
||||
|
||||
This template should help get you started developing with Svelte in Vite.
|
||||
|
||||
## Recommended IDE Setup
|
||||
|
||||
[VS Code](https://code.visualstudio.com/) + [Svelte](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode).
|
||||
|
||||
## Need an official Svelte framework?
|
||||
|
||||
Check out [SvelteKit](https://github.com/sveltejs/kit#readme), which is also powered by Vite. Deploy anywhere with its serverless-first approach and adapt to various platforms, with out of the box support for TypeScript, SCSS, and Less, and easily-added support for mdsvex, GraphQL, PostCSS, Tailwind CSS, and more.
|
||||
|
||||
## Technical considerations
|
||||
|
||||
**Why use this over SvelteKit?**
|
||||
|
||||
- It brings its own routing solution which might not be preferable for some users.
|
||||
- It is first and foremost a framework that just happens to use Vite under the hood, not a Vite app.
|
||||
`vite dev` and `vite build` wouldn't work in a SvelteKit environment, for example.
|
||||
|
||||
This template contains as little as possible to get started with Vite + Svelte, while taking into account the developer experience with regards to HMR and intellisense. It demonstrates capabilities on par with the other `create-vite` templates and is a good starting point for beginners dipping their toes into a Vite + Svelte project.
|
||||
|
||||
Should you later need the extended capabilities and extensibility provided by SvelteKit, the template has been structured similarly to SvelteKit so that it is easy to migrate.
|
||||
|
||||
**Why `global.d.ts` instead of `compilerOptions.types` inside `jsconfig.json` or `tsconfig.json`?**
|
||||
|
||||
Setting `compilerOptions.types` shuts out all other types not explicitly listed in the configuration. Using triple-slash references keeps the default TypeScript setting of accepting type information from the entire workspace, while also adding `svelte` and `vite/client` type information.
|
||||
|
||||
**Why include `.vscode/extensions.json`?**
|
||||
|
||||
Other templates indirectly recommend extensions via the README, but this file allows VS Code to prompt the user to install the recommended extension upon opening the project.
|
||||
|
||||
**Why enable `checkJs` in the JS template?**
|
||||
|
||||
It is likely that most cases of changing variable types in runtime are likely to be accidental, rather than deliberate. This provides advanced typechecking out of the box. Should you like to take advantage of the dynamically-typed nature of JavaScript, it is trivial to change the configuration.
|
||||
|
||||
**Why is HMR not preserving my local component state?**
|
||||
|
||||
HMR state preservation comes with a number of gotchas! It has been disabled by default in both `svelte-hmr` and `@sveltejs/vite-plugin-svelte` due to its often surprising behavior. You can read the details [here](https://github.com/rixo/svelte-hmr#svelte-hmr).
|
||||
|
||||
If you have state that's important to retain within a component, consider creating an external store which would not be replaced by HMR.
|
||||
|
||||
```js
|
||||
// store.js
|
||||
// An extremely simple external store
|
||||
import { writable } from 'svelte/store'
|
||||
export default writable(0)
|
||||
```
|
13
index.html
Normal file
13
index.html
Normal file
@ -0,0 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" href="/favicon.ico" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Svelte + Vite App</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script type="module" src="/src/main.js"></script>
|
||||
</body>
|
||||
</html>
|
34
jsconfig.json
Normal file
34
jsconfig.json
Normal file
@ -0,0 +1,34 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"moduleResolution": "node",
|
||||
"target": "esnext",
|
||||
"module": "esnext",
|
||||
/**
|
||||
* svelte-preprocess cannot figure out whether you have
|
||||
* a value or a type, so tell TypeScript to enforce using
|
||||
* `import type` instead of `import` for Types.
|
||||
*/
|
||||
"importsNotUsedAsValues": "error",
|
||||
"isolatedModules": true,
|
||||
"resolveJsonModule": true,
|
||||
/**
|
||||
* To have warnings / errors of the Svelte compiler at the
|
||||
* correct position, enable source maps by default.
|
||||
*/
|
||||
"sourceMap": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"baseUrl": ".",
|
||||
/**
|
||||
* Typecheck JS in `.svelte` and `.js` files by default.
|
||||
* Disable this if you'd like to use dynamic types.
|
||||
*/
|
||||
"checkJs": true
|
||||
},
|
||||
/**
|
||||
* Use global.d.ts instead of compilerOptions.types
|
||||
* to avoid limiting type declarations.
|
||||
*/
|
||||
"include": ["src/**/*.d.ts", "src/**/*.js", "src/**/*.svelte"]
|
||||
}
|
1130
package-lock.json
generated
Normal file
1130
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
20
package.json
Normal file
20
package.json
Normal file
@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "my-app",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vite build",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@sveltejs/vite-plugin-svelte": "^1.0.0-next.30",
|
||||
"svelte": "^3.44.0",
|
||||
"vite": "^2.9.9"
|
||||
},
|
||||
"dependencies": {
|
||||
"leaflet": "^1.8.0",
|
||||
"svelte-leafletjs": "^0.9.0"
|
||||
}
|
||||
}
|
BIN
public/favicon.ico
Normal file
BIN
public/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
110
src/App.svelte
Normal file
110
src/App.svelte
Normal file
@ -0,0 +1,110 @@
|
||||
<script>
|
||||
import logo from './assets/svelte.png'
|
||||
import Counter from './lib/Counter.svelte'
|
||||
import Stats from './components/Stats.svelte'
|
||||
import Map from './components/Map.svelte'
|
||||
import Routes from './components/Routes.svelte'
|
||||
|
||||
</script>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<main>
|
||||
|
||||
<!-- Write your comments here -->
|
||||
|
||||
<h1>Track your Bike!</h1>
|
||||
|
||||
<div class="sorting">
|
||||
<Stats/>
|
||||
<Routes/>
|
||||
</div>
|
||||
|
||||
<div class="sorting">
|
||||
<Map/>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="routes">
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</main>
|
||||
|
||||
|
||||
<style>
|
||||
:root {
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
|
||||
Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
|
||||
}
|
||||
|
||||
main {
|
||||
text-align: center;
|
||||
padding: 1em;
|
||||
margin: 0 auto;
|
||||
|
||||
}
|
||||
|
||||
img {
|
||||
height: 16rem;
|
||||
width: 16rem;
|
||||
}
|
||||
|
||||
h1 {
|
||||
color: #ff3e00;
|
||||
text-transform: uppercase;
|
||||
font-size: 4rem;
|
||||
font-weight: 100;
|
||||
line-height: 1.1;
|
||||
margin: 2rem auto;
|
||||
max-width: 14rem;
|
||||
|
||||
}
|
||||
|
||||
p {
|
||||
max-width: 14rem;
|
||||
margin: 1rem auto;
|
||||
line-height: 1.35;
|
||||
}
|
||||
|
||||
@media (min-width: 480px) {
|
||||
h1 {
|
||||
max-width: none;
|
||||
}
|
||||
|
||||
p {
|
||||
max-width: none;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* leaflet css*/
|
||||
#map { height: 500px; width: 500px; margin-left: 50%; }
|
||||
|
||||
.sorting {
|
||||
/*display:flex;
|
||||
width: 100%;
|
||||
height: 150px;
|
||||
/* background: #ce8888;*/
|
||||
float: left;
|
||||
}
|
||||
|
||||
.routes{
|
||||
height: 100%;
|
||||
width: 200px;
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
top: 0;
|
||||
left: 0;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</style>
|
BIN
src/assets/svelte.png
Normal file
BIN
src/assets/svelte.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.1 KiB |
73
src/components/Map.svelte
Normal file
73
src/components/Map.svelte
Normal file
@ -0,0 +1,73 @@
|
||||
<script>
|
||||
|
||||
// leaaflet map
|
||||
import * as L from 'leaflet';
|
||||
import '../../node_modules/leaflet/dist/leaflet.css'; // It might be better to use postcss.
|
||||
import { onMount } from 'svelte';
|
||||
|
||||
let div = null;
|
||||
onMount(() => {
|
||||
let map = L.map(div, {
|
||||
center: [17.385044, 78.486671],
|
||||
zoom: 10
|
||||
});
|
||||
|
||||
L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(map);
|
||||
});
|
||||
|
||||
</script>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
|
||||
<main>
|
||||
<div bind:this={div} id="map"></div>
|
||||
</main>
|
||||
|
||||
<style>
|
||||
:root {
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
|
||||
Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
|
||||
}
|
||||
|
||||
main {
|
||||
text-align: center;
|
||||
padding: 1em;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
img {
|
||||
height: 16rem;
|
||||
width: 16rem;
|
||||
}
|
||||
|
||||
h1 {
|
||||
color: #ff3e00;
|
||||
text-transform: uppercase;
|
||||
font-size: 4rem;
|
||||
font-weight: 100;
|
||||
line-height: 1.1;
|
||||
margin: 2rem auto;
|
||||
max-width: 14rem;
|
||||
}
|
||||
|
||||
p {
|
||||
max-width: 14rem;
|
||||
margin: 1rem auto;
|
||||
line-height: 1.35;
|
||||
}
|
||||
|
||||
@media (min-width: 480px) {
|
||||
h1 {
|
||||
max-width: none;
|
||||
}
|
||||
|
||||
p {
|
||||
max-width: none;
|
||||
}
|
||||
}
|
||||
|
||||
/* leaflet css*/
|
||||
#map { height: 800px; width: 1400px; }
|
||||
|
||||
|
||||
</style>
|
84
src/components/Routes.svelte
Normal file
84
src/components/Routes.svelte
Normal file
@ -0,0 +1,84 @@
|
||||
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<div class="container d-flex justify-content-center">
|
||||
|
||||
<ul class="list-group mt-5 text-white">
|
||||
<li class="list-group-item d-flex justify-content-between align-content-center">
|
||||
|
||||
<div class="d-flex flex-row">
|
||||
|
||||
<div class="ml-2">
|
||||
<h4 class="mb-0">Route 1</h4>
|
||||
<div class="about">
|
||||
|
||||
<span>Jan 21, 2020</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="list-group-item d-flex justify-content-between align-content-center">
|
||||
|
||||
<div class="d-flex flex-row">
|
||||
<div class="ml-2">
|
||||
<h4 class="mb-0">Route 2</h4>
|
||||
<div class="about">
|
||||
|
||||
<span>Jan 22, 2020</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
<style>
|
||||
body{
|
||||
background: #e68a43;
|
||||
}
|
||||
ul{
|
||||
list-style-type: none;
|
||||
}
|
||||
|
||||
.list-group{
|
||||
width: 250px !important;
|
||||
|
||||
}
|
||||
|
||||
.list-group-item{
|
||||
margin-top:16px;
|
||||
border-radius: none;
|
||||
background: #e68a43;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease-in-out;
|
||||
}
|
||||
|
||||
|
||||
.list-group-item:hover{
|
||||
transform: scaleX(1.1);
|
||||
}
|
||||
|
||||
.check{
|
||||
opacity: 0;
|
||||
transition: all 0.6s ease-in-out;
|
||||
}
|
||||
|
||||
.list-group-item:hover .check {
|
||||
opacity: 1;
|
||||
|
||||
}
|
||||
|
||||
.about span{
|
||||
font-size: 16px;
|
||||
margin-right: 10px;
|
||||
|
||||
}
|
||||
|
||||
</style>
|
140
src/components/Stats.svelte
Normal file
140
src/components/Stats.svelte
Normal file
@ -0,0 +1,140 @@
|
||||
|
||||
<div class="wrapper">
|
||||
<div class="panel">
|
||||
<div class="panel-header">
|
||||
<h3 class="title">Statistics</h3>
|
||||
|
||||
<div class="routes">
|
||||
<span>Route X</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="panel-body">
|
||||
<div class="categories">
|
||||
<div class="category">
|
||||
<span>kilometers traveled</span>
|
||||
<span>2 Km</span>
|
||||
</div>
|
||||
<div class="category">
|
||||
<span>traveled time</span>
|
||||
<span>2 min</span>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="chart">
|
||||
<div class="operating-systems">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
|
||||
<style>
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
html, body {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
font-family: 'Roboto', sans-serif;
|
||||
background: #d4d1d1;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.panel {
|
||||
width: 300px;
|
||||
height: 400px;
|
||||
background: #e68a43;
|
||||
box-shadow: 1px 2px 3px 0px rgba(0,0,0,0.10);
|
||||
border-radius: 6px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.panel-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 0 30px;
|
||||
height: 60px;
|
||||
background: rgb(241, 239, 239);
|
||||
}
|
||||
|
||||
.title {
|
||||
color: #5E6977;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.panel-body {
|
||||
display: flex;
|
||||
height: 340px;
|
||||
}
|
||||
.categories {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
flex-basis: 25%;
|
||||
padding: 39px 0px 41px 26px;
|
||||
}
|
||||
.category {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
.category span:first-child {
|
||||
font-weight: 300;
|
||||
font-size: 14px;
|
||||
opacity: 0.6;
|
||||
color: #fff;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
.category span:last-child {
|
||||
font-size: 32px;
|
||||
font-weight: 300;
|
||||
color: #fff;
|
||||
}
|
||||
.chart {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex-grow: 2;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.operating-systems {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
width: 215px;
|
||||
margin-top: 30px;
|
||||
margin-bottom: 50px;
|
||||
}
|
||||
|
||||
.android-os span {
|
||||
background: #80B354;
|
||||
}
|
||||
.ios-os span {
|
||||
background: #F5A623;
|
||||
}
|
||||
.windows-os span {
|
||||
background: #F8E71C;
|
||||
}
|
||||
.calendar-views span:hover {
|
||||
border: 2px solid #BDC6CF;
|
||||
cursor: pointer;
|
||||
border-radius: 15px;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
34
src/lib/Counter.svelte
Normal file
34
src/lib/Counter.svelte
Normal file
@ -0,0 +1,34 @@
|
||||
<script>
|
||||
let count = 0
|
||||
const increment = () => {
|
||||
count += 1
|
||||
}
|
||||
</script>
|
||||
|
||||
<button on:click={increment}>
|
||||
Clicks: {count}
|
||||
</button>
|
||||
|
||||
<style>
|
||||
button {
|
||||
font-family: inherit;
|
||||
font-size: inherit;
|
||||
padding: 1em 2em;
|
||||
color: #ff3e00;
|
||||
background-color: rgba(255, 62, 0, 0.1);
|
||||
border-radius: 2em;
|
||||
border: 2px solid rgba(255, 62, 0, 0);
|
||||
outline: none;
|
||||
width: 200px;
|
||||
font-variant-numeric: tabular-nums;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
button:focus {
|
||||
border: 2px solid #ff3e00;
|
||||
}
|
||||
|
||||
button:active {
|
||||
background-color: rgba(255, 62, 0, 0.2);
|
||||
}
|
||||
</style>
|
7
src/main.js
Normal file
7
src/main.js
Normal file
@ -0,0 +1,7 @@
|
||||
import App from './App.svelte'
|
||||
|
||||
const app = new App({
|
||||
target: document.getElementById('app')
|
||||
})
|
||||
|
||||
export default app
|
2
src/vite-env.d.ts
vendored
Normal file
2
src/vite-env.d.ts
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
/// <reference types="svelte" />
|
||||
/// <reference types="vite/client" />
|
7
vite.config.js
Normal file
7
vite.config.js
Normal file
@ -0,0 +1,7 @@
|
||||
import { defineConfig } from 'vite'
|
||||
import { svelte } from '@sveltejs/vite-plugin-svelte'
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [svelte()]
|
||||
})
|
Loading…
Reference in New Issue
Block a user