Skip to content

Commit

Permalink
update deps, set TS moduleResolution=bundler
Browse files Browse the repository at this point in the history
add PrevNext links to demo layout
  • Loading branch information
janosh committed Mar 15, 2023
1 parent bd7e2fd commit a12835e
Show file tree
Hide file tree
Showing 20 changed files with 65 additions and 76 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
cache-dependency-path: package.json

- name: Install dependencies
run: npm install
run: npm install --force

- name: Build site
run: npm run build
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:

- name: Install dependencies
run: |
npm install
npm install --force
npx playwright install chromium
- name: Run tests
Expand All @@ -41,7 +41,7 @@ jobs:

- name: Build package and publish to NPM
run: |
npm install
npm install --force
npm run package
npm login --auth-type=legacy
npm publish
Expand Down
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
"@sveltejs/kit": "^1.11.0",
"@sveltejs/package": "2.0.2",
"@sveltejs/vite-plugin-svelte": "^2.0.3",
"@typescript-eslint/eslint-plugin": "^5.54.1",
"@typescript-eslint/parser": "^5.54.1",
"@typescript-eslint/eslint-plugin": "^5.55.0",
"@typescript-eslint/parser": "^5.55.0",
"@vitest/coverage-c8": "^0.29.2",
"eslint": "^8.36.0",
"eslint-plugin-svelte3": "^4.0.0",
Expand All @@ -46,12 +46,12 @@
"prettier-plugin-svelte": "^2.9.0",
"rehype-autolink-headings": "^6.1.1",
"rehype-slug": "^5.1.0",
"svelte-check": "^3.1.2",
"svelte-preprocess": "^5.0.1",
"svelte-check": "^3.1.4",
"svelte-preprocess": "^5.0.2",
"svelte-toc": "^0.5.3",
"svelte-zoo": "^0.3.4",
"svelte2tsx": "^0.6.7",
"typescript": "^4.9.5",
"svelte-zoo": "^0.4.3",
"svelte2tsx": "^0.6.9",
"typescript": "5.0.1-rc",
"vite": "^4.1.4",
"vitest": "^0.29.2"
},
Expand Down
9 changes: 9 additions & 0 deletions src/routes/(demos)/+layout.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<script lang="ts">
import { page } from '$app/stores'
import { name } from '$root/package.json'
import { DemoNav } from '$site'
import { demos } from '$site/stores'
import { PrevNext } from 'svelte-zoo'
</script>

<h1>
Expand All @@ -11,6 +14,12 @@
<DemoNav style="place-content: center;" />

<slot />

<PrevNext
items={$demos}
current={$page.url.pathname}
style="max-width: 55em; margin: auto;"
/>
</main>

<style>
Expand Down
6 changes: 3 additions & 3 deletions src/routes/(demos)/allow-user-options/+page.svx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import MultiSelect from '$lib'
import { foods, languages } from '$src/options'
import { foods, languages } from '$site/options'
import { LanguageSlot } from '$site'

let selected_empty = []
Expand All @@ -13,7 +13,7 @@
```svelte example stackblitz id="foods"
<script>
import MultiSelect from '$lib'
import { foods } from '$src/options'
import { foods } from '$site/options'

let selected = '🍇 Grapes, 🍈 Melon, 🍉 Watermelon, 🍊 Tangerine'.split(', ')
</script>
Expand All @@ -34,7 +34,7 @@
```svelte example stackblitz id="languages"
<script>
import MultiSelect from '$lib'
import { languages } from '$src/options'
import { languages } from '$site/options'
import { LanguageSlot } from '$site'

let selected_append = ['Haskell', 'TypeScript']
Expand Down
2 changes: 1 addition & 1 deletion src/routes/(demos)/form/+page.svx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This example shows the JavaScript way of handling MultiSelect fields in form sub
<script lang="ts">
import MultiSelect from '$lib'
import { ColorSlot } from '$site'
import { colors } from '$src/options'
import { colors } from '$site/options'

