Search code examples
spartacus-storefront

Cannot find name 'DirectionConfig' in SAP Spartacus


I am trying to add RTL configuration in my SAP storefront. While implementing the configurations I am getting the error

Cannot find name DirectionConfig

and

Cannot find name DirectionMode

How to resolve this? Also, give some input to change the language and direction on clicking a change language button.


Solution

  • What version are you using? Since 2.1, these configuration are added to the public api of the storefront library. You should be able to import them, using:

    import {
      DirectionConfig,
      DirectionMode
    } from '@spartacus/storefront';
    

    The docs on directionality can be found at https://sap.github.io/spartacus-docs/directionality/. This documentations states that

    In Spartacus, the direction of the UI reflects the active language

    This means, that whenever the language is changed, the new (active) language will be used in the directionality logic.