fintraffic-design / fds-coreui-css

SCSS/CSS Framework for Fintraffic Design System
European Union Public License 1.2
0 stars 1 forks source link

Add generated style properties under a single namespace #14

Open ninopenttinen opened 9 months ago

ninopenttinen commented 9 months ago

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: https://github.com/evanw/esbuild/issues/1420

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

ninopenttinen commented 9 months ago

For more context: https://github.com/fintraffic-design/fds-coreui-css/pull/6

Haprog commented 7 months ago

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).

ninopenttinen commented 7 months ago

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.