Skip to content

Commit

Permalink
docs: uxdot elements to typescript (#1812)
Browse files Browse the repository at this point in the history
* docs: sidenav fixes

also ports uxdot-sidenav elements to typescript
also loads global css on each page
also reduces dom payload for uxdot-sidenav elements

chore: fix serve command

docs: fix tokens sidenav

* chore: update node version

* docs: reduce jspm cdn usage

* fix(icon): improve ssr performance

* docs: port toc to typescript

* feat(skip-link): href attr

* docs: replace uxdot-skip-navigation with rh-skip-link

* fix(alert): toast methods styles and types

* docs: port uxdot-copy-button to ts

* docs: port uxdot-copy-permalink to typescript

* docs: port uxdot-best-practice to typescript

* docs: port uxdot-feedback to typescript

* docs: port uxdot-feedback to typescript

* fix(footer): universal footer ssr

* docs: port uxdot-header to typescript

also improve layout esp. on mobile

* docs: port uxdot-header to typescript

* docs: port uxdot-masthead to typescript

* docs: port uxdot-search to typescript

* docs: port uxdot-repo-status-list to typescript

* chore: gitignore

* chore: gitignore

* Revert "feat(skip-link): href attr"

This reverts commit b9a28ea.

* chore: build
  • Loading branch information
bennypowers authored Sep 1, 2024
1 parent ea0d84a commit 1ec3653
Show file tree
Hide file tree
Showing 86 changed files with 1,774 additions and 1,944 deletions.
4 changes: 4 additions & 0 deletions .changeset/eager-spiders-stay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
"@rhds/elements": patch
---
`<rh-footer-universal>`: improve compatibility with <abbr title="Server side rendering">SSR</abbr>
4 changes: 4 additions & 0 deletions .changeset/moody-cobras-happen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
"@rhds/elements": patch
---
`<rh-alert>`: fixed styles and typings for the `RhAlert.toast()` method
4 changes: 4 additions & 0 deletions .changeset/sixty-cases-like.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
"@rhds/elements": patch
---
`<rh-icon>`: prevent error when hydrating server-side-rendered icons
2 changes: 1 addition & 1 deletion .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18'
node-version: '22'
cache: npm

- uses: google/wireit@setup-github-actions-caching/v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gzip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
node-version: '22'
cache: npm
- uses: preactjs/compressed-size-action@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18'
node-version: '22'
cache: npm

- uses: google/wireit@setup-github-actions-caching/v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: Configure node version
uses: actions/setup-node@v3
with:
node-version: '18'
node-version: '22'
cache: npm

- uses: google/wireit@setup-github-actions-caching/v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/validate-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
node-version: '22'
cache: 'npm'
- run: npm i semantic-release @changesets/read --prefer-offline
- uses: actions/github-script@v7
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ node_modules
_site
docs/pfe.min*
docs/assets/playgrounds/
docs/assets/javascript/elements/*.js
!docs/assets/javascript/elements/uxdot-example.js
!docs/assets/javascript/elements/uxdot-installation-tabs.js
!docs/assets/javascript/elements/uxdot-pattern.js
docs/_data/playgrounds.json

# Build artifacts
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v20.10.0
v22.7.0
2 changes: 2 additions & 0 deletions .stylelintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ rules:
ignoreTypes:
- heading
- actions
- rendered
- pending

selector-pseudo-element-no-unknown:
- true
Expand Down
7 changes: 2 additions & 5 deletions docs/_includes/layouts/base.njk
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<head>
{% include "../partials/meta.html" %}

<link rel="stylesheet" href="/assets/packages/@rhds/tokens/css/global.css">
<link rel="stylesheet" href="/styles/styles.css">

{# On browsers that don't yet support native declarative shadow DOM, a
Expand All @@ -41,14 +42,10 @@
</noscript>

{% include "../partials/javascript/global.html" %}
{%- if hasToc %}
<link rel="stylesheet" href="/assets/javascript/elements/uxdot-toc-lightdom.css">
<script type="module" src="/assets/javascript/elements/uxdot-toc.js"></script>
{%- endif %}
</head>

<body dsd-pending class="{{ extraPageClasses }}">
<uxdot-skip-navigation><a href="#main">Skip to main content</a></uxdot-skip-navigation>
<rh-skip-link><a href="#main">Skip to main content</a></rh-skip-link>
{{ content | safe }}
</body>
</html>
8 changes: 3 additions & 5 deletions docs/_includes/layouts/pages/basic.njk
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@ importElements:

{% include 'partials/component/header.njk' %}
{% if hasToc and (content | toc).length > 0 %}
<aside>
<uxdot-toc summary="On this page">
{{ content | toc | safe }}
</uxdot-toc>
</aside>
<uxdot-toc summary="On this page">
{{ content | toc | safe }}
</uxdot-toc>
{% endif %}

<div class="container">
Expand Down
13 changes: 4 additions & 9 deletions docs/_includes/layouts/pages/elements.njk
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,8 @@ eleventyComputed:
- rh-tag
- "{{ doc.tagName or element.tagName }}"
---
{%- if hasToc %}
<link rel="stylesheet" href="/assets/javascript/elements/uxdot-toc-lightdom.css">
{%- endif %}
{% if doc.pageTitle == 'Code' %}
<link rel="stylesheet" href="{{ '/styles/pages/code.css' | url }}">
<link rel="stylesheet" href="/styles/pages/code.css">
{% endif %}
<link rel="stylesheet" href="/assets/packages/@rhds/elements/elements/rh-table/rh-table-lightdom.css">
<link rel="stylesheet" href="/assets/packages/@rhds/tokens/css/global.css">
Expand Down Expand Up @@ -72,11 +69,9 @@ eleventyComputed:
</uxdot-header>

{% if hasToc and (content | toc).length > 0 %}
<aside>
<uxdot-toc summary="On this page">
{{ content | toc | safe }}
</uxdot-toc>
</aside>
<uxdot-toc summary="On this page">
{{ content | toc | safe }}
</uxdot-toc>
{% endif %}

<div class="container">
Expand Down
14 changes: 3 additions & 11 deletions docs/_includes/layouts/pages/pattern.njk
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,10 @@ importElements:
- rh-subnav
- rh-code-block
---
{% if hasToc %}
<link rel="stylesheet" href="/assets/javascript/elements/uxdot-toc-lightdom.css">
{% endif %}
<link rel="stylesheet" href="/styles/pages/backpage.css">

<script type="module" src="/assets/javascript/elements/uxdot-feedback.js"></script>
<script type="module" src="/assets/javascript/elements/uxdot-pattern.js"></script>
{% if hasToc %}
<script type="module" src="/assets/javascript/elements/uxdot-toc.js"></script>
{% endif %}
{% if tokenSearch %}
<script type="module" src="/assets/javascript/elements/uxdot-search.js"></script>
<script type="module" src="/assets/javascript/tokens.js"></script>
Expand All @@ -29,11 +23,9 @@ importElements:

{% include 'partials/component/header.njk' %}
{% if hasToc and (content | toc).length > 0 %}
<aside>
<uxdot-toc summary="On this page">
{{ content | toc | safe }}
</uxdot-toc>
</aside>
<uxdot-toc summary="On this page">
{{ content | toc | safe }}
</uxdot-toc>
{% endif %}

<div class="container">
Expand Down
145 changes: 59 additions & 86 deletions docs/_includes/partials/component/sidenav.njk
Original file line number Diff line number Diff line change
@@ -1,92 +1,65 @@
<uxdot-sidenav trigger="hamburger">
<ul>
<uxdot-sidenav-item href="/" {{ 'active' if page.url === '/'}}>Home</uxdot-sidenav-item>
{#
Loop through nav dropdowns
This uses data passed in via the eleventy.config.cjs file in the root
TODO: more this data to a global data, ideally this data would be normalized
prior to getting to the component template level.
#}
{%- for link in sideNavDropdowns -%}
{%- set active = link.url === page.url -%}
{%- set open = link.url in page.url -%}
<li>
<uxdot-sidenav-dropdown {{ 'open' if open }}>
<details {{ 'open' if open }}>
<summary>{{ link.title }}</summary>
<uxdot-sidenav-dropdown-menu>
{% if link.collection === "elementDocs" %}
{%- set active = '/elements/' === page.url -%}
<uxdot-sidenav-dropdown-menu-item href="/elements/"
{{ 'active' if active }}>All elements</uxdot-sidenav-dropdown-menu-item>
{%- for tagName, docs in collections.elementDocs | groupby('tagName') -%}
{%- set fst = docs[0] -%}
{%- set slug = fst.slug -%}
{%- set href = '/elements/' + slug + '/' -%}
{%- set active = href === page.url -%}
{%- set name = (fst.alias) or (slug | deslugify) %}
{%- set planned = isPlanned(repoStatus, name) %}
{% if not (tagName in comingSoonItems) %}
<uxdot-sidenav-dropdown-menu-item href="{{ href }}"
{{ 'active' if active }}>
{{ (fst.alias) or (slug | deslugify) }}{% if planned %} <rh-tag icon="notification-fill" color="gray">Planned</rh-tag>{% endif %}
</uxdot-sidenav-dropdown-menu-item>
{% endif %}
{%- endfor -%}
{% else %}
{% if link.collection === 'token' %}
{%- set active = page.url === "/tokens/" %}
<uxdot-sidenav-dropdown-menu-item href="/tokens/"
{{ 'active' if active }}>Overview</uxdot-sidenav-dropdown-menu-item>
{% endif -%}
<uxdot-sidenav-item href="/" {{ 'active' if page.url === '/'}}>Home</uxdot-sidenav-item>
{#
Loop through nav dropdowns
This uses data passed in via the eleventy.config.cjs file in the root
TODO: more this data to a global data, ideally this data would be normalized
prior to getting to the component template level.
#}
{%- for link in sideNavDropdowns -%}
{%- set active = link.url === page.url -%}
{%- set open = link.url in page.url -%}
<uxdot-sidenav-dropdown {{ 'open' if open }}>
<details {{ 'open' if open }}>
<summary>{{ link.title }}</summary>
<uxdot-sidenav-dropdown-menu>
{% if link.collection === "elementDocs" %}
{%- set active = '/elements/' === page.url -%}
<uxdot-sidenav-dropdown-menu-item href="/elements/" {{ 'active' if active }}>All elements</uxdot-sidenav-dropdown-menu-item>
{%- for tagName, docs in collections.elementDocs | groupby('tagName') -%}
{%- set fst = docs[0] -%}
{%- set slug = fst.slug -%}
{%- set href = '/elements/' + slug + '/' -%}
{%- set active = href === page.url -%}
{%- set name = (fst.alias) or (slug | deslugify) %}
{%- set planned = isPlanned(repoStatus, name) %}
{% if not (tagName in comingSoonItems) %}
<uxdot-sidenav-dropdown-menu-item href="{{ href }}" {{ 'active' if active }}>
{{- fst.alias or (slug | deslugify) -}}
{%- if planned -%}<rh-tag icon="notification-fill" color="gray">Planned</rh-tag>{%- endif -%}
</uxdot-sidenav-dropdown-menu-item>
{% endif %}
{%- endfor -%}
{% else %}
{% if link.collection === 'token' %}
{%- set active = page.url === "/tokens/" %}
<uxdot-sidenav-dropdown-menu-item href="/tokens/" {{ 'active' if active }}>Overview</uxdot-sidenav-dropdown-menu-item>
{% endif -%}

{%- if (link.collection !== 'elementDocs') and (link.collection !== 'token') -%}
{%- set sortedOn = "data.order" %}
{%- set sideNavCollection = collections[link.collection] | sort(attribute=sortedOn, case_sensitive=true) %}
{% else %}
{%- set sideNavCollection = collections[link.collection] %}
{%- endif -%}
{%- if (link.collection !== 'elementDocs') and (link.collection !== 'token') -%}
{%- set sortedOn = "data.order" %}
{%- set sideNavCollection = collections[link.collection] | sort(attribute=sortedOn, case_sensitive=true) %}
{% else %}
{%- set sideNavCollection = collections[link.collection] %}
{%- endif -%}

{%- for sublink in sideNavCollection -%}
{%- set active = sublink.url === page.url -%}
<uxdot-sidenav-dropdown-menu-item href="{{ sublink.url }}"
{{ 'active' if active }}>
{{- (sublink.data.sidenavTitle)
or (sublink.data.title or '' | capitalize)
or (sublink.title or ''| capitalize) -}}
</uxdot-sidenav-dropdown-menu-item>
{%- endfor -%}
{% endif %}
</uxdot-sidenav-dropdown-menu>
</details>
</uxdot-sidenav-dropdown>
</li>
{% endfor %}
{%- for sublink in sideNavCollection -%}
{%- set active = sublink.url === page.url -%}
<uxdot-sidenav-dropdown-menu-item href="{{ sublink.url }}" {{ 'active' if active }}>
{{- (sublink.data.sidenavTitle or sublink.data.title or sublink.title) | capitalize -}}
</uxdot-sidenav-dropdown-menu-item>
{%- endfor -%}
{% endif %}
</uxdot-sidenav-dropdown-menu>
</details>
</uxdot-sidenav-dropdown>

<li>
<uxdot-sidenav-item>
<a href="/design-code-status/">Design/code status</a>
</uxdot-sidenav-item>
</li>
{% endfor %}

<li>
<uxdot-sidenav-item>
<a href="/release-notes/">Release notes</a>
</uxdot-sidenav-item>
</li>

<li>
<uxdot-sidenav-item>
<a href="{{ '/support/' | url }}">Get support</a>
</uxdot-sidenav-item>
</li>

{%- if runMode == 'watch' -%}
<li>
<uxdot-sidenav-item>
<a href="/cheatsheet" class="link">Cheat sheet!</a>
</uxdot-sidenav-item>
</li>
{%- endif -%}
</ul>
<uxdot-sidenav-item href="/design-code-status/">Design/code status</uxdot-sidenav-item>
<uxdot-sidenav-item href="/release-notes/">Release notes</uxdot-sidenav-item>
<uxdot-sidenav-item href="/support/">Get support</uxdot-sidenav-item>
{%- if runMode == 'watch' -%}
<uxdot-sidenav-item class="link" href="/cheatsheet">Cheat sheet!</uxdot-sidenav-item>
{%- endif -%}
</uxdot-sidenav>
6 changes: 6 additions & 0 deletions docs/_includes/partials/javascript/global.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,17 @@

{# only load components that need hydrated (aka interactivity) #}
<script type="module">
import '@rhds/elements/rh-footer/rh-footer-universal.js';
import '/assets/javascript/elements/uxdot-copy-permalink.js';
import '/assets/javascript/elements/uxdot-sidenav.js';
import '/assets/javascript/elements/uxdot-example.js';
</script>

{%- if hasToc %}
<link rel="stylesheet" href="/assets/javascript/elements/uxdot-toc-lightdom.css">
<script type="module" src="/assets/javascript/elements/uxdot-toc.js"></script>
{%- endif %}

<script async src="https://ga.jspm.io/npm:[email protected]/dist/es-module-shims.js"></script>


Loading

0 comments on commit 1ec3653

Please sign in to comment.