-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor prerender functionality and add comprehensive Playwright tes…
…ts for CSS layers
- Loading branch information
Showing
14 changed files
with
230 additions
and
13 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
18 changes: 18 additions & 0 deletions
18
packages/runtime/e2e/progressive/comprehensive/index.test.ts
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 @@ | ||
import { expect, test } from '@playwright/test' | ||
import init from '../../init' | ||
import config from './master.css' | ||
import { readFileSync } from 'fs' | ||
import { fileURLToPath } from 'url' | ||
import { dirname, resolve } from 'path' | ||
|
||
const __filename = fileURLToPath(import.meta.url) | ||
const __dirname = dirname(__filename) | ||
|
||
test('basic', async ({ page }) => { | ||
const prerenderCSS = readFileSync(resolve(__dirname, 'prerender.css'), 'utf-8') | ||
const prerenderHTML = readFileSync(resolve(__dirname, 'prerender.html'), 'utf-8') | ||
await page.evaluate((html) => document.body.innerHTML = html, prerenderHTML) | ||
await init(page, prerenderCSS, config) | ||
const rules = await page.evaluate(() => globalThis.runtimeCSS.rules) | ||
expect(rules.map(({ name }) => name)).toEqual(['layer-statement', 'base', 'theme', 'preset', 'styles', 'general']) | ||
}) |
13 changes: 13 additions & 0 deletions
13
packages/runtime/e2e/progressive/comprehensive/master.css.ts
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 { Config } from '@master/css' | ||
|
||
export default { | ||
variables: { | ||
primary: { | ||
'@light': '#000000', | ||
'@dark': '#ffffff' | ||
} | ||
}, | ||
styles: { | ||
btn: 'inline-flex bg:primary' | ||
} | ||
} satisfies Config |
53 changes: 53 additions & 0 deletions
53
packages/runtime/e2e/progressive/comprehensive/prerender.css
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,53 @@ | ||
@layer base, theme, preset, styles, general; | ||
|
||
@layer base { | ||
.list-style\:none_ul\@base ul { | ||
list-style: none | ||
} | ||
} | ||
|
||
@layer theme { | ||
|
||
.light, | ||
:root { | ||
--primary: 0 0 0 | ||
} | ||
|
||
.dark { | ||
--primary: 255 255 255 | ||
} | ||
} | ||
|
||
@layer preset { | ||
.text\:16_p\@preset p { | ||
font-size: 1rem; | ||
line-height: calc(1rem + 0.875em) | ||
} | ||
} | ||
|
||
@layer styles { | ||
.btn { | ||
display: inline-flex; | ||
background-color: rgb(var(--primary)) | ||
} | ||
} | ||
|
||
@layer general { | ||
.flex { | ||
display: flex | ||
} | ||
|
||
.\@fade\|1s { | ||
animation: fade 1s | ||
} | ||
} | ||
|
||
@keyframes fade { | ||
0% { | ||
opacity: 0 | ||
} | ||
|
||
to { | ||
opacity: 1 | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
packages/runtime/e2e/progressive/comprehensive/prerender.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,7 @@ | ||
<div class="list-style:none_ul@base"> | ||
<button class="btn flex">Submit</button> | ||
<ul class="@fade|1s">…</ul> | ||
<article class="text:16_p@preset"> | ||
<p>…</p> | ||
</article> | ||
</div> |
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
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,24 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
lerna-debug.log* | ||
|
||
node_modules | ||
dist | ||
dist-ssr | ||
*.local | ||
|
||
# Editor directories and files | ||
.vscode/* | ||
!.vscode/extensions.json | ||
.idea | ||
.DS_Store | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? |
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,71 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Vite + TS</title> | ||
<style id="master"> | ||
@layer base, theme, preset, styles, general; | ||
|
||
@layer base { | ||
.list-style\:none_ul\@base ul { | ||
list-style: none | ||
} | ||
} | ||
|
||
@layer theme { | ||
|
||
.light, | ||
:root { | ||
--primary: 0 0 0 | ||
} | ||
|
||
.dark { | ||
--primary: 255 255 255 | ||
} | ||
} | ||
|
||
@layer preset { | ||
.text\:16_p\@preset p { | ||
font-size: 1rem; | ||
line-height: calc(1rem + 0.875em) | ||
} | ||
} | ||
|
||
@layer styles { | ||
.btn { | ||
display: inline-flex; | ||
background-color: rgb(var(--primary)) | ||
} | ||
} | ||
|
||
@layer general { | ||
.flex { | ||
display: flex | ||
} | ||
|
||
.\@fade\|1s { | ||
animation: fade 1s | ||
} | ||
} | ||
|
||
@keyframes fade { | ||
0% { | ||
opacity: 0 | ||
} | ||
|
||
to { | ||
opacity: 1 | ||
} | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<div id="app"></div> | ||
<script type="module" src="/src/main.ts"></script> | ||
<h1>Hello World</h1> | ||
</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,15 @@ | ||
{ | ||
"name": "playground", | ||
"private": true, | ||
"version": "0.0.0", | ||
"type": "module", | ||
"scripts": { | ||
"dev": "vite", | ||
"build": "tsc && vite build", | ||
"preview": "vite preview" | ||
}, | ||
"devDependencies": { | ||
"typescript": "~5.6.2", | ||
"vite": "^6.0.5" | ||
} | ||
} |
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 @@ | ||
import '../../src/global.min' |
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 @@ | ||
/// <reference types="vite/client" /> |
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,24 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ES2020", | ||
"useDefineForClassFields": true, | ||
"module": "ESNext", | ||
"lib": ["ES2020", "DOM", "DOM.Iterable"], | ||
"skipLibCheck": true, | ||
|
||
/* Bundler mode */ | ||
"moduleResolution": "bundler", | ||
"allowImportingTsExtensions": true, | ||
"isolatedModules": true, | ||
"moduleDetection": "force", | ||
"noEmit": true, | ||
|
||
/* Linting */ | ||
"strict": true, | ||
"noUnusedLocals": true, | ||
"noUnusedParameters": true, | ||
"noFallthroughCasesInSwitch": true, | ||
"noUncheckedSideEffectImports": true | ||
}, | ||
"include": ["src"] | ||
} |
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