Skip to content

Commit

Permalink
docs: code installation tabs (#1366)
Browse files Browse the repository at this point in the history
* docs: code installation tabs

Fixes #1361

* docs: hack a fix for install tabs

* docs: fix another careless error

* docs: doh
  • Loading branch information
bennypowers committed Dec 6, 2023
1 parent 422d627 commit 4b194d8
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 27 deletions.
4 changes: 4 additions & 0 deletions .changeset/tangy-sloths-scream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
"@rhds/elements": patch
---
`<rh-navigation-secondary>`: moves the deprecated `<rh-secondary-nav>` tag to a separate module
12 changes: 6 additions & 6 deletions docs/_plugins/shortcodes/renderInstallation.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ fully initialized.
<uxdot-installation-tabs>
<rh-tab slot="tab">Red Hat CDN</rh-tab>
<rh-tab-panel>
<uxdot-installation-tab-panel>
<rh-alert state="warning">
<h3 slot="header">CDN Prerelease</h3>
<p>We are currently working on our CDN, which will be soon moving
Expand Down Expand Up @@ -81,9 +81,9 @@ ${!lightdomcss ? '' : /* md */`${lightdomcssblock}
~~~
`}
</rh-tab-panel>
</uxdot-installation-tab-panel>
<rh-tab slot="tab">NPM</rh-tab>
<rh-tab-panel>
<uxdot-installation-tab-panel>
Install RHDS using your team's preferred NPM package manager, e.g.
Expand Down Expand Up @@ -111,9 +111,9 @@ Replace \`/path/to\` in the \`href\` attribute with the installation path
to the \`${docsPage.tagName}\` directory in your project.
`}
</rh-tab-panel>
</uxdot-installation-tab-panel>
<rh-tab slot="tab">JSPM</rh-tab>
<rh-tab-panel>
<uxdot-installation-tab-panel>
<rh-alert state="warning">
<h3 slot="header">Public CDNs</h3>
<p>JSPM and other public CDNs should not be used on corporate domains.
Expand Down Expand Up @@ -153,7 +153,7 @@ ${!lightdomcss ? '' : /* md */ `${lightdomcssblock}
~~~
`}
</rh-tab-panel>
</uxdot-installation-tab-panel>
</uxdot-installation-tabs>
${content ?? ''}`}
Expand Down
28 changes: 18 additions & 10 deletions docs/assets/elements/uxdot-installation-tabs.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { css } from 'lit';
import '@rhds/elements/rh-alert/rh-alert.js';

import { RhTabs } from '@rhds/elements/rh-tabs/rh-tabs.js';
import { RhTabPanel } from '@rhds/elements/rh-tabs/rh-tab-panel.js';

import { TabExpandEvent } from '@patternfly/elements/pf-tabs/BaseTab.js';
import '@rhds/elements/rh-alert/rh-alert.js';

const TABS_KEY = 'rhds-installation-tabs-selected-index';

Expand All @@ -11,17 +12,11 @@ export class InstallationTabs extends RhTabs {

static is = 'uxdot-installation-tabs';

static styles = [...RhTabs.styles, css`
::slotted(pre) {
max-width: 800px !important;
overflow-x: scroll;
}
`];

static { customElements.define(this.is, this); }

#onExpand(event) {
if (event instanceof TabExpandEvent) {
// TODO: when tabs is decoupled from PFE, update the event type here
if (event.constructor.name === 'TabExpandEvent') {
localStorage.setItem(TABS_KEY, this.activeIndex.toString());
}
}
Expand Down Expand Up @@ -49,3 +44,16 @@ export class InstallationTabs extends RhTabs {
this.addEventListener('expand', this.#onExpand);
}
}

export class InstallationTabPanel extends RhTabPanel {
static is = 'uxdot-installation-tab-panel';

static styles = [...RhTabPanel.styles, css`
::slotted(pre) {
max-width: 800px !important;
overflow-x: scroll;
}
`];

static { customElements.define(this.is, this); }
}
14 changes: 3 additions & 11 deletions elements/rh-navigation-secondary/rh-navigation-secondary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ import '@rhds/elements/lib/elements/rh-context-provider/rh-context-provider.js';
import './rh-navigation-secondary-menu-section.js';
import './rh-navigation-secondary-overlay.js';

/** @deprecated */
import './rh-secondary-nav.js';

import { RhNavigationSecondaryDropdown, SecondaryNavDropdownExpandEvent } from './rh-navigation-secondary-dropdown.js';

import { DirController } from '../../lib/DirController.js';
Expand Down Expand Up @@ -432,19 +435,8 @@ export class RhNavigationSecondary extends LitElement {
}
}

@customElement('rh-secondary-nav')
class RhSecondaryNav extends RhNavigationSecondary {
#logger = new Logger(this);

constructor() {
super();
this.#logger.warn('rh-secondary-nav is deprecated. Use rh-navigation-secondary instead.');
}
}

declare global {
interface HTMLElementTagNameMap {
'rh-navigation-secondary': RhNavigationSecondary;
'rh-secondary-nav': RhSecondaryNav;
}
}
20 changes: 20 additions & 0 deletions elements/rh-navigation-secondary/rh-secondary-nav.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/** @deprecated */

import { customElement } from 'lit/decorators/custom-element.js';
import { RhNavigationSecondary } from './rh-navigation-secondary.js';
import { Logger } from '@patternfly/pfe-core/controllers/logger.js';

@customElement('rh-secondary-nav')
class RhSecondaryNav extends RhNavigationSecondary {
constructor() {
super();
new Logger(this).warn('rh-secondary-nav is deprecated. Use rh-navigation-secondary instead.');
}
}


declare global {
interface HTMLElementTagNameMap {
'rh-secondary-nav': RhSecondaryNav;
}
}

0 comments on commit 4b194d8

Please sign in to comment.