File tree 20 files changed +477
-108
lines changed
tests/integration/components/hds
docs/components/side-nav/partials/code
20 files changed +477
-108
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " @hashicorp/design-system-components " : minor
3
+ ---
4
+
5
+ ` AppFrame ` :
6
+ - Modified sticky/fixed position to turn off when viewport height is under 480px in height
7
+ - Refactored styles to make ` AppFrame ` responsible for sticky/fixed layout of ` SideNav ` and ` AppHeader `
8
+
9
+ ` AppHeader ` :
10
+ - Styled inoperable actions as disabled (which occurs when the ` SideNav ` is expanded in mobile view)
11
+
12
+ ` SideNav ` :
13
+ - Removed the ` withAppHeader ` option as it is no longer needed.
Original file line number Diff line number Diff line change 2
2
Copyright (c) HashiCorp, Inc.
3
3
SPDX-License-Identifier: MPL-2.0
4
4
}}
5
- <div class =" hds-app-frame " ...attributes>
5
+ <div class ={{ this.classNames }} ...attributes>
6
6
{{ #if this.hasHeader }}
7
7
{{ yield (hash Header = (component " hds/app-frame/parts/header" ))}}
8
8
{{ /if }}
Original file line number Diff line number Diff line change @@ -33,47 +33,34 @@ export interface HdsAppFrameSignature {
33
33
}
34
34
35
35
export default class HdsAppFrameComponent extends Component < HdsAppFrameSignature > {
36
- /**
37
- * Indicates if the "header" container should be displayed
38
- *
39
- * @param hasHeader
40
- * @type {boolean }
41
- * @default true
42
- */
36
+ // Indicates if the "header" container should be displayed
43
37
get hasHeader ( ) : boolean {
44
38
return this . args . hasHeader ?? true ;
45
39
}
46
40
47
- /**
48
- * Indicates if the "sidebar" container should be displayed
49
- *
50
- * @param hasSidebar
51
- * @type {boolean }
52
- * @default true
53
- */
41
+ // Indicates if the "sidebar" container should be displayed
54
42
get hasSidebar ( ) : boolean {
55
43
return this . args . hasSidebar ?? true ;
56
44
}
57
45
58
- /**
59
- * Indicates if the "footer" container should be displayed
60
- *
61
- * @param hasFooter
62
- * @type {boolean }
63
- * @default true
64
- */
46
+ // Indicates if the "footer" container should be displayed
65
47
get hasFooter ( ) : boolean {
66
48
return this . args . hasFooter ?? true ;
67
49
}
68
50
69
- /**
70
- * Indicates if the "modals" container should be displayed
71
- *
72
- * @param hasModals
73
- * @type {boolean }
74
- * @default true
75
- */
51
+ // Indicates if the "modals" container should be displayed
76
52
get hasModals ( ) : boolean {
77
53
return this . args . hasModals ?? true ;
78
54
}
55
+
56
+ // Get the class names to apply to the component.
57
+ get classNames ( ) : string {
58
+ const classes = [ 'hds-app-frame' ] ;
59
+
60
+ if ( this . hasHeader && this . hasSidebar ) {
61
+ classes . push ( 'hds-app-frame--has-header-with-sidebar' ) ;
62
+ }
63
+
64
+ return classes . join ( ' ' ) ;
65
+ }
79
66
}
Original file line number Diff line number Diff line change @@ -27,7 +27,6 @@ interface HdsSideNavSignature {
27
27
onToggleMinimizedStatus ?: ( arg : boolean ) => void ;
28
28
// eslint-disable-next-line @typescript-eslint/no-explicit-any
29
29
onDesktopViewportChange ?: ( arg : boolean ) => void ;
30
- withAppHeader ?: boolean ;
31
30
} ;
32
31
Blocks : {
33
32
header ?: [
@@ -146,11 +145,6 @@ export default class HdsSideNavComponent extends Component<HdsSideNavSignature>
146
145
classes . push ( 'hds-side-nav--is-animating' ) ;
147
146
}
148
147
149
- // Add class based on the presence of app-header
150
- if ( this . args . withAppHeader ) {
151
- classes . push ( 'hds-side-nav--with-app-header' ) ;
152
- }
153
-
154
148
return classes . join ( ' ' ) ;
155
149
}
156
150
Original file line number Diff line number Diff line change 16
16
grid-template-rows : auto 1fr auto ;
17
17
grid-template-columns : auto 1fr ;
18
18
min-height : 100vh ;
19
-
20
- // prevent interaction with AppHeader when SideNav is open/expanded
21
- & :has (.hds-side-nav--is-not-minimized ) .hds-app-header--is-mobile {
22
- pointer-events : none ;
23
- }
24
19
}
25
20
26
-
27
21
// FRAME'S CONTAINERS
28
22
29
23
.hds-app-frame__header {
30
- z-index : 7 ;
24
+ z-index : 21 ; // needs to stay above the main content & sidebar
31
25
grid-area : header ;
32
26
33
- // NOTE: May not need to qualify this with .hds-app- header as it may not matter if AppHeader is not present
34
- & :has ( .hds-app-header ) {
27
+ // Make header position sticky/fixed if the viewport height is greater than 480px
28
+ @media ( height >= 480 px ) {
35
29
position : sticky ;
36
30
top : 0 ;
37
31
right : 0 ;
40
34
}
41
35
42
36
.hds-app-frame__sidebar {
43
- z-index : 6 ;
37
+ position : sticky ;
38
+ top : 0 ;
39
+ z-index : 20 ; // needs to stay above the main content
44
40
grid-area : sidebar;
41
+ height : 100vh ;
42
+ min-height : 100vh ;
43
+
44
+ // Modify sidenav layout when used together with fixed app-header
45
+ @media (height >= 480px ) {
46
+ .hds-app-frame--has-header-with-sidebar & {
47
+ top : var (--token-app-header-height );
48
+ height : calc (100vh - var (--token-app-header-height ));
49
+ min-height : calc (100vh - var (--token-app-header-height ));
50
+ }
51
+ }
45
52
}
46
53
47
54
.hds-app-frame__main {
52
59
grid-area : footer;
53
60
}
54
61
55
-
56
62
// MODALS "CONTAINER"
57
63
58
64
.hds-app-frame__modals {
Original file line number Diff line number Diff line change 13
13
14
14
.hds-app-header {
15
15
position : relative ;
16
- z-index : 20 ; // needs to stay above the main content
17
16
display : flex ;
18
17
gap : 12px ;
19
18
align-items : center ;
76
75
.hds-dropdown-toggle-button ,
77
76
.hds-dropdown-toggle-icon {
78
77
@include hds-interactive-dark-theme ();
78
+
79
+ // disabled state:
80
+ & :disabled ,
81
+ & [disabled ],
82
+ & .mock-disabled ,
83
+ & :disabled:focus ,
84
+ & [disabled ]:focus ,
85
+ & .mock-disabled :focus ,
86
+ & :disabled:hover ,
87
+ & [disabled ]:hover ,
88
+ & .mock-disabled :hover {
89
+ @include hds-interactive-dark-theme-state-disabled ();
90
+ }
91
+ }
92
+ }
93
+
94
+ // prevent interaction with AppHeader when SideNav is open/expanded
95
+ .hds-app-frame :has (.hds-side-nav--is-not-minimized ) .hds-app-header--is-mobile {
96
+ .hds-button ,
97
+ .hds-dropdown-toggle-button ,
98
+ .hds-dropdown-toggle-icon ,
99
+ .hds-app-header__home-link {
100
+ @include hds-interactive-dark-theme-state-disabled (); // emulate disabled state
101
+ pointer-events : none ;
79
102
}
80
103
}
81
104
90
113
// Set home link container size:
91
114
width : var (--token-app-header-home-link-size );
92
115
height : var (--token-app-header-home-link-size );
116
+
117
+ // disabled state:
118
+ & :disabled ,
119
+ & [disabled ],
120
+ & .mock-disabled ,
121
+ & :disabled:focus ,
122
+ & [disabled ]:focus ,
123
+ & .mock-disabled :focus ,
124
+ & :disabled:hover ,
125
+ & [disabled ]:hover ,
126
+ & .mock-disabled :hover {
127
+ @include hds-interactive-dark-theme-state-disabled ();
128
+ }
93
129
94
130
// Set SVG logo size:
95
131
svg {
Original file line number Diff line number Diff line change 47
47
width : 100% ;
48
48
height : 100% ;
49
49
padding : calc (var (--token-side-nav-header-home-link-padding ) - 1px ); // by design - we take in account the transparent border
50
+
51
+ // disabled state:
52
+ & :disabled ,
53
+ & [disabled ],
54
+ & .mock-disabled ,
55
+ & :disabled:focus ,
56
+ & [disabled ]:focus ,
57
+ & .mock-disabled :focus ,
58
+ & :disabled:hover ,
59
+ & [disabled ]:hover ,
60
+ & .mock-disabled :hover {
61
+ @include hds-interactive-dark-theme-state-disabled ();
62
+ }
50
63
}
51
64
52
65
67
80
.hds-dropdown-toggle-button ,
68
81
.hds-dropdown-toggle-icon {
69
82
@include hds-interactive-dark-theme ();
83
+
84
+ // disabled state:
85
+ & :disabled ,
86
+ & [disabled ],
87
+ & .mock-disabled ,
88
+ & :disabled:focus ,
89
+ & [disabled ]:focus ,
90
+ & .mock-disabled :focus ,
91
+ & :disabled:hover ,
92
+ & [disabled ]:hover ,
93
+ & .mock-disabled :hover {
94
+ @include hds-interactive-dark-theme-state-disabled ();
95
+ }
70
96
}
71
97
}
72
98
81
107
width : 36px ; // same height as the dropdown "toggle"
82
108
height : 36px ;
83
109
padding : 5px ; // we take in account the transparent border
110
+
111
+ // disabled state:
112
+ & :disabled ,
113
+ & [disabled ],
114
+ & .mock-disabled ,
115
+ & :disabled:focus ,
116
+ & [disabled ]:focus ,
117
+ & .mock-disabled :focus ,
118
+ & :disabled:hover ,
119
+ & [disabled ]:hover ,
120
+ & .mock-disabled :hover {
121
+ @include hds-interactive-dark-theme-state-disabled ();
122
+ }
84
123
}
Original file line number Diff line number Diff line change 8
8
//
9
9
10
10
.hds-side-nav {
11
- position : sticky ;
12
- top : 0 ;
13
- z-index : 20 ; // needs to stay above the main content
11
+ position : relative ;
14
12
width : var (--hds-app-sidenav-width-fixed ); // "default" width used by the `SideNav::Base` subcomponent (that is not responsive)
15
- height : 100 vh ;
16
- min-height : 100 vh ;
13
+ height : 100 % ;
14
+ min-height : 100 % ;
17
15
isolation : isolate ; // used to create a new stacking context (so we can set the overlay's z-index to -1)
18
16
19
17
// VARIATIONS
20
18
21
- // with-app-header
22
- // Modify sidenav layout when used together with app-header
23
-
24
- & .hds-side-nav--with-app-header {
25
- top : var (--token-app-header-height );
26
- height : calc (100vh - var (--token-app-header-height ));
27
- min-height : calc (100vh - var (--token-app-header-height ));
28
- }
29
-
30
19
// headerless
31
20
// SideNav without a :header block
32
21
& .hds-side-nav--is-headerless {
Original file line number Diff line number Diff line change 88
88
border-color : var (--token-color-palette-neutral-400 );
89
89
}
90
90
}
91
+ }
91
92
92
- // Disabled:
93
- & :disabled ,
94
- & [disabled ],
95
- & .mock-disabled ,
96
- & :disabled:focus ,
97
- & [disabled ]:focus ,
98
- & .mock-disabled :focus ,
99
- & :disabled:hover ,
100
- & [disabled ]:hover ,
101
- & .mock-disabled :hover {
102
- color : var (--token-color-foreground-disabled );
103
- background-color : var (--token-color-palette-neutral-600 );
104
- border-color : var (--token-color-palette-neutral-500 );
105
- }
93
+ @mixin hds-interactive-dark-theme-state-disabled () {
94
+ color : var (--token-color-foreground-disabled );
95
+ background-color : var (--token-color-palette-neutral-600 );
96
+ border-color : var (--token-color-palette-neutral-500 );
106
97
}
Original file line number Diff line number Diff line change @@ -66,6 +66,18 @@ body.layouts-app-frame {
66
66
width : 100% ;
67
67
height : 100% ;
68
68
}
69
+
70
+ // remove sticky positioning from examples
71
+ .hds-app-frame__header ,
72
+ .hds-app-frame__sidebar {
73
+ position : relative ;
74
+ top : 0 ;
75
+ }
76
+
77
+ .hds-app-frame__sidebar {
78
+ height : auto ;
79
+ min-height : 0 ;
80
+ }
69
81
}
70
82
71
83
.shw-layout-app-frame-wrapper--with-3d {
Original file line number Diff line number Diff line change 312
312
<Shw::Text::H4 >States</Shw::Text::H4 >
313
313
314
314
<Shw::Flex as |SF|>
315
- {{ #let (array " default" " hover" " active" " focus" ) as |states |}}
315
+ {{ #let (array " default" " hover" " active" " focus" " disabled " ) as |states |}}
316
316
{{ #each states as |state |}}
317
317
<SF .Item @label ={{ state }} >
318
318
<div class =" hds-app-header" >
324
324
</Shw::Flex >
325
325
326
326
<Shw::Flex as |SF|>
327
- {{ #let (array " default" " hover" " active" " focus" ) as |states |}}
327
+ {{ #let (array " default" " hover" " active" " focus" " disabled " ) as |states |}}
328
328
{{ #each states as |state |}}
329
329
<SF .Item>
330
330
<div class =" hds-app-header" >
349
349
350
350
<Shw::Text::Body >Secondary</Shw::Text::Body >
351
351
<Shw::Flex as |SF|>
352
- {{ #let (array " default" " hover" " active" " focus" ) as |states |}}
352
+ {{ #let (array " default" " hover" " active" " focus" " disabled " ) as |states |}}
353
353
{{ #each states as |state |}}
354
354
<SF .Item @label ={{ state }} >
355
355
<div class =" hds-app-header" >
368
368
369
369
<Shw::Text::Body >Primary</Shw::Text::Body >
370
370
<Shw::Flex as |SF|>
371
- {{ #let (array " default" " hover" " active" " focus" ) as |states |}}
371
+ {{ #let (array " default" " hover" " active" " focus" " disabled " ) as |states |}}
372
372
{{ #each states as |state |}}
373
373
<SF .Item @label ={{ state }} >
374
374
You can’t perform that action at this time.
0 commit comments