Skip to content

Instantly share code, notes, and snippets.

@EdCharbeneau
Last active January 16, 2019 22:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EdCharbeneau/07d73d170baf17d4988a0ef601882730 to your computer and use it in GitHub Desktop.
Save EdCharbeneau/07d73d170baf17d4988a0ef601882730 to your computer and use it in GitHub Desktop.
Kendo UI css dependencies
{
"version": "1.0",
"defaultProvider": "unpkg",
"libraries": [
{
"library": "@progress/kendo-theme-default@3.0.0",
"destination": "wwwroot/css/kendo-default",
"files": [
"dist/all.css"
]
},
{
"library": "@progress/kendo-theme-bootstrap@3.0.0",
"destination": "wwwroot/css/kendo-bootstrap",
"files": [
"dist/all.css"
]
},
{
"library": "@progress/kendo-theme-material@2.0.0",
"destination": "wwwroot/css/kendo-material",
"files": [
"dist/all.css"
]
}
]
}
<select onchange=@HandleThemeChange>
@foreach (var t in themes)
{
<option value=@t>@t</option>
}
</select>
@functions {
string[] themes = { "Default", "Bootstrap", "Material" };
async void HandleThemeChange(UIChangeEventArgs e)
{
string themePath = $"css/kendo-{e.Value}/dist/all.css".ToLower();
await Microsoft.JSInterop.JSRuntime.Current.InvokeAsync<string>("theme.changeCss", themePath);
}
}
window.theme = {
changeCss: function (cssFile) {
var oldlink = document.getElementById("kendoCss");
var newlink = document.createElement("link");
newlink.setAttribute("id", "kendoCss");
newlink.setAttribute("rel", "stylesheet");
newlink.setAttribute("type", "text/css");
newlink.setAttribute("href", cssFile);
document.getElementsByTagName("head").item(0).replaceChild(newlink, oldlink);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment