SAP / ui5-webcomponents

UI5 Web Components - the enterprise-flavored sugar on top of native APIs! Build SAP Fiori user interfaces with the technology of your choice.
https://sap.github.io/ui5-webcomponents/
Apache License 2.0
1.51k stars 260 forks source link

IllustratedMessage: Named imports of illustrations #8070

Closed ej612 closed 8 months ago

ej612 commented 8 months ago

Is your feature request related to a problem?

Hi there and happy new year,

We have an IllustratedMessage with different illustrations for different cases. Let's say our code looks like this:

import { IllustratedMessage, IllustrationMessageType } from '@ui5/webcomponents-react';
import '@ui5/webcomponents-fiori/dist/illustrations/BeforeSearch';

const App = () => (
  <IllustratedMessage
      name={IllustrationMessageType.BeforeSearch}
  />
);

For each illustration we use, we need to add a corresponding @ui5/webcomponents-fiori/dist/illustrations/* import. I'm aware that an AllIllustrations.js import exists, but in our organization, we are discouraged from using it as it increases the build chunk size. Having this implicit dependency between the illustration and its import is a potential point of failure, as not every contributor is aware of this and might update or add an illustration without adding or modifying the corresponding import.

Describe the solution you'd like

When using icons, we don't have this problem:

import { Button } from '@ui5/webcomponents-react';
import editIcon from '@ui5/webcomponents-icons/dist/edit';

const App = () => (
  <Button
      icon={editIcon}
  />
);

With a named import like this, we never run the risk of diverging between an icon and its corresponding import.

So my question is: Is using named imports like this currently possible with the IllustratedMessage component? And if not, would it be possible to add this functionality? IllustrationMessageType could then be deprecated (or not, as you please).

Thank you very much in advance!

Describe alternatives you've considered

No response

Additional Context

No response

Declaration

Lukas742 commented 8 months ago

Hi @ej612

currently, there's no default export for illustrations, so named imports aren't supported.

Since the UI5 Web Components team handles the implementation of the illustrations and the IllustratedMessage component, I'll transfer your feature request to their repository for consideration.

MarcusNotheis commented 8 months ago

Love this idea! Just adding my 2 cents: I think this might be a duplicate of #6735, but the description of this issue is with a way better than mine :)