Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
pickyzz committed Aug 9, 2022
0 parents commit dc7104d
Show file tree
Hide file tree
Showing 29 changed files with 2,563 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.DS_Store
node_modules
/build
/.svelte-kit
/package
.env
.env.*
!.env.example

# Ignore files for PNPM, NPM and YARN
pnpm-lock.yaml
package-lock.json
yarn.lock
20 changes: 20 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'prettier'],
plugins: ['svelte3', '@typescript-eslint'],
ignorePatterns: ['*.cjs'],
overrides: [{ files: ['*.svelte'], processor: 'svelte3/svelte3' }],
settings: {
'svelte3/typescript': () => require('typescript')
},
parserOptions: {
sourceType: 'module',
ecmaVersion: 2020
},
env: {
browser: true,
es2017: true,
node: true
}
};
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.DS_Store
node_modules
/build
/.svelte-kit
/package
.env
.env.*
!.env.example
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
engine-strict=true
13 changes: 13 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.DS_Store
node_modules
/build
/.svelte-kit
/package
.env
.env.*
!.env.example

# Ignore files for PNPM, NPM and YARN
pnpm-lock.yaml
package-lock.json
yarn.lock
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"useTabs": true,
"singleQuote": true,
"trailingComma": "none",
"printWidth": 100
}
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# SVELTE-DUPLY sveltekit template

simple sveltekit template for single page app building.

## Setup

- Clone/fork this repository (or click `use this template`)
- `yarn` or `npm install`
- `yarn dev` or `npm run dev`

## Build from

