Run pnpm format

This commit is contained in:
venashial 2022-05-20 00:10:45 -07:00
parent 0f6263d82e
commit d37fd6bea0
58 changed files with 653 additions and 687 deletions

View File

@ -6,15 +6,15 @@ module.exports = {
ignorePatterns: ['*.cjs'], ignorePatterns: ['*.cjs'],
overrides: [{ files: ['*.svelte'], processor: 'svelte3/svelte3' }], overrides: [{ files: ['*.svelte'], processor: 'svelte3/svelte3' }],
settings: { settings: {
'svelte3/typescript': () => require('typescript') 'svelte3/typescript': () => require('typescript'),
}, },
parserOptions: { parserOptions: {
sourceType: 'module', sourceType: 'module',
ecmaVersion: 2020 ecmaVersion: 2020,
}, },
env: { env: {
browser: true, browser: true,
es2017: true, es2017: true,
node: true node: true,
} },
}; };

View File

@ -1,5 +1,5 @@
import { defineMDSveXConfig as defineConfig } from 'mdsvex'; import { defineMDSveXConfig as defineConfig } from 'mdsvex';
import examples from 'mdsvexamples' import examples from 'mdsvexamples';
const config = defineConfig({ const config = defineConfig({
extensions: ['.svelte.md', '.md', '.svx'], extensions: ['.svelte.md', '.md', '.svx'],
@ -13,16 +13,16 @@ const config = defineConfig({
examples, examples,
{ {
defaults: { defaults: {
Wrapper: '$routes/_internal/components/Example.svelte' Wrapper: '$routes/_internal/components/Example.svelte',
} },
} },
] ],
], ],
rehypePlugins: [], rehypePlugins: [],
layout: { layout: {
_: "./src/routes/_internal/layout/page.svelte", _: './src/routes/_internal/layout/page.svelte',
} },
}); });
export default config; export default config;

View File

@ -1,55 +1,58 @@
import {ComponentParser} from 'sveld' import { ComponentParser } from 'sveld';
import * as svelte from 'svelte/compiler' import * as svelte from 'svelte/compiler';
import fs from 'fs/promises' import fs from 'fs/promises';
import path from 'path' import path from 'path';
import {preprocess} from "../src/package/config/svelte.config.js"; import { preprocess } from '../src/package/config/svelte.config.js';
export default function sveld() { export default function sveld() {
return { return {
name: 'vite-plugin-sveld', name: 'vite-plugin-sveld',
async transform(src, id) { async transform(src, id) {
if (id.endsWith('?raw&sveld')) { if (id.endsWith('?raw&sveld')) {
const raw = JSON.parse(src.split('export default ')[1]) const raw = JSON.parse(src.split('export default ')[1]);
const data = await parseRaw(raw, id) const data = await parseRaw(raw, id);
return { return {
code: `export default ${JSON.stringify(data)}`, code: `export default ${JSON.stringify(data)}`,
map: null map: null,
} };
} }
}, },
// This generates a `COMPONENT_API.json` with sveld in the `/_app` folder on build, which is used by the docs about components (only when built statically) // This generates a `COMPONENT_API.json` with sveld in the `/_app` folder on build, which is used by the docs about components (only when built statically)
async buildStart() { async buildStart() {
const output = {}; const output = {};
const componentFiles = await fs.readdir(path.resolve('./src/package/components')) const componentFiles = await fs.readdir(path.resolve('./src/package/components'));
for (const fileName of componentFiles) { for (const fileName of componentFiles) {
const filePath = path.resolve('./src/package/components', fileName) const filePath = path.resolve('./src/package/components', fileName);
const raw = (await fs.readFile(filePath)).toString() const raw = (await fs.readFile(filePath)).toString();
output[fileName] = await parseRaw(raw, filePath) output[fileName] = await parseRaw(raw, filePath);
} }
try { try {
await fs.mkdir(path.resolve('./src/generated')) await fs.mkdir(path.resolve('./src/generated'));
} catch { } catch {
// Do nothing, directory already exists // Do nothing, directory already exists
} }
await fs.writeFile(path.resolve('./src/generated/COMPONENT_API.json'), JSON.stringify(output)) await fs.writeFile(
path.resolve('./src/generated/COMPONENT_API.json'),
JSON.stringify(output)
);
}, },
} };
} }
async function parseRaw(raw, filePath) { async function parseRaw(raw, filePath) {
let { code } = await svelte.preprocess(raw, preprocess, { let { code } = await svelte.preprocess(raw, preprocess, {
filename: filePath filename: filePath,
}) });
return new ComponentParser({ return new ComponentParser({
verbose: false verbose: false,
}).parseSvelteComponent(code, { }).parseSvelteComponent(code, {
filePath, filePath,
moduleName: filePath moduleName: filePath,
}) });
} }

