-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(form-field-file-beta): addressed PR comments
addressed PR comments
- Loading branch information
1 parent
1dbcf8f
commit df41084
Showing
18 changed files
with
640 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
...components/gux-form-field-file-beta/components/gux-file-list-item/gux-file-list-item.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
:host { | ||
display: block; | ||
} | ||
|
||
.gux-file-list-item { | ||
display: flex; | ||
flex-direction: column; | ||
gap: var(--gse-ui-fileUpload-fileCard-card-gap); | ||
align-items: flex-start; | ||
background-color: var(--gse-ui-fileUpload-fileCard-foregroundColor); | ||
border: var(--gse-ui-fileUpload-fileCard-mainContainer-default-border-width) | ||
var(--gse-ui-fileUpload-fileCard-mainContainer-default-border-style) | ||
var(--gse-ui-fileUpload-fileCard-mainContainer-default-border-color); | ||
border-radius: var(--gse-ui-fileUpload-fileCard-borderRadius); | ||
box-shadow: var(--gse-ui-fileUpload-fileCard-boxShadow-offsetX) | ||
var(--gse-ui-fileUpload-fileCard-boxShadow-offsetY) | ||
var(--gse-ui-fileUpload-fileCard-boxShadow-blur) | ||
var(--gse-ui-fileUpload-fileCard-boxShadow-spread) | ||
var(--gse-ui-fileUpload-fileCard-boxShadow-color); | ||
|
||
&.gux-disabled { | ||
opacity: 0.5; | ||
} | ||
|
||
&.gux-error { | ||
padding-block-start: 0; | ||
border: var(--gse-ui-fileUpload-fileCard-mainContainer-error-border-width) | ||
var(--gse-ui-fileUpload-fileCard-mainContainer-error-border-style) | ||
var(--gse-ui-fileUpload-fileCard-mainContainer-error-border-color); | ||
} | ||
|
||
.gux-info { | ||
display: flex; | ||
align-items: center; | ||
inline-size: 100%; | ||
block-size: 32px; | ||
|
||
.gux-file-name { | ||
padding: var( | ||
--gse-ui-fileUpload-fileCard-card-errorCard-fileNameSection-padding | ||
); | ||
font-family: var(--gse-ui-fileUpload-fileCard-fileName-text-fontFamily); | ||
font-size: var(--gse-ui-fileUpload-fileCard-fileName-text-fontSize); | ||
font-weight: var(--gse-ui-fileUpload-fileCard-fileName-text-fontWeight); | ||
line-height: var(--gse-ui-fileUpload-fileCard-fileName-text-lineHeight); | ||
color: var(--gse-ui-fileUpload-fileCard-fileName-default); | ||
} | ||
|
||
.gux-indicator { | ||
&[icon-name='fa/circle-check-solid'] { | ||
--gse-ui-formControl-label-tooltipTrigger-color: var( | ||
--gse-ui-fileUpload-fileCard-statusIcon-success | ||
); | ||
} | ||
|
||
&[icon-name='fa/hexagon-exclamation-solid'] { | ||
--gse-ui-formControl-label-tooltipTrigger-color: var( | ||
--gse-ui-fileUpload-fileCard-statusIcon-error | ||
); | ||
} | ||
} | ||
} | ||
|
||
.gux-additional-info { | ||
display: flex; | ||
flex-direction: column; | ||
gap: var(--gse-ui-fileUpload-fileCard-card-errorCard-errorTextSection-gap); | ||
inline-size: 100%; | ||
padding-block: var(--gse-semantic-interactive-md-padding); | ||
font-family: var(--gse-ui-fileUpload-fileCard-error-text-fontFamily); | ||
font-size: var(--gse-ui-fileUpload-fileCard-error-text-fontSize); | ||
font-weight: var(--gse-ui-fileUpload-fileCard-error-text-fontWeight); | ||
line-height: var(--gse-ui-fileUpload-fileCard-error-text-lineHeight); | ||
border-block-start: var( | ||
--gse-ui-fileUpload-fileCard-mainContainer-default-border-width | ||
) | ||
var(--gse-ui-fileUpload-fileCard-mainContainer-default-border-style) | ||
var(--gse-ui-fileUpload-fileCard-mainContainer-default-border-color); | ||
|
||
.gux-additional-info-header { | ||
padding: var( | ||
--gse-ui-fileUpload-fileCard-card-errorCard-errorTextSection-padding | ||
); | ||
color: var(--gse-ui-fileUpload-fileCard-error-errorMessage); | ||
} | ||
|
||
.gux-additional-info-content { | ||
padding: var( | ||
--gse-ui-fileUpload-fileCard-card-errorCard-errorTextSection-padding | ||
); | ||
color: var(--gse-ui-fileUpload-fileCard-error-errorHelper); | ||
} | ||
} | ||
} |
153 changes: 153 additions & 0 deletions
153
.../components/gux-form-field-file-beta/components/gux-file-list-item/gux-file-list-item.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
import { | ||
Component, | ||
Element, | ||
Event, | ||
EventEmitter, | ||
JSX, | ||
Prop, | ||
h | ||
} from '@stencil/core'; | ||
|
||
import { buildI18nForComponent, GetI18nValue } from 'i18n'; | ||
import { ILocalizedComponentResources } from 'i18n/fetchResources'; | ||
|
||
import { trackComponent } from '@utils/tracking/usage'; | ||
import componentResources from './i18n/en.json'; | ||
|
||
@Component({ | ||
styleUrl: 'gux-file-list-item.scss', | ||
tag: 'gux-file-list-item', | ||
shadow: true | ||
}) | ||
export class GuxFileListItem { | ||
private getI18nValue: GetI18nValue; | ||
|
||
@Element() | ||
root: HTMLGuxFileListItemElement; | ||
|
||
@Prop() | ||
name!: string; | ||
|
||
@Prop() | ||
index!: number; | ||
|
||
@Prop() | ||
disabled: boolean = false; | ||
|
||
@Prop() | ||
status: 'default' | 'loading' | 'success' | 'error'; | ||
|
||
@Event() | ||
guxremovefile: EventEmitter<number>; | ||
|
||
async componentWillLoad(): Promise<void> { | ||
this.getI18nValue = await buildI18nForComponent( | ||
this.root, | ||
componentResources as ILocalizedComponentResources | ||
); | ||
|
||
trackComponent(this.root); | ||
} | ||
|
||
render(): JSX.Element { | ||
return ( | ||
<div | ||
class={{ | ||
'gux-file-list-item': true, | ||
[`gux-${this.status}`]: true, | ||
'gux-disabled': this.disabled | ||
}} | ||
> | ||
<div class="gux-info"> | ||
<gux-truncate> | ||
<span class="gux-file-name">{this.name}</span> | ||
</gux-truncate> | ||
|
||
{this.renderStatusIndicator()} | ||
{this.renderFileRemoveButton()} | ||
</div> | ||
|
||
{this.renderAdditionalInfo()} | ||
</div> | ||
) as JSX.Element; | ||
} | ||
|
||
private renderStatusIndicator(): JSX.Element { | ||
switch (this.status) { | ||
case 'loading': | ||
return ( | ||
<gux-radial-loading | ||
context="input" | ||
screenreader-text={this.getI18nValue('uploadingFile', { | ||
filename: this.name | ||
})} | ||
></gux-radial-loading> | ||
) as JSX.Element; | ||
case 'success': | ||
return ( | ||
<gux-icon-tooltip-beta | ||
icon-name="fa/circle-check-solid" | ||
class="gux-indicator" | ||
> | ||
<span slot="content"> | ||
{this.getI18nValue('success', { filename: this.name })} | ||
</span> | ||
</gux-icon-tooltip-beta> | ||
) as JSX.Element; | ||
case 'error': | ||
return ( | ||
<gux-icon-tooltip-beta | ||
icon-name="fa/hexagon-exclamation-solid" | ||
class="gux-indicator" | ||
> | ||
<span slot="content"> | ||
{this.getI18nValue('error', { filename: this.name })} | ||
</span> | ||
</gux-icon-tooltip-beta> | ||
) as JSX.Element; | ||
default: | ||
return null; | ||
} | ||
} | ||
|
||
private renderFileRemoveButton(): JSX.Element { | ||
if (this.disabled) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<gux-button-slot accent="ghost" icon-only> | ||
<button | ||
type="button" | ||
onClick={() => this.guxremovefile.emit(this.index)} | ||
> | ||
<gux-icon | ||
icon-name="fa/xmark-large-regular" | ||
size="small" | ||
decorative | ||
></gux-icon> | ||
<gux-screen-reader-beta> | ||
{this.getI18nValue('removeFile', { filename: this.name })} | ||
</gux-screen-reader-beta> | ||
</button> | ||
</gux-button-slot> | ||
) as JSX.Element; | ||
} | ||
|
||
private renderAdditionalInfo(): JSX.Element { | ||
if (this.status === 'error') { | ||
return ( | ||
<div class="gux-additional-info"> | ||
<div class="gux-additional-info-header"> | ||
<slot name="additional-info-header" /> | ||
</div> | ||
<div class="gux-additional-info-content"> | ||
<slot name="additional-info-content" /> | ||
</div> | ||
</div> | ||
) as JSX.Element; | ||
} | ||
|
||
return null; | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
...form-field/components/gux-form-field-file-beta/components/gux-file-list-item/i18n/en.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"removeFile": "Remove {filename} file", | ||
"uploadingFile": "Uploading {filename} file", | ||
"success": "{filename} file uploaded successfully", | ||
"error": "{filename} file has an error" | ||
} |
50 changes: 50 additions & 0 deletions
50
...eld/components/gux-form-field-file-beta/components/gux-file-list-item/readme.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# gux-file-list-item | ||
|
||
|
||
|
||
<!-- Auto Generated Below --> | ||
|
||
|
||
## Properties | ||
|
||
| Property | Attribute | Description | Type | Default | | ||
| ------------------- | ---------- | ----------- | --------- | ----------- | | ||
| `disabled` | `disabled` | | `boolean` | `false` | | ||
| `name` _(required)_ | `name` | | `string` | `undefined` | | ||
|
||
|
||
## Events | ||
|
||
| Event | Description | Type | | ||
| --------------- | ----------- | ----------------------------------------- | | ||
| `guxremovefile` | | `CustomEvent<HTMLGuxFileListItemElement>` | | ||
|
||
|
||
## Dependencies | ||
|
||
### Used by | ||
|
||
- [gux-form-field-file-beta](../..) | ||
|
||
### Depends on | ||
|
||
- [gux-truncate](../../../../../gux-truncate) | ||
- [gux-button-slot](../../../../../gux-button-slot) | ||
- [gux-icon](../../../../../gux-icon) | ||
- [gux-screen-reader-beta](../../../../../../beta/gux-screen-reader) | ||
|
||
### Graph | ||
```mermaid | ||
graph TD; | ||
gux-file-list-item --> gux-truncate | ||
gux-file-list-item --> gux-button-slot | ||
gux-file-list-item --> gux-icon | ||
gux-file-list-item --> gux-screen-reader-beta | ||
gux-truncate --> gux-tooltip | ||
gux-form-field-file-beta --> gux-file-list-item | ||
style gux-file-list-item fill:#f9f,stroke:#333,stroke-width:4px | ||
``` | ||
|
||
---------------------------------------------- | ||
|
||
*Built with [StencilJS](https://stenciljs.com/)* |
Oops, something went wrong.