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
2 changes: 2 additions & 0 deletions .changeset/docs-component-groups.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
2 changes: 2 additions & 0 deletions .changeset/docs-component-previews-check.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
2 changes: 2 additions & 0 deletions .changeset/docs-component-previews-grayscale-text.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
2 changes: 2 additions & 0 deletions .changeset/docs-component-previews.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
2 changes: 2 additions & 0 deletions .changeset/docs-landing-page.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
16 changes: 16 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ jobs:
pnpm --filter @cscfi/csc-ui-documentation run generate
pnpm --filter @cscfi/csc-ui-documentation run test:viewport

# The /components overview's pictures (public/previews) must still show
# each component as the generated site renders it: a change to a
# component's look fails here until `pnpm previews` has re-taken them.
- name: Docs component previews up to date
run: pnpm --filter @cscfi/csc-ui-documentation run test:previews

# `pnpm test` runs vitest from the repo root, so attachments land in
# `<root>/.vitest`; the per-package path only catches a run started
# inside a package. Both are listed — a failing visual case uploaded
Expand All @@ -119,6 +125,16 @@ jobs:
packages/**/.vitest/attachments/**
if-no-files-found: ignore

# The fresh pictures of the previews that no longer match, to compare
# with the committed ones.
- name: Upload out-of-date component previews
if: failure()
uses: actions/upload-artifact@v4
with:
name: component-previews
path: packages/csc-ui-documentation/.output/previews-check/**
if-no-files-found: ignore

# The behaviour specs on Firefox and WebKit (ADR-0077), beside the Chromium
# run above: one runner per engine, so a slow engine never holds up the
# other or crowds the Chromium visual baselines. Builds first because the
Expand Down
16 changes: 16 additions & 0 deletions CONTEXT.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ A web-component design-system library implemented as Vue SFCs compiled to custom

## Language

**CSC Design System**:
The design language of CSC's services — the semantic tokens and colour **families**, the **theme modes**, the accessibility rules, the component designs — and the documentation site that presents it (design-system.csc.fi). What the site and its landing page name and pitch; **CSC UI** is how a service gets it.
_Avoid_: csc-ui for the whole system, UI kit, style guide

**CSC UI** (`@cscfi/csc-ui`):
The web-component library implementing the **CSC Design System**: the package a service installs, with its **wrapper package**. Versioned and released; the design system is not.
_Avoid_: the design system (it is the implementation), CSC components

**Component**:
A reusable custom element with a stable tag name (e.g. `<c-button>`). The tag is the canonical identifier and survived the 3.x→4.x rewrite unchanged. Consumers depend on the tag, not the package internals.
_Avoid_: Widget, control, element
Expand Down Expand Up @@ -786,6 +794,14 @@ _Avoid_: sub-component (imprecise — conflates composed children with internal-
A component the consumer uses on its own — it keeps a top-level nav entry and its own page. The complement of a **composed child**. A standalone can still be a parent that owns composed children.
_Avoid_: top-level component, root component, main component

**Component group**:
One of the docs site's groupings of **standalone components** — Forms, Overlays, Feedback & status… — by which the landing page's overview, the components overview page and the side navigation list them, every standalone component in exactly one. A presentation choice of the docs, kept out of the **manifest**: nothing about a component's API depends on its group.
_Avoid_: Category (implies a manifest field), section, group alone (a **group label** names a set of form controls)

**Component preview**:
The picture of a **standalone component** on its card on the components overview page, one per **theme mode**. A preview is site content, re-taken from the component's live example whenever the component's look changes; CI fails while a preview no longer matches the component's render.
_Avoid_: Visual baseline (a test fixture of the component's own spec), thumbnail, screenshot (unqualified)

**Flavor**:
The reader's consumption dialect on the docs site: `vue | react | angular | typescript` (TypeScript = framework-free typed custom-element usage). One documentation-wide selection — clicking any example tab or the header switcher changes every example, and the getting-started code blocks, everywhere; persisted per reader (ADR-0020). Also the naming axis for **example variants** (`basic.react.tsx`).
_Avoid_: Framework (TypeScript is not one), consumer (that is the person/app using the library), language, target
Expand Down
272 changes: 272 additions & 0 deletions _plan/csc-ui-landing-page.md

Large diffs are not rendered by default.

146 changes: 6 additions & 140 deletions packages/csc-ui-documentation/app/app.vue
Original file line number Diff line number Diff line change
@@ -1,152 +1,18 @@
<template>
<div class="flex min-h-screen flex-col">
<!-- The bar must fit a 360px phone (plan: fullscreen-panel-and-mobile-docs,
part B): below `sm` only the logo, the three switchers and the burger
remain; the wordmark and badge return at `sm`, the switchers' labels
at `md` (ToolbarMenu). `min-w-0` + `truncate` keep the wordmark on
one line and the control cluster never shrinks off the right edge. -->
<c-toolbar>
<nuxt-link
aria-label="CSC Design System home"
class="flex shrink-0 items-center text-lg font-bold no-underline"
to="/"
>
<c-csc-logo aria-hidden="true" />
</nuxt-link>

<span class="min-w-0 truncate max-sm:hidden">CSC Design System</span>

<span
class="ml-[0.35rem] shrink-0 rounded-full bg-accent px-2 py-[0.1rem] align-middle text-xs font-semibold tracking-wider text-on-accent max-sm:hidden"
>
v{{ corePackage.version }}
</span>

<div class="ml-auto flex shrink-0 items-center gap-2">
<flavor-switcher />

<theme-toggle />

<color-switcher />

<c-navigation-button v-if="isMobile" />
</div>
</c-toolbar>

<div class="flex min-h-0 flex-1">
<!-- Design-system side navigation (dogfooded). `autoheight` is the
component's own host state (viewport minus the 60px toolbar, inner
scroll); `sticky top-15` pins it below the fixed toolbar while
the page scrolls. Both are inert on mobile, where the un-classed
host is display:contents and the drawer inside is fixed. Items use
`.prop`/@select (not href) so navigation stays client-side: each
item's value is its route. -->
<c-side-navigation
:mobile.prop="isMobile"
class="autoheight sticky top-15"
@select="navigateTo($event.detail.value)"
>
<c-side-navigation-title>Guides</c-side-navigation-title>

<c-side-navigation-item
:current.prop="route.path === '/getting-started'"
value="/getting-started"
>
Getting started
</c-side-navigation-item>

<c-side-navigation-item
:current.prop="route.path === '/customization'"
value="/customization"
>
Customization
</c-side-navigation-item>

<c-side-navigation-item
:current.prop="route.path === '/data-visualization'"
value="/data-visualization"
>
Data visualization
</c-side-navigation-item>

<c-side-navigation-item
:current.prop="route.path === '/migration'"
value="/migration"
>
Migration guide
</c-side-navigation-item>

<c-side-navigation-title>Components</c-side-navigation-title>

<c-side-navigation-item
v-for="component in navComponents"
:key="component.tagName"
:current.prop="route.path === `/components/${component.tagName}`"
:value="`/components/${component.tagName}`"
>
{{ component.tagName }}
</c-side-navigation-item>
</c-side-navigation>

<main
class="max-w-420 min-w-0 flex-1 px-5 pt-6 pb-12 md:px-12 md:pt-8 md:pb-16"
>
<nuxt-page />

<!-- Plain links: /v3/ is a static archive the client router does not
know, so it must load as a page of its own. -->
<footer
class="mt-16 flex flex-wrap gap-x-6 gap-y-2 border-t border-border pt-6 text-sm text-on-surface-muted"
>
<a class="underline" href="/v3/">
3.x documentation (archived, unsupported)
</a>

<a class="underline" href="https://github.com/CSCfi/ui">
Source on GitHub
</a>
</footer>
</main>
</div>
</div>
<!-- The docs pages use layouts/default.vue (toolbar, pinned side
navigation); the landing page at `/` uses layouts/landing.vue. -->
<nuxt-layout>
<nuxt-page />
</nuxt-layout>
</template>

<script setup lang="ts">
// The badge names the release these docs were built from: the core package's
// version, which only the Version packages PR changes. `/v3/` archives 3.x.
import corePackage from '../../csc-ui/package.json';

// A stable gutter keeps the page from reflowing when the library's page lock
// (an open c-select list, a c-modal) hides the document scrollbar (ADR-0014).
useHead({
htmlAttrs: {
class: 'scroll-smooth [scrollbar-gutter:stable]',
lang: 'en',
},
});

const { navComponents } = useManifest();

const route = useRoute();

// Viewport breakpoint for the side-navigation drawer mode. Measured from the
// window (the c-* hosts are display:contents and generate no box to observe).
// Defaults to a desktop width so SSR/prerender emits the desktop layout;
// corrected on mount. 1024px keeps the ~300–340px desktop drawer from
// squeezing the content column on tablets.
const width = ref(1280);

const updateWidth = () => {
width.value = window.innerWidth;
};

onMounted(() => {
updateWidth();
window.addEventListener('resize', updateWidth);
});

onBeforeUnmount(() => {
window.removeEventListener('resize', updateWidth);
});

const isMobile = computed(() => width.value < 1024);
</script>
28 changes: 28 additions & 0 deletions packages/csc-ui-documentation/app/assets/site.css
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,34 @@
}
}

/* Component previews (/components): one image per theme mode, keyed on the
same predicate as the Shiki colours above. A hidden lazy image is never
fetched, so a reader downloads only their mode's previews. */
.component-preview-light {
display: block;
}

