Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loader component #241

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open

Loader component #241

wants to merge 2 commits into from

Conversation

bagrub
Copy link
Collaborator

@bagrub bagrub commented Jan 15, 2025

Initial creation of the Loader component

@bagrub bagrub requested a review from dgibson666 January 15, 2025 14:23
Copy link
Collaborator

@dgibson666 dgibson666 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See code comments. I found a few discrepancies with the native progress element after reviewing MDN docs: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/progress

Copy link
Collaborator

@dgibson666 dgibson666 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty close. see code comments

@@ -10,14 +10,14 @@ export class CbpLoader {

@Element() host: HTMLElement;

/** Specifies a unique `ID` for the loader, used to wire up the controls and accessibility features. */
@Prop() uid: string = createNamespaceKey('cbp-accordion-item');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make this 'cbp-loader' as the prefix and name it "progressId" to be consistent with other IDs. If you just call it uid, it's not clear what it belongs to. (it's on the wrong thing anyway).

/** Used to set the loader to the 'success' state of the loader */
@Prop() success: boolean;
@Prop({mutable: true}) success: boolean;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs to be reflected too since you're using it as a CSS hook.


/** Used to set the loader to the 'error' state of the loader */
@Prop() error: boolean;
@Prop({mutable: true}) error: boolean;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs to be reflected too since you're using it as a CSS hook.

let statusIndicator;

if (this.color == 'success'){
statusDescription = <span>Success</span>;
if(this.success && !this.error){
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you don't need a !this.error in an if else... you're making the error take precedence over success then.

return (
<Host>
<Host
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The host is not a semantic element, so the ID doesn't do any good here. The ID should be on the actual progress element. aria-busy can be removed.

{statusIndicator}
</span>
}
{this.determinate && this.variant == 'circular' && this.size == 'small' && this.color != 'progress'
{this.determinate && this.variant == 'circular' && this.size == 'small' && (this.success || this.error)
?
statusIndicator
:
<progress
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the progress element needs the ID, which is referenced by the label.

{this.determinate && this.variant == 'linear' &&

<span class='cbpLoaderDesc'>{statusDescription}

<label class='cbp-loader-desc'>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might not need the class now that this is a label tag. The label needs to reference the progress' id with `htmlFor={this.progressId}

null
)
}
<slot name='cbp-loader-desc' />
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might not need to be a named slot if you don't have a default slot anywhere... I feel like the app could provide the success and error text as well but we can hold that for a later discussion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants