Skip to content

Commit

Permalink
repl demo website thingy
Browse files Browse the repository at this point in the history
  • Loading branch information
oofdere committed Aug 9, 2024
1 parent b6a33cf commit fc51dfb
Show file tree
Hide file tree
Showing 20 changed files with 285 additions and 13 deletions.
26 changes: 13 additions & 13 deletions biome.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"$schema": "https://biomejs.dev/schemas/1.8.3/schema.json",
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
}
},
"files": {
"ignore": ["dist/*", "node_modules/*"]
}
"$schema": "https://biomejs.dev/schemas/1.8.3/schema.json",
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
}
},
"files": {
"ignore": ["dist/*", "node_modules/*", "docs/*"]
}
}
21 changes: 21 additions & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
node_modules

# Output
.output
.vercel
/.svelte-kit
/build

# OS
.DS_Store
Thumbs.db

# Env
.env
.env.*
!.env.example
!.env.test

# Vite
vite.config.js.timestamp-*
vite.config.ts.timestamp-*
1 change: 1 addition & 0 deletions docs/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
engine-strict=true
4 changes: 4 additions & 0 deletions docs/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Package Managers
package-lock.json
pnpm-lock.yaml
yarn.lock
8 changes: 8 additions & 0 deletions docs/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"useTabs": true,
"singleQuote": true,
"trailingComma": "none",
"printWidth": 100,
"plugins": ["prettier-plugin-svelte"],
"overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }]
}
Binary file added docs/bun.lockb
Binary file not shown.
33 changes: 33 additions & 0 deletions docs/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import js from '@eslint/js';
import ts from 'typescript-eslint';
import svelte from 'eslint-plugin-svelte';
import prettier from 'eslint-config-prettier';
import globals from 'globals';

/** @type {import('eslint').Linter.Config[]} */
export default [
js.configs.recommended,
...ts.configs.recommended,
...svelte.configs['flat/recommended'],
prettier,
...svelte.configs['flat/prettier'],
{
languageOptions: {
globals: {
...globals.browser,
...globals.node
}
}
},
{
files: ['**/*.svelte'],
languageOptions: {
parserOptions: {
parser: ts.parser
}
}
},
{
ignores: ['build/', '.svelte-kit/', 'dist/']
}
];
41 changes: 41 additions & 0 deletions docs/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"name": "docs",
"version": "0.0.1",
"private": true,
"scripts": {
"dev": "vite dev",
"build": "vite build",
"preview": "vite preview",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"lint": "prettier --check . && eslint .",
"format": "prettier --write ."
},
"devDependencies": {
"@sveltejs/adapter-auto": "^3.0.0",
"@sveltejs/adapter-static": "^3.0.2",
"@sveltejs/kit": "^2.0.0",
"@sveltejs/vite-plugin-svelte": "^3.0.0",
"@types/eslint": "^9.6.0",
"browserslist": "^4.23.3",
"eslint": "^9.0.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-svelte": "^2.36.0",
"globals": "^15.0.0",
"prettier": "^3.1.1",
"prettier-plugin-svelte": "^3.1.2",
"svelte": "^5.0.0-next.1",
"svelte-check": "^3.6.0",
"typescript": "^5.0.0",
"typescript-eslint": "^8.0.0",
"vite": "^5.0.3"
},
"type": "module",
"dependencies": {
"@tailwindcss/vite": "^4.0.0-alpha.18",
"lightningcss": "^1.26.0",
"lightningcss-plugin-crosswind": "^0.1.1",
"lightningcss-wasm": "^1.26.0",
"tailwindcss": "^4.0.0-alpha.18"
}
}
1 change: 1 addition & 0 deletions docs/src/app.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@import 'tailwindcss';
13 changes: 13 additions & 0 deletions docs/src/app.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// See https://kit.svelte.dev/docs/types#app
// for information about these interfaces
declare global {
namespace App {
// interface Error {}
// interface Locals {}
// interface PageData {}
// interface PageState {}
// interface Platform {}
}
}

