Skip to content

Commit b5acc13

Browse files
didoodchyunandgen404jorytindallKristinLBradley
authored
Website documentation updates for v4.20.0 release (#2926)
Co-authored-by: Dylan Hyun <[email protected]> Co-authored-by: Andrew Gendel <[email protected]> Co-authored-by: Jory Tindall <[email protected]> Co-authored-by: Kristin Bradley <[email protected]> Co-authored-by: Majed <[email protected]> Co-authored-by: Melanie Sumner <[email protected]> Co-authored-by: Lee White <[email protected]> Co-authored-by: shleewhite <[email protected]>
1 parent 5c1ada7 commit b5acc13

File tree

19 files changed

+265
-361
lines changed

19 files changed

+265
-361
lines changed

website/app/styles/pages/components/advanced-table.scss

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,6 @@
66
// COMPONENTS > TABLE > ADVANCEDTABLE
77

88
#show-content-components-table-advanced-table {
9-
.doc-advanced-table-scrollable-wrapper {
10-
overflow-x: auto;
11-
}
12-
13-
.doc-advanced-table-vertical-scrollable-wrapper {
14-
height: 500px;
15-
}
16-
179
.doc-advanced-table-multiselect-with-pagination-demo {
1810
.hds-advanced-table + .hds-pagination {
1911
margin-top: 16px;

website/docs/components/app-header/partials/code/component-api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
A named block where the utility actions will be rendered. Typically, `Dropdown` or `Button` components should be added here, such as a help menu, user menu, or search button.
1414
</C.Property>
1515
<C.Property @name="breakpoint" @type="string" @default="1088px">
16-
Set a custom breakpoint to control the page width at which the UI switches from displaying the mobile/small view vs. the desktop/view.
16+
Set a custom breakpoint to control the page width at which the UI switches from displaying the mobile/small view vs. the desktop/large view.
1717
</C.Property>
1818
<C.Property @name="hasA11yRefocus" @type="boolean" @default="true">
1919
Controls whether a "navigator narrator" and a "skip link" are added to the navigation (provided by the [`ember-a11y-refocus` Ember addon](https://github.com/ember-a11y/ember-a11y-refocus)). It can be programmatically turned off by passing `false`. Warning: if it is set to false, then it will fail Bypass Blocks, [Success Criteria 2.4.1](https://www.w3.org/WAI/WCAG22/Understanding/bypass-blocks.html). Since this component appears on every page, the application will not be considered conformant.

website/docs/components/app-side-nav/partials/code/component-api.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ This is the full-fledged component (responsive and animated).
2121
<C.Property @name="isMinimized" @type="boolean" @default="false">
2222
Controls if the App Side Nav is rendered collapsed or expanded when initialized. This allows an application to preserve the collapsed/expanded state across sessions. After the initial render, this argument is altered based on user interactions (collapse/expand the App Side Nav or resize the window) and it is not a suitable way of controlling the App Side Nav state from outside after render (it’s an internal state).
2323
</C.Property>
24+
<C.Property @name="breakpoint" @type="string" @default="1088px">
25+
Set a custom breakpoint to control the page width at which the UI switches from displaying the mobile/small view vs. the desktop/large view.
26+
</C.Property>
2427
<C.Property @name="onToggleMinimizedStatus" @type="function">
2528
Callback function invoked when the `AppSideNav` is collapsed or expanded. The function receives a boolean argument stating if the `AppSideNav` is minimized or not.
2629
</C.Property>

website/docs/components/app-side-nav/partials/code/how-to-use.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ Below is an example (inspired by the Cloud UI navigation) of how the two kinds o
118118

119119
```handlebars
120120
{{!--
121-
for demo purposes we set `@isResponsive` to `false` but in your app it will probably need to be set to `true`
121+
for demo purposes we set `@isResponsive` to `false` but in your app it will probably need to be set to `true`
122122
(or omitted to rely on defaults)
123123
--}}
124124
<div class="doc-app-sidenav-demo--cloud-ui">
@@ -175,7 +175,7 @@ When the App Side Nav is used in conjunction with portals, the nesting of naviga
175175
As mentioned above, the full-fledged `Hds::AppSideNav` component is “responsive” by default:
176176

177177
- when the **viewport is `desktop`**, the sidebar navigation is static and has a fixed width
178-
- the width at which the viewport is considered “desktop” is controlled by a dedicated CSS variable `--hds-app-desktop-breakpoint`; if needed it can be overwritten (at `:root` level) to define a custom “desktop” breakpoint
178+
- the width at which the viewport is considered “desktop” can be overwritten using the `@breakpoint` argument
179179
- when the **viewport is `mobile`**, the sidebar navigation is responsive and the user can minimize or maximize its width via a toggle button (the component will take care automatically of the transitions between these two states)
180180
- in this case the App Side Nav occupies only a minimum width in terms of page layout, even when expanded (it partially covers the main content)
181181
- a toggle button is added to the App Side Nav, used to expand/minimize its width

website/docs/components/code-block/partials/code/how-to-use.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,12 @@ loadInitializers(App, config.modulePrefix);"
149149

150150
### Limit height
151151

152-
Code content uses `auto` height by default but you can opt to set a `maxHeight` value to save space. Vertical scrolling is enabled as part of this feature allowing users to scroll vertically to view the overflowing content.
152+
Code content uses `auto` height by default but you can opt to set a `maxHeight` value to save space. If the content height exceeds the set max height, vertical scrolling is enabled to view the overflowing content and a toggle button is displayed to expand the height and show the Code Block content in its entirety.
153153

154154
```handlebars
155155
<Hds::CodeBlock
156156
@language="javascript"
157-
@maxHeight="105px"
157+
@maxHeight="130px"
158158
@value="import Application from `@ember/application`;
159159
import Resolver from `ember-resolver`;
160160
import loadInitializers from `ember-load-initializers`;

website/docs/components/code-block/partials/guidelines/guidelines.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,21 @@ Line numbers are displayed by default and can make longer blocks of code and sni
6969
In the Figma component, the code examples have the appropriate number of lines by default but must be manually hidden or shown to match the length of custom snippets.
7070
!!!
7171

72+
## Height toggle button
73+
74+
For longer code content, it can be helpful to set a `maxHeight` for the Code Block to limit how much code is shown by default within the UI layout. If the content exceeds this height, a “Show more code” button will be displayed at the bottom of the Code Block, allowing users to expand it. Activating this button again will collapse the content back to its original height.
75+
76+
In Figma, this is enabled by setting `hasToggleHeightButton` to true. The button is placed inside a footer element that only appears when the content overflows, keeping the layout clean when the toggle isn’t needed.
77+
78+
![Collapsed Code Block showing limited lines and a 'Show more code' button at the bottom.](/assets/components/code-block/code-block-collapsed.png)
79+
80+
Interacting with this button removes the height limit, expanding the Code Block to display the full code snippet.
81+
82+
![Expanded Code Block with all lines visible and a 'Show less code' button displayed at the bottom](/assets/components/code-block/code-block-expanded.png)
83+
84+
Interacting with it again collapses the Code Block back to its set `maxHeight`.
85+
86+
7287
## Line highlighting
7388

7489
Use line highlighting to target and call attention to specific lines or multiple lines within a block of code.

website/docs/components/table/advanced-table/partials/code/component-api.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,11 @@ The Advanced Table component itself is where most of the options will be applied
9292
Determines if even-numbered rows will have a different background color from odd-numbered rows.<br><br>
9393
**Important**: Advanced Table does **not** support setting `isStriped` to true when there are nested rows.
9494
</C.Property>
95-
<C.Property @name="hasStickyHeader" @type="boolean" @default="false">
96-
Determines if the Advanced Table has a sticky header.
95+
<C.Property @name="maxHeight" @type="string">
96+
Sets the maximum height of the Advanced Table. If the `@maxHeight` is set, there will automatically be a sticky header. To turn off the sticky header and still have a max height, set `@hasStickyHeader` to false.
97+
</C.Property>
98+
<C.Property @name="hasStickyHeader" @type="boolean">
99+
Determines if the Advanced Table has a sticky header. If set to `true`, must be used with the `@maxHeight` argument. If `@maxHeight` is set and `@hasStickyHeader` is `false`, there will not be a sticky header.
97100
</C.Property>
98101
<C.Property @name="hasStickyFirstColumn" @type="boolean" @default="false">
99102
Determines if the Advanced Table has a sticky first column.

website/docs/components/table/advanced-table/partials/code/how-to-use.md

Lines changed: 51 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ This component takes advantage of the `sort-by` helper provided by [@nullvoxpopu
153153

154154
!!!
155155

156-
Add `isSortable=true` to the hash for each column that should be sortable.
156+
Add `isSortable=true` to the hash for each column that should be sortable.
157157

158158
```handlebars
159159
<Hds::AdvancedTable
@@ -382,32 +382,31 @@ We recommend using functionalities like [pagination](/components/pagination), [s
382382

383383
#### Vertical scrolling
384384

385-
For situations where the default number of rows visible may be high, it can be difficult for users to track which column is which once they scroll. In this case, the `hasStickyHeader` argument can be used to make the column headers persist as the user scrolls.
385+
For situations where the default number of rows visible may be high, it can be difficult for users to track which column is which once they scroll. In this case, the `maxHeight` argument can be used to set the maximum height of the Advanced Table which will also add a sticky header. This will make the column headers persist as the user scrolls.
386+
387+
If you want to set the `maxHeight` but not have a sticky header, set `hasStickyHeader` to false.
386388

387389
```handlebars
388-
<!-- this is an element with "height: 500px" -->
389-
<div class="doc-advanced-table-vertical-scrollable-wrapper">
390-
<Hds::AdvancedTable
391-
@model={{this.demoDataWithLargeNumberOfRows}}
392-
@columns={{array
393-
(hash key="id" label="ID")
394-
(hash key="name" label="Name" isSortable=true)
395-
(hash key="email" label="Email")
396-
(hash key="role" label="Role" isSortable=true)
397-
}}
398-
@hasStickyHeader={{true}}
399-
@maxHeight="500px"
400-
>
401-
<:body as |B|>
402-
<B.Tr>
403-
<B.Td>{{B.data.id}}</B.Td>
404-
<B.Td>{{B.data.name}}</B.Td>
405-
<B.Td>{{B.data.email}}</B.Td>
406-
<B.Td>{{B.data.role}}</B.Td>
407-
</B.Tr>
408-
</:body>
409-
</Hds::AdvancedTable>
410-
</div>
390+
<Hds::AdvancedTable
391+
@model={{this.demoDataWithLargeNumberOfRows}}
392+
@columns={{array
393+
(hash key="id" label="ID")
394+
(hash key="name" label="Name" isSortable=true)
395+
(hash key="email" label="Email")
396+
(hash key="role" label="Role" isSortable=true)
397+
}}
398+
@hasStickyHeader={{true}}
399+
@maxHeight="500px"
400+
>
401+
<:body as |B|>
402+
<B.Tr>
403+
<B.Td>{{B.data.id}}</B.Td>
404+
<B.Td>{{B.data.name}}</B.Td>
405+
<B.Td>{{B.data.email}}</B.Td>
406+
<B.Td>{{B.data.role}}</B.Td>
407+
</B.Tr>
408+
</:body>
409+
</Hds::AdvancedTable>
411410
```
412411

413412
#### Horizontal scrolling
@@ -419,36 +418,33 @@ The component adds the sticky styles to the `[B].Th` component in each row. If t
419418
Note: Using `@hasStickyFirstColumn` with nested rows is not supported.
420419

421420
```handlebars
422-
<!-- this is an element with "overflow: auto" -->
423-
<div class="doc-advanced-table-scrollable-wrapper">
424-
<Hds::AdvancedTable
425-
@hasStickyFirstColumn={{true}}
426-
@model={{this.demoDataWithLargeNumberOfColumns}}
427-
@columns={{array
428-
(hash key="first_name" label="First Name" isSortable=true)
429-
(hash key="last_name" label="Last Name" isSortable=true)
430-
(hash key="age" label="Age" isSortable=true)
431-
(hash key="email" label="Email")
432-
(hash key="phone" label="Phone")
433-
(hash key="bio" label="Biography" width="350px")
434-
(hash key="education" label="Education Degree")
435-
(hash key="occupation" label="Occupation")
436-
}}
437-
>
438-
<:body as |B|>
439-
<B.Tr>
440-
<B.Th>{{B.data.first_name}}</B.Th>
441-
<B.Td>{{B.data.last_name}}</B.Td>
442-
<B.Td>{{B.data.age}}</B.Td>
443-
<B.Td>{{B.data.email}}</B.Td>
444-
<B.Td>{{B.data.phone}}</B.Td>
445-
<B.Td>{{B.data.bio}}</B.Td>
446-
<B.Td>{{B.data.education}}</B.Td>
447-
<B.Td>{{B.data.occupation}}</B.Td>
448-
</B.Tr>
449-
</:body>
450-
</Hds::AdvancedTable>
451-
</div>
421+
<Hds::AdvancedTable
422+
@hasStickyFirstColumn={{true}}
423+
@model={{this.demoDataWithLargeNumberOfColumns}}
424+
@columns={{array
425+
(hash key="first_name" label="First Name" isSortable=true)
426+
(hash key="last_name" label="Last Name" isSortable=true)
427+
(hash key="age" label="Age" isSortable=true)
428+
(hash key="email" label="Email")
429+
(hash key="phone" label="Phone")
430+
(hash key="bio" label="Biography" width="350px")
431+
(hash key="education" label="Education Degree")
432+
(hash key="occupation" label="Occupation")
433+
}}
434+
>
435+
<:body as |B|>
436+
<B.Tr>
437+
<B.Th>{{B.data.first_name}}</B.Th>
438+
<B.Td>{{B.data.last_name}}</B.Td>
439+
<B.Td>{{B.data.age}}</B.Td>
440+
<B.Td>{{B.data.email}}</B.Td>
441+
<B.Td>{{B.data.phone}}</B.Td>
442+
<B.Td>{{B.data.bio}}</B.Td>
443+
<B.Td>{{B.data.education}}</B.Td>
444+
<B.Td>{{B.data.occupation}}</B.Td>
445+
</B.Tr>
446+
</:body>
447+
</Hds::AdvancedTable>
452448
```
453449

454450
### Multi-select Advanced Table
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
title: Breakpoints
3+
caption: Standardized breakpoints for different device widths.
4+
description: Breakpoints are width values that standardize responsive experiences across the HashiCorp product suite.
5+
links:
6+
figma: https://www.figma.com/design/uX4OEaJQdWfzULADchjAeN/HDS-Foundations-v2.0?node-id=13020-244&t=0N1UWbTuY6sSq3Od-1
7+
previewImage: assets/illustrations/foundations/breakpoints.jpg
8+
---
9+
10+
<section data-tab="Guidelines">
11+
@include "partials/guidelines/guidelines.md"
12+
</section>
13+
14+
<section data-tab="Code">
15+
@include "partials/code/how-to-use.md"
16+
</section>
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
## How to use the breakpoints
2+
3+
In [responsive design](https://developer.mozilla.org/en-US/docs/Learn_web_development/Core/CSS_layout/Responsive_Design) it's common practice to define specific media queries in CSS that can be used to control not only the layout of the entire page and its parts, but also other aspects of a UI like typography, spacing, the rendering of decorative elements, the resolution of media assets, and much more. These media queries are built using CSS `@media` declarations in combination with a set of standard breakpoints.
4+
5+
Our design system defines [breakpoint values](/foundations/breakpoints#the-ranges) based on browser viewport widths. The intervals between these breakpoints create distinct ranges, which can be used with the [Sass](/foundations/breakpoints?tab=code#sass) and [JavaScript](/foundations/breakpoints?tab=code#javascript) helpers to implement responsive designs for our applications.
6+
7+
### Sass
8+
9+
To use the Sass helpers provided by the design system, you must import the corresponding Sass file (via `@use`, [as recommended](https://sass-lang.com/documentation/at-rules/use/#differences-from-import)) from the `@hashicorp/design-system-components` package:
10+
11+
12+
```scss
13+
// from @hashicorp/design-system-components package
14+
@use "mixins/breakpoints" as *;
15+
```
16+
17+
!!! info
18+
19+
If you are not able to import the file using the declaration above, [contact the Design Systems Team](/about/support) for support.
20+
21+
!!!
22+
23+
Once the file is imported, you will have access to the Sass helpers described below.
24+
25+
#### Mixins
26+
27+
Sass mixins offer the simplest, most efficient way to implement responsive layouts using the standard breakpoints defined in our system. We provide three different mixins:
28+
29+
- `hds-breakpoint-above($name)` - for media queries that apply to a viewport range **above** a certain breakpoint (useful for a mobile-first approach)
30+
- `hds-breakpoint-below($name)` - for media queries that apply to a viewport range **below** a certain breakpoint (useful for a desktop-first approach)
31+
- `hds-breakpoint-between($lower, $upper)` - for media queries that apply to a viewport range **between** two breakpoints
32+
33+
Here is an example of how the mixins could be used in a mobile-first responsive layout:
34+
35+
```scss
36+
// from @hashicorp/design-system-components package
37+
@use "mixins/breakpoints" as *;
38+
39+
.my-responsive-layout {
40+
// this is the default behavior, that covers the range 0px–767px
41+
display: flex;
42+
direction: column;
43+
gap: 1rem;
44+
45+
// at 768px the layout changes, from a vertical stack to an horizontal one
46+
@include hds-breakpoint-above('md') {
47+
direction: row;
48+
}
49+
50+
// at larger viewports we increase the spacing between the items
51+
@include hds-breakpoint-above('xl') {
52+
gap: 2rem;
53+
}
54+
}
55+
```
56+
57+
The same layout could be achieved using a desktop-first approach in a similar way:
58+
59+
```scss
60+
// from @hashicorp/design-system-components package
61+
@use "mixins/breakpoints" as *;
62+
63+
.my-responsive-layout {
64+
// this is the default behavior
65+
display: flex;
66+
direction: row;
67+
gap: 2rem;
68+
69+
// at smaller viewports we decrease the spacing between the items
70+
@include hds-breakpoint-below('xl') {
71+
gap: 1rem;
72+
}
73+
74+
// at 768px the layout changes, from an horizontal stack to a vertical one
75+
@include hds-breakpoint-below('md') {
76+
direction: column;
77+
}
78+
}
79+
```
80+
81+
Of course, these are oversimplified examples. In your implementation, you will have to choose which mixin is best suited to achieve the desired responsive layout. This will depend on the design specifications, the context of the layout within the page, and how it relates with other UI elements.
82+
83+
#### Key/Value Map
84+
85+
For special use cases, we also provide a Sass map–`$hds-breakpoints`–which is a lower level helper than the mixins. Here's an example of how this map could be used:
86+
87+
```scss
88+
// explicit import of `map` module (required by Sass)
89+
@use "sass:map";
90+
// from @hashicorp/design-system-components package
91+
@use "mixins/breakpoints" as *;
92+
93+
@each $name, $size in $hds-breakpoints {
94+
.my-custom-breakpoint-class--#{$name} {
95+
// here you have access to the breakpoint name and its value (width in px)
96+
}
97+
}
98+
```
99+
100+
### JavaScript
101+
102+
We also provide helpers in case you need to access the breakpoints names/values in JavaScript code.
103+
104+
You have access to the list of breakpoint names and values using the `hdsBreakpoints` map:
105+
106+
```javascript{data-execute=false}
107+
import { hdsBreakpoints } from '@hashicorp/design-system-components/utils/hds-breakpoints';
108+
109+
// do something with a specific breakpoint value
110+
const myBreakpoint1 = hdsBreakpoints['xl'].value; // numeric (eg. 1440)
111+
const myBreakpoint2 = hdsBreakpoints['lg'].px; // size in px (eg. 1088px)
112+
const myBreakpoint3 = hdsBreakpoints['sm'].rem; // size in rem (eg. 30rem)
113+
114+
// loop over all the breakpoints
115+
Object.entries(hdsBreakpoints).forEach(([name, sizes]) => {
116+
// do something with a specific breakpoint value in px
117+
const myBreakpointSizePx = sizes.px;
118+
});
119+
```

0 commit comments

Comments
 (0)