Sharing Code and Resources (Part 4)
Adding CSS To
MyBlogServerSide
- Open Pages/_Host.cshtml.
- Remove these rows-
<link
rel = “stylesheet” href = “css/bootstrap/bootstrap.min.css” />
<link
href = “css/site.css” rel = “stylesheet” />
- Add a reference to the new stylesheet (containing both Bootstrap and the BootSwatch Darkly theme)-
<link
rel = “stylesheet” href = “_content/MyBlog.Shared/MyBlogStyle.min.css” />
- Open App.Razor and, in the router
component, add the following as an additional property-AdditionalAssemblies="new[]
{ typeof(MyBlog.Shared.Pages. Index).Assembly}"
- In _Imports.Razor,
add the following namespaces-
@using MyBlog.Shared
@using
MyBlog.Shared.Shared
- Set MyBlogServerSide as the start-up project and run the project by pressing Ctrl + F5.
Adding CSS To MyBlogWebAssembly.Client
- In the MyBlogWebAssembly.Client project, open wwwroot/index.html:
- Remove the following lines-
<link
href = “css/bootstrap/bootstrap.min.css” rel = “stylesheet” />
<link
href = “css/app.css” rel = “stylesheet” />
- Add the CSS-
<link
rel = “stylesheet” href = “_content/MyBlog.Shared/ MyBlogStyle.min.css” />
- Set MyBlogwebAssembly.Server
as the start-up project and run the project by pressing Ctrl + F5.
Making Admin Interface More
Useable
- Open MyBlogWebAssembly.Client/Shared/MainLayout.razor and put AutorizeView around the sidebar div.
- Do the same thing with MyBlogServerSide/Shared/MainLayout.razor.
- Set MyBlogServerSide as the start-up project and run it by pressing Ctrl + F5.
- Verify that the menu is only visible when you are logged in by logging in and out.
Making The Menu More Useful
- Open a web browser and navigate to https://github.com/twbs/icons/ releases/latest/.
- At the bottom of the page under the Assets header, there is a link to bootstrap icons-{versionnumber}.zip. Download that file.
- Once it's downloaded, extract the ZIP and copy bootstrap-Icons {versionnumber} to the wwwroot folder in our MyBlog.Shared project.
- We also need to change the top of the wwwroot\bootstrap icons-1.4.1\font\bootstrap-icons.css file. The path to the files needs to be the correct one taking into account that the file is in a library.
- Click on MyBlog.Shared/wwwroot/bootstrap-icons-1.4.1/fonts/ bootstrap-icons.woff and make sure that Copy to Output directory is set to Copy if newer.
- Click on MyBlog.Shared/wwwroot/bootstrap-icons-1.4.1 /fonts/ bootstrap-icons.woff2 and make sure that Copy to Output directory is set to Copy if newer.
- In the MyBlog.Shared project, open the Shared/Navmenu.razor file and edit the code.
Conclusion
We have successfully made
changes in the links and the icons of a file.
Comments
Post a Comment