View File

@ -1 +1 @@
module.exports = require('./src/package/config/postcss.config.cjs') module.exports = require('./src/package/config/postcss.config.cjs');

View File

@ -6,9 +6,9 @@
<link rel="icon" href="%svelte.assets%/assets/omorphia.png" /> <link rel="icon" href="%svelte.assets%/assets/omorphia.png" />
<meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#CF1971"> <meta name="theme-color" content="#CF1971" />
<meta name="twitter:card" content="summary"> <meta name="twitter:card" content="summary" />
<meta name="twitter:image" content="https://omorphia.modrinth.com/assets/omorphia.png"> <meta name="twitter:image" content="https://omorphia.modrinth.com/assets/omorphia.png" />
<meta property="og:site_name" content="Modrinth" /> <meta property="og:site_name" content="Modrinth" />
%svelte.head% %svelte.head%

View File

@ -17,15 +17,16 @@ const config = {
'--xl': '(min-width: 1280px)', '--xl': '(min-width: 1280px)',
}, },
}, },
] ],
} },
} },
}), }),
require('postcss-pxtorem'), require('postcss-pxtorem'),
require('autoprefixer'), require('autoprefixer'),
process.env.NODE_ENV === 'development' && require('cssnano')({ process.env.NODE_ENV === 'development' &&
require('cssnano')({
preset: 'default', preset: 'default',
}) }),
], ],
}; };

View File

@ -1,7 +1,5 @@
import { fetch } from 'undici'; import { fetch } from 'undici';
import { promises as fs } from 'fs'; import { promises as fs } from 'fs';
import sharp from 'sharp';
import FastAverageColor from 'fast-average-color';
import cliProgress from 'cli-progress'; import cliProgress from 'cli-progress';
export async function landingPage(API_URL: string) { export async function landingPage(API_URL: string) {

View File

@ -11,6 +11,6 @@
&__description { &__description {
font-size: 1.2rem; font-size: 1.2rem;
color: var(--color-text-light) color: var(--color-text-light);
} }
} }

View File

@ -20,7 +20,6 @@
&:hover { &:hover {
color: var(--color-link); color: var(--color-link);
} }
} }
} }

View File

@ -1,5 +1,4 @@
:root { :root {
/* these are values for the display CSS property */ /* these are values for the display CSS property */
/* /*
--display-values: ( --display-values: (

View File

@ -33,6 +33,7 @@
--font-weight-bold: 600; --font-weight-bold: 600;
/* Font stacks */ /* Font stacks */
--body-font: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji'; --body-font: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif,
'Apple Color Emoji', 'Segoe UI Emoji';
--mono-font: ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, Liberation Mono, monospace; --mono-font: ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, Liberation Mono, monospace;
} }

View File

@ -35,7 +35,9 @@ export function ago(
if (diffAbs >= interval.ge) { if (diffAbs >= interval.ge) {
const x = Math.round(Math.abs(diff) / interval.divisor); const x = Math.round(Math.abs(diff) / interval.divisor);
const isFuture = diff < 0; const isFuture = diff < 0;
return interval.unit ? rft.format(isFuture ? x : -x, interval.unit as Unit) : interval.text; return interval.unit
? rft.format(isFuture ? x : -x, interval.unit as Unit)
: interval.text;
} }
} }
} }

View File

@ -1,3 +1,3 @@
export function classCombine(names) { export function classCombine(names) {
return names.filter(name => name && !name.includes('undefined')).join(' ') return names.filter((name) => name && !name.includes('undefined')).join(' ');
} }

View File

@ -1,40 +0,0 @@
/**
* Convert large numbers to human readable strings
* @source https://github.com/rohmanhm/simplify-number
*/
export function simplify(num = 0): string {
let numberVar = num;
// 2 decimal places => 100, 3 => 1000, etc
const decPlaces = Math.pow(10, 1);
// Enumerate number abbreviations
const abbrev = ['K', 'M', 'B', 'T'];
// Go through the array backwards, so we do the largest first
for (let i = abbrev.length - 1; i >= 0; i--) {
// Convert array index to "1000", "1000000", etc
const size = Math.pow(10, (i + 1) * 3);
// If the number is bigger or equal do the abbreviation
if (size <= numberVar) {
// Here, we multiply by decPlaces, round, and then divide by decPlaces.
// This gives us nice rounding to a particular decimal place.
numberVar = Math.round((numberVar * decPlaces) / size) / decPlaces;
// Handle special case where we round up to the next abbreviation
if (numberVar === 1000 && i < abbrev.length - 1) {
numberVar = 1;
i++;
}
// Add the letter for the abbreviation
(numberVar as any) += abbrev[i];
// We are done... stop
break;
}
}
return String(numberVar);
}

