├── .gitattributes ├── .gitignore ├── BlazorEmbedContent.sln ├── Directory.Build.props ├── LICENSE ├── README.md ├── samples ├── BlazorComponentSample │ ├── BlazorComponentSample.csproj │ ├── Component1.razor │ ├── ExampleJsInterop.cs │ ├── Properties │ │ └── launchSettings.json │ └── content │ │ ├── background.png │ │ ├── exampleJsInterop.js │ │ └── styles.css ├── BlazorEmbedContent │ ├── App.razor │ ├── BlazorEmbedContent.csproj │ ├── Pages │ │ ├── Counter.razor │ │ ├── FetchData.razor │ │ ├── Index.razor │ │ └── _Imports.razor │ ├── Program.cs │ ├── Properties │ │ └── launchSettings.json │ ├── Shared │ │ ├── MainLayout.razor │ │ ├── NavMenu.razor │ │ └── SurveyPrompt.razor │ ├── Startup.cs │ ├── _Imports.razor │ └── wwwroot │ │ ├── css │ │ ├── bootstrap │ │ │ ├── bootstrap.min.css │ │ │ └── bootstrap.min.css.map │ │ ├── open-iconic │ │ │ ├── FONT-LICENSE │ │ │ ├── ICON-LICENSE │ │ │ ├── README.md │ │ │ └── font │ │ │ │ ├── css │ │ │ │ └── open-iconic-bootstrap.min.css │ │ │ │ └── fonts │ │ │ │ ├── open-iconic.eot │ │ │ │ ├── open-iconic.otf │ │ │ │ ├── open-iconic.svg │ │ │ │ ├── open-iconic.ttf │ │ │ │ └── open-iconic.woff │ │ └── site.css │ │ ├── index.html │ │ └── sample-data │ │ └── weather.json └── RazorComponentsSample │ └── RazorComponentsSample.Server │ ├── Components │ ├── App.razor │ ├── Pages │ │ ├── Counter.razor │ │ ├── FetchData.razor │ │ ├── Index.razor │ │ └── _ViewImports.cshtml │ ├── Shared │ │ ├── MainLayout.razor │ │ ├── NavMenu.razor │ │ └── _ViewImports.cshtml │ └── _ViewImports.cshtml │ ├── Pages │ ├── Index.cshtml │ └── _ViewImports.cshtml │ ├── Program.cs │ ├── Properties │ └── launchSettings.json │ ├── RazorComponentsSample.Server.csproj │ ├── Services │ ├── WeatherForecast.cs │ └── WeatherForecastService.cs │ ├── Startup.cs │ ├── appsettings.Development.json │ ├── appsettings.json │ └── wwwroot │ └── css │ ├── bootstrap │ ├── bootstrap.min.css │ └── bootstrap.min.css.map │ ├── open-iconic │ ├── FONT-LICENSE │ ├── ICON-LICENSE │ ├── README.md │ └── font │ │ ├── css │ │ └── open-iconic-bootstrap.min.css │ │ └── fonts │ │ ├── open-iconic.eot │ │ ├── open-iconic.otf │ │ ├── open-iconic.svg │ │ ├── open-iconic.ttf │ │ └── open-iconic.woff │ └── site.css └── src └── BlazorEmbedLibrary ├── BlazorDirectoryContents.cs ├── BlazorEmbedLibrary.csproj ├── BlazorFileInfo.cs ├── BlazorFileProvider.cs ├── EmbeddedContent.cs └── Properties └── launchSettings.json /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Build results 17 | [Dd]ebug/ 18 | [Dd]ebugPublic/ 19 | [Rr]elease/ 20 | [Rr]eleases/ 21 | x64/ 22 | x86/ 23 | [Aa][Rr][Mm]/ 24 | [Aa][Rr][Mm]64/ 25 | bld/ 26 | [Bb]in/ 27 | [Oo]bj/ 28 | [Ll]og/ 29 | 30 | # Visual Studio 2015/2017 cache/options directory 31 | .vs/ 32 | # Uncomment if you have tasks that create the project's static files in wwwroot 33 | #wwwroot/ 34 | 35 | # Visual Studio 2017 auto generated files 36 | Generated\ Files/ 37 | 38 | # MSTest test Results 39 | [Tt]est[Rr]esult*/ 40 | [Bb]uild[Ll]og.* 41 | 42 | # NUNIT 43 | *.VisualState.xml 44 | TestResult.xml 45 | 46 | # Build Results of an ATL Project 47 | [Dd]ebugPS/ 48 | [Rr]eleasePS/ 49 | dlldata.c 50 | 51 | # Benchmark Results 52 | BenchmarkDotNet.Artifacts/ 53 | 54 | # .NET Core 55 | project.lock.json 56 | project.fragment.lock.json 57 | artifacts/ 58 | 59 | # StyleCop 60 | StyleCopReport.xml 61 | 62 | # Files built by Visual Studio 63 | *_i.c 64 | *_p.c 65 | *_h.h 66 | *.ilk 67 | *.meta 68 | *.obj 69 | *.iobj 70 | *.pch 71 | *.pdb 72 | *.ipdb 73 | *.pgc 74 | *.pgd 75 | *.rsp 76 | *.sbr 77 | *.tlb 78 | *.tli 79 | *.tlh 80 | *.tmp 81 | *.tmp_proj 82 | *_wpftmp.csproj 83 | *.log 84 | *.vspscc 85 | *.vssscc 86 | .builds 87 | *.pidb 88 | *.svclog 89 | *.scc 90 | 91 | # Chutzpah Test files 92 | _Chutzpah* 93 | 94 | # Visual C++ cache files 95 | ipch/ 96 | *.aps 97 | *.ncb 98 | *.opendb 99 | *.opensdf 100 | *.sdf 101 | *.cachefile 102 | *.VC.db 103 | *.VC.VC.opendb 104 | 105 | # Visual Studio profiler 106 | *.psess 107 | *.vsp 108 | *.vspx 109 | *.sap 110 | 111 | # Visual Studio Trace Files 112 | *.e2e 113 | 114 | # TFS 2012 Local Workspace 115 | $tf/ 116 | 117 | # Guidance Automation Toolkit 118 | *.gpState 119 | 120 | # ReSharper is a .NET coding add-in 121 | _ReSharper*/ 122 | *.[Rr]e[Ss]harper 123 | *.DotSettings.user 124 | 125 | # JustCode is a .NET coding add-in 126 | .JustCode 127 | 128 | # TeamCity is a build add-in 129 | _TeamCity* 130 | 131 | # DotCover is a Code Coverage Tool 132 | *.dotCover 133 | 134 | # AxoCover is a Code Coverage Tool 135 | .axoCover/* 136 | !.axoCover/settings.json 137 | 138 | # Visual Studio code coverage results 139 | *.coverage 140 | *.coveragexml 141 | 142 | # NCrunch 143 | _NCrunch_* 144 | .*crunch*.local.xml 145 | nCrunchTemp_* 146 | 147 | # MightyMoose 148 | *.mm.* 149 | AutoTest.Net/ 150 | 151 | # Web workbench (sass) 152 | .sass-cache/ 153 | 154 | # Installshield output folder 155 | [Ee]xpress/ 156 | 157 | # DocProject is a documentation generator add-in 158 | DocProject/buildhelp/ 159 | DocProject/Help/*.HxT 160 | DocProject/Help/*.HxC 161 | DocProject/Help/*.hhc 162 | DocProject/Help/*.hhk 163 | DocProject/Help/*.hhp 164 | DocProject/Help/Html2 165 | DocProject/Help/html 166 | 167 | # Click-Once directory 168 | publish/ 169 | 170 | # Publish Web Output 171 | *.[Pp]ublish.xml 172 | *.azurePubxml 173 | # Note: Comment the next line if you want to checkin your web deploy settings, 174 | # but database connection strings (with potential passwords) will be unencrypted 175 | *.pubxml 176 | *.publishproj 177 | 178 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 179 | # checkin your Azure Web App publish settings, but sensitive information contained 180 | # in these scripts will be unencrypted 181 | PublishScripts/ 182 | 183 | # NuGet Packages 184 | *.nupkg 185 | # The packages folder can be ignored because of Package Restore 186 | **/[Pp]ackages/* 187 | # except build/, which is used as an MSBuild target. 188 | !**/[Pp]ackages/build/ 189 | # Uncomment if necessary however generally it will be regenerated when needed 190 | #!**/[Pp]ackages/repositories.config 191 | # NuGet v3's project.json files produces more ignorable files 192 | *.nuget.props 193 | *.nuget.targets 194 | 195 | # Microsoft Azure Build Output 196 | csx/ 197 | *.build.csdef 198 | 199 | # Microsoft Azure Emulator 200 | ecf/ 201 | rcf/ 202 | 203 | # Windows Store app package directories and files 204 | AppPackages/ 205 | BundleArtifacts/ 206 | Package.StoreAssociation.xml 207 | _pkginfo.txt 208 | *.appx 209 | 210 | # Visual Studio cache files 211 | # files ending in .cache can be ignored 212 | *.[Cc]ache 213 | # but keep track of directories ending in .cache 214 | !?*.[Cc]ache/ 215 | 216 | # Others 217 | ClientBin/ 218 | ~$* 219 | *~ 220 | *.dbmdl 221 | *.dbproj.schemaview 222 | *.jfm 223 | *.pfx 224 | *.publishsettings 225 | orleans.codegen.cs 226 | 227 | # Including strong name files can present a security risk 228 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 229 | #*.snk 230 | 231 | # Since there are multiple workflows, uncomment next line to ignore bower_components 232 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 233 | #bower_components/ 234 | # ASP.NET Core default setup: bower directory is configured as wwwroot/lib/ and bower restore is true 235 | **/wwwroot/lib/ 236 | 237 | # RIA/Silverlight projects 238 | Generated_Code/ 239 | 240 | # Backup & report files from converting an old project file 241 | # to a newer Visual Studio version. Backup files are not needed, 242 | # because we have git ;-) 243 | _UpgradeReport_Files/ 244 | Backup*/ 245 | UpgradeLog*.XML 246 | UpgradeLog*.htm 247 | ServiceFabricBackup/ 248 | *.rptproj.bak 249 | 250 | # SQL Server files 251 | *.mdf 252 | *.ldf 253 | *.ndf 254 | 255 | # Business Intelligence projects 256 | *.rdl.data 257 | *.bim.layout 258 | *.bim_*.settings 259 | *.rptproj.rsuser 260 | *- Backup*.rdl 261 | 262 | # Microsoft Fakes 263 | FakesAssemblies/ 264 | 265 | # GhostDoc plugin setting file 266 | *.GhostDoc.xml 267 | 268 | # Node.js Tools for Visual Studio 269 | .ntvs_analysis.dat 270 | node_modules/ 271 | 272 | # Visual Studio 6 build log 273 | *.plg 274 | 275 | # Visual Studio 6 workspace options file 276 | *.opt 277 | 278 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 279 | *.vbw 280 | 281 | # Visual Studio LightSwitch build output 282 | **/*.HTMLClient/GeneratedArtifacts 283 | **/*.DesktopClient/GeneratedArtifacts 284 | **/*.DesktopClient/ModelManifest.xml 285 | **/*.Server/GeneratedArtifacts 286 | **/*.Server/ModelManifest.xml 287 | _Pvt_Extensions 288 | 289 | # Paket dependency manager 290 | .paket/paket.exe 291 | paket-files/ 292 | 293 | # FAKE - F# Make 294 | .fake/ 295 | 296 | # JetBrains Rider 297 | .idea/ 298 | *.sln.iml 299 | 300 | # CodeRush personal settings 301 | .cr/personal 302 | 303 | # Python Tools for Visual Studio (PTVS) 304 | __pycache__/ 305 | *.pyc 306 | 307 | # Cake - Uncomment if you are using it 308 | # tools/** 309 | # !tools/packages.config 310 | 311 | # Tabs Studio 312 | *.tss 313 | 314 | # Telerik's JustMock configuration file 315 | *.jmconfig 316 | 317 | # BizTalk build output 318 | *.btp.cs 319 | *.btm.cs 320 | *.odx.cs 321 | *.xsd.cs 322 | 323 | # OpenCover UI analysis results 324 | OpenCover/ 325 | 326 | # Azure Stream Analytics local run output 327 | ASALocalRun/ 328 | 329 | # MSBuild Binary and Structured Log 330 | *.binlog 331 | 332 | # NVidia Nsight GPU debugger configuration file 333 | *.nvuser 334 | 335 | # MFractors (Xamarin productivity tool) working folder 336 | .mfractor/ 337 | 338 | # Local History for Visual Studio 339 | .localhistory/ 340 | 341 | # BeatPulse healthcheck temp database 342 | healthchecksdb -------------------------------------------------------------------------------- /BlazorEmbedContent.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.28621.142 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{84E71A33-28B5-485E-81CD-625ED1A95A24}" 7 | ProjectSection(SolutionItems) = preProject 8 | Directory.Build.props = Directory.Build.props 9 | LICENSE = LICENSE 10 | README.md = README.md 11 | EndProjectSection 12 | EndProject 13 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorEmbedLibrary", "src\BlazorEmbedLibrary\BlazorEmbedLibrary.csproj", "{2233FEFD-906A-48BA-B449-E1206CBA7068}" 14 | EndProject 15 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorEmbedContent", "samples\BlazorEmbedContent\BlazorEmbedContent.csproj", "{C8941EE2-3131-442A-8CD4-8E3D8F05E909}" 16 | EndProject 17 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorComponentSample", "samples\BlazorComponentSample\BlazorComponentSample.csproj", "{0E5308C8-4453-44C6-93E2-434E02C5A834}" 18 | EndProject 19 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RazorComponentsSample.Server", "samples\RazorComponentsSample\RazorComponentsSample.Server\RazorComponentsSample.Server.csproj", "{321B4834-0D15-4752-945A-350FE4F3E187}" 20 | EndProject 21 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{9463F8BD-A1F6-446A-9CE5-22BC6CF45F1D}" 22 | EndProject 23 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{F598DD43-93FF-45F7-B972-FA4E3E00D39A}" 24 | EndProject 25 | Global 26 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 27 | Debug|Any CPU = Debug|Any CPU 28 | Release|Any CPU = Release|Any CPU 29 | EndGlobalSection 30 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 31 | {C8941EE2-3131-442A-8CD4-8E3D8F05E909}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 32 | {C8941EE2-3131-442A-8CD4-8E3D8F05E909}.Debug|Any CPU.Build.0 = Debug|Any CPU 33 | {C8941EE2-3131-442A-8CD4-8E3D8F05E909}.Release|Any CPU.ActiveCfg = Release|Any CPU 34 | {C8941EE2-3131-442A-8CD4-8E3D8F05E909}.Release|Any CPU.Build.0 = Release|Any CPU 35 | {2233FEFD-906A-48BA-B449-E1206CBA7068}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 36 | {2233FEFD-906A-48BA-B449-E1206CBA7068}.Debug|Any CPU.Build.0 = Debug|Any CPU 37 | {2233FEFD-906A-48BA-B449-E1206CBA7068}.Release|Any CPU.ActiveCfg = Release|Any CPU 38 | {2233FEFD-906A-48BA-B449-E1206CBA7068}.Release|Any CPU.Build.0 = Release|Any CPU 39 | {0E5308C8-4453-44C6-93E2-434E02C5A834}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 40 | {0E5308C8-4453-44C6-93E2-434E02C5A834}.Debug|Any CPU.Build.0 = Debug|Any CPU 41 | {0E5308C8-4453-44C6-93E2-434E02C5A834}.Release|Any CPU.ActiveCfg = Release|Any CPU 42 | {0E5308C8-4453-44C6-93E2-434E02C5A834}.Release|Any CPU.Build.0 = Release|Any CPU 43 | {321B4834-0D15-4752-945A-350FE4F3E187}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 44 | {321B4834-0D15-4752-945A-350FE4F3E187}.Debug|Any CPU.Build.0 = Debug|Any CPU 45 | {321B4834-0D15-4752-945A-350FE4F3E187}.Release|Any CPU.ActiveCfg = Release|Any CPU 46 | {321B4834-0D15-4752-945A-350FE4F3E187}.Release|Any CPU.Build.0 = Release|Any CPU 47 | EndGlobalSection 48 | GlobalSection(SolutionProperties) = preSolution 49 | HideSolutionNode = FALSE 50 | EndGlobalSection 51 | GlobalSection(NestedProjects) = preSolution 52 | {C8941EE2-3131-442A-8CD4-8E3D8F05E909} = {F598DD43-93FF-45F7-B972-FA4E3E00D39A} 53 | {2233FEFD-906A-48BA-B449-E1206CBA7068} = {9463F8BD-A1F6-446A-9CE5-22BC6CF45F1D} 54 | {0E5308C8-4453-44C6-93E2-434E02C5A834} = {F598DD43-93FF-45F7-B972-FA4E3E00D39A} 55 | {321B4834-0D15-4752-945A-350FE4F3E187} = {F598DD43-93FF-45F7-B972-FA4E3E00D39A} 56 | EndGlobalSection 57 | GlobalSection(ExtensibilityGlobals) = postSolution 58 | SolutionGuid = {DC049A56-A934-4817-8415-152E6BBBAA16} 59 | EndGlobalSection 60 | EndGlobal 61 | -------------------------------------------------------------------------------- /Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 3.0.0-preview9.19424.4 4 | 3.0.0-preview9.19424.4 5 | 1.0.0 6 | 7 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 SQL-MisterMagoo 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # BlazorEmbedLibrary 3 | 4 | This is a component library that provides Blazor-style static file embedding for Razor Components/Blazor. 5 | 6 | Changelog: 7 | 8 | #### Version 1.0.0 9 | - Update to Preview9 10 | 11 | #### Version 0.1.0-beta-4 12 | - Add BlazorFileProvider : Static File Provider that serves embedded files from Blazor Libraries 13 | - Add usage example to RazorComponentSample to serve files from BlazorComponentSample 14 | 15 | #### Version 0.1.0-beta-3 16 | - Restructure source folders 17 | - Add ability to handle multiple component assemblies in one go 18 | - Add ability to block specific content files 19 | -- Including in Blazor 20 | 21 | #### Version 0.1.0-beta-2 22 | - Add compatibility with Pre-Rendering 23 | 24 | #### Version 0.1.0-beta-1 25 | - Initial release 26 | - Enable support for embedded content files (CSS/JS) in Razor Components 27 | 28 | Projects in this repo: 29 | 30 | ## BlazorEmbedLibrary 31 | 32 | This is the component library that provides all the functionality. 33 | 34 | It is a netstandard component library (i.e. a netstandard2.0 library). 35 | 36 | ## How to use this library 37 | 38 | Add the nuget package BlazorEmbedLibrary 39 | 40 | https://www.nuget.org/packages/BlazorEmbedLibrary/ 41 | 42 | #### Using the EmbeddedComponent to extract CSS/JS files 43 | 44 | I recommend placing this in your MainLayout (or equivalent), but you can do it on individual pages if that suits your project. 45 | 46 | Add a *Using* statement to the page to make it easier to reference the component 47 | 48 | *MainLayout.razor* 49 | ``` C# 50 | @using BlazorEmbedLibrary 51 | ``` 52 | 53 | ...add the component : 54 | 55 | ``` HTML 56 | 57 | ``` 58 | ``` C# 59 | @code 60 | { 61 | bool hasConnected = false; 62 | protected override void OnAfterRender(bool firstRender) 63 | { 64 | base.OnAfterRender(firstRender); 65 | if (firstRender) 66 | { 67 | StateHasChanged(); 68 | hasConnected = true; 69 | } 70 | } 71 | } 72 | ``` 73 | 74 | Note, by default the EmbeddedContent component has Debug turned off - if you enable it by setting Debug=true, it outputs the list of embedded resources. 75 | 76 | This will read any CSS or Js files, which are embedded resources, from the Component1 library and add them to the `head` of the document. 77 | 78 | ### Multiple Assemblies 79 | 80 | From version 0.1.0-beta-3 onwards, you can now handle multiple component libraries in one hit using the Assemblies Parameter 81 | 82 | ``` 83 | 84 | 85 | @code 86 | { 87 | List Assemblies = new List() 88 | { 89 | typeof(BlazorComponentSample.Component1).Assembly, 90 | typeof(Blazored.Toast.BlazoredToasts).Assembly 91 | }; 92 | } 93 | 94 | ``` 95 | 96 | ### Block Files 97 | 98 | From version 0.1.0-beta-3 onwards, you can now block individual files using the BlockCss Parameter 99 | 100 | This example will load content from Blazored.Toast and Component1, but will block the *styles.css* from BlazorComponentSample. 101 | 102 | ``` 103 | 104 | 105 | @code 106 | { 107 | List BlockCss = new List() 108 | { 109 | "BlazorComponentSample,styles.css" 110 | }; 111 | 112 | List Assemblies = new List() 113 | { 114 | typeof(BlazorComponentSample.Component1).Assembly, 115 | typeof(Blazored.Toast.BlazoredToasts).Assembly 116 | }; 117 | } 118 | 119 | ``` 120 | 121 | ### Serve Static Files (images/data etc) using BlazorFileProvider 122 | 123 | Available in 0.1.0-beta-4 is a new class that provides aspnetcore middleware to server embedded resources as static files in the pipeline. 124 | 125 | To use this facility in a Razor Components project, add the nuget to your project and simply add the new BlazorFileProvider to your Configure method and pass it a list of Blazor Library assemblies. 126 | 127 | ``` 128 | app.UseStaticFiles(); 129 | app.UseStaticFiles(new StaticFileOptions() 130 | { 131 | FileProvider = new BlazorFileProvider( 132 | new List() 133 | { 134 | typeof(BlazorComponentSample.Component1).Assembly 135 | } 136 | ) 137 | }); 138 | 139 | ``` 140 | 141 | _Note: Currently, there is a restriction that this provider will not allow duplicate file names. This is because CSS files added via the EmbeddedComponent appear in the root of the application, so any images requested by a relative URL will need to come from the root path as well, which means there is no way to distinguish between files with the same name. If two libraries have a file with the same name, the first one found will be used._ 142 | ## Sample Projects 143 | 144 | I have included Blazored.Toast and a simple custom component in the Razorcomponents and Blazor Apps 145 | 146 | 147 | ### BlazorComponentSample 148 | 149 | An out-of-the-box sample Blazor component library with static files. 150 | 151 | ### BlazorEmbedContent - Runnable 152 | 153 | A sample Blazor app to show how this library detects if Blazor has already linked the static files, and does not duplicate them. 154 | 155 | Also shows how we can toggle CSS files on/off at runtime. 156 | 157 | ### RazorComponentsSample.Server - Runnable 158 | 159 | A sample Razor Components App to show static files working. 160 | 161 | Also shows how we can toggle CSS files on/off at runtime. 162 | -------------------------------------------------------------------------------- /samples/BlazorComponentSample/BlazorComponentSample.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netstandard2.0 5 | true 6 | false 7 | latest 8 | 3.0 9 | true 10 | false 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /samples/BlazorComponentSample/Component1.razor: -------------------------------------------------------------------------------- 1 | @using Microsoft.AspNetCore.Components.Web 2 | @using Microsoft.JSInterop 3 | @inherits ComponentBase 4 | @inject IJSRuntime jSRuntime 5 | 6 |
7 | This Blazor component is defined in the BlazorComponentSample package. 8 |
9 | 10 | 11 | 12 | 13 | @code 14 | { 15 | ValueTask OnClick() 16 | { 17 | return ExampleJsInterop.Prompt(jSRuntime,"you clicked me"); 18 | } 19 | } -------------------------------------------------------------------------------- /samples/BlazorComponentSample/ExampleJsInterop.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Components; 2 | using Microsoft.JSInterop; 3 | using System.Threading.Tasks; 4 | 5 | namespace BlazorComponentSample 6 | { 7 | public class ExampleJsInterop 8 | { 9 | public static ValueTask Prompt(IJSRuntime jSRuntime, string message) 10 | { 11 | // Implemented in exampleJsInterop.js 12 | return jSRuntime.InvokeAsync( 13 | "exampleJsFunctions.showPrompt", 14 | message); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /samples/BlazorComponentSample/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:58850/", 7 | "sslPort": 0 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "BlazorComponentSample": { 19 | "commandName": "Project", 20 | "launchBrowser": true, 21 | "environmentVariables": { 22 | "ASPNETCORE_ENVIRONMENT": "Development" 23 | }, 24 | "applicationUrl": "http://localhost:58851/" 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /samples/BlazorComponentSample/content/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SQL-MisterMagoo/BlazorEmbedLibrary/43060cb15fbc47d7151a4fd397e5bbeba7c26d6a/samples/BlazorComponentSample/content/background.png -------------------------------------------------------------------------------- /samples/BlazorComponentSample/content/exampleJsInterop.js: -------------------------------------------------------------------------------- 1 | // This file is to show how a library package may provide JavaScript interop features 2 | // wrapped in a .NET API 3 | 4 | window.exampleJsFunctions = { 5 | showPrompt: function (message) { 6 | return prompt(message, 'Type anything here'); 7 | } 8 | }; 9 | -------------------------------------------------------------------------------- /samples/BlazorComponentSample/content/styles.css: -------------------------------------------------------------------------------- 1 | /* 2 | This file is to show how CSS and other static resources (such as images) can be 3 | used from a library project/package. 4 | */ 5 | 6 | .my-component { 7 | border: 2px dashed red; 8 | padding: 1em; 9 | margin: 1em 0; 10 | background-image: url('background.png'); 11 | } 12 | -------------------------------------------------------------------------------- /samples/BlazorEmbedContent/App.razor: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 |

Sorry, there's nothing at this address.

8 |
9 |
10 |
11 | -------------------------------------------------------------------------------- /samples/BlazorEmbedContent/BlazorEmbedContent.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netstandard2.0 5 | Exe 6 | 7.3 7 | 3.0 8 | false 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /samples/BlazorEmbedContent/Pages/Counter.razor: -------------------------------------------------------------------------------- 1 | @page "/counter" 2 | 3 |

Counter

4 | 5 |

Current count: @currentCount

6 | 7 | 8 | 9 | @functions { 10 | int currentCount = 0; 11 | 12 | void IncrementCount() 13 | { 14 | currentCount++; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /samples/BlazorEmbedContent/Pages/FetchData.razor: -------------------------------------------------------------------------------- 1 | @page "/fetchdata" 2 | @inject HttpClient Http 3 | 4 |

Weather forecast

5 | 6 |

This component demonstrates fetching data from the server.

7 | 8 | @if (forecasts == null) 9 | { 10 |

Loading...

11 | } 12 | else 13 | { 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | @foreach (var forecast in forecasts) 25 | { 26 | 27 | 28 | 29 | 30 | 31 | 32 | } 33 | 34 |
DateTemp. (C)Temp. (F)Summary
@forecast.Date.ToShortDateString()@forecast.TemperatureC@forecast.TemperatureF@forecast.Summary
35 | } 36 | 37 | @functions { 38 | WeatherForecast[] forecasts; 39 | 40 | protected override async Task OnInitializedAsync() 41 | { 42 | forecasts = await Http.GetJsonAsync("sample-data/weather.json"); 43 | } 44 | 45 | class WeatherForecast 46 | { 47 | public DateTime Date { get; set; } 48 | 49 | public int TemperatureC { get; set; } 50 | 51 | public int TemperatureF { get; set; } 52 | 53 | public string Summary { get; set; } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /samples/BlazorEmbedContent/Pages/Index.razor: -------------------------------------------------------------------------------- 1 | @page "/" 2 | 3 |

Hello, world!

4 | 5 | Welcome to your new app. 6 | 7 | 8 | 9 | 10 | 11 | @*@inject IToastService toastService*@ 12 | 13 |

Toast Demo

14 | 15 | To show a toast just click one of the buttons below. 16 | 17 | @* 18 | 19 | 20 | *@ 21 | 22 | -------------------------------------------------------------------------------- /samples/BlazorEmbedContent/Pages/_Imports.razor: -------------------------------------------------------------------------------- 1 | @layout MainLayout 2 | -------------------------------------------------------------------------------- /samples/BlazorEmbedContent/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Blazor.Hosting; 2 | 3 | namespace BlazorEmbedContent 4 | { 5 | public class Program 6 | { 7 | public static void Main(string[] args) 8 | { 9 | CreateHostBuilder(args).Build().Run(); 10 | } 11 | 12 | public static IWebAssemblyHostBuilder CreateHostBuilder(string[] args) => 13 | BlazorWebAssemblyHost.CreateDefaultBuilder() 14 | .UseBlazorStartup(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /samples/BlazorEmbedContent/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:55426/", 7 | "sslPort": 0 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "BlazorEmbedContent": { 19 | "commandName": "Project", 20 | "launchBrowser": true, 21 | "environmentVariables": { 22 | "ASPNETCORE_ENVIRONMENT": "Development" 23 | }, 24 | "applicationUrl": "http://localhost:5428/" 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /samples/BlazorEmbedContent/Shared/MainLayout.razor: -------------------------------------------------------------------------------- 1 | @inherits LayoutComponentBase 2 | 5 | 6 |
7 |
8 | About 9 |
10 | 11 |
12 | @Body 13 | @**@ 14 |
15 | 16 | 17 | @if (EmbedSwitch) 18 | { 19 |
@(new MarkupString("").Value)
20 | 21 | } 22 | else 23 | { 24 | @*
@(new MarkupString("").Value)
25 | *@ 26 |
@(new MarkupString("").Value)
27 | 28 | } 29 | @**@ 30 |
31 |
32 | 33 | 34 | @code 35 | { 36 | bool EmbedSwitch; 37 | List Assemblies = new List() 38 | { 39 | typeof(BlazorComponentSample.Component1).Assembly, 40 | //typeof(Blazored.Toast.BlazoredToasts).Assembly 41 | }; 42 | List BlockCss = new List() 43 | { 44 | "BlazorComponentSample,styles.css" 45 | }; 46 | void SwitchEmbedding() 47 | { 48 | EmbedSwitch = !EmbedSwitch; 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /samples/BlazorEmbedContent/Shared/NavMenu.razor: -------------------------------------------------------------------------------- 1 |  2 | 8 | 9 |
10 | 27 |
28 | 29 | @code { 30 | bool collapseNavMenu = true; 31 | 32 | string NavMenuCssClass => collapseNavMenu ? "collapse" : null; 33 | 34 | void ToggleNavMenu() 35 | { 36 | collapseNavMenu = !collapseNavMenu; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /samples/BlazorEmbedContent/Shared/SurveyPrompt.razor: -------------------------------------------------------------------------------- 1 |  11 | 12 | @functions { 13 | // Demonstrates how a parent component can supply parameters 14 | [Parameter] public string Title { get; set; } 15 | } 16 | -------------------------------------------------------------------------------- /samples/BlazorEmbedContent/Startup.cs: -------------------------------------------------------------------------------- 1 | //using Blazored.Toast.Services; 2 | using Microsoft.AspNetCore.Components.Builder; 3 | using Microsoft.Extensions.DependencyInjection; 4 | 5 | namespace BlazorEmbedContent 6 | { 7 | public class Startup 8 | { 9 | public void ConfigureServices(IServiceCollection services) 10 | { 11 | //services.AddScoped(); 12 | } 13 | 14 | public void Configure(IComponentsApplicationBuilder app) 15 | { 16 | app.AddComponent("app"); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /samples/BlazorEmbedContent/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using System.Net.Http 2 | @using Microsoft.AspNetCore.Components.Forms 3 | @using Microsoft.AspNetCore.Components.Routing 4 | @using Microsoft.AspNetCore.Components.Web 5 | @using Microsoft.JSInterop 6 | @using BlazorEmbedContent 7 | @using BlazorEmbedContent.Shared 8 | @using BlazorComponentSample 9 | @using BlazorEmbedLibrary 10 | @*@using Blazored.Toast.Services*@ 11 | 12 | -------------------------------------------------------------------------------- /samples/BlazorEmbedContent/wwwroot/css/open-iconic/FONT-LICENSE: -------------------------------------------------------------------------------- 1 | SIL OPEN FONT LICENSE Version 1.1 2 | 3 | Copyright (c) 2014 Waybury 4 | 5 | PREAMBLE 6 | The goals of the Open Font License (OFL) are to stimulate worldwide 7 | development of collaborative font projects, to support the font creation 8 | efforts of academic and linguistic communities, and to provide a free and 9 | open framework in which fonts may be shared and improved in partnership 10 | with others. 11 | 12 | The OFL allows the licensed fonts to be used, studied, modified and 13 | redistributed freely as long as they are not sold by themselves. The 14 | fonts, including any derivative works, can be bundled, embedded, 15 | redistributed and/or sold with any software provided that any reserved 16 | names are not used by derivative works. The fonts and derivatives, 17 | however, cannot be released under any other type of license. The 18 | requirement for fonts to remain under this license does not apply 19 | to any document created using the fonts or their derivatives. 20 | 21 | DEFINITIONS 22 | "Font Software" refers to the set of files released by the Copyright 23 | Holder(s) under this license and clearly marked as such. This may 24 | include source files, build scripts and documentation. 25 | 26 | "Reserved Font Name" refers to any names specified as such after the 27 | copyright statement(s). 28 | 29 | "Original Version" refers to the collection of Font Software components as 30 | distributed by the Copyright Holder(s). 31 | 32 | "Modified Version" refers to any derivative made by adding to, deleting, 33 | or substituting -- in part or in whole -- any of the components of the 34 | Original Version, by changing formats or by porting the Font Software to a 35 | new environment. 36 | 37 | "Author" refers to any designer, engineer, programmer, technical 38 | writer or other person who contributed to the Font Software. 39 | 40 | PERMISSION & CONDITIONS 41 | Permission is hereby granted, free of charge, to any person obtaining 42 | a copy of the Font Software, to use, study, copy, merge, embed, modify, 43 | redistribute, and sell modified and unmodified copies of the Font 44 | Software, subject to the following conditions: 45 | 46 | 1) Neither the Font Software nor any of its individual components, 47 | in Original or Modified Versions, may be sold by itself. 48 | 49 | 2) Original or Modified Versions of the Font Software may be bundled, 50 | redistributed and/or sold with any software, provided that each copy 51 | contains the above copyright notice and this license. These can be 52 | included either as stand-alone text files, human-readable headers or 53 | in the appropriate machine-readable metadata fields within text or 54 | binary files as long as those fields can be easily viewed by the user. 55 | 56 | 3) No Modified Version of the Font Software may use the Reserved Font 57 | Name(s) unless explicit written permission is granted by the corresponding 58 | Copyright Holder. This restriction only applies to the primary font name as 59 | presented to the users. 60 | 61 | 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font 62 | Software shall not be used to promote, endorse or advertise any 63 | Modified Version, except to acknowledge the contribution(s) of the 64 | Copyright Holder(s) and the Author(s) or with their explicit written 65 | permission. 66 | 67 | 5) The Font Software, modified or unmodified, in part or in whole, 68 | must be distributed entirely under this license, and must not be 69 | distributed under any other license. The requirement for fonts to 70 | remain under this license does not apply to any document created 71 | using the Font Software. 72 | 73 | TERMINATION 74 | This license becomes null and void if any of the above conditions are 75 | not met. 76 | 77 | DISCLAIMER 78 | THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 79 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF 80 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 81 | OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE 82 | COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 83 | INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL 84 | DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 85 | FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM 86 | OTHER DEALINGS IN THE FONT SOFTWARE. 87 | -------------------------------------------------------------------------------- /samples/BlazorEmbedContent/wwwroot/css/open-iconic/ICON-LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Waybury 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /samples/BlazorEmbedContent/wwwroot/css/open-iconic/README.md: -------------------------------------------------------------------------------- 1 | [Open Iconic v1.1.1](http://useiconic.com/open) 2 | =========== 3 | 4 | ### Open Iconic is the open source sibling of [Iconic](http://useiconic.com). It is a hyper-legible collection of 223 icons with a tiny footprint—ready to use with Bootstrap and Foundation. [View the collection](http://useiconic.com/open#icons) 5 | 6 | 7 | 8 | ## What's in Open Iconic? 9 | 10 | * 223 icons designed to be legible down to 8 pixels 11 | * Super-light SVG files - 61.8 for the entire set 12 | * SVG sprite—the modern replacement for icon fonts 13 | * Webfont (EOT, OTF, SVG, TTF, WOFF), PNG and WebP formats 14 | * Webfont stylesheets (including versions for Bootstrap and Foundation) in CSS, LESS, SCSS and Stylus formats 15 | * PNG and WebP raster images in 8px, 16px, 24px, 32px, 48px and 64px. 16 | 17 | 18 | ## Getting Started 19 | 20 | #### For code samples and everything else you need to get started with Open Iconic, check out our [Icons](http://useiconic.com/open#icons) and [Reference](http://useiconic.com/open#reference) sections. 21 | 22 | ### General Usage 23 | 24 | #### Using Open Iconic's SVGs 25 | 26 | We like SVGs and we think they're the way to display icons on the web. Since Open Iconic are just basic SVGs, we suggest you display them like you would any other image (don't forget the `alt` attribute). 27 | 28 | ``` 29 | icon name 30 | ``` 31 | 32 | #### Using Open Iconic's SVG Sprite 33 | 34 | Open Iconic also comes in a SVG sprite which allows you to display all the icons in the set with a single request. It's like an icon font, without being a hack. 35 | 36 | Adding an icon from an SVG sprite is a little different than what you're used to, but it's still a piece of cake. *Tip: To make your icons easily style able, we suggest adding a general class to the* `` *tag and a unique class name for each different icon in the* `` *tag.* 37 | 38 | ``` 39 | 40 | 41 | 42 | ``` 43 | 44 | Sizing icons only needs basic CSS. All the icons are in a square format, so just set the `` tag with equal width and height dimensions. 45 | 46 | ``` 47 | .icon { 48 | width: 16px; 49 | height: 16px; 50 | } 51 | ``` 52 | 53 | Coloring icons is even easier. All you need to do is set the `fill` rule on the `` tag. 54 | 55 | ``` 56 | .icon-account-login { 57 | fill: #f00; 58 | } 59 | ``` 60 | 61 | To learn more about SVG Sprites, read [Chris Coyier's guide](http://css-tricks.com/svg-sprites-use-better-icon-fonts/). 62 | 63 | #### Using Open Iconic's Icon Font... 64 | 65 | 66 | ##### …with Bootstrap 67 | 68 | You can find our Bootstrap stylesheets in `font/css/open-iconic-bootstrap.{css, less, scss, styl}` 69 | 70 | 71 | ``` 72 | 73 | ``` 74 | 75 | 76 | ``` 77 | 78 | ``` 79 | 80 | ##### …with Foundation 81 | 82 | You can find our Foundation stylesheets in `font/css/open-iconic-foundation.{css, less, scss, styl}` 83 | 84 | ``` 85 | 86 | ``` 87 | 88 | 89 | ``` 90 | 91 | ``` 92 | 93 | ##### …on its own 94 | 95 | You can find our default stylesheets in `font/css/open-iconic.{css, less, scss, styl}` 96 | 97 | ``` 98 | 99 | ``` 100 | 101 | ``` 102 | 103 | ``` 104 | 105 | 106 | ## License 107 | 108 | ### Icons 109 | 110 | All code (including SVG markup) is under the [MIT License](http://opensource.org/licenses/MIT). 111 | 112 | ### Fonts 113 | 114 | All fonts are under the [SIL Licensed](http://scripts.sil.org/cms/scripts/page.php?item_id=OFL_web). 115 | -------------------------------------------------------------------------------- /samples/BlazorEmbedContent/wwwroot/css/open-iconic/font/css/open-iconic-bootstrap.min.css: -------------------------------------------------------------------------------- 1 | @font-face{font-family:Icons;src:url(../fonts/open-iconic.eot);src:url(../fonts/open-iconic.eot?#iconic-sm) format('embedded-opentype'),url(../fonts/open-iconic.woff) format('woff'),url(../fonts/open-iconic.ttf) format('truetype'),url(../fonts/open-iconic.otf) format('opentype'),url(../fonts/open-iconic.svg#iconic-sm) format('svg');font-weight:400;font-style:normal}.oi{position:relative;top:1px;display:inline-block;speak:none;font-family:Icons;font-style:normal;font-weight:400;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.oi:empty:before{width:1em;text-align:center;box-sizing:content-box}.oi.oi-align-center:before{text-align:center}.oi.oi-align-left:before{text-align:left}.oi.oi-align-right:before{text-align:right}.oi.oi-flip-horizontal:before{-webkit-transform:scale(-1,1);-ms-transform:scale(-1,1);transform:scale(-1,1)}.oi.oi-flip-vertical:before{-webkit-transform:scale(1,-1);-ms-transform:scale(-1,1);transform:scale(1,-1)}.oi.oi-flip-horizontal-vertical:before{-webkit-transform:scale(-1,-1);-ms-transform:scale(-1,1);transform:scale(-1,-1)}.oi-account-login:before{content:'\e000'}.oi-account-logout:before{content:'\e001'}.oi-action-redo:before{content:'\e002'}.oi-action-undo:before{content:'\e003'}.oi-align-center:before{content:'\e004'}.oi-align-left:before{content:'\e005'}.oi-align-right:before{content:'\e006'}.oi-aperture:before{content:'\e007'}.oi-arrow-bottom:before{content:'\e008'}.oi-arrow-circle-bottom:before{content:'\e009'}.oi-arrow-circle-left:before{content:'\e00a'}.oi-arrow-circle-right:before{content:'\e00b'}.oi-arrow-circle-top:before{content:'\e00c'}.oi-arrow-left:before{content:'\e00d'}.oi-arrow-right:before{content:'\e00e'}.oi-arrow-thick-bottom:before{content:'\e00f'}.oi-arrow-thick-left:before{content:'\e010'}.oi-arrow-thick-right:before{content:'\e011'}.oi-arrow-thick-top:before{content:'\e012'}.oi-arrow-top:before{content:'\e013'}.oi-audio-spectrum:before{content:'\e014'}.oi-audio:before{content:'\e015'}.oi-badge:before{content:'\e016'}.oi-ban:before{content:'\e017'}.oi-bar-chart:before{content:'\e018'}.oi-basket:before{content:'\e019'}.oi-battery-empty:before{content:'\e01a'}.oi-battery-full:before{content:'\e01b'}.oi-beaker:before{content:'\e01c'}.oi-bell:before{content:'\e01d'}.oi-bluetooth:before{content:'\e01e'}.oi-bold:before{content:'\e01f'}.oi-bolt:before{content:'\e020'}.oi-book:before{content:'\e021'}.oi-bookmark:before{content:'\e022'}.oi-box:before{content:'\e023'}.oi-briefcase:before{content:'\e024'}.oi-british-pound:before{content:'\e025'}.oi-browser:before{content:'\e026'}.oi-brush:before{content:'\e027'}.oi-bug:before{content:'\e028'}.oi-bullhorn:before{content:'\e029'}.oi-calculator:before{content:'\e02a'}.oi-calendar:before{content:'\e02b'}.oi-camera-slr:before{content:'\e02c'}.oi-caret-bottom:before{content:'\e02d'}.oi-caret-left:before{content:'\e02e'}.oi-caret-right:before{content:'\e02f'}.oi-caret-top:before{content:'\e030'}.oi-cart:before{content:'\e031'}.oi-chat:before{content:'\e032'}.oi-check:before{content:'\e033'}.oi-chevron-bottom:before{content:'\e034'}.oi-chevron-left:before{content:'\e035'}.oi-chevron-right:before{content:'\e036'}.oi-chevron-top:before{content:'\e037'}.oi-circle-check:before{content:'\e038'}.oi-circle-x:before{content:'\e039'}.oi-clipboard:before{content:'\e03a'}.oi-clock:before{content:'\e03b'}.oi-cloud-download:before{content:'\e03c'}.oi-cloud-upload:before{content:'\e03d'}.oi-cloud:before{content:'\e03e'}.oi-cloudy:before{content:'\e03f'}.oi-code:before{content:'\e040'}.oi-cog:before{content:'\e041'}.oi-collapse-down:before{content:'\e042'}.oi-collapse-left:before{content:'\e043'}.oi-collapse-right:before{content:'\e044'}.oi-collapse-up:before{content:'\e045'}.oi-command:before{content:'\e046'}.oi-comment-square:before{content:'\e047'}.oi-compass:before{content:'\e048'}.oi-contrast:before{content:'\e049'}.oi-copywriting:before{content:'\e04a'}.oi-credit-card:before{content:'\e04b'}.oi-crop:before{content:'\e04c'}.oi-dashboard:before{content:'\e04d'}.oi-data-transfer-download:before{content:'\e04e'}.oi-data-transfer-upload:before{content:'\e04f'}.oi-delete:before{content:'\e050'}.oi-dial:before{content:'\e051'}.oi-document:before{content:'\e052'}.oi-dollar:before{content:'\e053'}.oi-double-quote-sans-left:before{content:'\e054'}.oi-double-quote-sans-right:before{content:'\e055'}.oi-double-quote-serif-left:before{content:'\e056'}.oi-double-quote-serif-right:before{content:'\e057'}.oi-droplet:before{content:'\e058'}.oi-eject:before{content:'\e059'}.oi-elevator:before{content:'\e05a'}.oi-ellipses:before{content:'\e05b'}.oi-envelope-closed:before{content:'\e05c'}.oi-envelope-open:before{content:'\e05d'}.oi-euro:before{content:'\e05e'}.oi-excerpt:before{content:'\e05f'}.oi-expand-down:before{content:'\e060'}.oi-expand-left:before{content:'\e061'}.oi-expand-right:before{content:'\e062'}.oi-expand-up:before{content:'\e063'}.oi-external-link:before{content:'\e064'}.oi-eye:before{content:'\e065'}.oi-eyedropper:before{content:'\e066'}.oi-file:before{content:'\e067'}.oi-fire:before{content:'\e068'}.oi-flag:before{content:'\e069'}.oi-flash:before{content:'\e06a'}.oi-folder:before{content:'\e06b'}.oi-fork:before{content:'\e06c'}.oi-fullscreen-enter:before{content:'\e06d'}.oi-fullscreen-exit:before{content:'\e06e'}.oi-globe:before{content:'\e06f'}.oi-graph:before{content:'\e070'}.oi-grid-four-up:before{content:'\e071'}.oi-grid-three-up:before{content:'\e072'}.oi-grid-two-up:before{content:'\e073'}.oi-hard-drive:before{content:'\e074'}.oi-header:before{content:'\e075'}.oi-headphones:before{content:'\e076'}.oi-heart:before{content:'\e077'}.oi-home:before{content:'\e078'}.oi-image:before{content:'\e079'}.oi-inbox:before{content:'\e07a'}.oi-infinity:before{content:'\e07b'}.oi-info:before{content:'\e07c'}.oi-italic:before{content:'\e07d'}.oi-justify-center:before{content:'\e07e'}.oi-justify-left:before{content:'\e07f'}.oi-justify-right:before{content:'\e080'}.oi-key:before{content:'\e081'}.oi-laptop:before{content:'\e082'}.oi-layers:before{content:'\e083'}.oi-lightbulb:before{content:'\e084'}.oi-link-broken:before{content:'\e085'}.oi-link-intact:before{content:'\e086'}.oi-list-rich:before{content:'\e087'}.oi-list:before{content:'\e088'}.oi-location:before{content:'\e089'}.oi-lock-locked:before{content:'\e08a'}.oi-lock-unlocked:before{content:'\e08b'}.oi-loop-circular:before{content:'\e08c'}.oi-loop-square:before{content:'\e08d'}.oi-loop:before{content:'\e08e'}.oi-magnifying-glass:before{content:'\e08f'}.oi-map-marker:before{content:'\e090'}.oi-map:before{content:'\e091'}.oi-media-pause:before{content:'\e092'}.oi-media-play:before{content:'\e093'}.oi-media-record:before{content:'\e094'}.oi-media-skip-backward:before{content:'\e095'}.oi-media-skip-forward:before{content:'\e096'}.oi-media-step-backward:before{content:'\e097'}.oi-media-step-forward:before{content:'\e098'}.oi-media-stop:before{content:'\e099'}.oi-medical-cross:before{content:'\e09a'}.oi-menu:before{content:'\e09b'}.oi-microphone:before{content:'\e09c'}.oi-minus:before{content:'\e09d'}.oi-monitor:before{content:'\e09e'}.oi-moon:before{content:'\e09f'}.oi-move:before{content:'\e0a0'}.oi-musical-note:before{content:'\e0a1'}.oi-paperclip:before{content:'\e0a2'}.oi-pencil:before{content:'\e0a3'}.oi-people:before{content:'\e0a4'}.oi-person:before{content:'\e0a5'}.oi-phone:before{content:'\e0a6'}.oi-pie-chart:before{content:'\e0a7'}.oi-pin:before{content:'\e0a8'}.oi-play-circle:before{content:'\e0a9'}.oi-plus:before{content:'\e0aa'}.oi-power-standby:before{content:'\e0ab'}.oi-print:before{content:'\e0ac'}.oi-project:before{content:'\e0ad'}.oi-pulse:before{content:'\e0ae'}.oi-puzzle-piece:before{content:'\e0af'}.oi-question-mark:before{content:'\e0b0'}.oi-rain:before{content:'\e0b1'}.oi-random:before{content:'\e0b2'}.oi-reload:before{content:'\e0b3'}.oi-resize-both:before{content:'\e0b4'}.oi-resize-height:before{content:'\e0b5'}.oi-resize-width:before{content:'\e0b6'}.oi-rss-alt:before{content:'\e0b7'}.oi-rss:before{content:'\e0b8'}.oi-script:before{content:'\e0b9'}.oi-share-boxed:before{content:'\e0ba'}.oi-share:before{content:'\e0bb'}.oi-shield:before{content:'\e0bc'}.oi-signal:before{content:'\e0bd'}.oi-signpost:before{content:'\e0be'}.oi-sort-ascending:before{content:'\e0bf'}.oi-sort-descending:before{content:'\e0c0'}.oi-spreadsheet:before{content:'\e0c1'}.oi-star:before{content:'\e0c2'}.oi-sun:before{content:'\e0c3'}.oi-tablet:before{content:'\e0c4'}.oi-tag:before{content:'\e0c5'}.oi-tags:before{content:'\e0c6'}.oi-target:before{content:'\e0c7'}.oi-task:before{content:'\e0c8'}.oi-terminal:before{content:'\e0c9'}.oi-text:before{content:'\e0ca'}.oi-thumb-down:before{content:'\e0cb'}.oi-thumb-up:before{content:'\e0cc'}.oi-timer:before{content:'\e0cd'}.oi-transfer:before{content:'\e0ce'}.oi-trash:before{content:'\e0cf'}.oi-underline:before{content:'\e0d0'}.oi-vertical-align-bottom:before{content:'\e0d1'}.oi-vertical-align-center:before{content:'\e0d2'}.oi-vertical-align-top:before{content:'\e0d3'}.oi-video:before{content:'\e0d4'}.oi-volume-high:before{content:'\e0d5'}.oi-volume-low:before{content:'\e0d6'}.oi-volume-off:before{content:'\e0d7'}.oi-warning:before{content:'\e0d8'}.oi-wifi:before{content:'\e0d9'}.oi-wrench:before{content:'\e0da'}.oi-x:before{content:'\e0db'}.oi-yen:before{content:'\e0dc'}.oi-zoom-in:before{content:'\e0dd'}.oi-zoom-out:before{content:'\e0de'} -------------------------------------------------------------------------------- /samples/BlazorEmbedContent/wwwroot/css/open-iconic/font/fonts/open-iconic.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SQL-MisterMagoo/BlazorEmbedLibrary/43060cb15fbc47d7151a4fd397e5bbeba7c26d6a/samples/BlazorEmbedContent/wwwroot/css/open-iconic/font/fonts/open-iconic.eot -------------------------------------------------------------------------------- /samples/BlazorEmbedContent/wwwroot/css/open-iconic/font/fonts/open-iconic.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SQL-MisterMagoo/BlazorEmbedLibrary/43060cb15fbc47d7151a4fd397e5bbeba7c26d6a/samples/BlazorEmbedContent/wwwroot/css/open-iconic/font/fonts/open-iconic.otf -------------------------------------------------------------------------------- /samples/BlazorEmbedContent/wwwroot/css/open-iconic/font/fonts/open-iconic.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | Created by FontForge 20120731 at Tue Jul 1 20:39:22 2014 9 | By P.J. Onori 10 | Created by P.J. Onori with FontForge 2.0 (http://fontforge.sf.net) 11 | 12 | 13 | 14 | 27 | 28 | 30 | 32 | 34 | 36 | 38 | 40 | 42 | 45 | 47 | 49 | 51 | 53 | 55 | 57 | 59 | 61 | 63 | 65 | 67 | 69 | 71 | 74 | 76 | 79 | 81 | 84 | 86 | 88 | 91 | 93 | 95 | 98 | 100 | 102 | 104 | 106 | 109 | 112 | 115 | 117 | 121 | 123 | 125 | 127 | 130 | 132 | 134 | 136 | 138 | 141 | 143 | 145 | 147 | 149 | 151 | 153 | 155 | 157 | 159 | 162 | 165 | 167 | 169 | 172 | 174 | 177 | 179 | 181 | 183 | 185 | 189 | 191 | 194 | 196 | 198 | 200 | 202 | 205 | 207 | 209 | 211 | 213 | 215 | 218 | 220 | 222 | 224 | 226 | 228 | 230 | 232 | 234 | 236 | 238 | 241 | 243 | 245 | 247 | 249 | 251 | 253 | 256 | 259 | 261 | 263 | 265 | 267 | 269 | 272 | 274 | 276 | 280 | 282 | 285 | 287 | 289 | 292 | 295 | 298 | 300 | 302 | 304 | 306 | 309 | 312 | 314 | 316 | 318 | 320 | 322 | 324 | 326 | 330 | 334 | 338 | 340 | 343 | 345 | 347 | 349 | 351 | 353 | 355 | 358 | 360 | 363 | 365 | 367 | 369 | 371 | 373 | 375 | 377 | 379 | 381 | 383 | 386 | 388 | 390 | 392 | 394 | 396 | 399 | 401 | 404 | 406 | 408 | 410 | 412 | 414 | 416 | 419 | 421 | 423 | 425 | 428 | 431 | 435 | 438 | 440 | 442 | 444 | 446 | 448 | 451 | 453 | 455 | 457 | 460 | 462 | 464 | 466 | 468 | 471 | 473 | 477 | 479 | 481 | 483 | 486 | 488 | 490 | 492 | 494 | 496 | 499 | 501 | 504 | 506 | 509 | 512 | 515 | 517 | 520 | 522 | 524 | 526 | 529 | 532 | 534 | 536 | 539 | 542 | 543 | 544 | -------------------------------------------------------------------------------- /samples/BlazorEmbedContent/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SQL-MisterMagoo/BlazorEmbedLibrary/43060cb15fbc47d7151a4fd397e5bbeba7c26d6a/samples/BlazorEmbedContent/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf -------------------------------------------------------------------------------- /samples/BlazorEmbedContent/wwwroot/css/open-iconic/font/fonts/open-iconic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SQL-MisterMagoo/BlazorEmbedLibrary/43060cb15fbc47d7151a4fd397e5bbeba7c26d6a/samples/BlazorEmbedContent/wwwroot/css/open-iconic/font/fonts/open-iconic.woff -------------------------------------------------------------------------------- /samples/BlazorEmbedContent/wwwroot/css/site.css: -------------------------------------------------------------------------------- 1 | @import url('open-iconic/font/css/open-iconic-bootstrap.min.css'); 2 | 3 | html, body { 4 | font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; 5 | } 6 | 7 | app { 8 | position: relative; 9 | display: flex; 10 | flex-direction: column; 11 | } 12 | 13 | .top-row { 14 | height: 3.5rem; 15 | display: flex; 16 | align-items: center; 17 | } 18 | 19 | .main { 20 | flex: 1; 21 | } 22 | 23 | .main .top-row { 24 | background-color: #e6e6e6; 25 | border-bottom: 1px solid #d6d5d5; 26 | } 27 | 28 | .sidebar { 29 | background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%); 30 | } 31 | 32 | .sidebar .top-row { 33 | background-color: rgba(0,0,0,0.4); 34 | } 35 | 36 | .sidebar .navbar-brand { 37 | font-size: 1.1rem; 38 | } 39 | 40 | .sidebar .oi { 41 | width: 2rem; 42 | font-size: 1.1rem; 43 | vertical-align: text-top; 44 | top: -2px; 45 | } 46 | 47 | .nav-item { 48 | font-size: 0.9rem; 49 | padding-bottom: 0.5rem; 50 | } 51 | 52 | .nav-item:first-of-type { 53 | padding-top: 1rem; 54 | } 55 | 56 | .nav-item:last-of-type { 57 | padding-bottom: 1rem; 58 | } 59 | 60 | .nav-item a { 61 | color: #d7d7d7; 62 | border-radius: 4px; 63 | height: 3rem; 64 | display: flex; 65 | align-items: center; 66 | line-height: 3rem; 67 | } 68 | 69 | .nav-item a.active { 70 | background-color: rgba(255,255,255,0.25); 71 | color: white; 72 | } 73 | 74 | .nav-item a:hover { 75 | background-color: rgba(255,255,255,0.1); 76 | color: white; 77 | } 78 | 79 | .content { 80 | padding-top: 1.1rem; 81 | } 82 | 83 | .navbar-toggler { 84 | background-color: rgba(255, 255, 255, 0.1); 85 | } 86 | 87 | @media (max-width: 767.98px) { 88 | .main .top-row { 89 | display: none; 90 | } 91 | } 92 | 93 | @media (min-width: 768px) { 94 | app { 95 | flex-direction: row; 96 | } 97 | 98 | .sidebar { 99 | width: 250px; 100 | height: 100vh; 101 | position: sticky; 102 | top: 0; 103 | } 104 | 105 | .main .top-row { 106 | position: sticky; 107 | top: 0; 108 | } 109 | 110 | .main > div { 111 | padding-left: 2rem !important; 112 | padding-right: 1.5rem !important; 113 | } 114 | 115 | .navbar-toggler { 116 | display: none; 117 | } 118 | 119 | .sidebar .collapse { 120 | /* Never collapse the sidebar for wide screens */ 121 | display: block; 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /samples/BlazorEmbedContent/wwwroot/index.html: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | BlazorEmbedContent 7 | 8 | 9 | 10 | 11 | 12 | Loading... 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /samples/BlazorEmbedContent/wwwroot/sample-data/weather.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "date": "2018-05-06", 4 | "temperatureC": 1, 5 | "summary": "Freezing", 6 | "temperatureF": 33 7 | }, 8 | { 9 | "date": "2018-05-07", 10 | "temperatureC": 14, 11 | "summary": "Bracing", 12 | "temperatureF": 57 13 | }, 14 | { 15 | "date": "2018-05-08", 16 | "temperatureC": -13, 17 | "summary": "Freezing", 18 | "temperatureF": 9 19 | }, 20 | { 21 | "date": "2018-05-09", 22 | "temperatureC": -16, 23 | "summary": "Balmy", 24 | "temperatureF": 4 25 | }, 26 | { 27 | "date": "2018-05-10", 28 | "temperatureC": -2, 29 | "summary": "Chilly", 30 | "temperatureF": 29 31 | } 32 | ] 33 | -------------------------------------------------------------------------------- /samples/RazorComponentsSample/RazorComponentsSample.Server/Components/App.razor: -------------------------------------------------------------------------------- 1 | @* 2 | The Router component displays whichever component has a @page 3 | directive matching the current URI. 4 | *@ 5 | 6 | -------------------------------------------------------------------------------- /samples/RazorComponentsSample/RazorComponentsSample.Server/Components/Pages/Counter.razor: -------------------------------------------------------------------------------- 1 | @page "/counter" 2 | @inject Blazored.LocalStorage.ILocalStorageService localStorage 3 | 4 |

Counter

5 | 6 |

Current count: @currentCount

7 | 8 | 9 | 10 | 11 | @functions { 12 | int currentCount = 0; 13 | 14 | Task IncrementCount() 15 | { 16 | currentCount++; 17 | return localStorage.SetItem("counter", currentCount); 18 | } 19 | 20 | protected override async Task OnInitAsync() 21 | { 22 | currentCount = await localStorage.GetItem("counter"); 23 | } 24 | 25 | } -------------------------------------------------------------------------------- /samples/RazorComponentsSample/RazorComponentsSample.Server/Components/Pages/FetchData.razor: -------------------------------------------------------------------------------- 1 | @page "/fetchdata" 2 | @using RazorComponentsSample.Server.Services 3 | @inject WeatherForecastService ForecastService 4 | 5 |

Weather forecast

6 | 7 |

This component demonstrates fetching data from the server.

8 | 9 | @if (forecasts == null) 10 | { 11 |

Loading...

12 | } 13 | else 14 | { 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | @foreach (var forecast in forecasts) 26 | { 27 | 28 | 29 | 30 | 31 | 32 | 33 | } 34 | 35 |
DateTemp. (C)Temp. (F)Summary
@forecast.Date.ToShortDateString()@forecast.TemperatureC@forecast.TemperatureF@forecast.Summary
36 | } 37 | 38 | @functions { 39 | WeatherForecast[] forecasts; 40 | 41 | protected override async Task OnInitAsync() 42 | { 43 | forecasts = await ForecastService.GetForecastAsync(DateTime.Now); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /samples/RazorComponentsSample/RazorComponentsSample.Server/Components/Pages/Index.razor: -------------------------------------------------------------------------------- 1 | @page "/" 2 | 3 |

Hello, world!

4 | 5 | Welcome to your new app. 6 | 7 | 8 | 9 | @inject IToastService toastService 10 | 11 |

Toast Demo

12 | 13 | To show a toast just click one of the buttons below. 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /samples/RazorComponentsSample/RazorComponentsSample.Server/Components/Pages/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @layout MainLayout 2 | @using BlazorComponentSample 3 | @using BlazorEmbedLibrary 4 | @using Blazored.LocalStorage 5 | @using Blazored.Toast.Services 6 | @addTagHelper *, BlazorComponentSample 7 | @addTagHelper *, BlazorEmbedLibrary 8 | @addTagHelper *, Blazored.Toast 9 | @addTagHelper *, Blazored.LocalStorage -------------------------------------------------------------------------------- /samples/RazorComponentsSample/RazorComponentsSample.Server/Components/Shared/MainLayout.razor: -------------------------------------------------------------------------------- 1 | @inherits LayoutComponentBase 2 | 5 | 6 |
7 |
8 | About 9 |
10 | 11 |
12 | @Body 13 | @**@ 14 |
15 | 16 | @if (EmbedSwitch) 17 | { 18 |
@(new MarkupString("").Value)
19 | 20 | } 21 | else 22 | { 23 |
@(new MarkupString("").Value)
24 | 25 |
@(new MarkupString("").Value)
26 | 27 | } 28 | 29 |
30 |
31 | 32 | 33 | @functions 34 | { 35 | bool EmbedSwitch; 36 | List Assemblies = new List() 37 | { 38 | typeof(BlazorComponentSample.Component1).Assembly, 39 | typeof(Blazored.Toast.BlazoredToasts).Assembly 40 | }; 41 | List BlockCss = new List() 42 | { 43 | "BlazorComponentSample,styles.css" 44 | }; 45 | void SwitchEmbedding(UIMouseEventArgs args) 46 | { 47 | EmbedSwitch = !EmbedSwitch; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /samples/RazorComponentsSample/RazorComponentsSample.Server/Components/Shared/NavMenu.razor: -------------------------------------------------------------------------------- 1 |  7 | 8 |
9 | 26 |
27 | 28 | @functions { 29 | bool collapseNavMenu = true; 30 | 31 | string NavMenuCssClass => collapseNavMenu ? "collapse" : null; 32 | 33 | void ToggleNavMenu() 34 | { 35 | collapseNavMenu = !collapseNavMenu; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /samples/RazorComponentsSample/RazorComponentsSample.Server/Components/Shared/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using BlazorEmbedLibrary 2 | @using Blazored.Toast.Services 3 | @using BlazorComponentSample 4 | @addTagHelper *, BlazorComponentSample 5 | @addTagHelper *, BlazorEmbedLibrary 6 | @addTagHelper *, Blazored.Toast 7 | -------------------------------------------------------------------------------- /samples/RazorComponentsSample/RazorComponentsSample.Server/Components/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using System.Net.Http 2 | @using Microsoft.AspNetCore.Components.Forms 3 | @using Microsoft.AspNetCore.Components.Layouts 4 | @using Microsoft.AspNetCore.Components.Routing 5 | @using Microsoft.JSInterop 6 | @using RazorComponentsSample.Server.Components.Shared 7 | -------------------------------------------------------------------------------- /samples/RazorComponentsSample/RazorComponentsSample.Server/Pages/Index.cshtml: -------------------------------------------------------------------------------- 1 | @page "{*clientPath}" 2 | 3 | 4 | 5 | 6 | 7 | RazorComponentsSample 8 | 9 | 10 | 11 | 12 | 13 | 18 | 19 | 20 | 21 | 22 | @(await Html.RenderComponentAsync()) 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /samples/RazorComponentsSample/RazorComponentsSample.Server/Pages/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using RazorComponentsSample.Server.Components 2 | @namespace RazorComponentsSample.Server.Pages 3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers -------------------------------------------------------------------------------- /samples/RazorComponentsSample/RazorComponentsSample.Server/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Hosting; 2 | using Microsoft.Extensions.Hosting; 3 | 4 | namespace RazorComponentsSample.Server 5 | { 6 | public class Program 7 | { 8 | public static void Main(string[] args) 9 | { 10 | CreateHostBuilder(args).Build().Run(); 11 | } 12 | 13 | public static IHostBuilder CreateHostBuilder(string[] args) => 14 | Host.CreateDefaultBuilder(args) 15 | .ConfigureWebHostDefaults(webBuilder => 16 | { 17 | webBuilder.UseStartup(); 18 | }); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /samples/RazorComponentsSample/RazorComponentsSample.Server/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:56517/", 7 | "sslPort": 56516 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "RazorComponentsSample.Server": { 19 | "commandName": "Project", 20 | "launchBrowser": true, 21 | "environmentVariables": { 22 | "ASPNETCORE_ENVIRONMENT": "Development" 23 | }, 24 | "applicationUrl": "http://localhost:44362;https://localhost:44361" 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /samples/RazorComponentsSample/RazorComponentsSample.Server/RazorComponentsSample.Server.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netcoreapp3.0 5 | <_RazorComponentInclude>Components\**\*.cshtml 6 | false 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | PreserveNewest 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /samples/RazorComponentsSample/RazorComponentsSample.Server/Services/WeatherForecast.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace RazorComponentsSample.Server.Services 4 | { 5 | public class WeatherForecast 6 | { 7 | public DateTime Date { get; set; } 8 | 9 | public int TemperatureC { get; set; } 10 | 11 | public int TemperatureF { get; set; } 12 | 13 | public string Summary { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /samples/RazorComponentsSample/RazorComponentsSample.Server/Services/WeatherForecastService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Threading.Tasks; 4 | 5 | namespace RazorComponentsSample.Server.Services 6 | { 7 | public class WeatherForecastService 8 | { 9 | private static string[] Summaries = new[] 10 | { 11 | "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" 12 | }; 13 | 14 | public Task GetForecastAsync(DateTime startDate) 15 | { 16 | var rng = new Random(); 17 | return Task.FromResult(Enumerable.Range(1, 5).Select(index => new WeatherForecast 18 | { 19 | Date = startDate.AddDays(index), 20 | TemperatureC = rng.Next(-20, 55), 21 | Summary = Summaries[rng.Next(Summaries.Length)] 22 | }).ToArray()); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /samples/RazorComponentsSample/RazorComponentsSample.Server/Startup.cs: -------------------------------------------------------------------------------- 1 | using Blazored.LocalStorage; 2 | using Blazored.Toast.Services; 3 | using BlazorEmbedLibrary; 4 | using Microsoft.AspNetCore.Builder; 5 | using Microsoft.AspNetCore.Hosting; 6 | using Microsoft.Extensions.DependencyInjection; 7 | using Microsoft.Extensions.Hosting; 8 | using RazorComponentsSample.Server.Components; 9 | using RazorComponentsSample.Server.Services; 10 | using System.Collections.Generic; 11 | using System.Reflection; 12 | 13 | namespace RazorComponentsSample.Server 14 | { 15 | public class Startup 16 | { 17 | // This method gets called by the runtime. Use this method to add services to the container. 18 | // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 19 | public void ConfigureServices(IServiceCollection services) 20 | { 21 | services.AddMvc() 22 | .AddNewtonsoftJson(); 23 | 24 | services.AddRazorComponents(); 25 | 26 | services.AddSingleton(); 27 | services.AddScoped(); 28 | services.AddScoped(); 29 | } 30 | 31 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 32 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env) 33 | { 34 | if (env.IsDevelopment()) 35 | { 36 | app.UseDeveloperExceptionPage(); 37 | } 38 | else 39 | { 40 | // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. 41 | app.UseHsts(); 42 | } 43 | 44 | //app.UseHttpsRedirection(); 45 | app.UseStaticFiles(); 46 | app.UseStaticFiles(new StaticFileOptions() 47 | { 48 | FileProvider = new BlazorFileProvider(new List() { typeof(BlazorComponentSample.Component1).Assembly }) 49 | }); 50 | 51 | app.UseRouting(routes => 52 | { 53 | routes.MapRazorPages(); 54 | routes.MapComponentHub("app"); 55 | }); 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /samples/RazorComponentsSample/RazorComponentsSample.Server/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Debug", 5 | "System": "Information", 6 | "Microsoft": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /samples/RazorComponentsSample/RazorComponentsSample.Server/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Warning", 5 | "Microsoft.Hosting.Lifetime": "Information" 6 | } 7 | }, 8 | "AllowedHosts": "*" 9 | } 10 | -------------------------------------------------------------------------------- /samples/RazorComponentsSample/RazorComponentsSample.Server/wwwroot/css/open-iconic/FONT-LICENSE: -------------------------------------------------------------------------------- 1 | SIL OPEN FONT LICENSE Version 1.1 2 | 3 | Copyright (c) 2014 Waybury 4 | 5 | PREAMBLE 6 | The goals of the Open Font License (OFL) are to stimulate worldwide 7 | development of collaborative font projects, to support the font creation 8 | efforts of academic and linguistic communities, and to provide a free and 9 | open framework in which fonts may be shared and improved in partnership 10 | with others. 11 | 12 | The OFL allows the licensed fonts to be used, studied, modified and 13 | redistributed freely as long as they are not sold by themselves. The 14 | fonts, including any derivative works, can be bundled, embedded, 15 | redistributed and/or sold with any software provided that any reserved 16 | names are not used by derivative works. The fonts and derivatives, 17 | however, cannot be released under any other type of license. The 18 | requirement for fonts to remain under this license does not apply 19 | to any document created using the fonts or their derivatives. 20 | 21 | DEFINITIONS 22 | "Font Software" refers to the set of files released by the Copyright 23 | Holder(s) under this license and clearly marked as such. This may 24 | include source files, build scripts and documentation. 25 | 26 | "Reserved Font Name" refers to any names specified as such after the 27 | copyright statement(s). 28 | 29 | "Original Version" refers to the collection of Font Software components as 30 | distributed by the Copyright Holder(s). 31 | 32 | "Modified Version" refers to any derivative made by adding to, deleting, 33 | or substituting -- in part or in whole -- any of the components of the 34 | Original Version, by changing formats or by porting the Font Software to a 35 | new environment. 36 | 37 | "Author" refers to any designer, engineer, programmer, technical 38 | writer or other person who contributed to the Font Software. 39 | 40 | PERMISSION & CONDITIONS 41 | Permission is hereby granted, free of charge, to any person obtaining 42 | a copy of the Font Software, to use, study, copy, merge, embed, modify, 43 | redistribute, and sell modified and unmodified copies of the Font 44 | Software, subject to the following conditions: 45 | 46 | 1) Neither the Font Software nor any of its individual components, 47 | in Original or Modified Versions, may be sold by itself. 48 | 49 | 2) Original or Modified Versions of the Font Software may be bundled, 50 | redistributed and/or sold with any software, provided that each copy 51 | contains the above copyright notice and this license. These can be 52 | included either as stand-alone text files, human-readable headers or 53 | in the appropriate machine-readable metadata fields within text or 54 | binary files as long as those fields can be easily viewed by the user. 55 | 56 | 3) No Modified Version of the Font Software may use the Reserved Font 57 | Name(s) unless explicit written permission is granted by the corresponding 58 | Copyright Holder. This restriction only applies to the primary font name as 59 | presented to the users. 60 | 61 | 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font 62 | Software shall not be used to promote, endorse or advertise any 63 | Modified Version, except to acknowledge the contribution(s) of the 64 | Copyright Holder(s) and the Author(s) or with their explicit written 65 | permission. 66 | 67 | 5) The Font Software, modified or unmodified, in part or in whole, 68 | must be distributed entirely under this license, and must not be 69 | distributed under any other license. The requirement for fonts to 70 | remain under this license does not apply to any document created 71 | using the Font Software. 72 | 73 | TERMINATION 74 | This license becomes null and void if any of the above conditions are 75 | not met. 76 | 77 | DISCLAIMER 78 | THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 79 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF 80 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 81 | OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE 82 | COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 83 | INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL 84 | DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 85 | FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM 86 | OTHER DEALINGS IN THE FONT SOFTWARE. 87 | -------------------------------------------------------------------------------- /samples/RazorComponentsSample/RazorComponentsSample.Server/wwwroot/css/open-iconic/ICON-LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Waybury 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /samples/RazorComponentsSample/RazorComponentsSample.Server/wwwroot/css/open-iconic/README.md: -------------------------------------------------------------------------------- 1 | [Open Iconic v1.1.1](http://useiconic.com/open) 2 | =========== 3 | 4 | ### Open Iconic is the open source sibling of [Iconic](http://useiconic.com). It is a hyper-legible collection of 223 icons with a tiny footprint—ready to use with Bootstrap and Foundation. [View the collection](http://useiconic.com/open#icons) 5 | 6 | 7 | 8 | ## What's in Open Iconic? 9 | 10 | * 223 icons designed to be legible down to 8 pixels 11 | * Super-light SVG files - 61.8 for the entire set 12 | * SVG sprite—the modern replacement for icon fonts 13 | * Webfont (EOT, OTF, SVG, TTF, WOFF), PNG and WebP formats 14 | * Webfont stylesheets (including versions for Bootstrap and Foundation) in CSS, LESS, SCSS and Stylus formats 15 | * PNG and WebP raster images in 8px, 16px, 24px, 32px, 48px and 64px. 16 | 17 | 18 | ## Getting Started 19 | 20 | #### For code samples and everything else you need to get started with Open Iconic, check out our [Icons](http://useiconic.com/open#icons) and [Reference](http://useiconic.com/open#reference) sections. 21 | 22 | ### General Usage 23 | 24 | #### Using Open Iconic's SVGs 25 | 26 | We like SVGs and we think they're the way to display icons on the web. Since Open Iconic are just basic SVGs, we suggest you display them like you would any other image (don't forget the `alt` attribute). 27 | 28 | ``` 29 | icon name 30 | ``` 31 | 32 | #### Using Open Iconic's SVG Sprite 33 | 34 | Open Iconic also comes in a SVG sprite which allows you to display all the icons in the set with a single request. It's like an icon font, without being a hack. 35 | 36 | Adding an icon from an SVG sprite is a little different than what you're used to, but it's still a piece of cake. *Tip: To make your icons easily style able, we suggest adding a general class to the* `` *tag and a unique class name for each different icon in the* `` *tag.* 37 | 38 | ``` 39 | 40 | 41 | 42 | ``` 43 | 44 | Sizing icons only needs basic CSS. All the icons are in a square format, so just set the `` tag with equal width and height dimensions. 45 | 46 | ``` 47 | .icon { 48 | width: 16px; 49 | height: 16px; 50 | } 51 | ``` 52 | 53 | Coloring icons is even easier. All you need to do is set the `fill` rule on the `` tag. 54 | 55 | ``` 56 | .icon-account-login { 57 | fill: #f00; 58 | } 59 | ``` 60 | 61 | To learn more about SVG Sprites, read [Chris Coyier's guide](http://css-tricks.com/svg-sprites-use-better-icon-fonts/). 62 | 63 | #### Using Open Iconic's Icon Font... 64 | 65 | 66 | ##### …with Bootstrap 67 | 68 | You can find our Bootstrap stylesheets in `font/css/open-iconic-bootstrap.{css, less, scss, styl}` 69 | 70 | 71 | ``` 72 | 73 | ``` 74 | 75 | 76 | ``` 77 | 78 | ``` 79 | 80 | ##### …with Foundation 81 | 82 | You can find our Foundation stylesheets in `font/css/open-iconic-foundation.{css, less, scss, styl}` 83 | 84 | ``` 85 | 86 | ``` 87 | 88 | 89 | ``` 90 | 91 | ``` 92 | 93 | ##### …on its own 94 | 95 | You can find our default stylesheets in `font/css/open-iconic.{css, less, scss, styl}` 96 | 97 | ``` 98 | 99 | ``` 100 | 101 | ``` 102 | 103 | ``` 104 | 105 | 106 | ## License 107 | 108 | ### Icons 109 | 110 | All code (including SVG markup) is under the [MIT License](http://opensource.org/licenses/MIT). 111 | 112 | ### Fonts 113 | 114 | All fonts are under the [SIL Licensed](http://scripts.sil.org/cms/scripts/page.php?item_id=OFL_web). 115 | -------------------------------------------------------------------------------- /samples/RazorComponentsSample/RazorComponentsSample.Server/wwwroot/css/open-iconic/font/css/open-iconic-bootstrap.min.css: -------------------------------------------------------------------------------- 1 | @font-face{font-family:Icons;src:url(../fonts/open-iconic.eot);src:url(../fonts/open-iconic.eot?#iconic-sm) format('embedded-opentype'),url(../fonts/open-iconic.woff) format('woff'),url(../fonts/open-iconic.ttf) format('truetype'),url(../fonts/open-iconic.otf) format('opentype'),url(../fonts/open-iconic.svg#iconic-sm) format('svg');font-weight:400;font-style:normal}.oi{position:relative;top:1px;display:inline-block;speak:none;font-family:Icons;font-style:normal;font-weight:400;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.oi:empty:before{width:1em;text-align:center;box-sizing:content-box}.oi.oi-align-center:before{text-align:center}.oi.oi-align-left:before{text-align:left}.oi.oi-align-right:before{text-align:right}.oi.oi-flip-horizontal:before{-webkit-transform:scale(-1,1);-ms-transform:scale(-1,1);transform:scale(-1,1)}.oi.oi-flip-vertical:before{-webkit-transform:scale(1,-1);-ms-transform:scale(-1,1);transform:scale(1,-1)}.oi.oi-flip-horizontal-vertical:before{-webkit-transform:scale(-1,-1);-ms-transform:scale(-1,1);transform:scale(-1,-1)}.oi-account-login:before{content:'\e000'}.oi-account-logout:before{content:'\e001'}.oi-action-redo:before{content:'\e002'}.oi-action-undo:before{content:'\e003'}.oi-align-center:before{content:'\e004'}.oi-align-left:before{content:'\e005'}.oi-align-right:before{content:'\e006'}.oi-aperture:before{content:'\e007'}.oi-arrow-bottom:before{content:'\e008'}.oi-arrow-circle-bottom:before{content:'\e009'}.oi-arrow-circle-left:before{content:'\e00a'}.oi-arrow-circle-right:before{content:'\e00b'}.oi-arrow-circle-top:before{content:'\e00c'}.oi-arrow-left:before{content:'\e00d'}.oi-arrow-right:before{content:'\e00e'}.oi-arrow-thick-bottom:before{content:'\e00f'}.oi-arrow-thick-left:before{content:'\e010'}.oi-arrow-thick-right:before{content:'\e011'}.oi-arrow-thick-top:before{content:'\e012'}.oi-arrow-top:before{content:'\e013'}.oi-audio-spectrum:before{content:'\e014'}.oi-audio:before{content:'\e015'}.oi-badge:before{content:'\e016'}.oi-ban:before{content:'\e017'}.oi-bar-chart:before{content:'\e018'}.oi-basket:before{content:'\e019'}.oi-battery-empty:before{content:'\e01a'}.oi-battery-full:before{content:'\e01b'}.oi-beaker:before{content:'\e01c'}.oi-bell:before{content:'\e01d'}.oi-bluetooth:before{content:'\e01e'}.oi-bold:before{content:'\e01f'}.oi-bolt:before{content:'\e020'}.oi-book:before{content:'\e021'}.oi-bookmark:before{content:'\e022'}.oi-box:before{content:'\e023'}.oi-briefcase:before{content:'\e024'}.oi-british-pound:before{content:'\e025'}.oi-browser:before{content:'\e026'}.oi-brush:before{content:'\e027'}.oi-bug:before{content:'\e028'}.oi-bullhorn:before{content:'\e029'}.oi-calculator:before{content:'\e02a'}.oi-calendar:before{content:'\e02b'}.oi-camera-slr:before{content:'\e02c'}.oi-caret-bottom:before{content:'\e02d'}.oi-caret-left:before{content:'\e02e'}.oi-caret-right:before{content:'\e02f'}.oi-caret-top:before{content:'\e030'}.oi-cart:before{content:'\e031'}.oi-chat:before{content:'\e032'}.oi-check:before{content:'\e033'}.oi-chevron-bottom:before{content:'\e034'}.oi-chevron-left:before{content:'\e035'}.oi-chevron-right:before{content:'\e036'}.oi-chevron-top:before{content:'\e037'}.oi-circle-check:before{content:'\e038'}.oi-circle-x:before{content:'\e039'}.oi-clipboard:before{content:'\e03a'}.oi-clock:before{content:'\e03b'}.oi-cloud-download:before{content:'\e03c'}.oi-cloud-upload:before{content:'\e03d'}.oi-cloud:before{content:'\e03e'}.oi-cloudy:before{content:'\e03f'}.oi-code:before{content:'\e040'}.oi-cog:before{content:'\e041'}.oi-collapse-down:before{content:'\e042'}.oi-collapse-left:before{content:'\e043'}.oi-collapse-right:before{content:'\e044'}.oi-collapse-up:before{content:'\e045'}.oi-command:before{content:'\e046'}.oi-comment-square:before{content:'\e047'}.oi-compass:before{content:'\e048'}.oi-contrast:before{content:'\e049'}.oi-copywriting:before{content:'\e04a'}.oi-credit-card:before{content:'\e04b'}.oi-crop:before{content:'\e04c'}.oi-dashboard:before{content:'\e04d'}.oi-data-transfer-download:before{content:'\e04e'}.oi-data-transfer-upload:before{content:'\e04f'}.oi-delete:before{content:'\e050'}.oi-dial:before{content:'\e051'}.oi-document:before{content:'\e052'}.oi-dollar:before{content:'\e053'}.oi-double-quote-sans-left:before{content:'\e054'}.oi-double-quote-sans-right:before{content:'\e055'}.oi-double-quote-serif-left:before{content:'\e056'}.oi-double-quote-serif-right:before{content:'\e057'}.oi-droplet:before{content:'\e058'}.oi-eject:before{content:'\e059'}.oi-elevator:before{content:'\e05a'}.oi-ellipses:before{content:'\e05b'}.oi-envelope-closed:before{content:'\e05c'}.oi-envelope-open:before{content:'\e05d'}.oi-euro:before{content:'\e05e'}.oi-excerpt:before{content:'\e05f'}.oi-expand-down:before{content:'\e060'}.oi-expand-left:before{content:'\e061'}.oi-expand-right:before{content:'\e062'}.oi-expand-up:before{content:'\e063'}.oi-external-link:before{content:'\e064'}.oi-eye:before{content:'\e065'}.oi-eyedropper:before{content:'\e066'}.oi-file:before{content:'\e067'}.oi-fire:before{content:'\e068'}.oi-flag:before{content:'\e069'}.oi-flash:before{content:'\e06a'}.oi-folder:before{content:'\e06b'}.oi-fork:before{content:'\e06c'}.oi-fullscreen-enter:before{content:'\e06d'}.oi-fullscreen-exit:before{content:'\e06e'}.oi-globe:before{content:'\e06f'}.oi-graph:before{content:'\e070'}.oi-grid-four-up:before{content:'\e071'}.oi-grid-three-up:before{content:'\e072'}.oi-grid-two-up:before{content:'\e073'}.oi-hard-drive:before{content:'\e074'}.oi-header:before{content:'\e075'}.oi-headphones:before{content:'\e076'}.oi-heart:before{content:'\e077'}.oi-home:before{content:'\e078'}.oi-image:before{content:'\e079'}.oi-inbox:before{content:'\e07a'}.oi-infinity:before{content:'\e07b'}.oi-info:before{content:'\e07c'}.oi-italic:before{content:'\e07d'}.oi-justify-center:before{content:'\e07e'}.oi-justify-left:before{content:'\e07f'}.oi-justify-right:before{content:'\e080'}.oi-key:before{content:'\e081'}.oi-laptop:before{content:'\e082'}.oi-layers:before{content:'\e083'}.oi-lightbulb:before{content:'\e084'}.oi-link-broken:before{content:'\e085'}.oi-link-intact:before{content:'\e086'}.oi-list-rich:before{content:'\e087'}.oi-list:before{content:'\e088'}.oi-location:before{content:'\e089'}.oi-lock-locked:before{content:'\e08a'}.oi-lock-unlocked:before{content:'\e08b'}.oi-loop-circular:before{content:'\e08c'}.oi-loop-square:before{content:'\e08d'}.oi-loop:before{content:'\e08e'}.oi-magnifying-glass:before{content:'\e08f'}.oi-map-marker:before{content:'\e090'}.oi-map:before{content:'\e091'}.oi-media-pause:before{content:'\e092'}.oi-media-play:before{content:'\e093'}.oi-media-record:before{content:'\e094'}.oi-media-skip-backward:before{content:'\e095'}.oi-media-skip-forward:before{content:'\e096'}.oi-media-step-backward:before{content:'\e097'}.oi-media-step-forward:before{content:'\e098'}.oi-media-stop:before{content:'\e099'}.oi-medical-cross:before{content:'\e09a'}.oi-menu:before{content:'\e09b'}.oi-microphone:before{content:'\e09c'}.oi-minus:before{content:'\e09d'}.oi-monitor:before{content:'\e09e'}.oi-moon:before{content:'\e09f'}.oi-move:before{content:'\e0a0'}.oi-musical-note:before{content:'\e0a1'}.oi-paperclip:before{content:'\e0a2'}.oi-pencil:before{content:'\e0a3'}.oi-people:before{content:'\e0a4'}.oi-person:before{content:'\e0a5'}.oi-phone:before{content:'\e0a6'}.oi-pie-chart:before{content:'\e0a7'}.oi-pin:before{content:'\e0a8'}.oi-play-circle:before{content:'\e0a9'}.oi-plus:before{content:'\e0aa'}.oi-power-standby:before{content:'\e0ab'}.oi-print:before{content:'\e0ac'}.oi-project:before{content:'\e0ad'}.oi-pulse:before{content:'\e0ae'}.oi-puzzle-piece:before{content:'\e0af'}.oi-question-mark:before{content:'\e0b0'}.oi-rain:before{content:'\e0b1'}.oi-random:before{content:'\e0b2'}.oi-reload:before{content:'\e0b3'}.oi-resize-both:before{content:'\e0b4'}.oi-resize-height:before{content:'\e0b5'}.oi-resize-width:before{content:'\e0b6'}.oi-rss-alt:before{content:'\e0b7'}.oi-rss:before{content:'\e0b8'}.oi-script:before{content:'\e0b9'}.oi-share-boxed:before{content:'\e0ba'}.oi-share:before{content:'\e0bb'}.oi-shield:before{content:'\e0bc'}.oi-signal:before{content:'\e0bd'}.oi-signpost:before{content:'\e0be'}.oi-sort-ascending:before{content:'\e0bf'}.oi-sort-descending:before{content:'\e0c0'}.oi-spreadsheet:before{content:'\e0c1'}.oi-star:before{content:'\e0c2'}.oi-sun:before{content:'\e0c3'}.oi-tablet:before{content:'\e0c4'}.oi-tag:before{content:'\e0c5'}.oi-tags:before{content:'\e0c6'}.oi-target:before{content:'\e0c7'}.oi-task:before{content:'\e0c8'}.oi-terminal:before{content:'\e0c9'}.oi-text:before{content:'\e0ca'}.oi-thumb-down:before{content:'\e0cb'}.oi-thumb-up:before{content:'\e0cc'}.oi-timer:before{content:'\e0cd'}.oi-transfer:before{content:'\e0ce'}.oi-trash:before{content:'\e0cf'}.oi-underline:before{content:'\e0d0'}.oi-vertical-align-bottom:before{content:'\e0d1'}.oi-vertical-align-center:before{content:'\e0d2'}.oi-vertical-align-top:before{content:'\e0d3'}.oi-video:before{content:'\e0d4'}.oi-volume-high:before{content:'\e0d5'}.oi-volume-low:before{content:'\e0d6'}.oi-volume-off:before{content:'\e0d7'}.oi-warning:before{content:'\e0d8'}.oi-wifi:before{content:'\e0d9'}.oi-wrench:before{content:'\e0da'}.oi-x:before{content:'\e0db'}.oi-yen:before{content:'\e0dc'}.oi-zoom-in:before{content:'\e0dd'}.oi-zoom-out:before{content:'\e0de'} -------------------------------------------------------------------------------- /samples/RazorComponentsSample/RazorComponentsSample.Server/wwwroot/css/open-iconic/font/fonts/open-iconic.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SQL-MisterMagoo/BlazorEmbedLibrary/43060cb15fbc47d7151a4fd397e5bbeba7c26d6a/samples/RazorComponentsSample/RazorComponentsSample.Server/wwwroot/css/open-iconic/font/fonts/open-iconic.eot -------------------------------------------------------------------------------- /samples/RazorComponentsSample/RazorComponentsSample.Server/wwwroot/css/open-iconic/font/fonts/open-iconic.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SQL-MisterMagoo/BlazorEmbedLibrary/43060cb15fbc47d7151a4fd397e5bbeba7c26d6a/samples/RazorComponentsSample/RazorComponentsSample.Server/wwwroot/css/open-iconic/font/fonts/open-iconic.otf -------------------------------------------------------------------------------- /samples/RazorComponentsSample/RazorComponentsSample.Server/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SQL-MisterMagoo/BlazorEmbedLibrary/43060cb15fbc47d7151a4fd397e5bbeba7c26d6a/samples/RazorComponentsSample/RazorComponentsSample.Server/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf -------------------------------------------------------------------------------- /samples/RazorComponentsSample/RazorComponentsSample.Server/wwwroot/css/open-iconic/font/fonts/open-iconic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SQL-MisterMagoo/BlazorEmbedLibrary/43060cb15fbc47d7151a4fd397e5bbeba7c26d6a/samples/RazorComponentsSample/RazorComponentsSample.Server/wwwroot/css/open-iconic/font/fonts/open-iconic.woff -------------------------------------------------------------------------------- /samples/RazorComponentsSample/RazorComponentsSample.Server/wwwroot/css/site.css: -------------------------------------------------------------------------------- 1 | @import url('open-iconic/font/css/open-iconic-bootstrap.min.css'); 2 | 3 | html, body { 4 | font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; 5 | } 6 | 7 | app { 8 | position: relative; 9 | display: flex; 10 | flex-direction: column; 11 | } 12 | 13 | .top-row { 14 | height: 3.5rem; 15 | display: flex; 16 | align-items: center; 17 | } 18 | 19 | .main { 20 | flex: 1; 21 | } 22 | 23 | .main .top-row { 24 | background-color: #e6e6e6; 25 | border-bottom: 1px solid #d6d5d5; 26 | } 27 | 28 | .sidebar { 29 | background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%); 30 | } 31 | 32 | .sidebar .top-row { 33 | background-color: rgba(0,0,0,0.4); 34 | } 35 | 36 | .sidebar .navbar-brand { 37 | font-size: 1.1rem; 38 | } 39 | 40 | .sidebar .oi { 41 | width: 2rem; 42 | font-size: 1.1rem; 43 | vertical-align: text-top; 44 | top: -2px; 45 | } 46 | 47 | .nav-item { 48 | font-size: 0.9rem; 49 | padding-bottom: 0.5rem; 50 | } 51 | 52 | .nav-item:first-of-type { 53 | padding-top: 1rem; 54 | } 55 | 56 | .nav-item:last-of-type { 57 | padding-bottom: 1rem; 58 | } 59 | 60 | .nav-item a { 61 | color: #d7d7d7; 62 | border-radius: 4px; 63 | height: 3rem; 64 | display: flex; 65 | align-items: center; 66 | line-height: 3rem; 67 | } 68 | 69 | .nav-item a.active { 70 | background-color: rgba(255,255,255,0.25); 71 | color: white; 72 | } 73 | 74 | .nav-item a:hover { 75 | background-color: rgba(255,255,255,0.1); 76 | color: white; 77 | } 78 | 79 | .content { 80 | padding-top: 1.1rem; 81 | } 82 | 83 | .navbar-toggler { 84 | background-color: rgba(255, 255, 255, 0.1); 85 | } 86 | 87 | @media (max-width: 767.98px) { 88 | .main .top-row { 89 | display: none; 90 | } 91 | } 92 | 93 | @media (min-width: 768px) { 94 | app { 95 | flex-direction: row; 96 | } 97 | 98 | .sidebar { 99 | width: 250px; 100 | height: 100vh; 101 | position: sticky; 102 | top: 0; 103 | } 104 | 105 | .main .top-row { 106 | position: sticky; 107 | top: 0; 108 | } 109 | 110 | .main > div { 111 | padding-left: 2rem !important; 112 | padding-right: 1.5rem !important; 113 | } 114 | 115 | .navbar-toggler { 116 | display: none; 117 | } 118 | 119 | .sidebar .collapse { 120 | /* Never collapse the sidebar for wide screens */ 121 | display: block; 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /src/BlazorEmbedLibrary/BlazorDirectoryContents.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Reflection; 5 | using Microsoft.Extensions.FileProviders; 6 | 7 | namespace BlazorEmbedLibrary 8 | { 9 | internal class BlazorDirectoryContents : IDirectoryContents 10 | { 11 | private readonly Assembly assembly; 12 | 13 | public BlazorDirectoryContents(Assembly assembly) 14 | { 15 | this.assembly = assembly; 16 | } 17 | public bool Exists => true; 18 | 19 | public IEnumerator GetEnumerator() 20 | { 21 | var resources = assembly.GetManifestResourceNames(); 22 | foreach (var item in resources) 23 | { 24 | var name = Path.GetFileName(item.Replace(":", "/")); 25 | yield return new BlazorFileInfo(item, name, assembly); 26 | } 27 | } 28 | 29 | IEnumerator IEnumerable.GetEnumerator() 30 | { 31 | throw new System.NotImplementedException(); 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /src/BlazorEmbedLibrary/BlazorEmbedLibrary.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netstandard2.0 5 | true 6 | latest 7 | true 8 | Mister Magoo 9 | MM 10 | A Blazor Component that brings Blazor-style static content to Razor Components 11 | 2019 SQL-MisterMagoo 12 | https://github.com/SQL-MisterMagoo/BlazorEmbedLibrary 13 | https://github.com/SQL-MisterMagoo/BlazorEmbedLibrary 14 | Blazor,Razor Components,Embed,Content,Component,css,javascript 15 | $(ReleaseVersion) 16 | true 17 | LICENSE 18 | 19 | false 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | True 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /src/BlazorEmbedLibrary/BlazorFileInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Reflection; 6 | using Microsoft.Extensions.FileProviders; 7 | 8 | namespace BlazorEmbedLibrary 9 | { 10 | internal class BlazorFileInfo : IFileInfo 11 | { 12 | private readonly string subpath; 13 | private readonly string filename; 14 | private readonly Assembly assembly; 15 | public BlazorFileInfo(string path, string name, Assembly assembly) 16 | { 17 | this.subpath = path; 18 | this.filename = name; 19 | this.assembly = assembly; 20 | } 21 | 22 | public bool Exists => true; 23 | 24 | public long Length => assembly.GetManifestResourceStream(subpath).Length; 25 | 26 | public string PhysicalPath => $"/{filename}"; 27 | 28 | public string Name => filename; 29 | 30 | public DateTimeOffset LastModified => DateTimeOffset.FromFileTime( int.Parse(assembly.GetName().Version.ToString().Replace(".",""))); 31 | 32 | public bool IsDirectory => false; 33 | 34 | public Stream CreateReadStream() 35 | { 36 | return assembly.GetManifestResourceStream(subpath); 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /src/BlazorEmbedLibrary/BlazorFileProvider.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Components; 2 | using Microsoft.AspNetCore.Components.RenderTree; 3 | using Microsoft.Extensions.FileProviders; 4 | using Microsoft.Extensions.Primitives; 5 | using Microsoft.JSInterop; 6 | using System; 7 | using System.Collections.Generic; 8 | using System.IO; 9 | using System.Linq; 10 | using System.Reflection; 11 | using System.Threading.Tasks; 12 | 13 | namespace BlazorEmbedLibrary 14 | { 15 | public class BlazorFileProvider : IFileProvider 16 | { 17 | /// 18 | /// Displays a list of the embedded files for each assembly and extra console logging. 19 | /// 20 | public bool Debug { get; set; } = false; 21 | /// 22 | /// Allows multiple Assemblies to be passed as a list e.g. Assemblies=@ListOfAssemblies (where ListOfAssemblies is List 23 | /// 24 | private List Assemblies { get; set; } 25 | 26 | private Dictionary fileMap; 27 | private Dictionary assMap; 28 | private Dictionary nameMap; 29 | public BlazorFileProvider(List assemblies) 30 | { 31 | Assemblies = assemblies ?? new List(); 32 | fileMap = new Dictionary(); 33 | assMap = new Dictionary(); 34 | nameMap = new Dictionary(); 35 | LoadEmbeddedResources(); 36 | } 37 | private void LoadEmbeddedResources() 38 | { 39 | foreach (var assembly in Assemblies) 40 | { 41 | string name = assembly.GetName().Name; 42 | assMap.Add(name, assembly); 43 | foreach (var item in ListEmbeddedResources(assembly)) 44 | { 45 | string key = Path.GetFileName(item.Replace(":","/")); 46 | if (nameMap.ContainsKey(key)) 47 | { 48 | DebugLog($"BFP: Duplicate resource - unable to add {key} from {name}"); 49 | } 50 | else 51 | { 52 | fileMap.Add(key, assembly); 53 | nameMap.Add(key, item); 54 | DebugLog($"BFP: Mapped {name}.{item} as {key}"); 55 | } 56 | } 57 | } 58 | } 59 | 60 | private void DebugLog(string message) 61 | { 62 | if (Debug) Console.WriteLine(message); 63 | } 64 | 65 | private IEnumerable ListEmbeddedResources(Assembly assembly) 66 | { 67 | var resources = assembly.GetManifestResourceNames(); 68 | DebugLog($"Got resources: {string.Join(", ", resources)}"); 69 | DebugLog($"Using assembly: {assembly.GetName().Name}"); 70 | foreach (var item in resources) 71 | { 72 | yield return item; 73 | } 74 | } 75 | 76 | public IFileInfo GetFileInfo(string subpath) 77 | { 78 | DebugLog($"BFP: GetFileInfo({subpath})"); 79 | var key = Path.GetFileName(subpath); 80 | if (nameMap.ContainsKey(key)) 81 | { 82 | return new BlazorFileInfo(nameMap[key], key, fileMap[key]); 83 | } 84 | return new NotFoundFileInfo(subpath); 85 | } 86 | 87 | public IDirectoryContents GetDirectoryContents(string subpath) 88 | { 89 | DebugLog($"BFP: GetDirectoryContents({subpath})"); 90 | var parts = subpath.Split('/'); 91 | string root; 92 | if (string.IsNullOrEmpty(parts[0]) && parts.Length>2) 93 | { 94 | root = parts[1]; 95 | } else 96 | { 97 | root = parts[0]; 98 | } 99 | 100 | if (root.Equals("_content")) 101 | { 102 | var name = parts[parts.Length-1]; 103 | return new BlazorDirectoryContents(assMap[name]); 104 | 105 | } 106 | return new NotFoundDirectoryContents(); 107 | } 108 | 109 | public IChangeToken Watch(string filter) 110 | { 111 | throw new NotImplementedException(); 112 | } 113 | 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /src/BlazorEmbedLibrary/EmbeddedContent.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Components; 2 | using Microsoft.AspNetCore.Components.Rendering; 3 | using Microsoft.AspNetCore.Components.RenderTree; 4 | using Microsoft.JSInterop; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Reflection; 9 | using System.Threading.Tasks; 10 | 11 | namespace BlazorEmbedLibrary 12 | { 13 | public class EmbeddedContent : ComponentBase 14 | { 15 | [Inject] IJSRuntime jSRuntime { get; set; } 16 | /// 17 | /// Displays a list of the embedded files for each assembly and extra console logging. 18 | /// 19 | [Parameter] public bool Debug { get; set; } = false; 20 | /// 21 | /// Easy way to enable one Assembly by passing a contained type e.g. BaseType=@(typeof(Mycomponent)) 22 | /// 23 | [Parameter] public Type BaseType { get; set; } 24 | /// 25 | /// Allows multiple Assemblies to be passed as a list e.g. Assemblies=@ListOfAssemblies (where ListOfAssemblies is List 26 | /// 27 | [Parameter] public List Assemblies { get; set; } 28 | /// 29 | /// Allows blocking/removal of any CSS file in this list e.g. BlockCssFiles=@BlockCss (where Css is List) 30 | /// 31 | /// Prefix by an assembly name and a comma to be more specific 32 | /// e.g. 33 | /// "Blazored.Toast,styles.css" will only block styles.css from the Blazored.Toast assembly 34 | /// "styles.css" will block styles.css from ANY assembly 35 | /// 36 | [Parameter] public List BlockCssFiles { get; set; } 37 | private bool PreRender { get; set; } = true; 38 | private bool HasRun; 39 | protected override void OnInitialized() 40 | { 41 | base.OnInitialized(); 42 | Assemblies = Assemblies ?? new List(); 43 | BlockCssFiles = BlockCssFiles ?? new List(); 44 | if (!(BaseType is null) && !Assemblies.Contains(BaseType.Assembly)) 45 | { 46 | Assemblies.Add(BaseType.Assembly); 47 | } 48 | } 49 | protected override async Task OnAfterRenderAsync(bool FirstRender) 50 | { 51 | await base.OnAfterRenderAsync(FirstRender); 52 | if (!PreRender && !HasRun) 53 | { 54 | HasRun = true; 55 | await LoadEmbeddedResources(); 56 | } 57 | 58 | } 59 | private async Task LoadEmbeddedResources() 60 | { 61 | foreach (var assembly in Assemblies) 62 | { 63 | 64 | foreach (var item in ListEmbeddedResources(assembly)) 65 | { 66 | var ext = System.IO.Path.GetExtension(item).ToLower(); 67 | if (Debug) DebugLog($"Extension: [{ext}]"); 68 | switch (ext) 69 | { 70 | case ".css": 71 | case ".js": 72 | bool linkExists = await DoesLinkExist(assembly, item); 73 | bool scriptExists = await DoesScriptExist(assembly, item); 74 | if (ShouldBlockItem(assembly, item, ext)) 75 | { 76 | if (linkExists) 77 | { 78 | var _ = await RemoveLink(assembly, item); 79 | } 80 | } 81 | else 82 | { 83 | if (!linkExists && !scriptExists) 84 | { 85 | string content; 86 | using (var stream = GetContentStream(assembly, item)) 87 | { 88 | using (var sr = new System.IO.StreamReader(stream)) 89 | { 90 | content = await sr.ReadToEndAsync(); 91 | } 92 | } 93 | if (Debug) DebugLog($"Content: {content}"); 94 | string attachName = $"{assembly.GetName().Name}.{item}"; 95 | switch (ext) 96 | { 97 | case ".css": 98 | await AttachStyleSheet(attachName, content); 99 | break; 100 | case ".js": 101 | await AttachJavaScript(attachName, content); 102 | break; 103 | default: 104 | break; 105 | } 106 | } 107 | } 108 | break; 109 | default: 110 | break; 111 | } 112 | } 113 | } 114 | } 115 | 116 | private bool ShouldBlockItem(Assembly assembly, string item, string ext) 117 | { 118 | if (!item.ToLowerInvariant().EndsWith(".css")) 119 | { 120 | return false; //Can only block css 121 | } 122 | 123 | var assemblyName = assembly.GetName().Name; 124 | return BlockCssFiles 125 | .Where(b => !string.IsNullOrWhiteSpace(b)) 126 | .Any(b => 127 | { 128 | var parts = b.Split(','); 129 | if (parts.Length > 1) 130 | { 131 | if (parts[0].Equals(assemblyName, StringComparison.InvariantCultureIgnoreCase)) 132 | { 133 | if (item.ToLowerInvariant().Contains(parts[1].ToLowerInvariant())) 134 | { 135 | return true; // matched on assemblyname and item 136 | } 137 | } 138 | return false; 139 | } 140 | if (item.ToLowerInvariant().Contains(b.ToLowerInvariant())) 141 | { 142 | return true; // no assembly 143 | } 144 | return false; 145 | }); 146 | } 147 | 148 | private void DebugLog(string message) 149 | { 150 | if (Debug) Console.WriteLine(message); 151 | } 152 | 153 | protected override void BuildRenderTree(RenderTreeBuilder builder) 154 | { 155 | 156 | base.BuildRenderTree(builder); 157 | if (Debug) 158 | { 159 | foreach (var assembly in Assemblies ) 160 | { 161 | 162 | builder.OpenElement(0, "h4"); 163 | builder.AddContent(1, $"--- Start Embedding Files from {assembly.GetName().Name} ---"); 164 | builder.CloseElement(); 165 | foreach (var item in ListEmbeddedResources(assembly)) 166 | { 167 | DebugLog(item); 168 | builder.OpenElement(3, "div"); 169 | builder.AddContent(4, item); 170 | if (ShouldBlockItem(assembly, item, ".css")) 171 | { 172 | builder.AddContent(5, "** Block **"); 173 | } 174 | builder.CloseElement(); 175 | } 176 | builder.OpenElement(6, "h4"); 177 | builder.AddContent(7, "--- End Embedding Files ---"); 178 | builder.CloseElement(); 179 | } 180 | } 181 | DetectRenderMode(builder); 182 | } 183 | 184 | private void DetectRenderMode(RenderTreeBuilder builder) 185 | { 186 | try 187 | { 188 | var btype = builder.GetType(); 189 | var rendererFI = btype.GetField("_renderer", BindingFlags.NonPublic | BindingFlags.Instance); 190 | if (rendererFI is null) 191 | { 192 | PreRender = false; 193 | return; 194 | } 195 | var renderer = rendererFI.GetValue(builder); 196 | if (renderer is null) 197 | { 198 | PreRender = false; 199 | return; 200 | } 201 | var rendererType = renderer.GetType(); 202 | if (rendererType is null) 203 | { 204 | PreRender = false; 205 | return; 206 | } 207 | var renderModeFI = rendererType.GetField("_prerenderMode", BindingFlags.NonPublic | BindingFlags.Instance); 208 | if (renderModeFI is null) 209 | { 210 | PreRender = false; 211 | return; 212 | } 213 | 214 | PreRender = (bool)renderModeFI.GetValue(renderer); 215 | } 216 | catch 217 | { 218 | // older previews didn't have pre-render 219 | } 220 | } 221 | 222 | private async Task AttachStyleSheet(string name, string content) 223 | { 224 | try 225 | { 226 | var blob = $"URL.createObjectURL(new Blob([\"{SafeJsString(content)}\"],{{ \"type\": \"text/css\"}}))"; 227 | await jSRuntime.InvokeAsync("eval", $"var newLink = document.createElement('link'); newLink.rel='stylesheet'; newLink.type='text/css';newLink.href={blob}; newLink.id='{SafeFileName(name)}'; document.head.appendChild(newLink);"); 228 | } 229 | catch (Exception ex) 230 | { 231 | Console.WriteLine(ex); 232 | } 233 | } 234 | 235 | private async Task AttachJavaScript(string name, string content) 236 | { 237 | try 238 | { 239 | var blob = $"URL.createObjectURL(new Blob([\"{SafeJsString(content)}\"],{{ \"type\": \"text/javascript\"}}))"; 240 | await jSRuntime.InvokeAsync("eval", $"var newScript = document.createElement('script'); newScript.src={blob}; newScript.id='{SafeFileName(name)}'; document.head.appendChild(newScript);"); 241 | } 242 | catch (Exception ex) 243 | { 244 | Console.WriteLine(ex); 245 | } 246 | } 247 | 248 | private async Task DoesLinkExist(Assembly assembly, string name) 249 | { 250 | // name will be blazor:js:somthing.js or AssemblyNameSpace.somthing.js 251 | string[] parts = name.Split(':'); 252 | string fileName = parts[parts.Length - 1]; 253 | if (parts.Length == 3) 254 | { 255 | // the name is blazor:js:somthing.js 256 | fileName = $"_content/{assembly.GetName().Name}/{fileName}"; 257 | } 258 | string attachName = $"{assembly.GetName().Name}.{name}"; 259 | string script = $"document.head.querySelector(\"link[id='{SafeFileName(attachName)}'],link[href='{fileName}']\")"; 260 | DebugLog($"DoesLinkExist {name}: {script}"); 261 | object result = null; 262 | try 263 | { 264 | result = await jSRuntime.InvokeAsync("eval", script); 265 | } 266 | catch (Exception ex) 267 | { 268 | 269 | Console.WriteLine(ex); 270 | 271 | } 272 | bool found = !(result is null); 273 | DebugLog($"DoesLinkExist {name}: {found}"); 274 | return found; 275 | } 276 | private async Task RemoveLink(Assembly assembly, string name) 277 | { 278 | // name will be blazor:js:somthing.js or AssemblyNameSpace.somthing.js 279 | string[] parts = name.Split(':'); 280 | string fileName = parts[parts.Length - 1]; 281 | if (parts.Length == 3) 282 | { 283 | // the name is blazor:js:somthing.js 284 | fileName = $"_content/{assembly.GetName().Name}/{fileName}"; 285 | } 286 | string attachName = $"{assembly.GetName().Name}.{name}"; 287 | string script = $"const el=document.head.querySelector(\"link[id='{SafeFileName(attachName)}'],link[href='{fileName}']\");el.disabled = true;el.remove();"; 288 | DebugLog($"RemoveLink {name}: {script}"); 289 | object result = null; 290 | try 291 | { 292 | result = await jSRuntime.InvokeAsync("eval", script); 293 | } 294 | catch (Exception ex) 295 | { 296 | Console.WriteLine(ex); 297 | } 298 | bool found = !(result is null); 299 | DebugLog($"RemoveLink {name}: {found}"); 300 | return found; 301 | } 302 | 303 | private async Task DoesScriptExist(Assembly assembly, string name) 304 | { 305 | // name will be blazor:js:somthing.js or AssemblyNameSpace.somthing.js 306 | string[] parts = name.Split(':'); 307 | string fileName = parts[parts.Length - 1]; 308 | if (parts.Length == 3) 309 | { 310 | // the name is blazor:js:somthing.js 311 | fileName = $"_content/{assembly.GetName().Name}/{fileName}"; 312 | } 313 | string attachName = $"{assembly.GetName().Name}.{name}"; 314 | string script = $"document.head.querySelector(\"script[id='{SafeFileName(attachName)}'],script[src='{fileName}']\")"; 315 | DebugLog($"DoesScriptExist {name}: {script}"); 316 | object result = null; 317 | try 318 | { 319 | result = await jSRuntime.InvokeAsync("eval", script); 320 | } 321 | catch (Exception ex) 322 | { 323 | 324 | Console.WriteLine(ex); 325 | 326 | } 327 | bool found = !(result is null); 328 | DebugLog($"DoesScriptExist {name}: {found}"); 329 | return found; 330 | } 331 | private async Task RemoveScript(Assembly assembly, string name) 332 | { 333 | // name will be blazor:js:somthing.js or AssemblyNameSpace.somthing.js 334 | string[] parts = name.Split(':'); 335 | string fileName = parts[parts.Length - 1]; 336 | if (parts.Length == 3) 337 | { 338 | // the name is blazor:js:somthing.js 339 | fileName = $"_content/{assembly.GetName().Name}/{fileName}"; 340 | } 341 | string attachName = $"{assembly.GetName().Name}.{name}"; 342 | string script = $"const el=document.head.querySelector(\"script[id='{SafeFileName(attachName)}'],script[src='{fileName}']\");el.disabled=true;el.remove();"; 343 | DebugLog($"RemoveScript {name}: {script}"); 344 | object result = null; 345 | try 346 | { 347 | result = await jSRuntime.InvokeAsync("eval", script); 348 | } 349 | catch (Exception ex) 350 | { 351 | Console.WriteLine(ex); 352 | } 353 | bool found = !(result is null); 354 | DebugLog($"RemoveScript {name}: {found}"); 355 | return found; 356 | } 357 | 358 | private IEnumerable ListEmbeddedResources(Assembly assembly) 359 | { 360 | var resources = assembly.GetManifestResourceNames(); 361 | DebugLog($"Got resources: {string.Join(", ", resources)}"); 362 | DebugLog($"Using assembly: {assembly.GetName().Name}"); 363 | foreach (var item in resources) 364 | { 365 | yield return item; 366 | } 367 | } 368 | 369 | private System.IO.Stream GetContentStream(Assembly assembly, string name) 370 | { 371 | DebugLog($"GetContentStream for {name} from assembly: {assembly.GetName().Name}"); 372 | return assembly.GetManifestResourceStream(name); 373 | } 374 | 375 | string SafeFileName(string name) => name.Replace(":", "_"); 376 | 377 | string SafeJsString(string content) => content.Replace(@"\", @"\\").Replace("\r", @"\r").Replace("\n", @"\n").Replace("'", @"\'").Replace("\"", @"\"""); 378 | 379 | } 380 | } 381 | -------------------------------------------------------------------------------- /src/BlazorEmbedLibrary/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:55564/", 7 | "sslPort": 0 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "BlazorEmbedLibrary": { 19 | "commandName": "Project", 20 | "launchBrowser": true, 21 | "environmentVariables": { 22 | "ASPNETCORE_ENVIRONMENT": "Development" 23 | }, 24 | "applicationUrl": "http://localhost:55565/" 25 | } 26 | } 27 | } --------------------------------------------------------------------------------