-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
317 additions
and
300 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ types | |
.tmpl | ||
coverage | ||
.DS_Store | ||
.svelte-kit | ||
|
||
yarn-debug.log* | ||
yarn-error.log* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"name": "svelttekit-demo", | ||
"type": "module", | ||
"scripts": { | ||
"dev": "vite dev", | ||
"build": "vite build", | ||
"preview": "vite preview" | ||
}, | ||
"devDependencies": { | ||
"@sveltejs/adapter-auto": "^3.0.0", | ||
"@sveltejs/kit": "^2.0.0", | ||
"@sveltejs/vite-plugin-svelte": "^3.0.0", | ||
"svelte": "^4.2.7", | ||
"vite": "^5.0.11", | ||
"vite-plugin-stylex-dev": "workspace:*" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" /> | ||
%sveltekit.head% | ||
</head> | ||
<body data-sveltekit-preload-data="hover"> | ||
<div style="display: contents">%sveltekit.body%</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<script lang="ts"> | ||
let count = 0; | ||
const incr = () => count++; | ||
const decr = () => count--; | ||
</script> | ||
|
||
|
||
<h1 {...attrs(stylex.props(styles.foo))}>SvelteKit ♥️ StyleX</h1> | ||
<div> | ||
<button on:click={decr}>-</button> | ||
{count} | ||
<button on:click={incr}>+</button> | ||
</div> | ||
<p>Visit <a href="https://kit.svelte.dev">kit.svelte.dev</a> to read the documentation</p> | ||
|
||
<script context="module" lang="ts"> | ||
import * as stylex from '@stylexjs/stylex'; | ||
import {globalTokens} from '../styles/globalTokens.stylex'; | ||
import {attrs} from '../styles/utils'; | ||
const styles = stylex.create({ | ||
foo: { | ||
color: globalTokens.green, | ||
fontFamily: 'system-ui, sans-serif', | ||
fontWeight: 200, | ||
fontSize: '4rem', | ||
}, | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import * as stylex from '@stylexjs/stylex' | ||
|
||
export const globalTokens = stylex.defineVars({ | ||
green: 'green', | ||
red: 'red' | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
export const attrs = ({ | ||
className, | ||
style | ||
}: Readonly<{ | ||
className?: string | undefined; | ||
style?: { [key: string]: string | number }; | ||
}>) => { | ||
const result: { class?: string; style?: string } = {} | ||
if (className != null) { | ||
result.class = className | ||
} | ||
if (style != null) { | ||
result.style = Object.entries(style) | ||
.map(([key, value]) => `${key}: ${value}`) | ||
.join('; ') | ||
} | ||
return result | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import adapter from '@sveltejs/adapter-auto' | ||
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: adapter() | ||
} | ||
} | ||
|
||
export default config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "./.svelte-kit/tsconfig.json" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import path from 'path' | ||
import { sveltekit } from '@sveltejs/kit/vite' | ||
import { defineConfig } from 'vite' | ||
import { stylexPlugin } from 'vite-plugin-stylex-dev' | ||
|
||
export default defineConfig({ | ||
plugins: [sveltekit(), stylexPlugin({ include: /\.(mjs|js|ts|vue|jsx|tsx|svelte)(\?.*|)$/ })], | ||
server: { | ||
fs: { | ||
allow: [path.resolve('../../../kit')] | ||
} | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.