Skip to content

Commit 6e523a7

Browse files
committed
feat: add icons for the nav
1 parent 613d578 commit 6e523a7

File tree

3 files changed

+42
-20
lines changed

3 files changed

+42
-20
lines changed

hello-world/blazor/README.md

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@ In this guide, we will be using [`dynamsoft-barcode-reader-bundle 10.2.1000`](ht
1616

1717
## Preparation
1818

19-
This sample was developed with Visual Studio 2022. For a more in-depth guide, please follow Microsoft's tutorial on [Building your first web app with ASP.NET Core using Blazor](https://dotnet.microsoft.com/en-us/learn/aspnet/blazor-tutorial/intro).
19+
This sample was developed using Visual Studio 2022. For a more in-depth guide on creating a Blazor web application with Visual Studio 2022, please follow Microsoft's tutorial on [Building your first web app with ASP.NET Core using Blazor](https://dotnet.microsoft.com/en-us/learn/aspnet/blazor-tutorial/intro).
2020

2121
## Quick Start
2222

23-
In Visual Studio 2022, click on the `Start Debugging` button (green arrow) in the Debug Toolbar run the app.
23+
1. **Open the application** in Visual Studio 2022 by clicking the `Open a Project or Solution` button, and choosing on the `BlazorApp.csproj` file.
2424

25-
A window should open to view the sample application
25+
2. **Run the application** by clicking the `Start Debugging` button (a green arrow) in the Debug Toolbar.
26+
27+
3. A window should open to view the sample application
2628

2729
> Note:
2830
>
@@ -114,7 +116,7 @@ These functions will be called by the Blazor components through JavaScript Inter
114116

115117
Reference: https://learn.microsoft.com/en-us/aspnet/core/blazor/javascript-interoperability/call-javascript-from-dotnet?view=aspnetcore-8.0#invoke-js-functions
116118

117-
```
119+
```javascript
118120
// Create JS function "startVideoDecode"
119121
window.startVideoDecode = async () => {
120122
const cameraViewContainer = document.getElementById("camera-view-container");
@@ -229,7 +231,7 @@ These functions will be called by the Blazor components through JavaScript Inter
229231
230232
Reference: https://learn.microsoft.com/en-us/aspnet/core/blazor/javascript-interoperability/call-javascript-from-dotnet?view=aspnetcore-8.0#invoke-js-functions
231233
232-
```
234+
```javascript
233235
// Create JS function "startImageDecode"
234236
window.startImageDecode = async () => {
235237
const inputElement = document.getElementById("inputElement");
@@ -328,28 +330,40 @@ Inside the `wwwroot\index.html` file, we will initialize the license and necessa
328330
> * `initLicense()` specify a license key to use the library. You can visit https://www.dynamsoft.com/customer/license/trialLicense?utm_source=sample&product=dbr&package=js to get your own trial license good for 30 days.
329331
330332
331-
### Modify the `Layout\NavMenu.razor` file
333+
### Modify the `Layout\NavMenu.razor` and `Layout\NavMenu.razor.css` file
332334
333-
Add this block of code to ensure that the pages we've created are accessible through the sidebar
335+
To make sure the `Decode Video` and `Decode Image` pages are accessible from the sidebar, add the following code block to `Layout\NavMenu.razor`.
334336
335337
```html
336338
...
337-
<div class="nav-item px-3">
338-
<NavLink class="nav-link" href="video" Match="NavLinkMatch.All">
339-
<span class="bi bi-house-door-fill-nav-menu" aria-hidden="true"></span> Decode Video
340-
</NavLink>
341-
</div>
342-
<div class="nav-item px-3">
343-
<NavLink class="nav-link" href="image" Match="NavLinkMatch.All">
344-
<span class="bi bi-house-door-fill-nav-menu" aria-hidden="true"></span> Decode Image
345-
</NavLink>
346-
</div>
339+
<div class="nav-item px-3">
340+
<NavLink class="nav-link" href="video" Match="NavLinkMatch.All">
341+
<span class="bi bi-video-fill-nav-menu" aria-hidden="true"></span> Decode Video
342+
</NavLink>
343+
</div>
344+
<div class="nav-item px-3">
345+
<NavLink class="nav-link" href="image" Match="NavLinkMatch.All">
346+
<span class="bi bi-camera-fill-nav-menu" aria-hidden="true"></span> Decode Image
347+
</NavLink>
348+
</div>
347349
...
348350
```
349351
352+
We'll also add the following CSS code to include the icons for `Decode Video` and `Decode Image` in the `Layout\NavMenu.razor.css` file.
353+
354+
```css
355+
.bi-video-fill-nav-menu {
356+
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-camera-video-fill' viewBox='0 0 16 16'%3E%3Cpath d='M0 5a2 2 0 0 1 2-2h7.5a2 2 0 0 1 1.983 1.738l3.11-1.382A1 1 0 0 1 16 4.269v7.462a1 1 0 0 1-1.406.913l-3.111-1.382A2 2 0 0 1 9.5 13H2a2 2 0 0 1-2-2z'/%3E%3C/svg%3E");
357+
}
358+
359+
.bi-camera-fill-nav-menu {
360+
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-camera-fill' viewBox='0 0 16 16'%3E%3Cpath d='M2 4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2h-1.172a2 2 0 0 1-1.414-.586l-.828-.828A2 2 0 0 0 9.172 2H6.828a2 2 0 0 0-1.414.586l-.828.828A2 2 0 0 1 3.172 4zm.5 2a.5.5 0 1 1 0-1 .5.5 0 0 1 0 1m9 2.5a3.5 3.5 0 1 1-7 0 3.5 3.5 0 0 1 7 0'/%3E%3C/svg%3E");
361+
}
362+
```
363+
350364
## Run the application
351365
352-
In Visual Studio 2022, click on the `Start Debugging` button (green arrow) in the Debug Toolbar run the app.
366+
We can run the application by clicking the `Start Debugging` button (a green arrow) in the Debug Toolbar.
353367
354368
If you followed all the steps correctly, you will have a working page that turns one of the cameras hooked to or built in your computer or mobile device into a barcode scanner. Also, if you want to decode a local image, just click the `Decode Image` button and select the image you want to decode.
355369

hello-world/blazor/hello-world-blazor/BlazorApp/Layout/NavMenu.razor

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616
</div>
1717
<div class="nav-item px-3">
1818
<NavLink class="nav-link" href="video" Match="NavLinkMatch.All">
19-
<span class="bi bi-house-door-fill-nav-menu" aria-hidden="true"></span> Decode Video
19+
<span class="bi bi-video-fill-nav-menu" aria-hidden="true"></span> Decode Video
2020
</NavLink>
2121
</div>
2222
<div class="nav-item px-3">
2323
<NavLink class="nav-link" href="image" Match="NavLinkMatch.All">
24-
<span class="bi bi-house-door-fill-nav-menu" aria-hidden="true"></span> Decode Image
24+
<span class="bi bi-camera-fill-nav-menu" aria-hidden="true"></span> Decode Image
2525
</NavLink>
2626
</div>
2727
</nav>

hello-world/blazor/hello-world-blazor/BlazorApp/Layout/NavMenu.razor.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@
2929
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-plus-square-fill' viewBox='0 0 16 16'%3E%3Cpath d='M2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2H2zm6.5 4.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3a.5.5 0 0 1 1 0z'/%3E%3C/svg%3E");
3030
}
3131

32+
.bi-video-fill-nav-menu {
33+
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-camera-video-fill' viewBox='0 0 16 16'%3E%3Cpath d='M0 5a2 2 0 0 1 2-2h7.5a2 2 0 0 1 1.983 1.738l3.11-1.382A1 1 0 0 1 16 4.269v7.462a1 1 0 0 1-1.406.913l-3.111-1.382A2 2 0 0 1 9.5 13H2a2 2 0 0 1-2-2z'/%3E%3C/svg%3E");
34+
}
35+
36+
.bi-camera-fill-nav-menu {
37+
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-camera-fill' viewBox='0 0 16 16'%3E%3Cpath d='M2 4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2h-1.172a2 2 0 0 1-1.414-.586l-.828-.828A2 2 0 0 0 9.172 2H6.828a2 2 0 0 0-1.414.586l-.828.828A2 2 0 0 1 3.172 4zm.5 2a.5.5 0 1 1 0-1 .5.5 0 0 1 0 1m9 2.5a3.5 3.5 0 1 1-7 0 3.5 3.5 0 0 1 7 0'/%3E%3C/svg%3E");
38+
}
39+
3240
.bi-list-nested-nav-menu {
3341
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-list-nested' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M4.5 11.5A.5.5 0 0 1 5 11h10a.5.5 0 0 1 0 1H5a.5.5 0 0 1-.5-.5zm-2-4A.5.5 0 0 1 3 7h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5zm-2-4A.5.5 0 0 1 1 3h10a.5.5 0 0 1 0 1H1a.5.5 0 0 1-.5-.5z'/%3E%3C/svg%3E");
3442
}

0 commit comments

Comments
 (0)