.component-preview-dark,
[data-theme='dark'] .component-preview-light {
display: none;
}

[data-theme='dark'] .component-preview-dark {
display: block;
}

@media (prefers-color-scheme: dark) {
:root:not([data-theme='light']):not([data-theme='dark'])
.component-preview-light {
display: none;
}

:root:not([data-theme='light']):not([data-theme='dark'])
.component-preview-dark {
display: block;
}
}

.example-shiki .shiki,
.usage .shiki {
border-radius: 0;
Expand Down
8 changes: 5 additions & 3 deletions packages/csc-ui-documentation/app/assets/tailwind.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@
@source not '../examples';

@theme {
/* CSC brand font stack (site-loaded, not the library's concern) — preflight
* picks it up as the document default. */
--font-sans: 'museo-sans', system-ui, sans-serif;
/* The site's typeface, Noto Sans, self-hosted through
* @fontsource-variable/noto-sans (nuxt.config.ts `css`); the library ships
* no font (ADR-0072), so components inherit it. Preflight picks it up as the
* document default. */
--font-sans: 'Noto Sans Variable', system-ui, sans-serif;
/* Keep the exact mono stack the site chrome always used. */
--font-mono: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;

Expand Down
17 changes: 17 additions & 0 deletions packages/csc-ui-documentation/app/components/AppFooter.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<template>
<!-- Plain links: /v3/ is a static archive the client router does not
know, so it must load as a page of its own. -->
<footer
class="flex flex-wrap gap-x-6 gap-y-2 border-t border-border pt-6 text-sm text-on-surface-muted"
>
<a class="underline" href="/v3/">
3.x documentation (archived, unsupported)
</a>

<a class="underline" href="https://github.com/CSCfi/ui">Source on GitHub</a>

<a class="underline" href="https://www.npmjs.com/package/@cscfi/csc-ui">
@cscfi/csc-ui on npm
</a>
</footer>
</template>
81 changes: 81 additions & 0 deletions packages/csc-ui-documentation/app/components/AppSideNavigation.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<template>
<!-- Design-system side navigation (dogfooded). `autoheight` is the
component's own host state (viewport minus the 60px toolbar, inner
scroll); `sticky top-15` pins it below the fixed toolbar while
the page scrolls. Both are inert on mobile, where the un-classed
host is display:contents and the drawer inside is fixed. Items use
`.prop`/@select (not href) so navigation stays client-side: each
item's value is its route. -->
<c-side-navigation
:mobile.prop
class="autoheight sticky top-15"
@select="navigateTo($event.detail.value)"
>
<c-side-navigation-title>Guides</c-side-navigation-title>

<c-side-navigation-item
:current.prop="route.path === '/getting-started'"
value="/getting-started"
>
Getting started
</c-side-navigation-item>

<c-side-navigation-item
:current.prop="route.path === '/customization'"
value="/customization"
>
Customization
</c-side-navigation-item>

<c-side-navigation-item
:current.prop="route.path === '/data-visualization'"
value="/data-visualization"
>
Data visualization
</c-side-navigation-item>

<c-side-navigation-item
:current.prop="route.path === '/migration'"
value="/migration"
>
Migration guide
</c-side-navigation-item>

<c-side-navigation-title>Components</c-side-navigation-title>

<!-- The title takes no link, so the component index is an item. -->
<c-side-navigation-item
:current.prop="route.path === '/components'"
value="/components"
>
Overview
</c-side-navigation-item>

<!-- The components in their groups, as the overview page sections them
(content/component-groups.ts keeps every standalone component in
exactly one). -->
<template v-for="group in COMPONENT_GROUPS" :key="group.id">
<c-side-navigation-title>{{ group.title }}</c-side-navigation-title>

<c-side-navigation-item
v-for="tag in group.tags"
:key="tag"
:current.prop="route.path === `/components/${tag}`"
:value="`/components/${tag}`"
>
{{ tag }}
</c-side-navigation-item>
</template>
</c-side-navigation>
</template>

<script setup lang="ts">
import { COMPONENT_GROUPS } from '~/content/component-groups';

defineProps<{
/** The slide-in drawer instead of the pinned desktop column. */
mobile: boolean;
}>();

const route = useRoute();
</script>
Loading
Loading