Kendo-angular: ng add <package> always registers a theme

Created on 19 Jul 2018  路  3Comments  路  Source: telerik/kendo-angular

I'm submitting a...

  • Bug report

Current behavior

Executing ng add @progress/kendo-angular-* will always register a theme in angular.json. This would normally be "kendo-theme-default" unless the styles section already contains a known theme.

In any case, the theme must be manually removed from angular.json if it is not desired - e.g. a custom theme is in use.

Expected behavior

The schematic should register the styles only if there is no kendo-theme-* _package_ installed.

Minimal reproduction of the problem with instructions

  1. Run ng new test-project --style=scss
  2. Run cd test-project
  3. Run ng add @progress/kendo-angular-buttons
  4. Remove the object containing "kendo-theme-default" from styles in angular.json (two in total):

    {
        "input": "node_modules/@progress/kendo-theme-default/scss/all.scss"
    },
    
  5. Add the following lines to src/styles.css:

    @import "~@progress/kendo-theme-default/scss/all";
    
  6. Run ng add @progress/kendo-angular-inputs
  7. Observe that angular.json now contains a reference to "kendo-theme-default"

What is the motivation or use case for changing the behavior?

Adding the theme by default is a convenience feature that ensures that the components are immediately ready for use. It becomes a problem when a custom theme is in use.

The schematic doesn't detect this scenario and will add a theme anyway. This results in an increased bundle size and styling issues.

Environment

N/A

/cc @gyoshev @rkonstantinov

Bug Styling

Most helpful comment

Update: Decided to drop the optional theme parameter as registering themes is a non-trivial task. For example, the user might be including styles for specific components, the file layout can be arbitrary, etc.

This limits the schematic to registering a theme only on first use, leaving the components in a fully functional state until the user decides to change or customize the theme. More importantly, it prevents the schematic from doing harm to existing projects.

All 3 comments

Update: The schematics have been updated to register the pre-built CSS files instead of SASS, improving build times and compatibility with IE.

Existing users are urged to replace the theme registration (2 instances) in angular.json with:

{
   "input": "node_modules/@progress/kendo-theme-default/dist/all.css"
}

Update: Decided to drop the optional theme parameter as registering themes is a non-trivial task. For example, the user might be including styles for specific components, the file layout can be arbitrary, etc.

This limits the schematic to registering a theme only on first use, leaving the components in a fully functional state until the user decides to change or customize the theme. More importantly, it prevents the schematic from doing harm to existing projects.

Fixed to register theme only on first install. No styles will be imported if the project has a dependency to any of the@progress/kendo-theme-* packages.

Was this page helpful?
0 / 5 - 0 ratings