Skip to content

Commit e90bb9f

Browse files
committed
Add project files.
1 parent 086a2ad commit e90bb9f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1742
-0
lines changed

BlazorExpress.Bulma.Docx.sln

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.14.36301.6 d17.14
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlazorExpress.Bulma.Docx", "BlazorExpress.Bulma.Docx\BlazorExpress.Bulma.Docx.csproj", "{A9551BC1-DF96-8F7C-691F-6B81CCDCD04C}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{A9551BC1-DF96-8F7C-691F-6B81CCDCD04C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{A9551BC1-DF96-8F7C-691F-6B81CCDCD04C}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{A9551BC1-DF96-8F7C-691F-6B81CCDCD04C}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{A9551BC1-DF96-8F7C-691F-6B81CCDCD04C}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {74A97AD8-C260-412B-BD82-3D3B04E8EEFE}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Razor">
2+
3+
<PropertyGroup>
4+
<PackageId>BlazorExpress.Bulma.Docx</PackageId>
5+
<Version>0.1.0</Version>
6+
<PackageVersion>0.1.0</PackageVersion>
7+
<PackageIconUrl>logo.png</PackageIconUrl>
8+
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
9+
<PackageProjectUrl>https://bulma.blazorexpress.com/</PackageProjectUrl>
10+
<RepositoryUrl>https://github.com/BlazorExpress/BlazorExpress.Bulma</RepositoryUrl>
11+
<Authors>Vikram Reddy</Authors>
12+
<Company>Blazor Express</Company>
13+
<Copyright>Copyright © 2025 Blazor Express</Copyright>
14+
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
15+
<Nullable>enable</Nullable>
16+
<ImplicitUsings>enable</ImplicitUsings>
17+
<OutputType>Library</OutputType>
18+
<IsPackable>true</IsPackable>
19+
<PackageIcon>logo.png</PackageIcon>
20+
<PackageReadmeFile>README.md</PackageReadmeFile>
21+
<RepositoryType>git</RepositoryType>
22+
</PropertyGroup>
23+
24+
<ItemGroup>
25+
<None Include="README.md">
26+
<Pack>True</Pack>
27+
<PackagePath>\</PackagePath>
28+
</None>
29+
<None Include="logo.png">
30+
<Pack>True</Pack>
31+
<PackagePath>\</PackagePath>
32+
</None>
33+
</ItemGroup>
34+
35+
<ItemGroup>
36+
<PackageReference Include="BlazorExpress.Bulma" Version="0.1.0" />
37+
</ItemGroup>
38+
39+
<ItemGroup>
40+
<SupportedPlatform Include="browser" />
41+
</ItemGroup>
42+
43+
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
44+
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="8.0.17" />
45+
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" />
46+
</ItemGroup>
47+
48+
<ItemGroup Condition="'$(TargetFramework)' == 'net9.0'">
49+
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="9.0.0" />
50+
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="9.0.0" />
51+
</ItemGroup>
52+
53+
</Project>
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
@namespace BlazorExpress.Bulma.Docx
2+
@inherits BulmaComponentBase
3+
4+
<div @ref="@Element"
5+
id="@Id"
6+
class="@ClassNames"
7+
style="@StyleNames"
8+
@attributes="@AdditionalAttributes">
9+
10+
@if (true)
11+
{
12+
@* <div class="be-bulma-doc-example-demo">
13+
<DynamicComponent Type="this.Type" />
14+
</div> *@
15+
<div class="be-bulma-doc-example-toolbar is-flex is-justify-content-space-between">
16+
<div class="pl-4 py-2">@LanguageCode.ToLanguageName()?.ToUpperInvariant()</div>
17+
<div class="pr-4 py-2"><i class="@clipboardTooltipIconName" role="button" @onclick="CopyToClipboardAsync"></i></div>
18+
</div>
19+
<div class="be-bulma-doc-example-snippet">
20+
<pre>
21+
<code class="@LanguageCode.ToLanguageCssClass()">
22+
@if (snippet is not null)
23+
{
24+
<text>@snippet</text>
25+
}
26+
</code>
27+
</pre>
28+
</div>
29+
}
30+
else
31+
{
32+
@* <Tabs>
33+
<Tab Title="Example">
34+
<div class="be-bulma-doc-example-demo">
35+
<DynamicComponent Type="this.Type" />
36+
</div>
37+
</Tab>
38+
<Tab Title="View Source">
39+
<div class="be-bulma-doc-example-snippet">
40+
<div class="pr-4 py-2 be-bulma-doc-float-end">
41+
<i class="@clipboardTooltipIconName" role="button" @onclick="CopyToClipboardAsync"></i>
42+
</div>
43+
<pre>
44+
<code class="@LanguageCode.ToLanguageCssClass()">
45+
@if (codeSnippet is not null)
46+
{
47+
<text>@codeSnippet</text>
48+
}
49+
</code>
50+
</pre>
51+
</div>
52+
</Tab>
53+
</Tabs> *@
54+
}
55+
</div>
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
using Microsoft.VisualBasic.FileIO;
2+
3+
namespace BlazorExpress.Bulma.Docx;
4+
5+
public partial class CodeChunk : BulmaComponentBase
6+
{
7+
#region Fields and Constants
8+
9+
private string? clipboardTooltipTitle = "Copy to clipboard";
10+
11+
private string? clipboardTooltipIconName = "bi bi-clipboard";
12+
13+
private string? snippet;
14+
15+
private float snippetWidth;
16+
17+
/// <summary>
18+
/// A reference to this component instance for use in JavaScript calls.
19+
/// </summary>
20+
private DotNetObjectReference<CodeChunk> objRef = default!;
21+
22+
#endregion
23+
24+
#region Methods
25+
26+
protected override async Task OnAfterRenderAsync(bool firstRender)
27+
{
28+
if (firstRender && !IsFirstRenderComplete)
29+
{
30+
await JSRuntime.InvokeVoidAsync("highlightCode");
31+
}
32+
33+
await base.OnAfterRenderAsync(firstRender);
34+
}
35+
36+
protected override async Task OnInitializedAsync()
37+
{
38+
objRef ??= DotNetObjectReference.Create(this);
39+
await base.OnInitializedAsync();
40+
}
41+
42+
protected override async Task OnParametersSetAsync()
43+
{
44+
if (snippet is not null)
45+
return;
46+
47+
if (string.IsNullOrWhiteSpace(FilePath))
48+
return;
49+
50+
var resourceName = FilePath.Replace("~", ProjectRootClassType.Assembly.GetName().Name).Replace("/", ".").Replace("\\", ".");
51+
52+
using (var stream = ProjectRootClassType.Assembly.GetManifestResourceStream(resourceName)!)
53+
{
54+
try
55+
{
56+
if (stream is null)
57+
return;
58+
59+
using (var reader = new StreamReader(stream))
60+
{
61+
snippet = await reader.ReadToEndAsync();
62+
}
63+
}
64+
catch (Exception ex)
65+
{
66+
Console.WriteLine(ex.Message);
67+
}
68+
}
69+
}
70+
71+
/// <summary>
72+
/// Handles a copy error event from JavaScript.
73+
/// </summary>
74+
/// <param name="errorMessage">The error message.</param>
75+
[JSInvokable]
76+
public void OnCopyFailJS(string errorMessage)
77+
{
78+
// TODO: show message
79+
}
80+
81+
/// <summary>
82+
/// Handles a copy success event from JavaScript.
83+
/// </summary>
84+
[JSInvokable]
85+
public void OnCopySuccessJS()
86+
{
87+
clipboardTooltipTitle = "Copied!";
88+
clipboardTooltipIconName = "bi bi-check2 has-text-primary";
89+
StateHasChanged();
90+
}
91+
92+
/// <summary>
93+
/// Handles a copy status reset event from JavaScript.
94+
/// </summary>
95+
[JSInvokable]
96+
public void ResetCopyStatusJS()
97+
{
98+
clipboardTooltipTitle = "Copy to clipboard";
99+
clipboardTooltipIconName = "bi bi-clipboard";
100+
StateHasChanged();
101+
}
102+
103+
private async Task CopyToClipboardAsync()
104+
=> await JSRuntime.InvokeVoidAsync("copyToClipboard", snippet, objRef);
105+
106+
#endregion
107+
108+
#region Properties, Indexers
109+
110+
protected override string? ClassNames
111+
=> BuildClassNames(Class, ("be-bulma-doc-example", true));
112+
113+
[Parameter] public LanguageCode LanguageCode { get; set; } = LanguageCode.Razor;
114+
115+
[Parameter] public string? FilePath { get; set; }
116+
117+
/// <summary>
118+
/// Gets or sets the type of the project root class.
119+
/// It is recommended to set this to the root class type of the project, such as <c>typeof(App)</c>, so that the demo code can render correctly on the UI as text with proper formatting.
120+
/// </summary>
121+
[Parameter] public Type ProjectRootClassType { get; set; } = typeof(CodeChunk);
122+
123+
#endregion
124+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
@namespace BlazorExpress.Bulma.Docx
2+
@inherits BulmaComponentBase
3+
4+
<div @ref="@Element"
5+
id="@Id"
6+
class="@ClassNames"
7+
style="@StyleNames"
8+
@attributes="@AdditionalAttributes">
9+
10+
@if (!Tabs)
11+
{
12+
<div class="be-bulma-doc-example-demo">
13+
<DynamicComponent Type="this.Type" />
14+
</div>
15+
<div class="be-bulma-doc-example-toolbar is-flex is-justify-content-space-between">
16+
<div class="pl-4 py-2">@LanguageCode.ToLanguageName()?.ToUpperInvariant()</div>
17+
<div class="pr-4 py-2"><i class="@clipboardTooltipIconName" role="button" @onclick="CopyToClipboardAsync"></i></div>
18+
</div>
19+
<div class="be-bulma-doc-example-snippet">
20+
<pre>
21+
<code class="@LanguageCode.ToLanguageCssClass()">
22+
@if (codeSnippet is not null)
23+
{
24+
<text>@codeSnippet</text>
25+
}
26+
</code>
27+
</pre>
28+
</div>
29+
}
30+
else
31+
{
32+
<Tabs>
33+
<Tab Title="Example">
34+
<div class="be-bulma-doc-example-demo">
35+
<DynamicComponent Type="this.Type" />
36+
</div>
37+
</Tab>
38+
<Tab Title="View Source">
39+
<div class="be-bulma-doc-example-snippet">
40+
<div class="pr-4 py-2 be-bulma-doc-float-end">
41+
<i class="@clipboardTooltipIconName" role="button" @onclick="CopyToClipboardAsync"></i>
42+
</div>
43+
<pre>
44+
<code class="@LanguageCode.ToLanguageCssClass()">
45+
@if (codeSnippet is not null)
46+
{
47+
<text>@codeSnippet</text>
48+
}
49+
</code>
50+
</pre>
51+
</div>
52+
</Tab>
53+
</Tabs>
54+
}
55+
</div>

0 commit comments

Comments
 (0)