export {};
12 changes: 12 additions & 0 deletions docs/src/app.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
%sveltekit.head%
</head>
<body data-sveltekit-preload-data="hover">
<div style="display: contents">%sveltekit.body%</div>
</body>
</html>
13 changes: 13 additions & 0 deletions docs/src/lib/demo.css.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
body {
@dark {
color: white;
background-color: black;
}
}

.box {
size: 8tw;
@screen md {
size: 16tw;
}
}
1 change: 1 addition & 0 deletions docs/src/lib/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// place files you want to import through the `$lib` alias in this folder.
43 changes: 43 additions & 0 deletions docs/src/lib/transform.svelte.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { crosswind } from 'lightningcss-plugin-crosswind/dist/index';
import init, { transform } from 'lightningcss-wasm';
import wasmUrl from 'lightningcss-wasm/lightningcss_node.wasm?url';

await init(wasmUrl);

export function createTransform(fn_input: string) {
let input = $state(fn_input);
let error: string | undefined = $state(undefined);

let output = $state(transform({
filename: 'crosswind.css',
code: new TextEncoder().encode(input),
...crosswind
}));

const code = $derived(new TextDecoder().decode(output.code))

return {
get input() { return input },
set input(i) {
input = i
try {
error = undefined;
output = transform({
filename: 'crosswind.css',
code: new TextEncoder().encode(input),
...crosswind
});
} catch (e) {
console.log(e)
error = JSON.stringify(e);
}
},

get output() { return output },

get code() { return code },

get error() { return error }
}
}

2 changes: 2 additions & 0 deletions docs/src/routes/+layout.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const ssr = false;
export const prerender = true;
23 changes: 23 additions & 0 deletions docs/src/routes/+page.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<script lang="ts">
import '../app.css';
import demo from '$lib/demo.css.txt?raw';
import { createTransform } from '$lib/transform.svelte';
const t = createTransform(demo);
</script>

<div class="flex w-screen h-screen flex-col-reverse md:flex-row">
<div class="h-full w-full">
<textarea class="h-full w-full" bind:value={t.input}></textarea>
</div>
<div class="h-full w-full flex flex-col">
{#if t.error}
<div class="bg-red-700 text-white">
<p>error: {t.error}</p>
<hr />
</div>
{/if}

<textarea class="h-full w-full" bind:value={t.code} disabled></textarea>
</div>
</div>
Binary file added docs/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.
18 changes: 18 additions & 0 deletions docs/svelte.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import adapter from '@sveltejs/adapter-static';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';

/** @type {import('@sveltejs/kit').Config} */
const config = {
// Consult https://kit.svelte.dev/docs/integrations#preprocessors
// for more information about preprocessors
preprocess: vitePreprocess(),

kit: {
// adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list.
// If your environment is not supported, or you settled on a specific environment, switch out the adapter.
// See https://kit.svelte.dev/docs/adapters for more information about adapters.
adapter: adapter()
}
};

export default config;
19 changes: 19 additions & 0 deletions docs/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"extends": "./.svelte-kit/tsconfig.json",
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
"moduleResolution": "bundler"
}
// Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias
// except $lib which is handled by https://kit.svelte.dev/docs/configuration#files
//
// If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes
// from the referenced tsconfig.json - TypeScript does not merge them in
}
19 changes: 19 additions & 0 deletions docs/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { sveltekit } from '@sveltejs/kit/vite';
import tailwindcss from '@tailwindcss/vite';
import browserslist from 'browserslist';
import { browserslistToTargets } from 'lightningcss';
import { crosswind } from 'lightningcss-plugin-crosswind';
import { defineConfig } from 'vite';

export default defineConfig({
plugins: [tailwindcss(), sveltekit()],
css: {
lightningcss: {
targets: browserslistToTargets(browserslist('>= 0.25%')),
...crosswind
}
},
build: {
target: 'esnext'
}
});

0 comments on commit fc51dfb

Please sign in to comment.