Run prettier

This commit is contained in:
venashial 2022-06-04 00:46:23 -07:00
parent 597c071c3d
commit c9ec9f14de
49 changed files with 1515 additions and 1469 deletions

15
.prettierignore Normal file
View File

@ -0,0 +1,15 @@
.DS_Store
node_modules
/.svelte-kit
/package
.mf/
build/
.idea/
.vscode/
.vercel_build_output
.pnpm-debug.log
generated/
.pnpm-store/
locales/
pnpm-lock.yaml
.nuxt/

15
.vscode/settings.json vendored
View File

@ -1,4 +1,19 @@
{ {
"prettier.endOfLine": "lf",
"cSpell.words": ["unplugin"],
"gitlens.showWelcomeOnInstall": false,
"gitlens.showWhatsNewAfterUpgrades": false,
"gitlens.plusFeatures.enabled": false,
"gitlens.currentLine.enabled": false,
"gitlens.currentLine.pullRequests.enabled": false,
"gitlens.currentLine.scrollable": true,
"gitlens.codeLens.enabled": false,
"gitlens.hovers.enabled": false,
"svelte.enable-ts-plugin": true,
"svelte.ask-to-enable-ts-plugin": false,
"yaml.schemas": {
"https://json.schemastore.org/github-workflow.json": "file:///Users/sha/Code/Modrinth/knossos/.github/workflows/deploy.yml"
},
"editor.formatOnSave": true, "editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode", "editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnPaste": true, "editor.formatOnPaste": true,

View File

@ -10,8 +10,8 @@
"prepare": "svelte-kit sync", "prepare": "svelte-kit sync",
"check": "svelte-check --tsconfig ./tsconfig.json", "check": "svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-check --tsconfig ./tsconfig.json --watch", "check:watch": "svelte-check --tsconfig ./tsconfig.json --watch",
"lint": "prettier --ignore-path .gitignore --check --plugin-search-dir=. . && eslint --ignore-path .gitignore .", "lint": "prettier --ignore-path .prettierignore --check --plugin-search-dir=. . && eslint --ignore-path .prettierignore .",
"format": "prettier --ignore-path .gitignore --write --plugin-search-dir=. ." "format": "prettier --ignore-path .prettierignore --write --plugin-search-dir=. ."
}, },
"devDependencies": { "devDependencies": {
"@sveltejs/adapter-static": "^1.0.0-next.29", "@sveltejs/adapter-static": "^1.0.0-next.29",
@ -25,6 +25,7 @@
"mdsvexamples": "^0.3.0", "mdsvexamples": "^0.3.0",
"nodemon": "^2.0.15", "nodemon": "^2.0.15",
"prettier": "^2.6.2", "prettier": "^2.6.2",
"prettier-plugin-svelte": "^2.7.0",
"sveld": "^0.13.4", "sveld": "^0.13.4",
"svelte": "^3.48.0", "svelte": "^3.48.0",
"svelte-check": "^2.2.6", "svelte-check": "^2.2.6",

30
pnpm-lock.yaml generated
View File

@ -36,6 +36,7 @@ specifiers:
postcss-pxtorem: ^6.0.0 postcss-pxtorem: ^6.0.0
postcss-strip-inline-comments: ^0.1.5 postcss-strip-inline-comments: ^0.1.5
prettier: ^2.6.2 prettier: ^2.6.2
prettier-plugin-svelte: ^2.7.0
sanitize.css: ^13.0.0 sanitize.css: ^13.0.0
sveld: ^0.13.4 sveld: ^0.13.4
svelte: ^3.48.0 svelte: ^3.48.0
@ -84,7 +85,7 @@ dependencies:
devDependencies: devDependencies:
'@sveltejs/adapter-static': 1.0.0-next.29 '@sveltejs/adapter-static': 1.0.0-next.29
'@sveltejs/kit': 1.0.0-next.345_svelte@3.48.0 '@sveltejs/kit': 1.0.0-next.348_svelte@3.48.0
'@typescript-eslint/eslint-plugin': 5.14.0_4p27j37cxves4nxlnqogdhp4ta '@typescript-eslint/eslint-plugin': 5.14.0_4p27j37cxves4nxlnqogdhp4ta
'@typescript-eslint/parser': 5.14.0_e6rt7vlgxfprtuallp2t3cvyi4 '@typescript-eslint/parser': 5.14.0_e6rt7vlgxfprtuallp2t3cvyi4
eslint: 7.32.0 eslint: 7.32.0
@ -94,6 +95,7 @@ devDependencies:
mdsvexamples: 0.3.0 mdsvexamples: 0.3.0
nodemon: 2.0.15 nodemon: 2.0.15
prettier: 2.6.2 prettier: 2.6.2
prettier-plugin-svelte: 2.7.0_kkjbqzpydplecjtkxrgomroeru
sveld: 0.13.4_jw3wiphoy34i6ad2hx6ga3jifa sveld: 0.13.4_jw3wiphoy34i6ad2hx6ga3jifa
svelte: 3.48.0 svelte: 3.48.0
svelte-check: 2.4.5_2pvebpkgu3ohgo43qaf5qmcxwm svelte-check: 2.4.5_2pvebpkgu3ohgo43qaf5qmcxwm
@ -758,14 +760,14 @@ packages:
tiny-glob: 0.2.9 tiny-glob: 0.2.9
dev: true dev: true
/@sveltejs/kit/1.0.0-next.345_svelte@3.48.0: /@sveltejs/kit/1.0.0-next.348_svelte@3.48.0:
resolution: {integrity: sha512-2nLZoXZ02uXMSxqRAMRCr/J4aCphqgKLxEhRRyh3c3aWLAjWiDWLDcvSB770eHt3y0MkYrTvp7JrDF7RhfyuBA==} resolution: {integrity: sha512-K9dfgzIbotWmbcdCsQ6ROGs9R+bsGWwmSdN6l6km1QV5esQehqg1UYHGD9q0VJsg4rJg/zmKVBYo0oBquSHPZw==}
engines: {node: '>=16.7'} engines: {node: '>=16.7'}
hasBin: true hasBin: true
peerDependencies: peerDependencies:
svelte: ^3.44.0 svelte: ^3.44.0
dependencies: dependencies:
'@sveltejs/vite-plugin-svelte': 1.0.0-next.44_svelte@3.48.0+vite@2.9.9 '@sveltejs/vite-plugin-svelte': 1.0.0-next.47_svelte@3.48.0+vite@2.9.9
chokidar: 3.5.3 chokidar: 3.5.3
sade: 1.8.1 sade: 1.8.1
svelte: 3.48.0 svelte: 3.48.0
@ -778,8 +780,8 @@ packages:
- supports-color - supports-color
dev: true dev: true
/@sveltejs/vite-plugin-svelte/1.0.0-next.44_svelte@3.48.0+vite@2.9.9: /@sveltejs/vite-plugin-svelte/1.0.0-next.47_svelte@3.48.0+vite@2.9.9:
resolution: {integrity: sha512-n+sssEWbzykPS447FmnNyU5GxEhrBPDVd0lxNZnxRGz9P6651LjjwAnISKr3CKgT9v8IybP8VD0n2i5XzbqExg==} resolution: {integrity: sha512-J6n8UN51aq/TEZGQ89/EtdXTtca3cRcTJGzi6fi+xK8LkgsHQLCZhRj+PJ+swktRSWTX9IOmQS55SqVg6bz5fA==}
engines: {node: ^14.13.1 || >= 16} engines: {node: ^14.13.1 || >= 16}
peerDependencies: peerDependencies:
diff-match-patch: ^1.0.5 diff-match-patch: ^1.0.5
@ -795,7 +797,7 @@ packages:
kleur: 4.1.4 kleur: 4.1.4
magic-string: 0.26.2 magic-string: 0.26.2
svelte: 3.48.0 svelte: 3.48.0
svelte-hmr: 0.14.11_svelte@3.48.0 svelte-hmr: 0.14.12_svelte@3.48.0
vite: 2.9.9 vite: 2.9.9
transitivePeerDependencies: transitivePeerDependencies:
- supports-color - supports-color
@ -3986,6 +3988,16 @@ packages:
engines: {node: '>=4'} engines: {node: '>=4'}
dev: true dev: true
/prettier-plugin-svelte/2.7.0_kkjbqzpydplecjtkxrgomroeru:
resolution: {integrity: sha512-fQhhZICprZot2IqEyoiUYLTRdumULGRvw0o4dzl5jt0jfzVWdGqeYW27QTWAeXhoupEZJULmNoH3ueJwUWFLIA==}
peerDependencies:
prettier: ^1.16.4 || ^2.0.0
svelte: ^3.2.0
dependencies:
prettier: 2.6.2
svelte: 3.48.0
dev: true
/prettier/2.6.2: /prettier/2.6.2:
resolution: {integrity: sha512-PkUpF+qoXTqhOeWL9fu7As8LXsIUZ1WYaJiY/a7McAQzxjk82OF0tibkFXVCDImZtWxbvojFjerkiLb0/q8mew==} resolution: {integrity: sha512-PkUpF+qoXTqhOeWL9fu7As8LXsIUZ1WYaJiY/a7McAQzxjk82OF0tibkFXVCDImZtWxbvojFjerkiLb0/q8mew==}
engines: {node: '>=10.13.0'} engines: {node: '>=10.13.0'}
@ -4519,8 +4531,8 @@ packages:
- sugarss - sugarss
dev: true dev: true
/svelte-hmr/0.14.11_svelte@3.48.0: /svelte-hmr/0.14.12_svelte@3.48.0:
resolution: {integrity: sha512-R9CVfX6DXxW1Kn45Jtmx+yUe+sPhrbYSUp7TkzbW0jI5fVPn6lsNG9NEs5dFg5qRhFNAoVdRw5qQDLALNKhwbQ==} resolution: {integrity: sha512-4QSW/VvXuqVcFZ+RhxiR8/newmwOCTlbYIezvkeN6302YFRE8cXy0naamHcjz8Y9Ce3ITTZtrHrIL0AGfyo61w==}
engines: {node: ^12.20 || ^14.13.1 || >= 16} engines: {node: ^12.20 || ^14.13.1 || >= 16}
peerDependencies: peerDependencies:
svelte: '>=3.19.0' svelte: '>=3.19.0'

View File

@ -1,12 +1,12 @@
<script lang="ts"> <script lang="ts">
import { Button } from 'omorphia'; import { Button } from 'omorphia'
import IconMoon from 'virtual:icons/heroicons-outline/moon'; import IconMoon from 'virtual:icons/heroicons-outline/moon'
import IconSun from 'virtual:icons/heroicons-outline/sun'; import IconSun from 'virtual:icons/heroicons-outline/sun'
export let meta: { raised: boolean }; export let meta: { raised: boolean }
let theme = 'light'; let theme = 'light'
let background = meta.raised ? 'var(--color-raised-bg)' : 'var(--color-bg)'; let background = meta.raised ? 'var(--color-raised-bg)' : 'var(--color-bg)'
</script> </script>
<div class="example"> <div class="example">
@ -17,8 +17,7 @@
<div class="example__source__options"> <div class="example__source__options">
<Button <Button
color="primary-light" color="primary-light"
on:click={() => (theme === 'light' ? (theme = 'dark') : (theme = 'light'))} on:click={() => (theme === 'light' ? (theme = 'dark') : (theme = 'light'))}>
>
{#if theme === 'light'} {#if theme === 'light'}
<IconMoon /> <IconMoon />
{:else} {:else}

View File

@ -1,23 +1,23 @@
<script lang="ts"> <script lang="ts">
import OmorphiaLogo from '../assets/omorphia.svg'; import OmorphiaLogo from '../assets/omorphia.svg'
import IconLogoGithub from 'virtual:icons/carbon/logo-github'; import IconLogoGithub from 'virtual:icons/carbon/logo-github'
import IconChat from 'virtual:icons/heroicons-outline/chat-alt-2'; import IconChat from 'virtual:icons/heroicons-outline/chat-alt-2'
import { onMount } from 'svelte'; import { onMount } from 'svelte'
let headerElement; let headerElement
onMount(() => { onMount(() => {
let lastScrollTop: number; let lastScrollTop: number
window.addEventListener('scroll', () => { window.addEventListener('scroll', () => {
let scrollTop = window.pageYOffset || document.documentElement.scrollTop; let scrollTop = window.pageYOffset || document.documentElement.scrollTop
if (scrollTop > lastScrollTop && headerElement) { if (scrollTop > lastScrollTop && headerElement) {
headerElement.style.top = '-100%'; headerElement.style.top = '-100%'
} else if (headerElement) { } else if (headerElement) {
headerElement.style.top = '0'; headerElement.style.top = '0'
} }
lastScrollTop = scrollTop; lastScrollTop = scrollTop
}); })
}); })
</script> </script>
<header class="header" bind:this={headerElement}> <header class="header" bind:this={headerElement}>
@ -50,8 +50,7 @@
top: 0; top: 0;
z-index: 10; z-index: 10;
background-color: hsl(0, 0%, 100%); background-color: hsl(0, 0%, 100%);
box-shadow: hsla(221, 39%, 11%, 0.2) 0 2px 4px 0, box-shadow: hsla(221, 39%, 11%, 0.2) 0 2px 4px 0, hsla(221, 39%, 11%, 0.05) 0 -2px 2px 0 inset;
hsla(221, 39%, 11%, 0.05) 0 -2px 2px 0 inset;
transition: top 0.3s ease-in-out; transition: top 0.3s ease-in-out;
@media not (--sm) { @media not (--sm) {

View File

@ -1,20 +1,20 @@
<script lang="ts"> <script lang="ts">
import { page } from '$app/stores'; import { page } from '$app/stores'
import IconMenu from 'virtual:icons/lucide/menu'; import IconMenu from 'virtual:icons/lucide/menu'
const components = Object.keys(import.meta.glob('../../routes/components/**')) const components = Object.keys(import.meta.glob('../../routes/components/**'))
.map((it) => it.replace('../../routes/components/', '').replace('.md', '')) .map((it) => it.replace('../../routes/components/', '').replace('.md', ''))
.sort(); .sort()
const classes = Object.keys(import.meta.glob('../../routes/classes/**')) const classes = Object.keys(import.meta.glob('../../routes/classes/**'))
.map((it) => it.replace('../../routes/classes/', '').replace('.md', '')) .map((it) => it.replace('../../routes/classes/', '').replace('.md', ''))
.sort(); .sort()
let slideIn = false; let slideIn = false
$: if ($page.url.pathname) { $: if ($page.url.pathname) {
slideIn = false; slideIn = false
} }
</script> </script>
@ -76,12 +76,7 @@
} }
&__content { &__content {
mask-image: linear-gradient( mask-image: linear-gradient(to bottom, transparent, hsla(0, 0%, 0%, 1) 5% 95%, transparent);
to bottom,
transparent,
hsla(0, 0%, 0%, 1) 5% 95%,
transparent
);
padding: 88px 32px 32px; padding: 88px 32px 32px;
height: 100vh; height: 100vh;
max-height: 100vh; max-height: 100vh;

View File

@ -1,28 +1,28 @@
<script lang="ts"> <script lang="ts">
import IconPencil from 'virtual:icons/heroicons-outline/pencil'; import IconPencil from 'virtual:icons/heroicons-outline/pencil'
import { page } from '$app/stores'; import { page } from '$app/stores'
import COMPONENT_API from '../../generated/COMPONENT_API.json'; import COMPONENT_API from '../../generated/COMPONENT_API.json'
export let fileName = $page.url.pathname export let fileName = $page.url.pathname
.substring($page.url.pathname.lastIndexOf('/') + 1) .substring($page.url.pathname.lastIndexOf('/') + 1)
.replace('.html', ''); .replace('.html', '')
export let title = fileName; export let title = fileName
export let description = 'Learn about Omorphia, the component & style library'; export let description = 'Learn about Omorphia, the component & style library'
let editUrl = `https://github.com/modrinth/omorphia/edit/main/src/routes/${ let editUrl = `https://github.com/modrinth/omorphia/edit/main/src/routes/${
$page.url.pathname.replace('/', '') || 'index' $page.url.pathname.replace('/', '') || 'index'
}.md`; }.md`
let api; let api
if ($page.url.pathname.includes('components')) { if ($page.url.pathname.includes('components')) {
if (import.meta.env.DEV) { if (import.meta.env.DEV) {
import(`../../../package/components/${title}.svelte?raw&sveld`).then( import(`../../../package/components/${title}.svelte?raw&sveld`).then(
(output) => (api = output.default) (output) => (api = output.default)
); )
} else { } else {
api = COMPONENT_API[`${title}.svelte`]; api = COMPONENT_API[`${title}.svelte`]
} }
} }
</script> </script>
@ -35,8 +35,7 @@
{#if title}<h1>{title}</h1>{/if} {#if title}<h1>{title}</h1>{/if}
<a class="edit-link" href={editUrl}> <a class="edit-link" href={editUrl}>
<IconPencil /> <IconPencil />
Edit this page on GitHub</a Edit this page on GitHub</a>
>
<slot /> <slot />
{#if api} {#if api}
@ -59,11 +58,8 @@
<td><code>{prop.type ?? ''}</code></td> <td><code>{prop.type ?? ''}</code></td>
<td><code>{prop.value ?? ''}</code></td> <td><code>{prop.value ?? ''}</code></td>
<td <td
>{prop.constant ? '[Read only] ' : ''}{prop.description?.replace( >{prop.constant ? '[Read only] ' : ''}{prop.description?.replace('null', '') ||
'null', ''}</td>
''
) || ''}</td
>
</tr> </tr>
{/each} {/each}
</tbody> </tbody>

View File

@ -1,40 +1,40 @@
<script lang="ts"> <script lang="ts">
// TODO: Make square icon `md` more rounded // TODO: Make square icon `md` more rounded
import { onMount } from 'svelte'; import { onMount } from 'svelte'
import { classCombine } from '../utils/classCombine'; import { classCombine } from '../utils/classCombine'
/** Optional, as a default icon will be substituted if no image was specified */ /** Optional, as a default icon will be substituted if no image was specified */
export let src: string | undefined; export let src: string | undefined
export let size: 'xs' | 'sm' | 'md' | 'lg'; export let size: 'xs' | 'sm' | 'md' | 'lg'
export let circle = false; export let circle = false
export let floatUp = false; export let floatUp = false
let className: string; let className: string
$: className = classCombine([ $: className = classCombine([
'avatar', 'avatar',
circle && 'avatar--circle', circle && 'avatar--circle',
`avatar--size-${size}`, `avatar--size-${size}`,
floatUp && 'avatar--float-up', floatUp && 'avatar--float-up',
]); ])
let img; let img
onMount(() => { onMount(() => {
if (img && img.naturalWidth) { if (img && img.naturalWidth) {
const isPixelated = () => { const isPixelated = () => {
if (img.naturalWidth < 96 && img.naturalWidth > 0) { if (img.naturalWidth < 96 && img.naturalWidth > 0) {
img.style = 'image-rendering: pixelated;'; img.style = 'image-rendering: pixelated;'
}
} }
};
if (img.naturalWidth) { if (img.naturalWidth) {
isPixelated(); isPixelated()
} else { } else {
img.onload = isPixelated; img.onload = isPixelated
} }
} }
}); })
</script> </script>
{#if src} {#if src}
@ -48,15 +48,13 @@
stroke-linejoin="round" stroke-linejoin="round"
stroke-miterlimit="1.5" stroke-miterlimit="1.5"
clip-rule="evenodd" clip-rule="evenodd"
viewBox="0 0 104 104" viewBox="0 0 104 104">
>
<path fill="none" d="M0 0h103.4v103.4H0z" /> <path fill="none" d="M0 0h103.4v103.4H0z" />
<path <path
fill="none" fill="none"
stroke="#9a9a9a" stroke="#9a9a9a"
stroke-width="5" stroke-width="5"
d="M51.7 92.5V51.7L16.4 31.3l35.3 20.4L87 31.3 51.7 11 16.4 31.3v40.8l35.3 20.4L87 72V31.3L51.7 11" d="M51.7 92.5V51.7L16.4 31.3l35.3 20.4L87 31.3 51.7 11 16.4 31.3v40.8l35.3 20.4L87 72V31.3L51.7 11" />
/>
</svg> </svg>
{/if} {/if}

View File

@ -1,19 +1,18 @@
<script lang="ts"> <script lang="ts">
// TODO: sizes // TODO: sizes
// TODO: icon only buttons should have uniform padding // TODO: icon only buttons should have uniform padding
// TODO: Could be a class
import { classCombine } from '../utils/classCombine'; import { classCombine } from '../utils/classCombine'
/** The element to be styled as a button */ /** The element to be styled as a button */
export let as: 'button' | 'a' | 'summary' | 'input' = 'button'; export let as: 'button' | 'a' | 'summary' | 'input' = 'button'
export let href = ''; export let href = ''
if (href) as = 'a'; if (href) as = 'a'
/** Use `value` if the button is an `<input`> */ /** Use `value` if the button is an `<input`> */
export let value = ''; export let value = ''
export let size: 'sm' | 'md' | 'lg' = 'md'; export let size: 'sm' | 'md' | 'lg' = 'md'
export let color: export let color:
| '' | ''
| 'raised' | 'raised'
@ -23,26 +22,26 @@
| 'tertiary' | 'tertiary'
| 'danger' | 'danger'
| 'danger-light' | 'danger-light'
| 'transparent' = ''; | 'transparent' = ''
/** Show notification badge in the upper right of button */ /** Show notification badge in the upper right of button */
export let badge = false; export let badge = false
export let disabled = false; export let disabled = false
/** Hover title for accessibility */ /** Hover title for accessibility */
export let title = ''; export let title = ''
/** Link target */ /** Link target */
export let target = ''; export let target = ''
let className: string; let className: string
$: className = classCombine([ $: className = classCombine([
'button', 'button',
`button--size-${size}`, `button--size-${size}`,
`button--color-${color}`, `button--color-${color}`,
badge && 'has-badge', badge && 'has-badge',
]); ])
</script> </script>
{#if as === 'a'} {#if as === 'a'}
@ -74,10 +73,10 @@
background-color: var(--color-button-bg); background-color: var(--color-button-bg);
border-radius: var(--rounded); border-radius: var(--rounded);
transition: opacity 0.5s ease-in-out, filter 0.05s ease-in-out; transition: opacity 0.5s ease-in-out, filter 0.2s ease-in-out;
&:hover { &:hover {
filter: brightness(0.9); filter: brightness(0.85);
} }
&--color { &--color {

View File

@ -2,18 +2,18 @@
import { uniqueId } from '../utils/uniqueId' import { uniqueId } from '../utils/uniqueId'
import IconCheck from 'virtual:icons/heroicons-outline/check' import IconCheck from 'virtual:icons/heroicons-outline/check'
export let checked = false; export let checked = false
const id = `checkbox-${uniqueId()}` const id = `checkbox-${uniqueId()}`
</script> </script>
<div class="checkbox"> <div class="checkbox">
<input type="checkbox" bind:checked={checked} on:change id={id} name={id}> <input type="checkbox" bind:checked on:change {id} name={id} />
<label for={id} class="checkbox__label"> <label for={id} class="checkbox__label">
<span class="checkbox__label__box"> <span class="checkbox__label__box">
<IconCheck /> <IconCheck />
</span> </span>
<slot/> <slot />
</label> </label>
</div> </div>
@ -50,12 +50,12 @@
display: none; display: none;
width: 1rem; width: 1rem;
height: 1rem; height: 1rem;
color: var(--color-raised-bg) color: var(--color-raised-bg);
} }
} }
} }
[type=checkbox]:checked + label span { [type='checkbox']:checked + label span {
background-color: var(--color-brand); background-color: var(--color-brand);
:global(.icon) { :global(.icon) {

View File

@ -1,21 +1,21 @@
<script lang="ts"> <script lang="ts">
import Checkbox from './Checkbox.svelte'; import Checkbox from './Checkbox.svelte'
import type { Option } from './types'; import type { Option } from './types'
export let value = []; export let value = []
export let options: Option[] = []; export let options: Option[] = []
/** Wrap the options horizontally */ /** Wrap the options horizontally */
export let wrap = false; export let wrap = false
const handleChange = (e, key) => { const handleChange = (e, key) => {
if (e.target.checked) { if (e.target.checked) {
if (!value) value = []; if (!value) value = []
value = [key, ...value]; value = [key, ...value]
} else { } else {
value = value.filter((it) => key !== it); value = value.filter((it) => key !== it)
}
} }
};
</script> </script>
<div class="checkbox-list" class:wrap> <div class="checkbox-list" class:wrap>

View File

@ -1,24 +1,24 @@
<script lang="ts"> <script lang="ts">
// TODO: Add fade out styling on top and bottom // TODO: Add fade out styling on top and bottom
import Checkbox from './Checkbox.svelte'; import Checkbox from './Checkbox.svelte'
import VirtualList from 'svelte-tiny-virtual-list'; import VirtualList from 'svelte-tiny-virtual-list'
import type { Option } from './types'; import type { Option } from './types'
/** Height in pixels of list */ /** Height in pixels of list */
export let height = 200; export let height = 200
export let value = []; export let value = []
export let options: Option[] = []; export let options: Option[] = []
const handleChange = (e, key) => { const handleChange = (e, key) => {
if (e.target.checked) { if (e.target.checked) {
if (!value) value = []; if (!value) value = []
value = [key, ...value]; value = [key, ...value]
} else { } else {
value = value.filter((it) => key !== it); value = value.filter((it) => key !== it)
}
} }
};
</script> </script>
<VirtualList width="100%" {height} itemCount={options.length} itemSize={26}> <VirtualList width="100%" {height} itemCount={options.length} itemSize={26}>
@ -27,13 +27,11 @@
let:index let:index
let:style let:style
{style} {style}
style:padding-bottom={options.length - 1 === index ? '2.5rem' : ''} style:padding-bottom={options.length - 1 === index ? '2.5rem' : ''}>
>
{@const option = options[index]} {@const option = options[index]}
<Checkbox <Checkbox
checked={value && value.includes(option.value)} checked={value && value.includes(option.value)}
on:change={(e) => handleChange(e, option.value)} on:change={(e) => handleChange(e, option.value)}>
>
{#if option.icon && typeof option.icon === 'string'} {#if option.icon && typeof option.icon === 'string'}
{@html option.icon} {@html option.icon}
{:else if option.icon} {:else if option.icon}

View File

@ -1,21 +1,21 @@
<script lang="ts"> <script lang="ts">
import Button from "./Button.svelte"; import Button from './Button.svelte'
import IconCheck from 'virtual:icons/heroicons-outline/check' import IconCheck from 'virtual:icons/heroicons-outline/check'
interface Option { interface Option {
label: string; label: string
value: string | number; value: string | number
} }
export let options: Option[] = []; export let options: Option[] = []
export let value: string | number; export let value: string | number
// If set to true, one chip is always selected // If set to true, one chip is always selected
export let neverEmpty = false; export let neverEmpty = false
let selected: Option | null = options.find((option) => option.value === (value || '')); let selected: Option | null = options.find((option) => option.value === (value || ''))
$: if (selected) { $: if (selected) {
value = selected.value; value = selected.value
} else { } else {
value = '' value = ''
} }
@ -27,11 +27,8 @@
<Button <Button
color={isSelected ? 'primary-light' : undefined} color={isSelected ? 'primary-light' : undefined}
on:click={() => { on:click={() => {
isSelected && !neverEmpty isSelected && !neverEmpty ? (selected = null) : (selected = option)
? selected = null }}>
: selected = option
}}
>
{#if isSelected} {#if isSelected}
<IconCheck /> <IconCheck />
{/if} {/if}

View File

@ -1,8 +1,8 @@
<script lang="ts"> <script lang="ts">
import { uniqueId } from '../utils/uniqueId' import { uniqueId } from '../utils/uniqueId'
export let required = false; export let required = false
export let label: string; export let label: string
const id = `form-field-${uniqueId()}` const id = `form-field-${uniqueId()}`
</script> </script>
@ -14,7 +14,6 @@
<slot {id} /> <slot {id} />
</div> </div>
<style lang="postcss"> <style lang="postcss">
.form-field { .form-field {
display: flex; display: flex;

View File

@ -1,29 +1,29 @@
<script lang="ts"> <script lang="ts">
import { page } from '$app/stores'; import { page } from '$app/stores'
interface Link { interface Link {
href: string; href: string
label: string; label: string
} }
export let links: Link[]; export let links: Link[]
export let query = ''; export let query = ''
export let resetScroll = false; export let resetScroll = false
/** Path level in URL, zero-indexed */ /** Path level in URL, zero-indexed */
export let level = 0; export let level = 0
let path: string[]; let path: string[]
$: path = [ $: path = [
...$page.url.pathname ...$page.url.pathname
.substring(1) .substring(1)
.split('/') .split('/')
.map((route) => '/' + route), .map((route) => '/' + route),
'/', '/',
]; ]
$: basePath = path.slice(0, level).join(''); $: basePath = path.slice(0, level).join('')
</script> </script>
<nav class="navigation"> <nav class="navigation">
@ -37,14 +37,13 @@
? link.href ? link.href
: basePath + link.href} : basePath + link.href}
on:click={() => { on:click={() => {
if (resetScroll) document.body.scrollTo(0, 0); if (resetScroll) document.body.scrollTo(0, 0)
}} }}
class="navigation__link" class="navigation__link"
class:is-active={query class:is-active={query
? ($page.url.searchParams.get(query) || '') === link.href ? ($page.url.searchParams.get(query) || '') === link.href
: path[level] === link.href || path[level] === link.href.slice(0, -1)} : path[level] === link.href || path[level] === link.href.slice(0, -1)}
sveltekit:noscroll={!resetScroll}>{link.label}</a sveltekit:noscroll={!resetScroll}>{link.label}</a>
>
{/each} {/each}
</nav> </nav>

View File

@ -1,14 +1,14 @@
<script lang="ts"> <script lang="ts">
// TODO: Fix mobile support, currently just cuts off buttons // TODO: Fix mobile support, currently just cuts off buttons
import IconArrowRight from 'virtual:icons/heroicons-outline/arrow-right'; import IconArrowRight from 'virtual:icons/heroicons-outline/arrow-right'
import IconArrowLeft from 'virtual:icons/heroicons-outline/arrow-left'; import IconArrowLeft from 'virtual:icons/heroicons-outline/arrow-left'
import IconMinus from 'virtual:icons/heroicons-outline/minus'; import IconMinus from 'virtual:icons/heroicons-outline/minus'
import Button from './Button.svelte'; import Button from './Button.svelte'
import { createEventDispatcher } from 'svelte'; import { createEventDispatcher } from 'svelte'
export let page: number; export let page: number
export let count: number; export let count: number
$: options = $: options =
count > 4 count > 4
@ -17,9 +17,9 @@
: page > 4 : page > 4
? [1, '-', page - 1, page, page + 1, '-', count] ? [1, '-', page - 1, page, page + 1, '-', count]
: [1, 2, 3, 4, 5, '-', count] : [1, 2, 3, 4, 5, '-', count]
: Array.from({ length: count }, (_, i) => i + 1); : Array.from({ length: count }, (_, i) => i + 1)
const dispatch = createEventDispatcher(); const dispatch = createEventDispatcher()
</script> </script>
{#if count > 1} {#if count > 1}
@ -37,16 +37,14 @@
{:else} {:else}
<Button <Button
color={option === page ? 'primary' : 'raised'} color={option === page ? 'primary' : 'raised'}
on:click={() => dispatch('change', option)}>{option}</Button on:click={() => dispatch('change', option)}>{option}</Button>
>
{/if} {/if}
{/each} {/each}
<Button <Button
color="raised" color="raised"
on:click={() => dispatch('change', page + 1)} on:click={() => dispatch('change', page + 1)}
disabled={page >= count} disabled={page >= count}
title="Next page" title="Next page">
>
<IconArrowRight height="20px" /> <IconArrowRight height="20px" />
</Button> </Button>
</div> </div>

View File

@ -5,8 +5,8 @@
import { onMount } from 'svelte' import { onMount } from 'svelte'
interface Option { interface Option {
label: string; label: string
value: string | number; value: string | number
} }
export let options: Option[] = [] export let options: Option[] = []
@ -22,10 +22,28 @@
value = selected.value value = selected.value
} }
const minWidth = options // Returns the width of a string based on the font size and family
.map(it => it.label || it.value) const getTextWidth = Object.assign(
.reduce((it, acc) => String(it).length > acc ? it : acc, '') (text: string, font: string) => {
.length * 9 if (typeof document !== 'undefined') {
const canvas =
getTextWidth.canvas || (getTextWidth.canvas = document.createElement('canvas'))
const context = canvas.getContext('2d')
context.font = font
const metrics = context.measureText(text)
return metrics.width
} else {
// Return estimate if SSR
return text.length * 7.75
}
},
// Reuses the same canvas object
{ canvas: null }
)
const minWidth = Math.max(
...options.map((it) => getTextWidth(String(it.label || it.value), '16px Inter'))
)
let shouldOpenUp = false let shouldOpenUp = false
let element: HTMLElement let element: HTMLElement
@ -73,26 +91,25 @@
class:is-open={open} class:is-open={open}
class:select--opens-up={shouldOpenUp} class:select--opens-up={shouldOpenUp}
use:clickOutside={() => { use:clickOutside={() => {
open = false; open = false
}} }}
bind:this={element} bind:this={element}
tabindex="0" tabindex="0"
on:keydown={keydown} on:keydown={keydown}>
>
<div <div
class="select__input" class="select__input"
on:click={() => { on:click={() => {
open = !open; open = !open
}} }}>
>
{#if icon} {#if icon}
<svelte:component this={icon}/> <svelte:component this={icon} />
{/if} {/if}
<span class="select__input__value" style:min-width="{minWidth}px">{label || selected?.label || value || 'Choose...'}</span> <span class="select__input__value" style:min-width="{minWidth}px"
>{label || selected?.label || value || 'Choose...'}</span>
{#if !icon} {#if !icon}
<div class="select__input__arrow"> <div class="select__input__arrow">
<slot name="expandIcon"> <slot name="expandIcon">
<IconChevronDown/> <IconChevronDown />
</slot> </slot>
</div> </div>
{/if} {/if}
@ -102,11 +119,10 @@
{#each options as option (option.value)} {#each options as option (option.value)}
<li <li
on:click={() => { on:click={() => {
selected = option; selected = option
open = false; open = false
}} }}
class:is-selected={selected?.value === option.value} class:is-selected={selected?.value === option.value}>
>
{option.label || option.value} {option.label || option.value}
</li> </li>
{/each} {/each}

View File

@ -1,8 +1,8 @@
<script lang="ts"> <script lang="ts">
export let value: number; export let value: number
export let min: number; export let min: number
export let max: number; export let max: number
export let id: string = undefined; export let id: string = undefined
</script> </script>
<div class="slider"> <div class="slider">

View File

@ -1,11 +1,11 @@
<script lang="ts"> <script lang="ts">
import type { SvelteComponent } from 'svelte'; import type { SvelteComponent } from 'svelte'
export let placeholder = ''; export let placeholder = ''
export let icon: SvelteComponent = undefined; export let icon: SvelteComponent = undefined
export let value = ''; export let value = ''
export let multiline = false; export let multiline = false
export let id: string = undefined; export let id: string = undefined
</script> </script>
<div class="text-input"> <div class="text-input">

View File

@ -43,7 +43,15 @@ export async function tags(API_URL) {
// Write JSON file // Write JSON file
await fs.writeFile( await fs.writeFile(
'./generated/tags.json', './generated/tags.json',
JSON.stringify({ categories, loaders, projectTypes, licenses, donationPlatforms, reportTypes, tagIcons }) JSON.stringify({
categories,
loaders,
projectTypes,
licenses,
donationPlatforms,
reportTypes,
tagIcons,
})
) )
progressBar.increment() progressBar.increment()

View File

@ -1,9 +1,9 @@
<script lang="ts"> <script lang="ts">
import '$package/styles.postcss'; import '$package/styles.postcss'
import '../docs/styles/prism-one-dark.css'; import '../docs/styles/prism-one-dark.css'
import '../docs/styles/gh-markdown.postcss'; import '../docs/styles/gh-markdown.postcss'
import Sidebar from '../docs/components/Sidebar.svelte'; import Sidebar from '../docs/components/Sidebar.svelte'
import Header from '../docs/components/Header.svelte'; import Header from '../docs/components/Header.svelte'
</script> </script>
<div class="app theme-light"> <div class="app theme-light">

View File

@ -6,9 +6,9 @@
</script> </script>
<div class="actions"> <div class="actions">
<Button><IconHeartSolid /> Unfollow </Button> <Button><IconHeartSolid /> Unfollow</Button>
<span class="stat"> <span class="stat">
<IconCalendar/> <IconCalendar />
Updated 12 days ago Updated 12 days ago
</span> </span>
</div> </div>

View File

@ -1,7 +1,5 @@
Base should be applied to a "root" element, like `<body>`, to provide base styles for common things like text. The theme mode, `light-theme`, `dark-theme`, or `oled-theme`, should also be added to this element. Base should be applied to a "root" element, like `<body>`, to provide base styles for common things like text. The theme mode, `light-theme`, `dark-theme`, or `oled-theme`, should also be added to this element.
```svelte example ```svelte example
<div class="base theme-light"> <div class="base theme-light">...</div>
...
</div>
``` ```

View File

@ -5,7 +5,9 @@
<h3>Moon/Distance to Earth</h3> <h3>Moon/Distance to Earth</h3>
<h2>238,900 mi</h2> <h2>238,900 mi</h2>
<p> <p>
The moon's distance from Earth affects the strength of ocean tides and the appearance of solar eclipses in our skies. The average distance between the blue planet and its only natural satellite is about 238,855 miles (384,400 kilometers), according to NASA. The moon's distance from Earth affects the strength of ocean tides and the appearance of solar
eclipses in our skies. The average distance between the blue planet and its only natural
satellite is about 238,855 miles (384,400 kilometers), according to NASA.
</p> </p>
</div> </div>
``` ```
@ -14,17 +16,17 @@
```svelte example ```svelte example
<script lang="ts"> <script lang="ts">
import { Button } from "omorphia"; import { Button } from 'omorphia'
import IconPencil from 'virtual:icons/heroicons-outline/pencil' import IconPencil from 'virtual:icons/heroicons-outline/pencil'
import { Avatar } from "omorphia"; import { Avatar } from 'omorphia'
</script> </script>
<div class="card"> <div class="card">
<div class="card__overlay"> <div class="card__overlay">
<Button color="raised"><IconPencil /> Edit</Button> <Button color="raised"><IconPencil /> Edit</Button>
</div> </div>
<div class="card__banner card__banner--short card__banner--dark" ></div> <div class="card__banner card__banner--short card__banner--dark" />
<Avatar size="md" floatUp/> <Avatar size="md" floatUp />
<h1 class="title">Project</h1> <h1 class="title">Project</h1>
<p class="summary">A project that has a description right here.</p> <p class="summary">A project that has a description right here.</p>
</div> </div>

View File

@ -1,10 +1,10 @@
```svelte example raised ```svelte example raised
<div class="info-table"> <div class="info-table">
<span class="info-table__label">License</span> <span class="info-table__label">License</span>
<a href="#mit" class="link">MIT</a> <a href="#mit" class="link">MIT</a>
<span class="info-table__label">Project ID</span> <span class="info-table__label">Project ID</span>
<span>11223344</span> <span>11223344</span>
<span class="info-table__label">Visibilty</span> <span class="info-table__label">Visibilty</span>
<span>Approved</span> <span>Approved</span>
</div> </div>
``` ```

View File

@ -1,10 +1,10 @@
```svelte example raised ```svelte example raised
<script lang="ts"> <script lang="ts">
import { Avatar } from "omorphia"; import { Avatar } from 'omorphia'
</script> </script>
<a class="member" href="#user"> <a class="member" href="#user">
<Avatar src="https://avatars1.githubusercontent.com/u/6166773" size="sm" circle/> <Avatar src="https://avatars1.githubusercontent.com/u/6166773" size="sm" circle />
<div class="member__info"> <div class="member__info">
<span class="member__info__link">Prospector</span> <span class="member__info__link">Prospector</span>
<span>Owner</span> <span>Owner</span>

View File

@ -6,7 +6,7 @@
</script> </script>
<div class="stat"> <div class="stat">
<IconStar/> <IconStar />
123K stars 123K stars
</div> </div>
``` ```
@ -21,11 +21,11 @@
<div class="stat-group"> <div class="stat-group">
<div class="stat"> <div class="stat">
<IconDownload/> <IconDownload />
4.1B downloads 4.1B downloads
</div> </div>
<div class="stat stat--light"> <div class="stat stat--light">
<IconHeart/> <IconHeart />
3 followers 3 followers
</div> </div>
</div> </div>

View File

@ -6,10 +6,10 @@
<div class="tag-group"> <div class="tag-group">
<div class="tag"> <div class="tag">
<IconCarrot/> Food <IconCarrot /> Food
</div> </div>
<div class="tag"> <div class="tag">
<IconGlobe/> World generation <IconGlobe /> World generation
</div> </div>
</div> </div>
``` ```

View File

@ -2,12 +2,14 @@ Avatars are used for project icons and user profile pictures. Low resolution ima
```svelte example raised ```svelte example raised
<script lang="ts"> <script lang="ts">
import { Avatar } from "omorphia"; import { Avatar } from 'omorphia'
</script> </script>
<Avatar size="lg" circle src="https://avatars3.githubusercontent.com/u/44736536?v=4" /> <Avatar size="lg" circle src="https://avatars3.githubusercontent.com/u/44736536?v=4" />
<Avatar size="md" src="https://cdn.modrinth.com/data/AANobbMI/icon.png" /> <Avatar size="md" src="https://cdn.modrinth.com/data/AANobbMI/icon.png" />
<Avatar size="md" src="https://staging-cdn.modrinth.com/data/d1SqMrzw/9a39b0c80a49976b0c04053682708374e18105fe.png" /> <Avatar
size="md"
src="https://staging-cdn.modrinth.com/data/d1SqMrzw/9a39b0c80a49976b0c04053682708374e18105fe.png" />
<Avatar size="sm" /> <Avatar size="sm" />
<Avatar size="xs" circle src="https://avatars1.githubusercontent.com/u/6166773?v=4" /> <Avatar size="xs" circle src="https://avatars1.githubusercontent.com/u/6166773?v=4" />
``` ```

View File

@ -1,6 +1,6 @@
```svelte example raised ```svelte example raised
<script lang="ts"> <script lang="ts">
import { Badge } from "omorphia"; import { Badge } from 'omorphia'
</script> </script>
<Badge color="red" label="Tomato" /> <Badge color="red" label="Tomato" />

View File

@ -2,7 +2,7 @@
```svelte example ```svelte example
<script lang="ts"> <script lang="ts">
import { Button } from "omorphia"; import { Button } from 'omorphia'
import IconDownload from 'virtual:icons/heroicons-outline/download' import IconDownload from 'virtual:icons/heroicons-outline/download'
</script> </script>
@ -13,7 +13,7 @@
```svelte example raised ```svelte example raised
<script lang="ts"> <script lang="ts">
import { Button } from "omorphia"; import { Button } from 'omorphia'
import IconDownload from 'virtual:icons/heroicons-outline/download' import IconDownload from 'virtual:icons/heroicons-outline/download'
</script> </script>
@ -35,13 +35,13 @@
```svelte example raised ```svelte example raised
<script lang="ts"> <script lang="ts">
import { Button } from "omorphia"; import { Button } from 'omorphia'
import IconDownload from 'virtual:icons/heroicons-outline/download' import IconDownload from 'virtual:icons/heroicons-outline/download'
import IconHeart from 'virtual:icons/heroicons-outline/heart' import IconHeart from 'virtual:icons/heroicons-outline/heart'
</script> </script>
<div class="button-group"> <div class="button-group">
<Button color="primary"><IconDownload /></Button> <Button color="primary"><IconDownload /></Button>
<Button><IconHeart /> Follow mod </Button> <Button><IconHeart /> Follow mod</Button>
</div> </div>
``` ```

View File

@ -2,7 +2,7 @@
```svelte example raised ```svelte example raised
<script lang="ts"> <script lang="ts">
import { Checkbox } from "omorphia"; import { Checkbox } from 'omorphia'
</script> </script>
<Checkbox>Extra components</Checkbox> <Checkbox>Extra components</Checkbox>
@ -12,9 +12,9 @@
```svelte example raised ```svelte example raised
<script lang="ts"> <script lang="ts">
import { Checkbox } from "omorphia"; import { Checkbox } from 'omorphia'
import IconCarrot from 'virtual:icons/lucide/carrot' import IconCarrot from 'virtual:icons/lucide/carrot'
</script> </script>
<Checkbox><IconCarrot /> Food </Checkbox> <Checkbox><IconCarrot /> Food</Checkbox>
``` ```

View File

@ -1,6 +1,6 @@
```svelte example raised ```svelte example raised
<script lang="ts"> <script lang="ts">
import { CheckboxList } from "omorphia"; import { CheckboxList } from 'omorphia'
import IconSquare from 'virtual:icons/lucide/square' import IconSquare from 'virtual:icons/lucide/square'
import IconCircle from 'virtual:icons/lucide/circle' import IconCircle from 'virtual:icons/lucide/circle'
import IconTriangle from 'virtual:icons/lucide/triangle' import IconTriangle from 'virtual:icons/lucide/triangle'
@ -30,8 +30,7 @@
label: 'Blank', label: 'Blank',
value: 'BLA', value: 'BLA',
}, },
]} ]} />
/>
Selected: {selected} Selected: {selected}
``` ```

View File

@ -1,11 +1,12 @@
```svelte example raised ```svelte example raised
<script lang="ts"> <script lang="ts">
import { CheckboxVirtualList } from "omorphia"; import { CheckboxVirtualList } from 'omorphia'
import IconStar from 'virtual:icons/heroicons-outline/star' import IconStar from 'virtual:icons/heroicons-outline/star'
import { uniqueId } from 'omorphia/utils/uniqueId' import { uniqueId } from 'omorphia/utils/uniqueId'
let options = Array(100).fill({}) let options = Array(100)
.map(option => ({ .fill({})
.map((option) => ({
label: 'Star-' + uniqueId(), label: 'Star-' + uniqueId(),
icon: IconStar, icon: IconStar,
value: uniqueId(), value: uniqueId(),
@ -14,10 +15,7 @@
let selected = ['2', '6'] let selected = ['2', '6']
</script> </script>
<CheckboxVirtualList <CheckboxVirtualList bind:value={selected} {options} />
bind:value={selected}
{options}
/>
Selected: {selected} Selected: {selected}
``` ```

View File

@ -2,42 +2,46 @@
```svelte example raised ```svelte example raised
<script lang="ts"> <script lang="ts">
import { Chips } from "omorphia"; import { Chips } from 'omorphia'
</script> </script>
<Chips options={[ <Chips
options={[
{ {
label: 'One', label: 'One',
value: 'one' value: 'one',
}, },
{ {
label: 'Two', label: 'Two',
value: 'two' value: 'two',
}]} },
/> ]} />
``` ```
### Force an option to be selected with `neverEmpty` ### Force an option to be selected with `neverEmpty`
```svelte example raised ```svelte example raised
<script lang="ts"> <script lang="ts">
import { Chips } from "omorphia"; import { Chips } from 'omorphia'
let foo = 'modpack' let foo = 'modpack'
</script> </script>
<Chips neverEmpty bind:value={foo} options={[ <Chips
neverEmpty
bind:value={foo}
options={[
{ {
label: 'Mod', label: 'Mod',
value: 'mod' value: 'mod',
}, },
{ {
label: 'Modpack', label: 'Modpack',
value: 'modpack' value: 'modpack',
}, },
{ {
label: 'World', label: 'World',
value: 'world' value: 'world',
}]} },
/> ]} />
``` ```

View File

@ -1,12 +1,12 @@
```svelte example raised ```svelte example raised
<script lang="ts"> <script lang="ts">
import { FormField } from "omorphia"; import { FormField } from 'omorphia'
import { Slider } from "omorphia"; import { Slider } from 'omorphia'
import { TextInput } from "omorphia"; import { TextInput } from 'omorphia'
</script> </script>
<FormField label="Favorite number"> <FormField label="Favorite number">
<Slider min=0 max=100 value=69 /> <Slider min="0" max="100" value="69" />
</FormField> </FormField>
<FormField label="Favorite color"> <FormField label="Favorite color">
<TextInput placeholder="Enter another color..." /> <TextInput placeholder="Enter another color..." />

View File

@ -2,7 +2,7 @@
```svelte example raised ```svelte example raised
<script lang="ts"> <script lang="ts">
import { NavRow } from "omorphia"; import { NavRow } from 'omorphia'
</script> </script>
<NavRow <NavRow
@ -10,16 +10,16 @@
links={[ links={[
{ {
href: '/Button', href: '/Button',
label: 'Button' label: 'Button',
}, },
{ {
href: '/Chips', href: '/Chips',
label: 'Chips' label: 'Chips',
}, },
{ {
href: '/NavRow', href: '/NavRow',
label: 'NavRow' label: 'NavRow',
} },
]}> ]}>
Click for fun Click for fun
</NavRow> </NavRow>

View File

@ -2,7 +2,7 @@ Use pagination to show a set of page numbers and navigation directions to move t
```svelte example ```svelte example
<script lang="ts"> <script lang="ts">
import { Pagination } from "omorphia" import { Pagination } from 'omorphia'
</script> </script>
<Pagination page={20} count={50} /> <Pagination page={20} count={50} />

View File

@ -1,19 +1,17 @@
```svelte example raised ```svelte example raised
<script lang="ts"> <script lang="ts">
import { Select } from "omorphia"; import { Select } from 'omorphia'
let sortMethod = "downloads" let sortMethod = 'downloads'
</script> </script>
<Select <Select
color="raised"
options={[ options={[
{ value: "", label: "Relevance" }, { value: '', label: 'Relevance' },
{ value: "downloads", label: "Downloads" }, { value: 'downloads', label: 'Downloads' },
{ value: "follows", label: "Followers" }, { value: 'follows', label: 'Followers' },
{ value: "newest", label: "Recently created" }, { value: 'newest', label: 'Recently' },
{ value: "updated", label: "Recently updated" }, { value: 'updated', label: 'Recently updated really fast whoot' },
]} ]}
bind:value={sortMethod} bind:value={sortMethod} />
/>
``` ```

View File

@ -1,7 +1,7 @@
```svelte example raised ```svelte example raised
<script lang="ts"> <script lang="ts">
import { Slider } from "omorphia"; import { Slider } from 'omorphia'
</script> </script>
<Slider min=0 max=10 value=4 /> <Slider min="0" max="10" value="4" />
``` ```

View File

@ -1,6 +1,6 @@
```svelte example raised ```svelte example raised
<script lang="ts"> <script lang="ts">
import { TextInput } from "omorphia"; import { TextInput } from 'omorphia'
import IconSearch from 'virtual:icons/heroicons-outline/search' import IconSearch from 'virtual:icons/heroicons-outline/search'
</script> </script>

View File

@ -23,5 +23,5 @@ Then use the icon as if it were a Svelte component:
import IconHeart from 'virtual:icons/heroicons-outline/heart' import IconHeart from 'virtual:icons/heroicons-outline/heart'
</script> </script>
<p> That's lovely <IconHeart height="14px" />! </p> <p>That's lovely <IconHeart height="14px" />!</p>
``` ```

View File

@ -14,9 +14,10 @@ The `markdown` parser is designed for bodies of markdown text and supports image
```svelte example ```svelte example
<script lang="ts"> <script lang="ts">
import { markdown } from "omorphia/utils" import { markdown } from 'omorphia/utils'
const source = '## Example markdown \n\ const source =
'## Example markdown \n\
This is **some** *text*! \n\ This is **some** *text*! \n\
#### An image \n\ #### An image \n\
<img src="https://cdn.modrinth.com/data/YL57xq9U/images/d382106b9a2b943d06107c31c139c77849f1a0e8.png" />' <img src="https://cdn.modrinth.com/data/YL57xq9U/images/d382106b9a2b943d06107c31c139c77849f1a0e8.png" />'
@ -33,9 +34,9 @@ The `markdownInline` parser is perfect for translations and short bios. It doesn
```svelte example raised ```svelte example raised
<script lang="ts"> <script lang="ts">
import { markdownInline } from "omorphia/utils" import { markdownInline } from 'omorphia/utils'
const source = "This is some **bolded** and *italicized* text." const source = 'This is some **bolded** and *italicized* text.'
</script> </script>
<p>{@html markdownInline(source)}</p> <p>{@html markdownInline(source)}</p>
@ -45,7 +46,7 @@ The `markdownInline` parser is perfect for translations and short bios. It doesn
```svelte example raised ```svelte example raised
<script lang="ts"> <script lang="ts">
import { ago } from 'omorphia/utils'; import { ago } from 'omorphia/utils'
</script> </script>
<p>Something happened {ago(Date.now())}.</p> <p>Something happened {ago(Date.now())}.</p>
@ -60,18 +61,18 @@ The `Permissions` class provides an easy way to manage user permissions.
```svelte example raised ```svelte example raised
<script lang="ts"> <script lang="ts">
import { Permissions } from 'omorphia/utils' import { Permissions } from 'omorphia/utils'
const permissions = new Permissions(128) // Can be integer or 'ALL' const permissions = new Permissions(128) // Can be integer or 'ALL'
</script> </script>
<p> <p>
<input type="checkbox" bind:checked={permissions.uploadVersions} id="ex-1"/> <input type="checkbox" bind:checked={permissions.uploadVersions} id="ex-1" />
<label for="ex-1">Can edit versions</label><br> <label for="ex-1">Can edit versions</label><br />
<input type="checkbox" bind:checked={permissions.deleteProject} id="ex-2"/> <input type="checkbox" bind:checked={permissions.deleteProject} id="ex-2" />
<label for="ex-2">Can delete project</label><br><br> <label for="ex-2">Can delete project</label><br /><br />
Integer: {permissions.toInteger()}<br> Integer: {permissions.toInteger()}<br />
Can access settings page: {permissions.settingsPage} Can access settings page: {permissions.settingsPage}
</p> </p>
``` ```
@ -82,8 +83,8 @@ The `formatVersions` function provides an easy way to parse a project's versions
```svelte example raised ```svelte example raised
<script lang="ts"> <script lang="ts">
import { formatVersions } from 'omorphia/utils'; import { formatVersions } from 'omorphia/utils'
</script> </script>
<p>{formatVersions(["1.18", "1.18.1", "1.18.2", "1.17.1"])}</p> <p>{formatVersions(['1.18', '1.18.1', '1.18.2', '1.17.1'])}</p>
``` ```

View File

@ -22,7 +22,7 @@ Use a component by importing from `omorphia`. For example, use the [Button compo
```svelte example raised ```svelte example raised
<script lang="ts"> <script lang="ts">
import { Button } from "omorphia" import { Button } from 'omorphia'
</script> </script>
<Button color="primary">I'm a button!</Button> <Button color="primary">I'm a button!</Button>