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

Empty state component #476

Merged
merged 8 commits into from
Feb 21, 2025
Merged

Empty state component #476

merged 8 commits into from
Feb 21, 2025

Conversation

Xegushu
Copy link
Contributor

@Xegushu Xegushu commented Feb 19, 2025

What does this PR do?

This PR adds an empty state component

What are the observable changes?

image

Good PR checklist

  • Title makes sense
  • Is against the correct branch
  • Only addresses one issue
  • Properly assigned
  • Added/updated tests
  • Added/updated documentation
  • Migrated touched components to Glimmer Components
  • Properly labeled

@Xegushu Xegushu self-assigned this Feb 19, 2025
Copy link

linear bot commented Feb 19, 2025

Comment on lines 6 to 7
{{else if @image}}
<OSS::Badge @icon={{@image}} @size="lg" />
Copy link
Member

Choose a reason for hiding this comment

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

@badgeIcon instead of @image would be better imo

@@ -0,0 +1,22 @@
<div class="fx-1 fx-col fx-xalign-center fx-gap-px-18">
{{#if (has-block "image")}}
<span class="">
Copy link
Member

Choose a reason for hiding this comment

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

why the span here? as it's a named block, let's just let the caller handle the content here. same below for the actions

Comment on lines 10 to 15
<div class="font-color-gray-900 font-size-{{this.titleSize}} font-weight-semibold">
{{@title}}
</div>
<div class="font-color-gray-500 font-size-{{this.subtitleSize}}">
{{@subtitle}}
</div>
Copy link
Member

Choose a reason for hiding this comment

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

title & subtitle are marked as optional in the TS but there is no check on their presence here, leading to empty divs.

I think we can remove the optional side in the TS and make both mandatory for now (i don't remember seeing an empty state w/ only a subtitle, or only a title)

Also, i think the div can be span instead.

get subtitleSize(): string {
return this.args.size || 'md';
}
}
Copy link
Member

Choose a reason for hiding this comment

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

you could add a size getter that returns this.args.size ?? 'md' and use it locally. or even:

get size(): string {
  return ['sm', 'md'].includes(this.args.size) ? this.args.size : 'md';
}

(so we properly handle invalid sizes)

@@ -0,0 +1,18 @@
<div class="fx-1 fx-col fx-xalign-center fx-gap-px-18">
Copy link
Member

Choose a reason for hiding this comment

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

I think we should include splattributes here just to be safe

Aside from the classes, it will allow us to define a data-control-name in the parent if needed

return this.size === 'sm' ? 'md' : 'lg';
}

get size(): string {
Copy link
Member

Choose a reason for hiding this comment

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

nit: maybe have subtitleSize here to match naming scheme with titleSize ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have mixed feelings about this because it's also used for invalid values handling
Or should I add a subtitleSize getter that just pass the size getter ?

control: { type: 'text' }
},
title: {
description: 'The title of the state',
Copy link
Member

Choose a reason for hiding this comment

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

Nit: I would remove "state" alone because it can have loads of definitions which are not in this context.

How about
title: "A title displayed below the icon or badge in the component" ?
subtitle: "A subtitle displayed under the title in the component"

assert.dom('.upf-badge').exists();
});

test('it supports block usage for image', async function (assert) {
Copy link
Member

Choose a reason for hiding this comment

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

nit: named-block instead of just block, same at line 39

assert.dom('button').hasText('Retry');
});

test('it applies size-based styles', async function (assert) {
Copy link
Member

Choose a reason for hiding this comment

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

missing test for MD size ?

}

get size(): string {
return this.args.size && ['sm', 'md'].includes(this.args.size) ? this.args.size : 'md';
Copy link
Contributor

Choose a reason for hiding this comment

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

You can set ['sm', 'md'] in const with ALLOWED_SIZE for example of wording

assert.dom('button').hasText('Retry');
});

test('it applies size-based styles', async function (assert) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing not allowed size like random

size?: 'sm' | 'md';
}

const ALLOWED_SIZE = ['sm', 'md'];
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const ALLOWED_SIZE = ['sm', 'md'];
const ALLOWED_SIZES = ['sm', 'md'];

My bad I forget the "s" at the end, don't forget the type also

Copy link
Contributor

@JulienVannier66 JulienVannier66 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@Miexil Miexil left a comment

Choose a reason for hiding this comment

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

Minor typo left in story book, pre-approving ✅

parameters: {
docs: {
description: {
component: 'An component used when there is nothing to display on a page'
Copy link
Member

Choose a reason for hiding this comment

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

Small typo here, should be A component instead of an :)

@Xegushu Xegushu merged commit d0e5e21 into master Feb 21, 2025
3 checks passed
@Xegushu Xegushu deleted the hc/vel-4677/empty-state-component branch February 21, 2025 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants