Skip to content

Commit 18a2d08

Browse files
FileInput - Add 100% width style (HDS-5106) (#3318)
Co-authored-by: Cristiano Rastelli <[email protected]>
1 parent f9697a9 commit 18a2d08

File tree

5 files changed

+55
-0
lines changed

5 files changed

+55
-0
lines changed

.changeset/dark-pandas-buy.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@hashicorp/design-system-components": patch
3+
---
4+
5+
<!-- START components/form/file-input -->
6+
`FileInput` - Added width of 100% to prevent the component from overflowing its container and making it consistent with other Input components
7+
<!-- END -->

packages/components/src/styles/components/form/file-input.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
@use "../../mixins/button" as *;
1111

1212
.hds-form-file-input {
13+
width: 100%; // we want to prevent the input from overflowing its container
1314
margin: -4px 0 -4px -4px; // offset shadow padding + default 1px spacing
1415
padding: 3px 0 3px 3px; // add padding so button shadow is visible
1516
color: var(--token-color-foreground-primary);

showcase/app/components/page-components/form/file-input/index.gts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import ShwTextH1 from 'showcase/components/shw/text/h1';
1111

1212
import SubSectionBaseControl from 'showcase/components/page-components/form/file-input/sub-sections/base-control';
1313
import SubSectionFieldControl from 'showcase/components/page-components/form/file-input/sub-sections/field-control';
14+
import SubSectionContainers from 'showcase/components/page-components/form/file-input/sub-sections/containers';
1415

1516
export default class FormFileInputIndex extends Component {
1617
@tracked showHighlight = false;
@@ -35,6 +36,7 @@ export default class FormFileInputIndex extends Component {
3536
</button>
3637
<SubSectionBaseControl @showHighlight={{this.showHighlight}} />
3738
<SubSectionFieldControl @showHighlight={{this.showHighlight}} />
39+
<SubSectionContainers @showHighlight={{this.showHighlight}} />
3840
</section>
3941
</template>
4042
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/**
2+
* Copyright (c) HashiCorp, Inc.
3+
* SPDX-License-Identifier: MPL-2.0
4+
*/
5+
import type { TemplateOnlyComponent } from '@ember/component/template-only';
6+
import style from 'ember-style-modifier';
7+
8+
import ShwFlex from 'showcase/components/shw/flex';
9+
import ShwTextH2 from 'showcase/components/shw/text/h2';
10+
import ShwOutliner from 'showcase/components/shw/outliner';
11+
12+
import { HdsFormFileInputField } from '@hashicorp/design-system-components/components';
13+
14+
export interface SubSectionContainersSignature {
15+
Args: {
16+
showHighlight: boolean;
17+
};
18+
}
19+
20+
const SubSectionContainers: TemplateOnlyComponent<SubSectionContainersSignature> =
21+
<template>
22+
<ShwTextH2>Containers</ShwTextH2>
23+
24+
<div
25+
class="{{if
26+
@showHighlight
27+
'shw-component-form-file-input-layout-highlight'
28+
}}"
29+
>
30+
<ShwFlex @gap="2rem" as |SF|>
31+
<SF.Item @label="Within a fixed-width container">
32+
<ShwOutliner {{style width="220px"}}>
33+
<HdsFormFileInputField as |F|>
34+
<F.Label>This is the label text</F.Label>
35+
<F.HelperText>This is the helper text with longer wrapping text</F.HelperText>
36+
</HdsFormFileInputField>
37+
</ShwOutliner>
38+
</SF.Item>
39+
</ShwFlex>
40+
</div>
41+
</template>;
42+
43+
export default SubSectionContainers;

showcase/app/components/page-components/form/file-input/sub-sections/field-control.gts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ const SubSectionFieldControl: TemplateOnlyComponent<SubSectionFieldControlSignat
8787
</HdsFormFileInputField>
8888
</SG.Item>
8989
</ShwGrid>
90+
91+
<ShwDivider />
9092
</template>;
9193

9294
export default SubSectionFieldControl;

0 commit comments

Comments
 (0)