-
-
Notifications
You must be signed in to change notification settings - Fork 780
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(postcss): directive support in vue and svelte components (#2338)
- Loading branch information
Showing
17 changed files
with
230 additions
and
23 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
shamefully-hoist=true |
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" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Svelte + TS + Vite App</title> | ||
</head> | ||
<body> | ||
<div id="app"></div> | ||
<script type="module" src="/src/main.ts"></script> | ||
</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,23 @@ | ||
{ | ||
"name": "unocss-svelte-ts", | ||
"type": "module", | ||
"version": "0.0.0", | ||
"scripts": { | ||
"dev": "vite", | ||
"build": "vite build", | ||
"serve": "vite preview", | ||
"check": "svelte-check --tsconfig ./tsconfig.json" | ||
}, | ||
"devDependencies": { | ||
"@iconify-json/logos": "^1.1.23", | ||
"@sveltejs/vite-plugin-svelte": "^2.0.3", | ||
"@tsconfig/svelte": "^3.0.0", | ||
"@unocss/postcss": "link:..\\..\\packages\\postcss", | ||
"svelte": "^3.55.1", | ||
"svelte-check": "^3.0.4", | ||
"tslib": "^2.5.0", | ||
"typescript": "^4.9.5", | ||
"unocss": "link:../../packages/unocss", | ||
"vite": "^4.1.4" | ||
} | ||
} |
Empty file.
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,5 @@ | ||
module.exports = { | ||
plugins: { | ||
'@unocss/postcss': {}, | ||
}, | ||
} |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,31 @@ | ||
<div text-center font-sans p4 flex flex-col items-center gap-8> | ||
<div class="flex gap-4"> | ||
<div class="i-logos-svelte-icon text-3xl" /> | ||
<div class="i-logos-unocss text-3xl" /> | ||
<div class="i-logos-postcss text-3xl" /> | ||
</div> | ||
<div text-gray2 text-2xl font-medium> | ||
UnoCSS + Svelte + PostCSS | ||
</div> | ||
<div class="bg-[url(../src/uno.svg)] bg-[url(/uno.svg)]" h-220px w-220px /> | ||
<div class="flex gap-2 items-center"> | ||
<button> | ||
Hello | ||
</button> | ||
<div class="dark"> | ||
<a href="#">Hello</a> | ||
</div> | ||
</div> | ||
<div class="my-class"> | ||
Directives in Svelte SFC | ||
</div> | ||
</div> | ||
|
||
<style lang="postcss"> | ||
@screen md { | ||
.my-class { | ||
@apply bg-red-800; | ||
color: theme('colors.red.300'); | ||
} | ||
} | ||
</style> |
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,8 @@ | ||
import App from './App.svelte' | ||
import './style.css' | ||
|
||
const app = new App({ | ||
target: document.getElementById('app'), | ||
}) | ||
|
||
export default app |
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,30 @@ | ||
@layer base, components, utilities; | ||
|
||
@layer base { | ||
@unocss preflights; | ||
} | ||
|
||
@layer utilities { | ||
@unocss default; | ||
|
||
@unocss; | ||
} | ||
|
||
@layer components { | ||
html { | ||
background: theme('colors.black'); | ||
color: theme('colors.gray.300'); | ||
} | ||
button, a { | ||
@apply focus-visible:outline-none focus:outline-2 focus:outline-offset-2 focus:outline-sky-600; | ||
@apply [&:hover]:text-[#fff] bg-gray-900 hover:bg-gray-700 text-gray-200 text-base no-underline b-0 dark:hover:bg-blue-600; | ||
@apply px-4 py-2 rounded-lg block; | ||
} | ||
} | ||
|
||
@screen at-sm { | ||
html { | ||
background: theme('colors.gray.900'); | ||
} | ||
} | ||
|
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 @@ | ||
/// <reference types="svelte" /> | ||
/// <reference types="vite/client" /> | ||
/// <reference types="unocss/vite" /> |
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,5 @@ | ||
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte' | ||
|
||
export default { | ||
preprocess: [vitePreprocess()], | ||
} |
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,19 @@ | ||
{ | ||
"extends": "@tsconfig/svelte/tsconfig.json", | ||
"compilerOptions": { | ||
"target": "esnext", | ||
"useDefineForClassFields": true, | ||
"module": "esnext", | ||
"resolveJsonModule": true, | ||
"baseUrl": ".", | ||
/** | ||
* Typecheck JS in `.svelte` and `.js` files by default. | ||
* Disable checkJs if you'd like to use dynamic types in JS. | ||
* Note that setting allowJs false does not prevent the use | ||
* of JS in `.svelte` files. | ||
*/ | ||
"allowJs": true, | ||
"checkJs": true | ||
}, | ||
"include": ["src/**/*.d.ts", "src/**/*.ts", "src/**/*.js", "src/**/*.svelte"] | ||
} |
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 @@ | ||
import { | ||
defineConfig, | ||
extractorSvelte, | ||
presetAttributify, | ||
presetIcons, | ||
presetTypography, | ||
presetUno, | ||
presetWebFonts, | ||
} from 'unocss' | ||
|
||
export default defineConfig({ | ||
extractors: [extractorSvelte], | ||
presets: [ | ||
presetUno({ | ||
attributifyPseudo: true, | ||
}), | ||
presetAttributify(), | ||
presetIcons({ | ||
scale: 1.2, | ||
}), | ||
presetTypography(), | ||
presetWebFonts({ | ||
provider: 'none', | ||
fonts: { | ||
script: 'Homemade Apple', | ||
}, | ||
}), | ||
], | ||
}) |
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,9 @@ | ||
import { defineConfig } from 'vite' | ||
import { svelte } from '@sveltejs/vite-plugin-svelte' | ||
|
||
// https://vitejs.dev/config/ | ||
export default defineConfig({ | ||
plugins: [ | ||
svelte(), | ||
], | ||
}) |
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
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