Skip to content

Commit dd6c35a

Browse files
authored
Website: create new content section (#2572)
1 parent 8a30b64 commit dd6c35a

29 files changed

+452
-82
lines changed

website/app/components/doc/page/header/index.hbs

+27-18
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<ul role="list" aria-labelledby="primary-navigation">
1313
<Doc::Page::Header::NavItem @label="About" @route="about" @currentTopRoute={{@currentTopRoute}} />
1414
<Doc::Page::Header::NavItem @label="Foundations" @route="foundations" @currentTopRoute={{@currentTopRoute}} />
15+
<Doc::Page::Header::NavItem @label="Content" @route="content" @currentTopRoute={{@currentTopRoute}} />
1516
<Doc::Page::Header::NavItem @label="Components" @route="components" @currentTopRoute={{@currentTopRoute}} />
1617
<Doc::Page::Header::NavItem @label="Patterns" @route="patterns" @currentTopRoute={{@currentTopRoute}} />
1718
<li class="doc-page-header__nav-item-generic doc-page-header__nav-item--split">
@@ -21,24 +22,28 @@
2122
discover the search results.</div>
2223
<button
2324
type="button"
24-
class="doc-page-header__search-button"
25+
class="doc-page-header__desktop-icon-item"
2526
data-doc-algolia-search-autocomplete-secondary-trigger
2627
aria-describedby="search-button"
28+
aria-label="Search"
2729
>
28-
<Hds::Icon @name="search" />
29-
Search
30+
<Hds::Icon @name="search" @size="24" />
3031
</button>
3132
</li>
32-
<Doc::Page::Header::NavItem
33-
@label="Support"
34-
@route="show"
35-
@model="about/support"
36-
@currentTopRoute={{@currentTopRoute}}
37-
/>
3833
<li class="doc-page-header__nav-item-generic">
39-
<a href="https://github.com/hashicorp/design-system" target="_blank" rel="noopener noreferrer">
34+
<LinkTo class="doc-page-header__desktop-icon-item" @route="show" @model="about/support" aria-label="Support">
35+
<Hds::Icon @name="help" @size="24" />
36+
</LinkTo>
37+
</li>
38+
<li class="doc-page-header__nav-item-generic">
39+
<a
40+
href="https://github.com/hashicorp/design-system"
41+
target="_blank"
42+
rel="noopener noreferrer"
43+
class="doc-page-header__desktop-icon-item"
44+
aria-label="GitHub"
45+
>
4046
<Hds::Icon @name="github" @size="24" />
41-
<span class="doc-sr-only">GitHub</span>
4247
</a>
4348
</li>
4449
</ul>
@@ -49,17 +54,21 @@
4954
class="doc-page-header__mobile-only-menu-button"
5055
data-doc-algolia-search-autocomplete-secondary-trigger
5156
aria-describedby="search-button"
57+
aria-label="Search"
5258
>
53-
<Hds::Icon @name="search" />
54-
Search
59+
<Hds::Icon @name="search" @size="24" />
5560
</button>
56-
<button type="button" class="doc-page-header__mobile-only-menu-button" {{on "click" @onToggleBurgerMenu}}>
61+
<button
62+
type="button"
63+
aria-label="Menu"
64+
aria-expanded={{if @isSidebarVisibleOnSmallViewport "true" "false"}}
65+
class="doc-page-header__mobile-only-menu-button"
66+
{{on "click" @onToggleBurgerMenu}}
67+
>
5768
{{#if @isSidebarVisibleOnSmallViewport}}
58-
<Hds::Icon @name="x" />
59-
Close
69+
<Hds::Icon @name="x" @size="24" />
6070
{{else}}
61-
<Hds::Icon @name="menu" />
62-
Menu
71+
<Hds::Icon @name="menu" @size="24" />
6372
{{/if}}
6473
</button>
6574
</div>

website/app/components/doc/page/sidebar.hbs

+3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
<li class="doc-table-of-contents__item doc-table-of-contents__item--depth-2">
1717
<LinkTo class="doc-table-of-contents__link" @route="foundations">Foundations</LinkTo>
1818
</li>
19+
<li class="doc-table-of-contents__item doc-table-of-contents__item--depth-2">
20+
<LinkTo class="doc-table-of-contents__link" @route="content">Content</LinkTo>
21+
</li>
1922
<li class="doc-table-of-contents__item doc-table-of-contents__item--depth-2">
2023
<LinkTo class="doc-table-of-contents__link" @route="components">Components</LinkTo>
2124
</li>

website/app/components/doc/page/sidebar.js

+3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const getTocSectionsBundle = (section) => {
1717
const ABOUT = ['about', 'whats-new', 'getting-started'];
1818
const FOUNDATIONS = ['foundations', 'icons'];
1919
const COMPONENTS = ['components', 'layouts', 'overrides', 'utilities'];
20+
const CONTENT = ['content'];
2021
const PATTERNS = ['patterns'];
2122
// this will be removed later
2223
const TESTING = ['testing'];
@@ -29,6 +30,8 @@ const getTocSectionsBundle = (section) => {
2930
return COMPONENTS;
3031
} else if (PATTERNS.includes(section)) {
3132
return PATTERNS;
33+
} else if (CONTENT.includes(section)) {
34+
return CONTENT;
3235
} else if (TESTING.includes(section)) {
3336
return TESTING;
3437
} else {

website/app/controllers/content.js

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* Copyright (c) HashiCorp, Inc.
3+
* SPDX-License-Identifier: MPL-2.0
4+
*/
5+
6+
import Controller from '@ember/controller';
7+
8+
export default class ContentController extends Controller {
9+
get cards() {
10+
// we want to use a flat tree here...
11+
const tocTree = this.model.toc.flat;
12+
const sections = ['content'];
13+
const cards = {};
14+
sections.forEach((section) => {
15+
cards[section] = tocTree
16+
.filter(
17+
(page) =>
18+
page.pageParents[0] === section &&
19+
!page.pageAttributes?.navigation?.hidden
20+
)
21+
.map((page) => {
22+
return {
23+
image: page.pageAttributes.previewImage,
24+
title:
25+
page.pageAttributes?.navigation?.label ||
26+
page.pageAttributes.title,
27+
caption: page.pageAttributes.caption,
28+
status: page.pageAttributes.status,
29+
route: 'show',
30+
model: page.pageURL,
31+
};
32+
});
33+
});
34+
return cards;
35+
}
36+
}

website/app/controllers/index.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@ import Controller from '@ember/controller';
77

88
export default class IndexController extends Controller {
99
cards = [
10-
{
11-
title: 'About',
12-
description:
13-
'Our aims, principles, and strategy and how to get started with Helios.',
14-
route: 'about',
15-
},
1610
{
1711
title: 'Foundations',
1812
description:
1913
'Design decisions and guidance for colors, icons, typography, and more.',
2014
route: 'foundations',
2115
},
16+
{
17+
title: 'Content',
18+
description:
19+
'Structured guidelines on tone and voice, user communication and more.',
20+
route: 'content',
21+
},
2222
{
2323
title: 'Components',
2424
description:

website/app/router.js

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Router.map(function () {
1616
this.route('foundations');
1717
this.route('components');
1818
this.route('patterns');
19+
this.route('content');
1920

2021
this.route('error');
2122

website/app/styles/pages/application/header.scss

+20-58
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@
113113

114114
a {
115115
@include doc-font-style-navigation();
116-
@include doc-header-custom-focus ();
116+
@include doc-header-custom-focus();
117117
display: flex;
118118
align-items: center;
119119
height: 100%;
@@ -139,75 +139,36 @@
139139
}
140140
}
141141

142-
.doc-page-header__nav-item-generic {
143-
a {
144-
display: block;
145-
color: var(--doc-color-gray-400);
146-
147-
&:visited {
148-
color: var(--doc-color-gray-400);
149-
}
150-
151-
&:hover {
152-
color: var(--doc-color-white);
153-
}
154-
155-
&:focus-visible {
156-
border-radius: 3px;
157-
outline: 2px solid var(--doc-focus-ring-color);
158-
}
159-
}
160-
}
161-
162142
.doc-page-header__nav-item--split {
163143
margin: 0 0 0 auto;
164144
}
165145

166-
// "fake" search button (this triggers another button, the "Algolia search" one, which is hidden)
167-
168-
.doc-page-header__search-button {
146+
.doc-page-header__desktop-icon-item {
169147
@include doc-font-style-navigation();
170-
@include doc-header-custom-focus ();
171-
display: flex;
172-
gap: 4px;
173-
align-items: center;
174-
height: 36px;
175-
margin: 0;
176-
padding: 4px 12px;
148+
@include doc-header-custom-focus();
149+
display: block;
150+
margin: 0 12px;
151+
padding: 0;
177152
color: var(--doc-color-gray-400);
178-
background-color: var(--doc-color-gray-100);
179-
border: 1px solid var(--doc-color-gray-300);
180-
border-radius: 3px;
153+
background-color: transparent;
154+
border: 1px solid transparent;
181155
cursor: pointer;
182156

183-
&:hover {
184-
color: var(--doc-color-white);
185-
}
186-
187-
&:focus {
188-
border-color: var(--doc-focus-ring-color);
189-
outline: 1px solid var(--doc-focus-ring);
190-
outline-offset: 0;
191-
}
192-
193157
svg {
194-
display: block;
195-
width: 16px;
196-
height: 16px;
197-
color: inherit;
158+
width: 24px;
159+
height: 24px;
160+
}
198161

199-
&:hover { // we need this to avoid overwriting by the `aa-SubmitIcon` class, which is the same classname used in the modal form
200-
color: inherit;
201-
}
162+
&:hover {
163+
color: var(--doc-color-white);
202164
}
203165
}
204166

205-
206167
// "MOBILE" ONLY MENU
207168

208169
.doc-page-header__mobile-only-menu {
209170
display: flex;
210-
gap: 8px;
171+
gap: 24px;
211172
align-items: center;
212173
align-self: stretch;
213174
margin: 0 0 0 auto;
@@ -222,16 +183,17 @@
222183
.doc-page-header__mobile-only-menu-button {
223184
@include doc-font-style-navigation();
224185
@include doc-header-custom-focus ();
225-
display: flex;
226-
gap: 8px;
227-
align-items: center;
228-
align-self: stretch;
229-
padding: 4px 6px;
186+
padding: 0;
230187
color: var(--doc-color-gray-400);
231188
background-color: transparent;
232189
border: 1px solid transparent;
233190
cursor: pointer;
234191

192+
svg {
193+
width: 24px;
194+
height: 24px;
195+
}
196+
235197
&:hover {
236198
color: var(--doc-color-white);
237199
}

website/app/templates/content.hbs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{{!
2+
Copyright (c) HashiCorp, Inc.
3+
SPDX-License-Identifier: MPL-2.0
4+
}}
5+
6+
{{page-title "Content"}}
7+
8+
<Doc::Page::Stage>
9+
<Doc::Page::Cover @title="Content" />
10+
<Doc::Page::Content @breakthrough={{true}}>
11+
<Doc::Cards::Deck @cols="4" @cards={{this.cards.content}} />
12+
</Doc::Page::Content>
13+
</Doc::Page::Stage>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
title: Writing guidelines
3+
caption: Consistent language guidelines for components and patterns.
4+
description: Consistent language guidelines for components and patterns.
5+
previewImage: assets/illustrations/content/writing-guidelines.jpg
6+
---
7+
8+
## Date and time
9+
10+
Display dates and times clearly and consistently across products.
11+
12+
### Usage
13+
14+
These formatting options are available in the [Time](/components/time) component. Choose the format most appropriate for your user needs.
15+
16+
- **Relative date**: Displays time in relative terms, e.g., "3 hours ago" or "in 2 days". This format is recommended for recent events, particularly within the past or upcoming week, as it simplifies recognition of time-sensitive actions.
17+
- **Friendly date**: Provides a user-friendly date and time, e.g., "Sep 5, 2018, 3:30 PM EST". Limit time format to the minute.
18+
- **Friendly local date**: Converts the date to the user’s local timezone for added clarity, e.g., "Sep 2, 2024, 3:30 PM EST". Ideal for exact dates and times. Limit time format to the minute.
19+
- **Date range**: Displays a range by specifying a start and end date, e.g., "Sep 2–Sep 9, 2024".
20+
- **Precise time**: Displays date and time in a UTC format for a log stream or where human readability isn't necessary, e.g., “2024-09-05T23:15:17345Z”.
21+
22+
### Relative dates
23+
24+
Relative dates work well for periods from one minute up to one week. For added accuracy, a [Tooltip](/components/tooltip) can display the exact timestamp, including seconds and the local timezone, e.g., "Sep 5, 2018, 4:07:32 PM PST". This helps users who need precise information without manually converting from UTC.
25+
26+
![A relative date displayed as "5 days ago" with the full date shown in a tooltip in the friendly local format "Sep 5, 2018, 4:07:32 PM EST".](/assets/content/writing-guidelines/writing-guidelines-relative-dates-with-tooltip.png)
27+
28+
- Omit "about" in phrases like "about 3 hours ago" since the approximation is implied.
29+
To improve readability, show only the most significant unit, e.g., "3 days ago" instead of "3 days, 4 hours ago."
30+
- Friendly dates limit the visible display to the minute, e.g., "Sep 5, 2018, 4:07 PM".

0 commit comments

Comments
 (0)