Skip to content

Commit

Permalink
Merge pull request #282 from centrica-engineering/feature/content-str…
Browse files Browse the repository at this point in the history
…ucture

[discovery] content structure
  • Loading branch information
andij authored Jan 4, 2024
2 parents e5223c6 + e000906 commit 34e7a60
Show file tree
Hide file tree
Showing 214 changed files with 1,243 additions and 2,082 deletions.
40 changes: 5 additions & 35 deletions astro.config.mjs
Original file line number Diff line number Diff line change
@@ -1,40 +1,7 @@
import { defineConfig } from "astro/config";
import starlight from "@astrojs/starlight";
import cem from "@connectedhomes/nucleus/custom-elements.json";
import lit from "@astrojs/lit";

const componentSidebar = {
label: "Components",
items: cem.tags
.sort((a, b) => a.name.localeCompare(b.name))
.map((component) => ({
label: component.name,
badge: component.deprecated ? "Deprecated" : undefined,
collapsed: true,
items: [
{
label: "Overview",
attrs: {
class: `ns-sidebar sidebar-${component.name}`,
},
link: `/components/${component.name}`,
},
{
label: "Guidance",
link: `/components/${component.name}/guidance`,
},
{
label: "Placement",
link: `/components/${component.name}/placement`,
},
{
label: "Implementation",
link: `/components/${component.name}/implementation`,
},
],
})),
};

