diff --git a/.oxfmtrc.json b/.oxfmtrc.json index e137f358..ad399d6b 100644 --- a/.oxfmtrc.json +++ b/.oxfmtrc.json @@ -1,6 +1,7 @@ { "$schema": "./node_modules/oxfmt/configuration_schema.json", "singleQuote": true, + "singleAttributePerLine": true, "ignorePatterns": [ "dist", ".astro", diff --git a/.prettierrc.json b/.prettierrc.json index 14a66abe..6cf84090 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -1,5 +1,6 @@ { "singleQuote": true, + "singleAttributePerLine": true, "plugins": ["prettier-plugin-astro"], "overrides": [{ "files": "*.astro", "options": { "parser": "astro" } }] } diff --git a/_features/01-lookandfeel.md b/_features/01-lookandfeel.md deleted file mode 100644 index 34c412a2..00000000 --- a/_features/01-lookandfeel.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -author: mallowigi -featimg: lookandfeel.svg -title: A fresh new Look and Feel ---- -A brand look and feel with multiple flavors based on Material Design. diff --git a/_features/02-colorschemes.md b/_features/02-colorschemes.md deleted file mode 100644 index 1a681c03..00000000 --- a/_features/02-colorschemes.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -author: mallowigi -featimg: colorschemes.svg -title: Colorful color schemes ---- -A set of colorful color schemes with support for 60+ languages diff --git a/_features/03-icons.md b/_features/03-icons.md deleted file mode 100644 index e3fae7a5..00000000 --- a/_features/03-icons.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -author: mallowigi -featimg: icons-folder.svg -title: Material Icons ---- -Replace icons with Material Design icons and Brand icons. diff --git a/_features/04-components.md b/_features/04-components.md deleted file mode 100644 index cb95d865..00000000 --- a/_features/04-components.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -author: mallowigi -featimg: background.svg -title: Material Components ---- -Redesign components' appearance: buttons, text fields, background, tabs... diff --git a/_features/05-customizable.md b/_features/05-customizable.md deleted file mode 100644 index ce832d2c..00000000 --- a/_features/05-customizable.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -author: mallowigi -featimg: customizable.svg -title: Customizable ---- -Lots of options to customize the appearance to your taste. diff --git a/_features/06-extensible.md b/_features/06-extensible.md deleted file mode 100644 index 8586c345..00000000 --- a/_features/06-extensible.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -author: mallowigi -featimg: extensible.svg -title: Easily extensible ---- -Easily extensible for custom themes, schemes and icon associations. diff --git a/astro.config.mjs b/astro.config.mjs index 5f30a46a..b588941a 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -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. @@ -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'], @@ -68,5 +89,6 @@ export default defineConfig({ }, }, }), + mdx(), ], }); diff --git a/docs/reference/color-palette.md b/docs/reference/color-palette.md deleted file mode 100644 index f80e28cc..00000000 --- a/docs/reference/color-palette.md +++ /dev/null @@ -1,53 +0,0 @@ ---- -layout: docs -title: Color Palette -group: reference -toc: true -comments: true - -previous: - url: '/docs/icons/associations-editor' - title: Icon Associations Editor -next: - url: '/docs/reference/file-icons' - title: File Icons ---- - -You can find here a reference of all colors used in the themes. -{:class='title'} - -{% include carbonads.html %} - -## Material themes - - - - - -## Other themes - - - - - - \ No newline at end of file diff --git a/e2e/content-components.spec.ts b/e2e/content-components.spec.ts new file mode 100644 index 00000000..f40ca46a --- /dev/null +++ b/e2e/content-components.spec.ts @@ -0,0 +1,77 @@ +import fs from 'node:fs'; +import { load } from 'js-yaml'; +import { expect, test } from '@playwright/test'; + +const readYaml = (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>('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'); + }); +}); diff --git a/e2e/landing.spec.ts b/e2e/landing.spec.ts new file mode 100644 index 00000000..89cfc174 --- /dev/null +++ b/e2e/landing.spec.ts @@ -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', + ); + }); +}); diff --git a/e2e/themes.spec.ts b/e2e/themes.spec.ts index 552eee1c..1f356693 100644 --- a/e2e/themes.spec.ts +++ b/e2e/themes.spec.ts @@ -27,7 +27,7 @@ test('the saved theme is on 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(); @@ -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, diff --git a/package.json b/package.json index aed46a94..36c412ee 100644 --- a/package.json +++ b/package.json @@ -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" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 465f7cc9..81043008 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,12 +8,18 @@ importers: .: dependencies: + '@astrojs/mdx': + specifier: 8.1.6 + version: 8.1.6(@astrojs/markdown-satteri@0.4.10)(astro@7.4.12(@netlify/blobs@11.1.9)(@types/node@26.6.6)(esbuild@0.28.1)(yaml@2.9.1)) '@astrojs/starlight': specifier: ^0.43.1 version: 0.43.1(astro@7.4.12(@netlify/blobs@11.1.9)(@types/node@26.6.6)(esbuild@0.28.1)(yaml@2.9.1))(typescript@6.0.3) astro: specifier: ^7.3.6 version: 7.4.12(@netlify/blobs@11.1.9)(@types/node@26.6.6)(esbuild@0.28.1)(yaml@2.9.1) + astro-auto-import: + specifier: 0.6.0 + version: 0.6.0(astro@7.4.12(@netlify/blobs@11.1.9)(@types/node@26.6.6)(esbuild@0.28.1)(yaml@2.9.1)) js-yaml: specifier: 5.5.0 version: 5.5.0 @@ -2120,6 +2126,11 @@ packages: resolution: {integrity: sha512-6KuK/7nZ/2Qh7sGuVEiwxjCxzTY2Pdb5mTo5z1e6/J8BA0tvjR7G8vQJKrQMTqwmnA3UPEyKIFX4YUS1DO1Hvw==} engines: {node: '>=18'} + astro-auto-import@0.6.0: + resolution: {integrity: sha512-ru98hrmIZcLvNIcQWtGHKlYE2C+5+8dp86vGnDiGpdmqcFcG/Tn7uNVGhF1CUkvxNRtE+YZhmWTD94lnxY++rA==} + peerDependencies: + astro: ^7.2.4 + astro-expressive-code@0.44.4: resolution: {integrity: sha512-TxdQ/E1xP7P6gq9Z5XHuLNpWzgOP2xz7aKyW3w2FDkIOkXbcyXh/C7of7E+NYIX3Ws2Oq+Aaliuwy/ewavH+UQ==} peerDependencies: @@ -7770,6 +7781,11 @@ snapshots: ast-module-types@6.0.2: {} + astro-auto-import@0.6.0(astro@7.4.12(@netlify/blobs@11.1.9)(@types/node@26.6.6)(esbuild@0.28.1)(yaml@2.9.1)): + dependencies: + acorn: 8.19.0 + astro: 7.4.12(@netlify/blobs@11.1.9)(@types/node@26.6.6)(esbuild@0.28.1)(yaml@2.9.1) + astro-expressive-code@0.44.4(astro@7.4.12(@netlify/blobs@11.1.9)(@types/node@26.6.6)(esbuild@0.28.1)(yaml@2.9.1)): dependencies: astro: 7.4.12(@netlify/blobs@11.1.9)(@types/node@26.6.6)(esbuild@0.28.1)(yaml@2.9.1) diff --git a/src/components/content/AccentColors.astro b/src/components/content/AccentColors.astro new file mode 100644 index 00000000..434c391b --- /dev/null +++ b/src/components/content/AccentColors.astro @@ -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'; +--- + +
+ {accentColors.map((color) => ( + + ))} +
+ + diff --git a/src/components/content/ChromeThemes.astro b/src/components/content/ChromeThemes.astro new file mode 100644 index 00000000..4717cd3f --- /dev/null +++ b/src/components/content/ChromeThemes.astro @@ -0,0 +1,52 @@ +--- +// Replaces _includes/chromethemes.html. Reads the page's `chromeThemes` front matter +// (previously `gallery.themes`). +const { chromeThemes = [] } = Astro.locals.starlightRoute.entry.data; +--- + +
+ {chromeThemes.map((theme) => ( + +
+ {theme.name} +
{theme.name}
+
+
+ ))} +
+ + diff --git a/src/components/content/ColorSwatch.astro b/src/components/content/ColorSwatch.astro new file mode 100644 index 00000000..134f24d5 --- /dev/null +++ b/src/components/content/ColorSwatch.astro @@ -0,0 +1,71 @@ +--- +// Replaces _includes/color.html and color2.html: a gradient (dark → light) or a solid color swatch. +// Usage: , or . +import type { AccentColor, PaletteColor } from '../../data/site'; +import type { Theme } from '../../data/themes'; + +interface Props { + color?: PaletteColor | AccentColor; + theme?: Theme; + field?: keyof Theme; +} + +const { color, theme, field } = Astro.props; + +const capitalize = (value: string) => + value.charAt(0).toUpperCase() + value.slice(1); + +let name = ''; +let title = ''; +let style = ''; +let tags: string[] = []; +const isGradient = !!color && 'dark' in color; + +if (color && 'dark' in color) { + name = capitalize(color.name); + title = `${color.dark} - ${color.light}`; + style = `background: linear-gradient(to right, ${color.dark} 0%, ${color.light} 100%)`; + tags = color.tags ?? []; +} else if (color) { + name = capitalize(color.name); + title = color.color; + style = `background: ${color.color}; color: ${color.light ? 'black' : 'white'}`; +} else if (theme && field) { + const value = String(theme[field]); + + name = capitalize(theme.name); + title = value; + style = `background: ${value}; color: ${theme.light ? 'black' : 'white'}`; +} +--- + +
+ {name} + {tags.length > 0 &&

Tags: {tags.join(', ')}

} +
+ + diff --git a/src/components/content/Figure.astro b/src/components/content/Figure.astro new file mode 100644 index 00000000..4c3970c4 --- /dev/null +++ b/src/components/content/Figure.astro @@ -0,0 +1,61 @@ +--- +// Replaces _includes/figure.html. Authors pass the same `content` / `caption` the Liquid include took. +interface Props { + content: string; + caption: string; +} + +const { content, caption } = Astro.props; + +// The old include produced `/img//screens/...` because `content` started with a slash; collapse it. +const src = `/img/${content}`.replace(/\/{2,}/g, '/'); +--- + +
+ + {caption} + + +
{caption}
+
+ + diff --git a/src/components/content/Gallery.astro b/src/components/content/Gallery.astro new file mode 100644 index 00000000..2e683e9d --- /dev/null +++ b/src/components/content/Gallery.astro @@ -0,0 +1,206 @@ +--- +// Replaces _includes/gallery_lightbox.html: a masonry of figure cards that open in a small lightbox. +// Reads the page's `gallery` front matter (same shape as the Jekyll one), so authors just write . +const { gallery = [] } = Astro.locals.starlightRoute.entry.data; +const images = gallery.flatMap((group) => group.images); +--- + +
+ {images.map((image, index) => ( +
+ + {image.alttext} + + +
{image.alttext}
+
+ ))} +
+ + + + + +
+ +
+
+ + +
+ + + + diff --git a/src/components/content/PaletteColors.astro b/src/components/content/PaletteColors.astro new file mode 100644 index 00000000..c7d34052 --- /dev/null +++ b/src/components/content/PaletteColors.astro @@ -0,0 +1,17 @@ +--- +// Replaces `{% for color in site.data.colors %}{% include color.html %}{% endfor %}` (Material palette). +import { colors } from '../../data/site'; +import ColorSwatch from './ColorSwatch.astro'; +--- + +
+ {colors.map((color) => ( + + ))} +
+ + diff --git a/src/components/content/RecommendedPlugins.astro b/src/components/content/RecommendedPlugins.astro new file mode 100644 index 00000000..f13742c2 --- /dev/null +++ b/src/components/content/RecommendedPlugins.astro @@ -0,0 +1,24 @@ +--- +// Replaces _includes/recommended-plugins.html, fed by src/data/recommendedPlugins.yml. +import { recommendedPlugins } from '../../data/site'; +--- + + + + + + + + + + + {recommendedPlugins.map((plugin) => ( + + + + + ))} + +
TitleDescription
+ {plugin.title} + {plugin.description}
diff --git a/src/components/content/ThemeCard.astro b/src/components/content/ThemeCard.astro new file mode 100644 index 00000000..6b69358b --- /dev/null +++ b/src/components/content/ThemeCard.astro @@ -0,0 +1,41 @@ +--- +// Replaces _includes/theme-card.html: a card with the theme name and description on its own background. +import type { Theme } from '../../data/themes'; + +interface Props { + theme: Theme; +} + +const { theme } = Astro.props; +const capitalize = (value: string) => + value.charAt(0).toUpperCase() + value.slice(1); +--- + +
  • + {capitalize(theme.name)} +

    {theme.desc}

    +
  • + + diff --git a/src/components/content/ThemeCards.astro b/src/components/content/ThemeCards.astro new file mode 100644 index 00000000..4141deae --- /dev/null +++ b/src/components/content/ThemeCards.astro @@ -0,0 +1,28 @@ +--- +// Replaces `
      {% for theme in site.data.themes. %}{% include theme-card.html %}`. +// Usage: +import { themeGroups } from '../../data/themes'; +import ThemeCard from './ThemeCard.astro'; + +interface Props { + groups: string[]; +} + +const list = Astro.props.groups.flatMap((group) => themeGroups[group] ?? []); +--- + +
        + {list.map((theme) => ( + + ))} +
      + + diff --git a/src/components/content/ThemeColors.astro b/src/components/content/ThemeColors.astro new file mode 100644 index 00000000..4059c0ce --- /dev/null +++ b/src/components/content/ThemeColors.astro @@ -0,0 +1,31 @@ +--- +// Replaces `{% for theme in site.data.themes. %}{% include color.html color=theme field="..." %}`: +// one swatch per theme for a given theme property, e.g. . +import { themes } from '../../data/themes'; +import type { Theme } from '../../data/themes'; +import ColorSwatch from './ColorSwatch.astro'; + +interface Props { + field: keyof Theme; +} + +const { field } = Astro.props; +--- + +
      + {themes.map((theme) => ( + + ))} +
      + + diff --git a/src/components/content/ThemePalette.astro b/src/components/content/ThemePalette.astro new file mode 100644 index 00000000..7dd710d8 --- /dev/null +++ b/src/components/content/ThemePalette.astro @@ -0,0 +1,129 @@ +--- +// Replaces _includes/theme.html: the full color palette of one theme, each row styled with its own color. +import type { Theme } from '../../data/themes'; + +interface Props { + theme: Theme; +} + +type Row = [ + label: string, + key: keyof Theme, + css: (t: Theme, value: string) => string, +]; + +const text = (_: Theme, value: string) => `color: ${value}`; +const fill = (_: Theme, value: string) => `background: ${value}`; +const none = () => ''; + +const sections: Row[][] = [ + [ + ['Background', 'background', none], + ['Foreground', 'foreground', none], + ['Text', 'text', text], + [ + 'Selection Background', + 'selectBg', + (t, v) => `background: ${v}; color: ${t.selectFg}`, + ], + [ + 'Selection Foreground', + 'selectFg', + (t, v) => `background: ${t.selectBg}; color: ${v}`, + ], + ['Buttons', 'button', (t, v) => `background: ${v}; color: ${t.text}`], + ['Second Background', 'second', fill], + ['Disabled', 'disabled', text], + ['Contrast', 'contrast', fill], + ['Active', 'table', fill], + ['Border', 'border', (_, v) => `border: 2px solid ${v}`], + ['Highlight', 'hl', fill], + ['Tree', 'tree', (t, v) => `background: ${v}; color: ${t.selectFg}`], + ['Notifications', 'notif', fill], + ['Accent Color', 'accent', text], + ['Excluded Files Color', 'excluded', fill], + ], + [ + ['Green Color', 'green', text], + ['Yellow Color', 'yellow', text], + ['Blue Color', 'blue', text], + ['Red Color', 'red', text], + ['Purple Color', 'purple', text], + ['Orange Color', 'orange', text], + ['Cyan Color', 'cyan', text], + ['Gray Color', 'gray', text], + ['White/Black Color', 'white', text], + ['Error Color', 'error', text], + ], + [ + ['Comments Color', 'comments', text], + ['Variables Color', 'vars', text], + ['Links Color', 'links', text], + ['Functions Color', 'functions', text], + ['Keywords Color', 'keywords', text], + ['Tags Color', 'tags', text], + ['Strings Color', 'strings', text], + ['Operators Color', 'operators', text], + ['Attributes Color', 'attributes', text], + ['Numbers Color', 'numbers', text], + ['Parameters Color', 'parameters', text], + ], +]; + +const { theme } = Astro.props; +const capitalize = (value: string) => + value.charAt(0).toUpperCase() + value.slice(1); +--- + +
    • + {capitalize(theme.name)} + + {sections.map((rows, index) => ( + <> + {index > 0 &&
      } + {rows.map(([label, key, css]) => { + const value = String(theme[key]); + + return ( +

      + {label}: {value} +

      + ); + })} + + ))} +
    • + + diff --git a/src/components/content/ThemePalettes.astro b/src/components/content/ThemePalettes.astro new file mode 100644 index 00000000..363b6aba --- /dev/null +++ b/src/components/content/ThemePalettes.astro @@ -0,0 +1,28 @@ +--- +// Replaces `
        {% for theme in site.data.themes. %}{% include theme.html %}`. +// Usage: +import { themeGroups } from '../../data/themes'; +import ThemePalette from './ThemePalette.astro'; + +interface Props { + groups: string[]; +} + +const list = Astro.props.groups.flatMap((group) => themeGroups[group] ?? []); +--- + +
          + {list.map((theme) => ( + + ))} +
        + + diff --git a/src/components/content/Wallpapers.astro b/src/components/content/Wallpapers.astro new file mode 100644 index 00000000..e9db2de5 --- /dev/null +++ b/src/components/content/Wallpapers.astro @@ -0,0 +1,31 @@ +--- +// Replaces the `{% for wallpaper in page.wallpapers %}` loop. Reads the page's `wallpapers` front matter. +// Wallpaper filenames are full URLs (hosted on the image CDN), unlike gallery images. +const { wallpapers = [] } = Astro.locals.starlightRoute.entry.data; +--- + +
        + {wallpapers.map((wallpaper) => ( + {wallpaper.alttext} + ))} +
        + + diff --git a/src/components/landing/Features.astro b/src/components/landing/Features.astro new file mode 100644 index 00000000..fc970b0f --- /dev/null +++ b/src/components/landing/Features.astro @@ -0,0 +1,73 @@ +--- +// Replaces the _features collection + feature.html: six tiles read from src/data/features.yml. +import { readData } from '../../data/load'; + +interface Feature { + title: string; + image: string; + text: string; +} + +const features = readData('features.yml'); +--- + +
        +

        Features

        + +
          + {features.map((feature) => ( +
        • + +

          {feature.title}

          +

          {feature.text}

          +
        • + ))} +
        +
        + + diff --git a/src/components/landing/Sponsors.astro b/src/components/landing/Sponsors.astro new file mode 100644 index 00000000..b971530c --- /dev/null +++ b/src/components/landing/Sponsors.astro @@ -0,0 +1,41 @@ +--- +// The 10 OpenCollective sponsor avatars (slots 0-9); an unfilled slot just renders a blank avatar. +const slots = Array.from({ length: 10 }, (_, index) => index); +const base = + 'https://opencollective.com/atom-material-themes-and-plugins/sponsor'; +--- + +
        +

        Sponsors

        + +
        + {slots.map((slot) => ( + + {`Sponsor + + ))} +
        +
        + + diff --git a/src/components/landing/ThemeChooser.astro b/src/components/landing/ThemeChooser.astro new file mode 100644 index 00000000..cfc10f8d --- /dev/null +++ b/src/components/landing/ThemeChooser.astro @@ -0,0 +1,149 @@ +--- +// The landing page theme chooser. Swatches switch the whole site theme through the same +// window.materialTheme.apply() the floating button uses; the screenshot follows the current theme, +// so it also updates when the theme is changed from the floating button. +import { GROUP_LABELS, themeGroups } from '../../data/themes'; + +const featured = ['material', 'material2']; +const others = ['other', 'other2', 'other3']; +const sections = [ + { title: 'Available Themes', groups: featured }, + { title: 'Check out the other themes', groups: others }, +]; +--- + +
        + {sections.map((section, index) => ( + <> +

        {section.title}

        + + {section.groups.map((group) => ( +
          + {themeGroups[group].map((theme) => ( +
        • +
        • + ))} +
        + ))} + + {index === 0 && ( + + Oceanic theme screenshot + + )} + + ))} +
        + + + + diff --git a/src/components/overrides/ThemeProvider.astro b/src/components/overrides/ThemeProvider.astro index ecb593b7..b81850b9 100644 --- a/src/components/overrides/ThemeProvider.astro +++ b/src/components/overrides/ThemeProvider.astro @@ -49,5 +49,11 @@ const script = `(() => { })();`; --- - -