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

Add generated style properties under a single namespace #14

Open
ninopenttinen opened this issue Feb 2, 2024 · 3 comments
Open

Add generated style properties under a single namespace #14

ninopenttinen opened this issue Feb 2, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@ninopenttinen
Copy link
Collaborator

We had this ticketed in our project, so I thought I might as well raise an issue about it here, since FDS is no longer "under our jurisdiction".

Original ticket description (in finnish):

Tällä hetkellä coreui-css-kirjastosta importoitavat tyylipropertyt täytyy importata erikseen, esim.

import {
  FdsColorInteractive200,
  FdsColorInteractive300,
  FdsSize1,
  FdsSize3,
  FdsTypographyHeadingSmallHeading5FontSize,
} from '@fintraffic-design/coreui-css'

Olisi kätevämpää jos tämän sijaan voisi importoida yhden Fds-namespacen. Tämän voi toteuttaa coreui-css-kirjastossa tiedostoon index.js (ja index.d.ts):

// ...
export * as Fds from './style-properties'

Ongelmana tässä on se, että esbuild ei tällä hetkellä hyödynnä tree-shake-ominaisuutta namespace-exporteille: evanw/esbuild#1420

Toteutetaan tämä kun esbuild-ongelma ratkeaa tai tähän löytyy jokin muu tapa.

@ninopenttinen
Copy link
Collaborator Author

For more context: #6

@Haprog
Copy link
Contributor

Haprog commented Apr 8, 2024

As a workaround you can already do:

import * as Fds from '@fintraffic/fds-coreui-css'

But I guess a benefit from having a wildcard export from the package would be so that your IDE can auto-import it. We would need to carefully consider the naming of the namespace export though to not conflict with what we might want to export from the components package for example.

But also if used from namespace like Fds, the usage would get a bit repetitive being Fds.Fds<Something> unless the constants within the namespace would be with shorter names without the extra prefix but that change would probably not be so trivial anymore (at least if we want to keep supporting the current import style without namespace also).

@Haprog Haprog added the enhancement New feature or request label Apr 8, 2024
@ninopenttinen
Copy link
Collaborator Author

Thanks for the workaround, didn't event consider we could do that too. But yeah, would of course be nice to just get it directly from FDS with an auto-complete, auto-import and all that.

Regards to the naming, moving from the direct imports into namespace import would be ideal imo. Then we would not need the extra prefix e.g. Fds.ColorInteractive200, and would also be enforcing a certain style for usage (which would be good).

Of course hard to say how much of a "breaking change" this would be for other projects using this library.

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

No branches or pull requests

2 participants