View File

@ -48,7 +48,10 @@ export function formatVersions(versionArray: string[]): string {
]); ]);
if (lastSnapshot !== null && lastSnapshot !== j + 1) { if (lastSnapshot !== null && lastSnapshot !== j + 1) {
newIntervals.push([[allVersions[lastSnapshot].version, lastSnapshot, -1], interval[1]]); newIntervals.push([
[allVersions[lastSnapshot].version, lastSnapshot, -1],
interval[1],
]);
} else { } else {
newIntervals.push([interval[1]]); newIntervals.push([interval[1]]);
} }

View File

@ -28,6 +28,7 @@ import { page } from '$app/stores';
<a href="/getting-started/css" class="section__link">Writing CSS</a> <a href="/getting-started/css" class="section__link">Writing CSS</a>
<a href="/getting-started/illustrations" class="section__link">Illustrations</a> <a href="/getting-started/illustrations" class="section__link">Illustrations</a>
<a href="/getting-started/utils" class="section__link">Built-in utilities</a> <a href="/getting-started/utils" class="section__link">Built-in utilities</a>
<a href="/getting-started/generator" class="section__link">Generator plugin</a>
</div> </div>
<div class="section"> <div class="section">

View File

@ -27,12 +27,14 @@
position: relative; position: relative;
} }
&:where(h2:first-child, h1:first-child, h1:first-child + h2, h3:first-child, h4:first-child, h5:first-child, h6:first-child) { &:where(h2:first-child, h1:first-child, h1:first-child
+ h2, h3:first-child, h4:first-child, h5:first-child, h6:first-child) {
margin-top: 0; margin-top: 0;
padding-top: 0; padding-top: 0;
} }
&:where(h1:hover a.anchor, h2:hover a.anchor, h3:hover a.anchor, h4:hover a.anchor, h5:hover a.anchor, h6:hover a.anchor) { &:where(h1:hover a.anchor, h2:hover a.anchor, h3:hover a.anchor, h4:hover a.anchor, h5:hover
a.anchor, h6:hover a.anchor) {
text-decoration: none; text-decoration: none;
} }
@ -119,12 +121,14 @@
padding-top: 0; padding-top: 0;
} }
&:where(body > h3:first-child, body > h4:first-child, body > h5:first-child, body > h6:first-child) { &:where(body > h3:first-child, body > h4:first-child, body > h5:first-child, body
> h6:first-child) {
margin-top: 0; margin-top: 0;
padding-top: 0; padding-top: 0;
} }
&:where(a:first-child h1, a:first-child h2, a:first-child h3, a:first-child h4, a:first-child h5, a:first-child h6) { &:where(a:first-child h1, a:first-child h2, a:first-child h3, a:first-child h4, a:first-child
h5, a:first-child h6) {
margin-top: 0; margin-top: 0;
padding-top: 0; padding-top: 0;
} }

View File

