Skip to content

docs: add Styling guide (adopted style sheets, css helper, CSS modules) - #182

Open
megheaiulian wants to merge 2 commits into
mainfrom
docs/styling-guide
Open

megheaiulian wants to merge 2 commits into
mainfrom
docs/styling-guide

Conversation

@megheaiulian

Copy link
Copy Markdown
Contributor

Summary

Adds a long-requested Styling guide and fixes two doc-site defects found along the way.

New: guides/styling page

Covers the styling APIs that have zero documentation today despite heavy real-world use (123+ css imports across Neovici's cosmoz components; styleSheets used by nearly every modern component):

  • Inline <style> in templates — when it's fine, when it's not
  • Adopted style sheets via the styleSheets option + the css tagged template, with the *.style.ts file convention used in the wild as the recommended pattern
  • Theming/composition with css interpolation
  • Renderer-level App.styleSheets and its precedence over options
  • The sheet() helper for standalone CSSStyleSheet construction
  • Native CSS modulesimport styles from './my-app.css' with { type: 'css' } works out of the box since styleSheets passes through existing CSSStyleSheet instances; includes bundler notes
  • Light DOM — plainly documents that styleSheets requires a shadow root to adopt into, with the document.adoptedStyleSheets alternative
  • API reference table for css, sheet, styleSheets, shadowRootInit, useShadowDOM

Also wires the page into the sidebar and guides index, and fixes the README component() Options signature, which was missing shadowRootInit and styleSheets entirely.

Fixed: silently-broken card icons

Starlight silently skips unknown icon names (Icons[name]undefined), so all 23 cards across the guides index, hooks index and homepage rendered without icons — they were authored with names that don't exist in Starlight's built-in set (settings, layers, terminal, view-in-ar, repeat, memory, bookmark, …).

Remapped all cards to semantically-close built-in icons (e.g. Attributes → setting, useLayoutEffect → clock, useMemo → database). Verified post-build: all 9/10/4 cards now render <svg> icons.

Verification

  • npm run build in docs/ — 23 pages, zero warnings
  • Programmatic check: every icon="…" in the repo validated against Starlight's actual icon set
  • Post-build HTML inspection confirms icons render inside all card articles

Notes for review

  • All documented behavior was verified against source (src/component.ts L98–121 for styleSheets/shadowRootInit/useShadowDOM; src/util.ts for css/sheet) and cross-checked against production usage patterns across the cosmoz-* component family
  • Two logical commits: the guide itself, then the icon repairs

- New guides/styling page covering inline <style>, the styleSheets
  option, the css tagged template (with interpolation/composition
  for theming), renderer-level styleSheets precedence, the sheet()
  helper, and native CSS modules (import ... with { type: 'css' })
  which work out of the box since styleSheets accepts existing
  CSSStyleSheet instances
- Documents light DOM behavior: styleSheets requires a shadow root
  to adopt into, with document.adoptedStyleSheets alternative
- Includes API reference table for css, sheet, styleSheets,
  shadowRootInit and useShadowDOM options
- Add Styling card to guides index and sidebar entry in
  astro.config.mjs; remap the guides index card icons to valid
  Starlight built-in names while there
- Fix README component() Options signature: add shadowRootInit and
  styleSheets, which were missing entirely
Starlight silently skips unknown icon names (Icons[name] -> undefined),
so every Card on the hooks index rendered icon-less: they were authored
with non-existent names (repeat, share, sync, settings, speed, memory,
layers, filter-list, bookmark).

Remap all hook cards to semantically-close built-in icons:
useCallback -> link, useContext -> external, useEffect -> analytics,
useHost -> setting, useLayoutEffect -> clock, useMemo -> database,
useProperty -> pen, useReducer -> list-format, useRef -> magnifier.

Verified post-build: all 10 hook cards now render <svg> icons.
@changeset-bot

changeset-bot Bot commented Sep 7, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 5fe8a61

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@netlify

netlify Bot commented Sep 7, 2026

Copy link
Copy Markdown

Deploy Preview for pionjs ready!

Name Link
🔨 Latest commit 5fe8a61
🔍 Latest deploy log https://app.netlify.com/projects/pionjs/deploys/6a9ecd4cebbb7d0008ff96ca
😎 Deploy Preview https://deploy-preview-182--pionjs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant