Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/tutorialkit.dev/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@
"sharp": "^0.32.6",
"starlight-links-validator": "^0.9.0",
"typescript": "^5.4.5",
"unocss": "^0.59.4"
"unocss": "66.5.2"
}
}
6 changes: 3 additions & 3 deletions e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@
"@types/node": "^22.2.0",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@unocss/reset": "^0.59.4",
"@unocss/transformer-directives": "^0.62.0",
"@unocss/reset": "66.5.2",
"@unocss/transformer-directives": "66.5.2",
"astro": "^4.15.0",
"fast-glob": "^3.3.2",
"playwright": "^1.46.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"unocss": "^0.59.4",
"unocss": "66.5.2",
"unzipper": "^0.12.3"
}
}
37 changes: 34 additions & 3 deletions e2e/test/topbar.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/// <reference types="node" />
import { readdirSync, readFileSync, rmSync } from 'node:fs';
import type { Readable } from 'node:stream';
import { test, expect } from '@playwright/test';
import * as unzipper from 'unzipper';
import { theme } from '../../packages/theme/src/theme';
import { theme } from '../../packages/theme/src/theme.js';

test('user can change theme', async ({ page }) => {
await page.goto('/');
Expand All @@ -13,16 +13,47 @@

// default light theme
await expect(html).toHaveAttribute('data-theme', 'light');
await expect(heading).toHaveCSS('color', hexToRGB(theme.colors.gray[800]));

/**
* Normalize both the expected token and the computed style to canonical rgba(...) to
* avoid mismatches caused by different color-space serializations (oklab vs rgb)
*/
const normalizeColor = (cssColor: string) =>
page.evaluate((c: string) => {
const canvas = document.createElement('canvas');
canvas.width = 1;
canvas.height = 1;

const ctx = canvas.getContext('2d');

if (!ctx) {
return c;
}

ctx.clearRect(0, 0, 1, 1);
ctx.fillStyle = c;
ctx.fillRect(0, 0, 1, 1);

const d = ctx.getImageData(0, 0, 1, 1).data;

return 'rgba(' + d[0] + ', ' + d[1] + ', ' + d[2] + ', ' + d[3] / 255 + ')';
}, cssColor);

const expectedLight = await normalizeColor(hexToRGB(theme.colors.gray[800]));
const observedLightRgba = await normalizeColor(await heading.evaluate((el) => getComputedStyle(el).color));
expect(observedLightRgba).toBe(expectedLight);

await page.getByRole('navigation').getByRole('button', { name: 'Toggle Theme' }).click();

await expect(html).toHaveAttribute('data-theme', 'dark');
await expect(heading).toHaveCSS('color', hexToRGB(theme.colors.gray[200]));

const expectedDark = await normalizeColor(hexToRGB(theme.colors.gray[200]));
const observedDarkRgba = await normalizeColor(await heading.evaluate((el) => getComputedStyle(el).color));
expect(observedDarkRgba).toBe(expectedDark);
});

test('user can download project as zip', async ({ page }) => {
await page.goto('/', { waitUntil: 'networkidle' });

Check failure on line 56 in e2e/test/topbar.test.ts

View workflow job for this annotation

GitHub Actions / Test E2E

[Default] › test/topbar.test.ts:55:1 › user can download project as zip

1) [Default] › test/topbar.test.ts:55:1 › user can download project as zip ─────────────────────── Error: page.goto: Test timeout of 30000ms exceeded. Call log: - navigating to "http://localhost:4329/", waiting until "networkidle" 54 | 55 | test('user can download project as zip', async ({ page }) => { > 56 | await page.goto('/', { waitUntil: 'networkidle' }); | ^ 57 | 58 | const downloadPromise = page.waitForEvent('download'); 59 | await page.getByRole('navigation').getByRole('button', { name: 'Download lesson as zip-file' }).click(); at /home/runner/work/tutorialkit/tutorialkit/e2e/test/topbar.test.ts:56:14

const downloadPromise = page.waitForEvent('download');
await page.getByRole('navigation').getByRole('button', { name: 'Download lesson as zip-file' }).click();
Expand Down
4 changes: 2 additions & 2 deletions packages/astro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"@tutorialkit/theme": "workspace:*",
"@tutorialkit/types": "workspace:*",
"@types/react": "^18.3.3",
"@unocss/reset": "^0.62.2",
"@unocss/reset": "66.5.2",
"@webcontainer/api": "1.5.1",
"astro": "^4.15.0",
"astro-expressive-code": "^0.35.3",
Expand All @@ -61,7 +61,7 @@
"remark-directive": "^3.0.0",
"unified": "^11.0.5",
"unist-util-visit": "^5.0.0",
"unocss": "^0.59.4",
"unocss": "66.5.2",
"zod": "3.23.8"
},
"devDependencies": {
Expand Down
8 changes: 4 additions & 4 deletions packages/astro/src/remark/callouts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ export function remarkCalloutsPlugin() {
const hideIcon = attributes.hideIcon === 'true';

const classes = [
`callout callout-${variant} my-4 flex flex-col p-3 bg-tk-elements-markdown-callouts-backgroundColor text-tk-elements-markdown-callouts-textColor`,
`callout callout-${variant} my-4 flex flex-col p-3 bg-[var(--tk-elements-markdown-callouts-backgroundColor)] text-[var(--tk-elements-markdown-callouts-textColor)]`,
attributes.class ?? '',
...(noBorder ? [] : ['border-l-3', 'border-tk-elements-markdown-callouts-borderColor']),
...(noBorder ? [] : ['border-l-3', 'border-[var(--tk-elements-markdown-callouts-borderColor)]']),
];

node.attributes = {
Expand Down Expand Up @@ -139,7 +139,7 @@ function generate(title: string, children: any[], callout: Callout, hideIcon: bo
data: {
hName: 'div',
hProperties: {
className: 'w-full flex gap-2 items-center text-tk-elements-markdown-callouts-titleTextColor',
className: 'w-full flex gap-2 items-center text-[var(--tk-elements-markdown-callouts-titleTextColor)]',
ariaHidden: true,
},
},
Expand All @@ -149,7 +149,7 @@ function generate(title: string, children: any[], callout: Callout, hideIcon: bo
: ([
{
type: 'html',
value: `<span class="text-6 inline-block text-tk-elements-markdown-callouts-iconColor ${callout.icon}"></span>`,
value: `<span class="text-6 inline-block text-[var(--tk-elements-markdown-callouts-iconColor)] ${callout.icon}"></span>`,
},
] satisfies Children)),
{
Expand Down
2 changes: 1 addition & 1 deletion packages/theme/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"@iconify-json/ph": "^1.1.13",
"@iconify-json/svg-spinners": "^1.1.2",
"fast-glob": "^3.3.2",
"unocss": "^0.59.4"
"unocss": "66.5.2"
},
"devDependencies": {
"@types/node": "^22.4.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/theme/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import fs from 'node:fs/promises';
import { createRequire } from 'node:module';
import { basename, dirname, resolve } from 'node:path';
import * as fastGlob from 'fast-glob';
import { mergeConfigs, presetIcons, presetUno, transformerDirectives, type UserConfig } from 'unocss';
import { mergeConfigs, presetIcons, presetWind4, transformerDirectives, type UserConfig } from 'unocss';

import { theme } from './theme.js';
import { transitionTheme } from './transition-theme.js';
Expand All @@ -26,7 +26,7 @@ export function defineConfig(config: UserConfig) {
}),
},
presets: [
presetUno({
presetWind4({
dark: {
dark: '[data-theme="dark"]',
},
Expand Down
Loading
Loading