Skip to content

Instantly share code, notes, and snippets.

View shinokada's full-sized avatar

Shinichi Okada shinokada

View GitHub Profile
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + Svelte + PWA</title>
<link rel="manifest" href="/assets/manifest-1a803fe8.webmanifest" />
<meta name="theme-color" content="#ffffff" />
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
<link rel="icon" href="favicon.ico" type="image/x-icon" />
{
"name": "Vite Svelte PWA",
"short_name": "vite-svelte-pwa",
"scope": "/",
"start_url": ".",
"icons": [
{
"src": "/apple-touch-icon.png",
"sizes": "180x180",
"type": "image/png"
const GHPATH = 'https://vite-svelte-pwa.codewithshin.com';
const APP_PREFIX = 'vite_svelte_pwa_';
const VERSION = 'version_02';
const URLS = [
`${GHPATH}/`,
`${GHPATH}/index.html`
];
const CACHE_NAME = APP_PREFIX + VERSION;
self.addEventListener('fetch', function (e) {
/*
This script reads the files in the dist directory and creates a new exports object in the package.json file
with the appropriate svelte and types paths for each Svelte component file found in the dist directory,
except for index.js and index.d.ts.
The resulting exports object is structured as follows:
"exports": {
".": {
"types": "./dist/index.d.ts",
"svelte": "./dist/index.js"
},
// Use this script where you have sub-directories
// This script reads the files in the dist directory and creates a new exports object in the package.json file
import fs from 'fs';
import path from 'path';
const distDir = './dist';
const packageJsonPath = './package.json';
const componentNames = fs.readdirSync(distDir);
const componentExports = {};
<script>
import { Heading, Button, Modal, ImagePlaceholder, TextPlaceholder } from 'flowbite-svelte'
let defaultModal = false;
</script>
<Heading tag="h1" customSize="text-5xl">My website</Heading>
<ImagePlaceholder class='my-4'/>
<Button on:click={() => defaultModal = true} class='mb-4'>Default modal</Button>
<TextPlaceholder class='pb-8' size='xxl'/>
<TextPlaceholder class='pb-8' size='xxl'/>
<script lang='ts'>
import "../app.postcss"
import { Navbar, NavBrand, NavLi, NavUl, NavHamburger, Footer, FooterBrand, FooterCopyright, FooterLinkGroup, FooterLink, Hr } from 'flowbite-svelte'
</script>
<Navbar let:hidden let:toggle>
<NavBrand href="/">
<img
src="https://flowbite-svelte.com/images/flowbite-svelte-icon-logo.svg"
class="mr-3 h-6 sm:h-9"
<script lang='ts'>
import "../app.postcss"
import { Navbar, NavBrand, NavLi, NavUl, NavHamburger } from 'flowbite-svelte'
</script>
<Navbar let:hidden let:toggle>
<NavBrand href="/">
<img
src="https://flowbite-svelte.com/images/flowbite-svelte-icon-logo.svg"
class="mr-3 h-6 sm:h-9"
/*
Use this with the following script
```
"write-package-json": "node ./scripts/package-json-writer.js",
"add-exports": "node ./scripts/add-exports-to-package-json.js",
"package:publish": "standard-version && git push --follow-tags origin main && npm run package &&
npm run add-exports && npm run write-package-json && npm publish",
```
This script reads the content of a folder named 'dist' and generates an exports object to be included in the
import plotly.express as px
df = pd.read_csv('https://raw.githubusercontent.com/shinokada/covid-19-stats/master/data/daily-new-confirmed-cases-of-covid-19-tests-per-case.csv')
df.columns = ['Country','Code','Date','Confirmed','Days since confirmed']
includes=['United States','Russia', 'India','Brazil']
df=df[df['Country'].isin(includes)]
df['Date']= pd.to_datetime(df['Date']).dt.strftime('%Y-%m-%d')
df=df[(df['Date']>'2020-03-15') & (df['Date'] <'2020-06-14')]
fig = px.scatter(df, x="Date", y="Confirmed",
color="Country", animation_frame="Date", animation_group="Country", size="Confirmed",