Skip to content
Merged
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
1 change: 1 addition & 0 deletions .oxfmtrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"$schema": "./node_modules/oxfmt/configuration_schema.json",
"singleQuote": true,
"singleAttributePerLine": true,
"ignorePatterns": [
"dist",
".astro",
Expand Down
1 change: 1 addition & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"singleQuote": true,
"singleAttributePerLine": true,
"plugins": ["prettier-plugin-astro"],
"overrides": [{ "files": "*.astro", "options": { "parser": "astro" } }]
}
6 changes: 0 additions & 6 deletions _features/01-lookandfeel.md

This file was deleted.

6 changes: 0 additions & 6 deletions _features/02-colorschemes.md

This file was deleted.

6 changes: 0 additions & 6 deletions _features/03-icons.md

This file was deleted.

6 changes: 0 additions & 6 deletions _features/04-components.md

This file was deleted.

6 changes: 0 additions & 6 deletions _features/05-customizable.md

This file was deleted.

6 changes: 0 additions & 6 deletions _features/06-extensible.md

This file was deleted.

22 changes: 22 additions & 0 deletions astro.config.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// @ts-check
import { defineConfig } from 'astro/config';
import mdx from '@astrojs/mdx';
import starlight from '@astrojs/starlight';
import AutoImport from 'astro-auto-import';

// Material themes that have a matching bundled Shiki theme (code blocks follow these 5 only);
// every other theme falls back to github-dark/light by its light/dark type.
Expand All @@ -18,6 +20,25 @@ export default defineConfig({
trailingSlash: 'always',
build: { format: 'directory' },
integrations: [
// Content components are available in every MDX page without import lines.
// Order matters: AutoImport, then Starlight, then MDX (Expressive Code must precede MDX).
AutoImport({
imports: [
'./src/components/content/AccentColors.astro',
'./src/components/content/ChromeThemes.astro',
'./src/components/content/ColorSwatch.astro',
'./src/components/content/Figure.astro',
'./src/components/content/Gallery.astro',
'./src/components/content/PaletteColors.astro',
'./src/components/content/RecommendedPlugins.astro',
'./src/components/content/ThemeCard.astro',
'./src/components/content/ThemeCards.astro',
'./src/components/content/ThemeColors.astro',
'./src/components/content/ThemePalette.astro',
'./src/components/content/ThemePalettes.astro',
'./src/components/content/Wallpapers.astro',
],
}),
starlight({
title: 'Material Theme UI',
customCss: ['./src/styles/custom.css'],
Expand Down Expand Up @@ -68,5 +89,6 @@ export default defineConfig({
},
},
}),
mdx(),
],
});
53 changes: 0 additions & 53 deletions docs/reference/color-palette.md

This file was deleted.

77 changes: 77 additions & 0 deletions e2e/content-components.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import fs from 'node:fs';
import { load } from 'js-yaml';
import { expect, test } from '@playwright/test';

const readYaml = <T>(file: string) => load(fs.readFileSync(`src/data/${file}`, 'utf8')) as T;

test.describe('Accents page', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/docs/configuration/accents/');
});

test('renders one swatch per accent color in the data', async ({ page }) => {
const accents = readYaml<{ name: string }[]>('accentColors.yml');

await expect(page.locator('.mt-colors .mt-color')).toHaveCount(accents.length);
await expect(page.locator('.mt-colors .mt-color').first()).toContainText(accents[0].name);
});

test('figures are centered, link to the full-size image and have a caption', async ({ page }) => {
const figure = page.locator('figure.mt-figure', { hasText: 'Material Accent Picker' });
const link = figure.locator('a');

await expect(link).toHaveAttribute('href', '/img/screens/accents/accentPicker.png');
await expect(figure.locator('img')).toHaveAttribute(
'src',
'/img/screens/accents/accentPicker.png',
);
await expect(figure.locator('figcaption')).toHaveText('Material Accent Picker');

const box = (await figure.boundingBox())!;
const container = (await page.locator('.sl-markdown-content').boundingBox())!;
const left = box.x - container.x;
const right = container.x + container.width - (box.x + box.width);

expect(Math.abs(left - right)).toBeLessThanOrEqual(2);
});

test('no figure link contains a double slash', async ({ page }) => {
const hrefs = await page
.locator('figure.mt-figure a')
.evaluateAll((links) => links.map((link) => link.getAttribute('href')));

expect(hrefs.length).toBeGreaterThan(0);

for (const href of hrefs) {
expect(href).not.toContain('//');
}
});

