Permalink
Browse files

creating a blazor lib and including a shared component

  • Loading branch information...
lusocoding committed Jan 27, 2019
1 parent f27aa81 commit 3fe8c61831c79d817e6ff91fdf11f00600abdaff
@@ -5,6 +5,8 @@ VisualStudioVersion = 15.0.28307.271
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WasmWithBlazorApp", "WasmWithBlazorApp\WasmWithBlazorApp.csproj", "{8D5D3715-5353-4D97-8730-FF59CFB361CA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WasmWithBlazorComponentsLib", "WasmWithBlazorComponentsLib\WasmWithBlazorComponentsLib.csproj", "{E528824C-6BCD-404D-BA94-EE1AB2010165}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -15,6 +17,10 @@ Global
{8D5D3715-5353-4D97-8730-FF59CFB361CA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8D5D3715-5353-4D97-8730-FF59CFB361CA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8D5D3715-5353-4D97-8730-FF59CFB361CA}.Release|Any CPU.Build.0 = Release|Any CPU
{E528824C-6BCD-404D-BA94-EE1AB2010165}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E528824C-6BCD-404D-BA94-EE1AB2010165}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E528824C-6BCD-404D-BA94-EE1AB2010165}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E528824C-6BCD-404D-BA94-EE1AB2010165}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -8,4 +8,6 @@ Welcome to your new app.

<Counter Title="Index Counter">
This counter is being displayed on the Index component.
</Counter>
</Counter>

<Component1 />
@@ -1 +1,2 @@
@layout MainLayout
@addTagHelper WasmWithBlazorComponentsLib.Component1, WasmWithBlazorComponentsLib
@@ -14,4 +14,8 @@
<DotNetCliToolReference Include="Microsoft.AspNetCore.Blazor.Cli" Version="0.7.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\WasmWithBlazorComponentsLib\WasmWithBlazorComponentsLib.csproj" />
</ItemGroup>

</Project>
@@ -0,0 +1,3 @@
<div class="my-component">
This Blazor component is defined in the <strong>WasmWithBlazorComponentsLib</strong> package.
</div>
@@ -0,0 +1,16 @@
using Microsoft.JSInterop;
using System.Threading.Tasks;

namespace WasmWithBlazorComponentsLib
{
public class ExampleJsInterop
{
public static Task<string> Prompt(string message)
{
// Implemented in exampleJsInterop.js
return JSRuntime.Current.InvokeAsync<string>(
"exampleJsFunctions.showPrompt",
message);
}
}
}
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<OutputType>Library</OutputType>
<IsPackable>true</IsPackable>
<BlazorLinkOnBuild>false</BlazorLinkOnBuild>
<LangVersion>7.3</LangVersion>
</PropertyGroup>

<ItemGroup>
<!-- .js/.css files will be referenced via <script>/<link> tags; other content files will just be included in the app's 'dist' directory without any tags referencing them -->
<EmbeddedResource Include="content\**\*.js" LogicalName="blazor:js:%(RecursiveDir)%(Filename)%(Extension)" />
<EmbeddedResource Include="content\**\*.css" LogicalName="blazor:css:%(RecursiveDir)%(Filename)%(Extension)" />
<EmbeddedResource Include="content\**" Exclude="**\*.js;**\*.css" LogicalName="blazor:file:%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Blazor.Browser" Version="0.7.0" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="0.7.0" PrivateAssets="all" />
</ItemGroup>

</Project>
Binary file not shown.
@@ -0,0 +1,8 @@
// This file is to show how a library package may provide JavaScript interop features
// wrapped in a .NET API

window.exampleJsFunctions = {
showPrompt: function (message) {
return prompt(message, 'Type anything here');
}
};
@@ -0,0 +1,11 @@
/*
This file is to show how CSS and other static resources (such as images) can be
used from a library project/package.
*/

.my-component {
border: 2px dashed red;
padding: 1em;
margin: 1em 0;
background-image: url('background.png');
}

0 comments on commit 3fe8c61

Please sign in to comment.