Skip to content

Commit

Permalink
example site and dep bump
Browse files Browse the repository at this point in the history
  • Loading branch information
rob-balfre committed Sep 28, 2022
1 parent 3849f21 commit 1f8d00f
Show file tree
Hide file tree
Showing 56 changed files with 308 additions and 234 deletions.
405 changes: 219 additions & 186 deletions package-lock.json

Large diffs are not rendered by default.

21 changes: 11 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,29 @@
"devDependencies": {
"@rollup/plugin-alias": "^3.1.9",
"@sveltejs/adapter-auto": "next",
"@sveltejs/kit": "1.0.0-next.405",
"autoprefixer": "^10.4.8",
"@sveltejs/kit": "1.0.0-next.504",
"autoprefixer": "^10.4.12",
"cross-env": "^7.0.3",
"find-in-files": "^0.5.0",
"prettier": "~2.7.1",
"prettier-plugin-svelte": "^2.7.0",
"release-it": "^15.3.0",
"rollup": "^2.77.2",
"prettier-plugin-svelte": "^2.7.1",
"release-it": "^15.4.2",
"rollup": "^2.79.1",
"rollup-plugin-cleaner": "^1.0.0",
"rollup-plugin-css-only": "^3.1.0",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-postcss": "^4.0.2",
"rollup-plugin-replace": "^2.2.0",
"rollup-plugin-svelte": "^7.1.0",
"sirv-cli": "^2.0.2",
"svelte": "^3.49.0",
"svelte": "^3.50.1",
"svelte-highlight": "^6.2.1",
"svelte-preprocess": "^4.10.7",
"svelte-tiny-virtual-list": "^2.0.5",
"svelte2tsx": "^0.5.13",
"svelte2tsx": "^0.5.19",
"tape-modern": "^1.1.2",
"typescript": "^4.7.4",
"vite": "^3.0.4"
"typescript": "^4.8.4",
"vite": "^3.1.4"
},
"author": "Robert Balfré <rob.balfre@gmail.com> (https://github.com/rob-balfre)",
"license": "ISC",
Expand All @@ -59,7 +60,7 @@
},
"type": "module",
"dependencies": {
"@floating-ui/dom": "^1.0.1",
"@floating-ui/dom": "^1.0.2",
"svelte-floating-ui": "^0.3.2"
}
}
63 changes: 49 additions & 14 deletions src/routes/__layout.svelte → src/routes/+layout.svelte
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
<script>
import { page } from '$app/stores';
const _props = import.meta.glob('./examples/props/*.svelte');
const _slots = import.meta.glob('./examples/slots/*.svelte');
const _events = import.meta.glob('./examples/events/*.svelte');
const _advanced = import.meta.glob('./examples/advanced/*.svelte');
$: props = buildLinks(_props);
$: slots = buildLinks(_slots);
$: events = buildLinks(_events);
$: advanced = buildLinks(_advanced);
import { Highlight } from 'svelte-highlight';
import typescript from 'svelte-highlight/languages/typescript';
import highlightStyles from 'svelte-highlight/styles/atom-one-dark';
const _props = import.meta.glob('./examples/props/*/*.svelte', { as: 'raw' });
const _slots = import.meta.glob('./examples/slots/*/*.svelte', { as: 'raw' });
const _events = import.meta.glob('./examples/events/*/*.svelte', { as: 'raw' });
const _advanced = import.meta.glob('./examples/advanced/*/*.svelte', { as: 'raw' });
$: setup = {
props: buildLinks(_props),
slots: buildLinks(_slots),
events: buildLinks(_events),
advanced: buildLinks(_advanced),
};
function buildLinks(obj) {
return Object.keys(obj).map((key) => {
Expand All @@ -18,44 +24,74 @@
return {
href: `${sp[1]}/${sp[2]}/` + name,
name: name.replace(/-./g, (x) => x[1].toUpperCase()),
source: obj[key],
};
});
}
$: handleExampleCode($page);
let source;
async function handleExampleCode(newPage) {
if (!newPage?.routeId) return;
if (newPage.routeId.includes('examples/')) {
const s = newPage.routeId.split('/');
const file = setup[s[1]].find((i) => i.href.includes(s[2]));
const raw = await file.source();
source = raw.replace('$lib/Select.svelte', 'svelte-select');
} else {
source = null;
}
}
</script>
<svelte:head>
{@html highlightStyles}
</svelte:head>
<div class="container">
<nav>
<ul>
<li><a <a class:active={$page.routeId === 'examples'} href="/">Home</a></li>
</ul>
<h2>Props</h2>
<ul>
{#each props as { href, name }}
{#each setup.props as { href, name }}
<li><a class:active={$page.routeId === href} href={`/${href}`}>{name}</a></li>
{/each}
</ul>
<h2>Slots</h2>
<ul>
{#each slots as { href, name }}
{#each setup.slots as { href, name }}
<li><a class:active={$page.routeId === href} href={`/${href}`}>{name}</a></li>
{/each}
</ul>
<h2>Events</h2>
<ul>
{#each events as { href, name }}
{#each setup.events as { href, name }}
<li><a class:active={$page.routeId === href} href={`/${href}`}>{name}</a></li>
{/each}
</ul>
<h2>Advanced</h2>
<ul>
{#each advanced as { href, name }}
{#each setup.advanced as { href, name }}
<li><a class:active={$page.routeId === href} href={`/${href}`}>{name}</a></li>
{/each}
</ul>
</nav>
<div class="content">
<slot />
{#if source}
<Highlight language={typescript} code={source} />
{/if}
</div>
</div>
Expand All @@ -70,7 +106,6 @@
font-size: 16px;
padding: 10px;
border-bottom: 1px solid #f3f1fd;
}
nav {
Expand Down
5 changes: 5 additions & 0 deletions src/routes/+page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { redirect } from '@sveltejs/kit';

export async function load() {
throw redirect(301, "/examples");
}
Empty file added src/routes/+page.svelte
Empty file.
20 changes: 20 additions & 0 deletions src/routes/examples/+page.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<div align="center">
<img
src="https://raw.githubusercontent.com/rob-balfre/svelte-select/feature/v5/svelte-select.png"
alt="Svelte Select"
width="150" />
<h1>Svelte Select Examples</h1>

<div>
<a href="https://npmjs.org/package/svelte-select">
<img src="https://badgen.now.sh/npm/v/svelte-select" alt="version" />
</a>
<a href="https://npmjs.org/package/svelte-select">
<img src="https://badgen.now.sh/npm/dm/svelte-select" alt="downloads" />
</a>

<a href="https://github.com/rob-balfre/svelte-select">
<img src="https://badgen.net/badge/icon/github?icon=github&label" alt="downloads" />
</a>
</div>
</div>
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.
12 changes: 0 additions & 12 deletions src/routes/examples/index.svelte

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
let topConfig = {
placement: 'top-start',
};
</script>

<div class="container">
Expand Down
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.
8 changes: 0 additions & 8 deletions src/routes/index.svelte

This file was deleted.

1 change: 0 additions & 1 deletion test/src/ItemSlotTest.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import Select from '../../src/lib/Select.svelte';
let items = ['one', 'two'];
</script>

<Select bind:items listOpen>
Expand Down
5 changes: 4 additions & 1 deletion vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import { sveltekit } from '@sveltejs/kit/vite';

/** @type {import('vite').UserConfig} */
const config = {
plugins: [sveltekit()]
plugins: [sveltekit()],
optimizeDeps: {
include: ['highlight.js', 'highlight.js/lib/core'],
},
};

export default config;

0 comments on commit 1f8d00f

Please sign in to comment.