File tree 2 files changed +16
-5
lines changed
packages/components/src/components/hds/layout/flex
2 files changed +16
-5
lines changed 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
- {{! ADD YOUR TEMPLATE CONTENT HERE }}
6
- <div class ={{ this.classNames }} ...attributes>
7
- {{ yield }}
8
- </div >
5
+ {{ #if (eq this.componentTag " div" )}}
6
+ <div class ={{ this.classNames }} ...attributes>{{ yield }} </div >
7
+ {{ else }}
8
+ {{ #let (element this.componentTag ) as |Tag |}} <Tag class ={{ this.classNames }} ...attributes>{{ yield }} </Tag >{{ /let }}
9
+ {{ /if }}
Original file line number Diff line number Diff line change @@ -22,8 +22,14 @@ export const DIRECTIONS: string[] = Object.values(HdsLayoutFlexDirectionValues);
22
22
export const JUSTIFYS : string [ ] = Object . values ( HdsLayoutFlexJustifyValues ) ;
23
23
export const ALIGNS : string [ ] = Object . values ( HdsLayoutFlexAlignValues ) ;
24
24
25
+ // A list of all existing tag names in the HTMLElementTagNameMap interface
26
+ type AvailableTagNames = keyof HTMLElementTagNameMap ;
27
+ // A union of all types in the HTMLElementTagNameMap interface
28
+ type AvailableElements = HTMLElementTagNameMap [ keyof HTMLElementTagNameMap ] ;
29
+
25
30
export interface HdsLayoutFlexSignature {
26
31
Args : {
32
+ tag ?: AvailableTagNames ;
27
33
direction ?: HdsLayoutFlexDirections ;
28
34
justify ?: HdsLayoutFlexJustifys ;
29
35
align ?: HdsLayoutFlexAligns ;
@@ -33,10 +39,14 @@ export interface HdsLayoutFlexSignature {
33
39
Blocks : {
34
40
default : [ ] ;
35
41
} ;
36
- Element : HTMLDivElement ;
42
+ Element : AvailableElements ;
37
43
}
38
44
39
45
export default class HdsLayoutFlex extends Component < HdsLayoutFlexSignature > {
46
+ get componentTag ( ) : AvailableTagNames {
47
+ return this . args . tag ?? 'div' ;
48
+ }
49
+
40
50
get direction ( ) : HdsLayoutFlexDirections {
41
51
return this . args . direction ?? DEFAULT_DIRECTION ;
42
52
}
You can’t perform that action at this time.
0 commit comments