generated from yunsii/unplugin-starter
-
-
Notifications
You must be signed in to change notification settings - Fork 1
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
17 changed files
with
742 additions
and
96 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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
{ | ||
"cSpell.words": ["bumpp", "nuxt"] | ||
"cSpell.words": ["bumpp", "nuxt"], | ||
"tailwindCSS.experimental.classRegex": ["cls`([^`]*)"], | ||
"css.lint.unknownAtRules": "ignore" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import clsx from 'clsx' | ||
|
||
function normalizeStrings(strings: string[]) { | ||
const result: string[] = [] | ||
strings.forEach((stringItem) => { | ||
stringItem | ||
.split('\n') | ||
.map((item) => item.trim()) | ||
// 支持使用 // 的行注释 | ||
.filter((item) => !item.startsWith('//') && !!item) | ||
.forEach((item) => result.push(item)) | ||
}) | ||
return result | ||
} | ||
|
||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#tagged_templates | ||
export default function cls( | ||
strings: TemplateStringsArray, | ||
...expressions: any[] | ||
) { | ||
const classNamesList = strings.reduce((prev, current, currentIndex) => { | ||
const expression = expressions[currentIndex] || '' | ||
prev.push(current, clsx(expression)) | ||
return prev | ||
}, [] as string[]) | ||
const result = normalizeStrings(classNamesList).join(' ') | ||
return result | ||
} | ||
|
||
export { cls, clsx } |
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 @@ | ||
@tailwind base; | ||
@tailwind components; | ||
@tailwind utilities; |
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 |
---|---|---|
@@ -1,13 +1,19 @@ | ||
<!DOCTYPE html> | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<link rel="icon" href="/favicon.ico" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
</head> | ||
<body> | ||
<div id="app"></div> | ||
<a href="/__inspect/module?id=./main.ts&index=2" target="_blank" style="text-decoration: none; margin-top:10px; display: block;">visit /__inspect/ to inspect the intermediate state</a> | ||
<script type="module" src="./main.ts"></script> | ||
</body> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" href="/favicon.ico" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
</head> | ||
<body> | ||
<div id="app"></div> | ||
<a | ||
href="/__inspect/module?id=./main.ts&index=2" | ||
class="text-blue-500" | ||
target="_blank" | ||
style="text-decoration: none; margin-top: 10px; display: block" | ||
>visit /__inspect/ to inspect the intermediate state</a | ||
> | ||
<script type="module" 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 |
---|---|---|
@@ -1 +1,23 @@ | ||
import './global.css' | ||
|
||
import { cls } from './cls' | ||
|
||
const p1 = document.createElement('p') | ||
p1.className = cls` | ||
cursor-pointer | ||
font-bold text-xl | ||
text-sky-500 | ||
hover:text-sky-600 | ||
` | ||
p1.innerText = 'Hello, world.' | ||
|
||
const p2 = document.createElement('p') | ||
p2.className = cls` | ||
font-bold text-xl | ||
${1} | ||
` | ||
p2.innerText = 'Today is great day.' | ||
|
||
document.getElementById('app')!.innerHTML = '__UNPLUGIN__' | ||
document.getElementById('app')!.appendChild(p1) | ||
document.getElementById('app')!.appendChild(p2) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
plugins: { | ||
tailwindcss: {}, | ||
autoprefixer: {}, | ||
}, | ||
} |
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 @@ | ||
/** @type {import('tailwindcss').Config} */ | ||
module.exports = { | ||
content: ['./**/*.ts', './**/*.html'], | ||
theme: { | ||
extend: {}, | ||
}, | ||
plugins: [], | ||
} |
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.