Skip to content

Commit

Permalink
chore(form-field-file-beta): addressed PR comments
Browse files Browse the repository at this point in the history
addressed PR comments
  • Loading branch information
daragh-king-genesys committed Jan 22, 2025
1 parent 1dbcf8f commit df41084
Show file tree
Hide file tree
Showing 18 changed files with 640 additions and 80 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@
### Used by

- [gux-avatar-beta](../gux-avatar)
- [gux-file-list-item](../../stable/gux-form-field/components/gux-form-field-file-beta/components/gux-file-list-item)
- [gux-icon-tooltip-beta](../gux-icon-tooltip)
- [gux-label-info-beta](../gux-label-info)

### Graph
```mermaid
graph TD;
gux-avatar-beta --> gux-screen-reader-beta
gux-file-list-item --> gux-screen-reader-beta
gux-icon-tooltip-beta --> gux-screen-reader-beta
gux-label-info-beta --> gux-screen-reader-beta
style gux-screen-reader-beta fill:#f9f,stroke:#333,stroke-width:4px
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
- [gux-button-multi](../gux-button-multi)
- [gux-context-menu](../gux-context-menu)
- [gux-dismiss-button](../gux-dismiss-button)
- [gux-file-list-item](../gux-form-field/components/gux-form-field-file-beta/components/gux-file-list-item)
- [gux-form-field-file-beta](../gux-form-field/components/gux-form-field-file-beta)
- [gux-pagination-buttons](../gux-pagination/gux-pagination-buttons)
- [gux-pagination-buttons-legacy](../../legacy/gux-pagination-legacy/gux-pagination-buttons-legacy)
Expand All @@ -48,6 +49,7 @@ graph TD;
gux-button-multi --> gux-button-slot
gux-context-menu --> gux-button-slot
gux-dismiss-button --> gux-button-slot
gux-file-list-item --> gux-button-slot
gux-form-field-file-beta --> gux-button-slot
gux-pagination-buttons --> gux-button-slot
gux-pagination-buttons-legacy --> gux-button-slot
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ This component is meant for use in other components as a dismiss button.

### Used by

- [gux-form-field-file-beta](../gux-form-field/components/gux-form-field-file-beta)
- [gux-modal](../gux-modal)
- [gux-modal-legacy](../../legacy/gux-modal-legacy)
- [gux-notification-toast-legacy](../../legacy/gux-notification-toast-legacy)
Expand All @@ -39,7 +38,6 @@ This component is meant for use in other components as a dismiss button.
graph TD;
gux-dismiss-button --> gux-button-slot
gux-dismiss-button --> gux-icon
gux-form-field-file-beta --> gux-dismiss-button
gux-modal --> gux-dismiss-button
gux-modal-legacy --> gux-dismiss-button
gux-notification-toast-legacy --> gux-dismiss-button
Expand Down
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);
}
}
}
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;
}
}
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"
}
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/)*
Loading

0 comments on commit df41084

Please sign in to comment.