export default defineConfig({
integrations: [
starlight({
Expand All @@ -60,19 +27,22 @@ export default defineConfig({
github: "https://github.com/centrica-engineering/nucleus-docs",
},
components: {
TableOfContents: "./src/components/toc.astro",
PageTitle: "./src/components/starlight/PageTitle.astro",
TableOfContents: "./src/components/starlight/TableOfContents.astro",
TwoColumnContent: "./src/components/starlight/TwoColumnContent.astro"
},
expressiveCode: {
themes: ["github-dark", "github-light"],
},
sidebar: [
componentSidebar,
{
label: "Guidelines",
autogenerate: { directory: "guidelines" },
},
{
label: "Components",
autogenerate: { directory: "components" },
},
{
label: "Patterns",
autogenerate: { directory: "patterns" },
Expand Down
Binary file removed src/assets/houston.webp
Binary file not shown.
File renamed without changes.
14 changes: 9 additions & 5 deletions src/components/NucleusPageTitle.astro
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,28 @@ const componentName = Astro.props.slug?.replace('components/', '');
isComponentPage && toc?.items?.length > 0 && (
<div class="page-nav">
{
toc.items.map((toc) => <a class="page-nav-header" href=`#${toc.slug}`>{toc.text === 'Top' ? 'Overview' : toc.text}</a>)
toc.items.map((toc) => <a class="page-nav-header" href=`#${toc.slug}`>{toc.text}</a>)
}
</div>
)
}
</div>


<style>
.page-title {
padding: 1.5rem;
padding-block-start: 1rem;
padding-inline: 1.5rem;
}

.page-nav {
padding: 1.5rem var(--sl-content-pad-x);
padding-block: 1rem;
}

.page-nav [href="#_top"] {
display: none;
}

.page-nav-header {
padding-right: 1rem;
}
</style>
</style>
28 changes: 15 additions & 13 deletions src/components/ce/example-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,17 @@ export class ExampleView extends LitElement {
.example {
background: #fff;
height: 100%;
border-radius: 4px;
border-start-start-radius: 0.5rem;
border-start-end-radius: 0.5rem;
padding: 0.5rem;
border: 1px solid var(--sl-color-gray-6);
}
iframe {
border: none;
height: 100%;
width: 100%;
min-height: var(--min-height);
}
.preview {
height: 100%;
transform: scale(0.75);
transform-origin: 0 0;
width: 133%;
min-height: var(--min-height);
}
Expand Down Expand Up @@ -75,7 +70,7 @@ export class ExampleView extends LitElement {

this.title = 'Example';

this.__minHeight = 200;
this.__minHeight = 275;
this.__isDragging = false;
}

Expand All @@ -86,8 +81,15 @@ export class ExampleView extends LitElement {
<head>
<script src="https://www.britishgas.co.uk/nucleus/nucleus.min.js" type="text/javascript"></script>
</head>
<body class="ndsn">
${inner}
<body>
<!-- TODO: @drew - 2024-01-02 - This is a hack to get the snippet into ns-panel. This should be done by looking at 'Component placement' in jsdoc -->
<main class="ndsn" id="content">
<ns-panel>
<div>
${inner}
</div>
</ns-panel>
</main>
</body>
`;
}
Expand Down
10 changes: 10 additions & 0 deletions src/components/cem-description.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
const { name } = Astro.props;
import cem from "@connectedhomes/nucleus/custom-elements.json";
const compDetails = cem.tags.find((tag) => tag.name === name);
---

<div class="purpose">
<p>{compDetails?.description}</p>
</div>
2 changes: 1 addition & 1 deletion src/components/code-snippet.astro
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ htmlContent = `${htmlContentParts[0]}${prefixToLookup}
${htmlContentParts[1]}`;
---

<div set:html={htmlContent} />
<div style="margin-top: 0;" set:html={htmlContent} />
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import { Icon } from '@astrojs/starlight/components';
<nav aria-labelledby="sidebar-contribute">
<h2 id="sidebar-contribute">Contribute</h2>
<ul>
<li><a href="/edit-this-page/"><Icon name="pencil" />Edit this page</a></li>
<li><a href="/edit-this-page/"><Icon name="pencil" />Suggest changes</a></li>
<li><a href="/feedback/"><Icon name="pen" />Feedback</a></li>
</ul>
</nav>

<style>
h2 {
margin-block-start: 1.5rem;
nav {
margin-block: 1.5rem;
}
ul {
padding: 0;
Expand Down
112 changes: 62 additions & 50 deletions src/components/starlight/TwoColumnContent.astro
Original file line number Diff line number Diff line change
@@ -1,58 +1,70 @@
---
import type { Props } from "@astrojs/starlight/props";
import NucleusPageTitle from '../NucleusPageTitle.astro';
import NucleusPageTitle from "../NucleusPageTitle.astro";
---

<NucleusPageTitle {...Astro.props}/>
<div class="section-tabs">
<NucleusPageTitle {...Astro.props} />
</div>

<div class="lg:sl-flex">
{
Astro.props.toc && (
<aside class="right-sidebar-container">
<div class="right-sidebar">
<slot name="right-sidebar" />
</div>
</aside>
)
}
<div class="main-pane"><slot /></div>
{
Astro.props.toc && (
<aside class="right-sidebar-container">
<div class="right-sidebar">
<slot name="right-sidebar" />
</div>
</aside>
)
}
<div class="main-pane"><slot /></div>
</div>

<style>
.main-pane {
isolation: isolate;
}

@media (min-width: 72rem) {
.right-sidebar-container {
order: 2;
position: relative;
width: calc(
var(--sl-sidebar-width) + (100% - var(--sl-content-width) - var(--sl-sidebar-width)) / 2
);
}

.right-sidebar {
position: fixed;
/* top: 0; */
border-inline-start: 1px solid var(--sl-color-gray-6);
padding-top: var(--sl-nav-height);
width: 100%;
height: 100vh;
overflow-y: auto;
scrollbar-width: none;
}

.main-pane {
width: 100%;
}

:global([data-has-sidebar][data-has-toc]) .main-pane {
--sl-content-margin-inline: auto 0;

order: 1;
width: calc(
var(--sl-content-width) + (100% - var(--sl-content-width) - var(--sl-sidebar-width)) / 2
);
}
}
</style>
.section-tabs {
position: sticky;
top: 64px;
z-index: 1;
background-color: #f4f6f8;
}

.main-pane {
isolation: isolate;
}

@media (min-width: 72rem) {
.right-sidebar-container {
order: 2;
position: relative;
width: calc(
var(--sl-sidebar-width) +
(100% - var(--sl-content-width) - var(--sl-sidebar-width)) / 2
);
}

.right-sidebar {
position: fixed;
/* top: 0; */
border-inline-start: 1px solid var(--sl-color-gray-6);
padding-top: var(--sl-nav-height);
width: 100%;
height: 100vh;
overflow-y: auto;
scrollbar-width: none;
}

.main-pane {
width: 100%;
}

:global([data-has-sidebar][data-has-toc]) .main-pane {
--sl-content-margin-inline: auto 0;

order: 1;
width: calc(
var(--sl-content-width) +
(100% - var(--sl-content-width) - var(--sl-sidebar-width)) / 2
);
}
}
</style>
16 changes: 0 additions & 16 deletions src/components/wrapper.astro

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<ns-alert state="info">
<ns-alert type="highlighter" state="info">
<h2 slot="heading">Priority Services Register</h2>
<p>You may be able to receive free priority support, <a href="#!">find out if you qualify</a>.</p>
</ns-alert>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<ns-alert type="highlighter" state="error">
<ns-alert type="highlighter">
<h2 slot="heading">Unfortunately, we're having technical problems at the moment</h2>
<p>Either stay on this page and try again in a few moments, or try again later.</p>
</ns-alert>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<ns-inputter class="inline" heading="What options do you like?" helper="How can we help you?" validation="[&quot;isRequired&quot;]" name="checkboxes">
<div slot="tip-details">By providing clarification on why this information is necessary.</div>
<input checked type="checkbox" name="checkboxes" value="a" id="checkbox-01">
<label for="checkbox-01">Option A</label>
<input type="checkbox" name="checkboxes" value="b" id="checkbox-02">
<label for="checkbox-02">Option B</label>
<input type="checkbox" name="checkboxes" value="c" id="checkbox-03">
<label for="checkbox-03">Option C</label>
</ns-inputter>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<ns-inputter heading="What options do you like?" helper="How can we help you?" validation="[&quot;isRequired&quot;]" name="checkboxes">
<div slot="tip-details">By providing clarification on why this information is necessary.</div>
<input checked type="checkbox" name="checkboxes" value="a" id="checkbox-01">
<label for="checkbox-01">Option A</label>
<input type="checkbox" name="checkboxes" value="b" id="checkbox-02">
<label for="checkbox-02">Option B</label>
<input type="checkbox" name="checkboxes" value="c" id="checkbox-03">
<label for="checkbox-03">Option C</label>
</ns-inputter>
5 changes: 5 additions & 0 deletions src/content/docs/_examples/components/ns-inputter/email.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<ns-inputter helper="How can we help you?" validation="[&quot;isRequired&quot;,&quot;isEmail&quot;]">
<div slot="tip-details">By providing clarification on why this information is necessary.</div>
<label slot="label">Email</label>
<input type="email" placeholder="e.g. [email protected]" autocomplete="email">
</ns-inputter>
4 changes: 4 additions & 0 deletions src/content/docs/_examples/components/ns-inputter/mask.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<ns-inputter mask="000000" validation="[&quot;isRequired&quot;]">
<label slot="label">Mask</label>
<input type="text">
</ns-inputter>
4 changes: 4 additions & 0 deletions src/content/docs/_examples/components/ns-inputter/number.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<ns-inputter validation="[&quot;isRequired&quot;,&quot;isBetween(5,20)&quot;]">
<label slot="label">Number</label>
<input type="number" min="0" max="10">
</ns-inputter>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<ns-inputter>
<label slot="label">Password</label>
<input type="password">
</ns-inputter>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<ns-inputter class="inline" heading="Which choice would you prefer?" helper="How can we help you?" validation="[&quot;isRequired&quot;]" name="radiobuttons">
<div slot="tip-details">By providing clarification on why this information is necessary.</div>
<input checked type="radio" name="radiobuttons" value="a" id="radio-01">
<label for="radio-01">Choice A</label>
<input type="radio" name="radiobuttons" value="b" id="radio-02">
<label for="radio-02">Choice B</label>
<input type="radio" name="radiobuttons" value="c" id="radio-03">
<label for="radio-03">Choice C</label>
</ns-inputter>
Loading

0 comments on commit 34e7a60

Please sign in to comment.