test('the gallery lists every front matter image and opens a lightbox', async ({ page }) => {
const gallery = page.locator('[data-mt-gallery] figure');

await expect(gallery).toHaveCount(21);
const link = gallery.first().locator('a');

// Lazy images have no height until loaded, so the link counts as hidden.
await link.locator('img').evaluate((img: HTMLImageElement) => {
img.loading = 'eager';
});
await link.click();
await expect(page.locator('dialog[data-mt-lightbox]')).toBeVisible();
await page.keyboard.press('Escape');
await expect(page.locator('dialog[data-mt-lightbox]')).toBeHidden();
});
});

test.describe('Color Palette page', () => {
test('renders one palette card per theme, grouped as in the data', async ({ page }) => {
const groups = readYaml<Record<string, { className: string }[]>>('themes.yml');
const total = Object.values(groups).flat().length;

await page.goto('/docs/reference/color-palette/');

await expect(page.locator('.mt-theme-palette')).toHaveCount(total);
await expect(page.locator('#theme-oceanic')).toContainText('Background: #263238');
});
});
42 changes: 42 additions & 0 deletions e2e/landing.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { expect, test } from '@playwright/test';

test.describe('Landing page', () => {
test('renders the hero, features, other editions and sponsors', async ({ page }) => {
await page.goto('/');

await expect(page.getByRole('link', { name: 'Download' })).toHaveAttribute(
'href',
'https://plugins.jetbrains.com/plugin/8006-material-theme-ui',
);
await expect(page.getByRole('heading', { name: 'Available Themes' })).toBeVisible();
await expect(page.locator('.mt-chooser [data-mt-theme]')).toHaveCount(32);
await expect(page.locator('.mt-features li')).toHaveCount(6);
await expect(page.getByRole('heading', { name: 'Other Editions' })).toBeVisible();
await expect(page.locator('.mt-sponsors a')).toHaveCount(10);
});

test('clicking a theme switches the site theme and the screenshot', async ({ page }) => {
await page.goto('/');

await page.locator('.mt-chooser [data-mt-theme="dracula"]').click();

await expect(page.locator('html')).toHaveAttribute('data-material-theme', 'dracula');
await expect(page.locator('[data-mt-screenshot] img')).toHaveAttribute(
'src',
'/img/themes/dracula.png',
);
await expect(page.locator('.mt-chooser [data-mt-theme="dracula"]')).toHaveAttribute(
'aria-pressed',
'true',
);
});

test('the screenshot also follows a theme set elsewhere', async ({ page }) => {
await page.goto('/?theme=monokai');

await expect(page.locator('[data-mt-screenshot] img')).toHaveAttribute(
'src',
'/img/themes/monokai.png',
);
});
});
6 changes: 3 additions & 3 deletions e2e/themes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ test('the saved theme is on <html> before the body is parsed (no flash)', async
test('a picked theme persists across reload and navigation', async ({ page }) => {
await page.goto('/');
await openPicker(page);
await page.locator('[data-mt-theme="dracula"]').click();
await page.locator('.mt-theme-fab [data-mt-theme="dracula"]').click();
await expect(html(page)).toHaveAttribute('data-material-theme', 'dracula');

await page.reload();
Expand All @@ -47,13 +47,13 @@ test('?theme= overrides the saved theme without replacing it', async ({ page })
test('all 32 themes can be picked and set light or dark accordingly', async ({ page }) => {
await page.goto('/');
await openPicker(page);
const cards = page.locator('[data-mt-theme]');
const cards = page.locator('.mt-theme-fab [data-mt-theme]');
await expect(cards).toHaveCount(32);

for (const name of await cards.evaluateAll((els) =>
els.map((e) => (e as HTMLElement).dataset.mtTheme!),
)) {
await page.locator(`[data-mt-theme="${name}"]`).click();
await page.locator(`.mt-theme-fab [data-mt-theme="${name}"]`).click();
await expect(html(page)).toHaveAttribute('data-material-theme', name);
const { scheme, theme } = await html(page).evaluate((el) => ({
scheme: getComputedStyle(el).colorScheme,
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
"format:check": "oxfmt --check && prettier --check \"src/**/*.astro\""
},
"dependencies": {
"@astrojs/mdx": "8.1.6",
"@astrojs/starlight": "^0.43.1",
"astro": "^7.3.6",
"astro-auto-import": "0.6.0",
"js-yaml": "5.5.0",
"sharp": "^0.35.3"
},
Expand Down
16 changes: 16 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions src/components/content/AccentColors.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
// Replaces `{% for color in site.data.accentColors %}{% include color2.html %}{% endfor %}`.
import { accentColors } from '../../data/site';
import ColorSwatch from './ColorSwatch.astro';
---

<div class="not-content mt-colors">
{accentColors.map((color) => (
<ColorSwatch color={color} />
))}
</div>

<style>
.mt-colors {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
gap: 0.35rem;
margin: 1rem 0;
}
</style>
Loading
Loading