- Sveltekit + vite (Typescript)
- [Tailwindcss](https://tailwindcss.com)
- [DaisyUi](https://daisyui.com)
43 changes: 43 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"name": "svelte-duply",
"version": "0.0.1",
"scripts": {
"dev": "vite dev",
"build": "vite build",
"package": "svelte-kit package",
"preview": "vite preview",
"test": "playwright test",
"check": "svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-check --tsconfig ./tsconfig.json --watch",
"lint": "prettier --check --plugin-search-dir=. . && eslint .",
"format": "prettier --write --plugin-search-dir=. ."
},
"devDependencies": {
"@playwright/test": "^1.22.2",
"@sveltejs/adapter-auto": "next",
"@sveltejs/kit": "next",
"@typescript-eslint/eslint-plugin": "^5.27.0",
"@typescript-eslint/parser": "^5.27.0",
"autoprefixer": "^10.4.7",
"daisyui": "^2.22.0",
"eslint": "^8.16.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-svelte3": "^4.0.0",
"postcss": "^8.4.14",
"postcss-load-config": "^4.0.1",
"prettier": "^2.6.2",
"prettier-plugin-svelte": "^2.7.0",
"svelte": "^3.44.0",
"svelte-check": "^2.7.1",
"svelte-preprocess": "^4.10.7",
"svelte-share-buttons-component": "^1.5.0",
"tailwindcss": "^3.1.5",
"theme-change": "^2.2.0",
"tslib": "^2.3.1",
"typescript": "^4.7.4",
"vite": "^3.0.0"
},
"type": "module",
"license": "MIT",
"dependencies": {}
}
10 changes: 10 additions & 0 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import type { PlaywrightTestConfig } from '@playwright/test';

const config: PlaywrightTestConfig = {
webServer: {
command: 'npm run build && npm run preview',
port: 4173
}
};

export default config;
13 changes: 13 additions & 0 deletions postcss.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const tailwindcss = require('tailwindcss');
const autoprefixer = require('autoprefixer');

const config = {
plugins: [
//Some plugins, like tailwindcss/nesting, need to run before Tailwind,
tailwindcss(),
//But others, like autoprefixer, need to run after,
autoprefixer
]
};

module.exports = config;
4 changes: 4 additions & 0 deletions src/app.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/* Write your global styles here, in PostCSS syntax */
@tailwind base;
@tailwind components;
@tailwind utilities;
11 changes: 11 additions & 0 deletions src/app.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// See https://kit.svelte.dev/docs/types#app
// for information about these interfaces
// and what to do when importing types
declare namespace App {
// interface Locals {}
// interface Platform {}
// interface PrivateEnv {}
// interface PublicEnv {}
// interface Session {}
// interface Stuff {}
}
13 changes: 13 additions & 0 deletions src/app.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en" data-theme="coffee">
<head>
<meta charset="utf-8" />
<meta name="description" content="" />
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
%sveltekit.head%
</head>
<body>
<div>%sveltekit.body%</div>
</body>
</html>
9 changes: 9 additions & 0 deletions src/lib/components/Darkmode.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<div class="fixed top-[2%] right-4">
<div>
<span class="mx-2">Light</span>
<select data-choose-theme class="select select-bordered select-sm">
<option value="coffee">Off</option>
<option value="garden">On</option>
</select>
</div>
</div>
10 changes: 10 additions & 0 deletions src/lib/components/Footer.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<script>
const d = new Date()
const y = d.getFullYear()
</script>

<div class="w-full hidden lg:flex fixed top-auto bottom-4 center gap-2 pr-4 sm:pr-0 justify-center">
<span class="text-[12px]">
<a href="https://pickyzz.dev" target="_blank">Pickyzz</a> {y}
</span>
</div>
25 changes: 25 additions & 0 deletions src/lib/components/Head.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<script lang="ts">
export let title: string
export let description: string
export let url: string
export let imageUrl: string
</script>

<svelte:head>
<title>{title}</title>

<meta name="title" content={title} />
<meta name="description" content={description} />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta property="og:url" content={url} />
<meta property="og:type" content="website" />
<meta property="og:title" content={title} />
<meta property="og:description" content={description} />
<meta name="twitter:title" content={title} />
<meta name="twitter:card" content="summary_large_image" />

{#if imageUrl}
<meta property="og:image" content={imageUrl} />
<meta name="twitter:image" content={imageUrl} />
{/if}
</svelte:head>
30 changes: 30 additions & 0 deletions src/lib/components/Kofi.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<script lang="ts">
import LibLoader from './LibLoader.svelte'
export let name: string
export let label = 'Buy me Coffee'
const loadKofiWidget = () => {
window.kofiWidgetOverlay?.draw(
name,
{
type: 'floating-chat',
'floating-chat.donateButton.text': label,
'floating-chat.donateButton.background-color': 'orange',
'floating-chat.donateButton.text-color': 'black'
},
'kofiContainer'
)
}
</script>

{#if name}
<div id="kofiContainer" class="web-only">{label}</div>

<LibLoader
on:load={loadKofiWidget}
src="https://storage.ko-fi.com/cdn/scripts/overlay-widget.js"
libraryDetectionObject="kofiWidgetOverlay"
/>
{/if}

24 changes: 24 additions & 0 deletions src/lib/components/LibLoader.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<script lang="ts">
// Based on code from https://stackoverflow.com/questions/59629947/how-do-i-load-an-external-js-library-in-svelte-sapper
import { onMount, createEventDispatcher } from 'svelte'
const dispatch = createEventDispatcher()
export let src: string
export let libraryDetectionObject: string
let script: HTMLScriptElement
onMount(() => {
if (libraryDetectionObject && window && typeof window[libraryDetectionObject] !== 'undefined') {
return dispatch('load')
}
script.addEventListener('load', () => {
dispatch('load')
})
script.addEventListener('error', (event) => {
dispatch('error')
})
})
</script>

<svelte:head>
<script bind:this={script} {src}></script>
</svelte:head>

16 changes: 16 additions & 0 deletions src/lib/components/ShareButton.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<script lang="ts">
import { Facebook, Twitter, Line } from 'svelte-share-buttons-component'
export let url: string
export let title: string
</script>

{#if url}
<div
class="w-full fixed top-auto bottom-4 lg:right-2 md:right-0 center flex gap-2 pr-4 sm:pr-0 justify-end sm:justify-end"
>
<Facebook class="h-10 w-10 rounded-full" {url} quote={title} />
<Twitter class="h-10 w-10 rounded-full" {url} text={title} />
</div>
{/if}

28 changes: 28 additions & 0 deletions src/routes/__layout.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<script lang='ts'>
import '../app.css';
import Footer from '$lib/components/Footer.svelte'
import Head from '$lib/components/Head.svelte'
import Kofi from '$lib/components/Kofi.svelte'
import ShareButton from '$lib/components/ShareButton.svelte'
import { themeChange } from 'theme-change'
import { onMount } from 'svelte'
import Darkmode from '$lib/components/Darkmode.svelte'
onMount(() => {
themeChange(false)
})
const url = 'https://svelte-duply.pickyzz.dev'
const title = 'Svelte-duply'
const description = 'Sveltekit Template'
const imageUrl = `${url}/screenshot.png`
</script>

<Head {title} {description} {url} {imageUrl} />
<Kofi name="pickyzz" label="Buy me Coffee" />
<ShareButton {url} {title} />
<main>
<Darkmode />
<Footer />
<slot />
</main>
8 changes: 8 additions & 0 deletions src/routes/index.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<script lang="ts">
</script>

<div class="w-full h-screen flex flex-col justify-center items-center">
<h1 class="text-6xl flex flex-col">
<span>Cats think </span><span>they will</span><span>rule the world</span>
</h1>
</div>
Binary file added static/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions svelte.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import adapter from '@sveltejs/adapter-auto';
import preprocess from 'svelte-preprocess';

/** @type {import('@sveltejs/kit').Config} */
const config = {
// Consult https://github.com/sveltejs/svelte-preprocess
// for more information about preprocessors
preprocess: [
preprocess({
postcss: true
})
],

kit: {
adapter: adapter()
}
};

export default config;
13 changes: 13 additions & 0 deletions tailwind.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const config = {
content: ['./src/**/*.{html,js,svelte,ts}'],

theme: {
extend: {}
},

plugins: [
require('daisyui')
]
};

module.exports = config;
6 changes: 6 additions & 0 deletions tests/test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { expect, test } from '@playwright/test';

test('index page has expected h1', async ({ page }) => {
await page.goto('/');
expect(await page.textContent('h1')).toBe('Welcome to SvelteKit');
});
Loading

0 comments on commit dc7104d

Please sign in to comment.