@ -28,12 +28,12 @@
* --syntax-cursor-line: hsla(220, 100%, 80%, 0.04); * --syntax-cursor-line: hsla(220, 100%, 80%, 0.04);
*/ */
code[class*="language-"], code[class*='language-'],
pre[class*="language-"] { pre[class*='language-'] {
background: hsl(220, 13%, 18%); background: hsl(220, 13%, 18%);
color: hsl(220, 14%, 71%); color: hsl(220, 14%, 71%);
text-shadow: 0 1px rgba(0, 0, 0, 0.3); text-shadow: 0 1px rgba(0, 0, 0, 0.3);
font-family: "Fira Code", "Fira Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace; font-family: 'Fira Code', 'Fira Mono', Menlo, Consolas, 'DejaVu Sans Mono', monospace;
direction: ltr; direction: ltr;
text-align: left; text-align: left;
white-space: pre; white-space: pre;
@ -50,24 +50,24 @@ pre[class*="language-"] {
} }
/* Selection */ /* Selection */
code[class*="language-"]::-moz-selection, code[class*='language-']::-moz-selection,
code[class*="language-"] *::-moz-selection, code[class*='language-'] *::-moz-selection,
pre[class*="language-"] *::-moz-selection { pre[class*='language-'] *::-moz-selection {
background: hsl(220, 13%, 28%); background: hsl(220, 13%, 28%);
color: inherit; color: inherit;
text-shadow: none; text-shadow: none;
} }
code[class*="language-"]::selection, code[class*='language-']::selection,
code[class*="language-"] *::selection, code[class*='language-'] *::selection,
pre[class*="language-"] *::selection { pre[class*='language-'] *::selection {
background: hsl(220, 13%, 28%); background: hsl(220, 13%, 28%);
color: inherit; color: inherit;
text-shadow: none; text-shadow: none;
} }
/* Code blocks */ /* Code blocks */
pre[class*="language-"] { pre[class*='language-'] {
padding: 16px; padding: 16px;
margin: 0.5em 0; margin: 0.5em 0;
overflow: auto; overflow: auto;
@ -75,7 +75,7 @@ pre[class*="language-"] {
} }
/* Inline code */ /* Inline code */
:not(pre) > code[class*="language-"] { :not(pre) > code[class*='language-'] {
padding: 0.2em 0.3em; padding: 0.2em 0.3em;
border-radius: 0.3em; border-radius: 0.3em;
white-space: normal; white-space: normal;
@ -83,8 +83,8 @@ pre[class*="language-"] {
/* Print */ /* Print */
@media print { @media print {
code[class*="language-"], code[class*='language-'],
pre[class*="language-"] { pre[class*='language-'] {
text-shadow: none; text-shadow: none;
} }
} }
@ -178,7 +178,10 @@ pre[class*="language-"] {
color: hsl(286, 60%, 67%); color: hsl(286, 60%, 67%);
} }
.language-javascript .token.template-string > .token.interpolation > .token.interpolation-punctuation.punctuation { .language-javascript
.token.template-string
> .token.interpolation
> .token.interpolation-punctuation.punctuation {
color: hsl(5, 48%, 51%); color: hsl(5, 48%, 51%);
} }

View File

@ -17,7 +17,6 @@
/> />
``` ```
### Force an option to be selected with `neverEmpty` ### Force an option to be selected with `neverEmpty`
```svelte example raised ```svelte example raised

View File

@ -1,4 +1,4 @@
```svelte example ```svelte example raised
<script lang="ts"> <script lang="ts">
import { Slider } from "omorphia"; import { Slider } from "omorphia";
</script> </script>

View File

@ -9,19 +9,15 @@ To make use of the built-in icons, styles, and plugins in omorphia, you will nee
Add the following parts to your `svelte.config.js` file: Add the following parts to your `svelte.config.js` file:
```js ```js
import { preprocess, plugins } from 'omorphia/config/svelte.config' import { preprocess, plugins } from 'omorphia/config/svelte.config';
/** @type {import('@sveltejs/kit').Config} */ /** @type {import('@sveltejs/kit').Config} */
const config = { const config = {
preprocess: [ preprocess: [preprocess],
preprocess,
],
kit: { kit: {
vite: { vite: {
plugins: [ plugins: [...plugins],
...plugins,
],
}, },
}, },
}; };
@ -36,5 +32,5 @@ Create a `postcss.config.cjs` file in the root of your project.
Add the following line to that file: Add the following line to that file:
```js ```js
module.exports = require('omorphia/config/postcss.config.cjs') module.exports = require('omorphia/config/postcss.config.cjs');
``` ```

View File

@ -1,19 +1,16 @@
import { mdsvex } from 'mdsvex'; import { mdsvex } from 'mdsvex';
import mdsvexConfig from './mdsvex.config.js'; import mdsvexConfig from './mdsvex.config.js';
import adapter from '@sveltejs/adapter-static'; import adapter from '@sveltejs/adapter-static';
import examples from 'mdsvexamples/vite' import examples from 'mdsvexamples/vite';
import sveld from './plugins/sveld.js' import sveld from './plugins/sveld.js';
import path from "path"; import path from 'path';
import { preprocess, plugins } from './src/package/config/svelte.config.js' import { preprocess, plugins } from './src/package/config/svelte.config.js';
/** @type {import('@sveltejs/kit').Config} */ /** @type {import('@sveltejs/kit').Config} */
const config = { const config = {
extensions: ['.svelte', ...mdsvexConfig.extensions], extensions: ['.svelte', ...mdsvexConfig.extensions],
preprocess: [ preprocess: [preprocess, mdsvex(mdsvexConfig)],
preprocess,
mdsvex(mdsvexConfig),
],
kit: { kit: {
adapter: adapter(), adapter: adapter(),
@ -38,13 +35,13 @@ const config = {
build: { build: {
rollupOptions: { rollupOptions: {
external: '/_app/COMPONENT_API.json' external: '/_app/COMPONENT_API.json',
} },
} },
}, },
files: { files: {
lib: 'src/package', lib: 'src/package',
} },
}, },
}; };