async function handle_submit(event: SubmitEvent) {
// use bind:this={form} or event.target as arg to new FormData()
Expand Down
2 changes: 1 addition & 1 deletion src/routes/(demos)/kit-form-actions/+page.svx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ HTML.
<script lang="ts">
import MultiSelect from '$lib'
import { ColorSlot } from '$site'
import { colors } from '$src/options'
import { colors } from '$site/options'
import { repository } from '$root/package.json'
import type { ActionData, PageServerData } from './$types'

Expand Down
2 changes: 1 addition & 1 deletion src/routes/(demos)/min-max-select/+page.svx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
```svelte example stackblitz id="languages"
<script lang="ts">
import MultiSelect from '$lib'
import { languages } from '$src/options'
import { languages } from '$site/options'
import { LanguageSlot } from '$site'
</script>

Expand Down
6 changes: 3 additions & 3 deletions src/routes/(demos)/persistent/+page.svx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import hljs from 'highlight.js/lib/common'
import 'highlight.js/styles/vs2015.css'
import store_code from '/src/stores.ts?raw'
import store_code from '$site/stores.ts?raw'
</script>

## Page-Reload Persistent MultiSelect
Expand All @@ -13,9 +13,9 @@
```svelte example stackblitz id="languages"
<script>
import MultiSelect from '$lib'
import { languages } from '$src/options'
import { languages } from '$site/options'
import { LanguageSlot } from '$site'
import { language_store } from '$src/stores'
import { language_store } from '$site/stores'
</script>

<MultiSelect
Expand Down
4 changes: 2 additions & 2 deletions src/routes/(demos)/slots/+page.svx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
```svelte example stackblitz id="languages-1"
<script>
import MultiSelect from '$lib'
import { languages } from '$src/options'
import { languages } from '$site/options'
import { LanguageSlot, MinusIcon } from '$site'
import { Icon } from 'svelte-zoo'
</script>
Expand All @@ -28,7 +28,7 @@
```svelte example stackblitz id="languages-2"
<script>
import MultiSelect from '$lib'
import { languages } from '$src/options'
import { languages } from '$site/options'
import { LanguageSlot } from '$site'
import { Icon } from 'svelte-zoo'

Expand Down
4 changes: 2 additions & 2 deletions src/routes/(demos)/sort-selected/+page.svx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
```svelte example stackblitz id="default-sort"
<script>
import MultiSelect from '$lib'
import { frontend_libs } from '$src/options'
import { frontend_libs } from '$site/options'
</script>

<MultiSelect
Expand All @@ -22,7 +22,7 @@
```svelte example stackblitz id="custom-sort"
<script lang="ts">
import MultiSelect, { type Option } from '$lib'
import { frontend_libs } from '$src/options'
import { frontend_libs } from '$site/options'

const sortSelected = (op1: Option, op2: Option) => {
if (op1.lang !== op2.lang) return op1.lang.localeCompare(op2.lang)
Expand Down
2 changes: 1 addition & 1 deletion src/routes/(demos)/ui/+page.svx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
```svelte example stackblitz id="foods"
<script>
import MultiSelect from '$lib'
import { foods } from '$src/options'
import { foods } from '$site/options'
</script>

<MultiSelect
Expand Down
19 changes: 14 additions & 5 deletions src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,27 @@
import { page } from '$app/stores'
import { CmdPalette } from '$lib'
import { repository } from '$root/package.json'
import { Footer } from '$site'
import { demos } from '$site/stores'
import { GitHubCorner } from 'svelte-zoo'
import '../app.css'
import Footer from '../site/Footer.svelte'
const actions = Object.keys(import.meta.glob(`./**/+page.{svx,svelte,md}`)).map(
const routes = Object.keys(import.meta.glob(`./**/+page.{svx,svelte,md}`)).map(
(filename) => {
const parts = filename.split(`/`).filter((part) => !part.startsWith(`(`)) // remove hidden route segments
const route = `/${parts.slice(1, -1).join(`/`)}`
return { label: route, action: () => goto(route) }
return { route: `/${parts.slice(1, -1).join(`/`)}`, filename }
}
)
if (routes.length < 3) {
console.error(`Too few demo routes found: ${routes.length}`)
}
$demos = routes
.filter(({ filename }) => filename.includes(`/(demos)/`))
.map(({ route }) => route)
const actions = routes.map(({ route }) => ({ label: route, action: () => goto(route) }))
</script>

<CmdPalette {actions} placeholder="Go to..." />
Expand Down
11 changes: 2 additions & 9 deletions src/site/DemoNav.svelte
Original file line number Diff line number Diff line change
@@ -1,24 +1,17 @@
<script lang="ts">
import { page } from '$app/stores'
import { demos } from './stores'
export let style: string | null = null
const routes = Object.keys(
// eslint-disable-next-line @typescript-eslint/quotes
import.meta.glob('/src/routes/\\(demos\\)/*/+page*.{svx,md,svelte}')
).map((filename) => filename.split(`/`)[4])
if (routes.length < 3) {
throw new Error(`Too few demo routes found: ${routes.length}`)
}
$: is_current = (path: string) => {
if (`/${path}` == $page.url.pathname) return `page`
return undefined
}
</script>

<nav {style}>
{#each routes as href, idx}
{#each $demos as href, idx}
{#if idx > 0}<strong>&bull;</strong>{/if}
<a {href} aria-current={is_current(href)}>{href}</a>
{/each}
Expand Down
10 changes: 5 additions & 5 deletions src/site/Examples.svx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
```svelte example collapsible repl="https://svelte.dev/repl/e3b88f59f62b498d943ecf7756ab75d7" stackblitz="src/site/Examples.svx"
<script lang="ts">
import MultiSelect from '$lib'
import { languages } from '../options'
import { languages } from '$site/options'
import LanguageSlot from './LanguageSlot.svelte'

let selected: string[]
Expand All @@ -29,7 +29,7 @@
```svelte example collapsible repl="https://svelte.dev/repl/79e22e1905c94456aa21564b4d5f8759" stackblitz="src/site/Examples.svx"
<script lang="ts">
import MultiSelect from '$lib'
import { ml_libs } from '../options'
import { ml_libs } from '$site/options'

let value: { label: string, disabled: boolean, preselected: boolean }
let searchText = ''
Expand Down Expand Up @@ -64,7 +64,7 @@
```svelte example collapsible repl="https://svelte.dev/repl/516279bd62ec424986115263c2cdc169" stackblitz="src/site/Examples.svx"
<script lang="ts">
import MultiSelect from '$lib'
import { frontend_libs } from '../options'
import { frontend_libs } from '$site/options'
import RepoSlot from './RepoSlot.svelte'
import { Confetti } from 'svelte-zoo'
import type { ObjectOption } from '$lib'
Expand Down Expand Up @@ -105,7 +105,7 @@
```svelte example collapsible repl="https://svelte.dev/repl/3a217c39932047a09f61d6425b04a7c3" stackblitz="src/site/Examples.svx"
<script lang="ts">
import MultiSelect from '$lib'
import { colors } from '../options'
import { colors } from '$site/options'
import ColorSlot from './ColorSlot.svelte'

let selected: string[]
Expand Down Expand Up @@ -142,7 +142,7 @@
```svelte example collapsible repl="https://svelte.dev/repl/4ff40862436e4bfbb2bd55d234352bb1" stackblitz="src/site/Examples.svx"
<script lang="ts">
import MultiSelect from '$lib'
import { countries } from '../options'
import { countries } from '$site/options'

let selected: string[]
// required={1} means form validation will prevent submission if no option selected
Expand Down
File renamed without changes.
9 changes: 9 additions & 0 deletions src/site/stores.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { session_store } from 'svelte-zoo'
import { writable } from 'svelte/store'

export const language_store = session_store<string[]>(
`language-store`,
`Python TypeScript C Haskell`.split(` `)
)

export const demos = writable<string[]>([])
31 changes: 0 additions & 31 deletions src/stores.ts

This file was deleted.

2 changes: 1 addition & 1 deletion tests/MultiSelect.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect, test } from '@playwright/test'
import { foods } from '../src/options.ts'
import { foods } from '../src/site/options.ts'
import { wait_for_animation_end } from './index.ts'

// to run tests in this file, use `npm run test:e2e`
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"strict": true,
"module": "esnext",
"target": "esnext",
"moduleResolution": "node",
"moduleResolution": "bundler",

// 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.
Expand Down

0 comments on commit a12835e

Please sign in to comment.