Skip to content

Commit

Permalink
Merge pull request #1 from VisualAcademy/Bootstrap5Modal
Browse files Browse the repository at this point in the history
Bootstrp 4 Modal에서 Bootstrap 5 Modal로 변경
  • Loading branch information
VisualAcademy committed Oct 6, 2022
2 parents b5531e4 + 38a290c commit b7b5b6c
Show file tree
Hide file tree
Showing 3 changed files with 118 additions and 6 deletions.
6 changes: 3 additions & 3 deletions RedPlus/Components/PortfolioList.razor
Expand Up @@ -19,8 +19,8 @@
</div>
<div class="card-footer">
<button class="btn btn-primary"
data-toggle="modal"
data-target="#portfolioModal"
data-bs-toggle="modal"
data-bs-target="#portfolioModal"
@onclick="() => SelectPortfolio(portfolio.Id)">
Read More...
</button>
Expand All @@ -39,7 +39,7 @@
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">@selectedPortfolio.Title</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<button type="button" class="close" data-bs-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
Expand Down
111 changes: 111 additions & 0 deletions RedPlus/Components/PortfolioListBS4.razor
@@ -0,0 +1,111 @@
@using RedPlus.Models
@using RedPlus.Services
@using Microsoft.AspNetCore.Components.Web
@inject PortfolioServiceJsonFile PortfolioService

<h2>Blazor Component 사용 출력</h2>
<div class="row portfolio-list">
@foreach (var portfolio in PortfolioService.GetPortfolios())
{
<div class="col-lg-4 col-sm-6 portfolio-item">
<div class="card h-100">
<div class="portfolio-item-image"
style="background-image: url('@portfolio.Image');"></div>
<div class="card-body">
<h4 class="card-title">
<a href="#">@portfolio.Title</a>
</h4>
<p class="card-text">@portfolio.Description</p>
</div>
<div class="card-footer">
<button class="btn btn-primary"
data-toggle="modal"
data-target="#portfolioModal"
@onclick="() => SelectPortfolio(portfolio.Id)">
Read More...
</button>
</div>
</div>
</div>
}
</div>
<!-- /.row -->

@if (selectedPortfolio != null)
{
<!-- Modal -->
<div class="modal fade" id="portfolioModal" tabindex="-1" role="dialog" aria-labelledby="portfolioModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">@selectedPortfolio.Title</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<div class="card h-100">
<div class="portfolio-item-image"
style="background-image: url('@selectedPortfolio.Image');"></div>
<div class="card-body">
<p class="card-text">@selectedPortfolio.Description</p>
</div>
</div>
</div>
<div class="modal-footer">
@if (voteCount == 0)
{
<span>투표하세요!</span>
}
else
{
<span>@voteCount @voteLabel</span>
}
@for (int i = 1; i < 6; i++)
{
var currentStar = i;
if (i <= currentRating)
{
<span style="cursor: pointer;"
@onclick="() => HandleClick(currentStar)"></span>
}
else
{
<span style="cursor: pointer;"
@onclick="() => HandleClick(currentStar)">☆</span>
}
}
</div>
</div>
</div>
</div>
}

@code {
Portfolio selectedPortfolio = new Portfolio();
int currentRating = 0;
int voteCount = 0;
string voteLabel;
void SelectPortfolio(int portfolioId)
{
selectedPortfolio = PortfolioService.GetPortfolios().First(p => p.Id == portfolioId);

if (selectedPortfolio.Ratings == null)
{
currentRating = 0;
voteCount = 0;
}
else
{
voteCount = selectedPortfolio.Ratings.Count();
voteLabel = (voteCount > 1) ? "Votes" : "Vote";
currentRating = selectedPortfolio.Ratings.Sum() / voteCount;
}
}

void HandleClick(int rating)
{
PortfolioService.AddRating(selectedPortfolio.Id, rating);
SelectPortfolio(selectedPortfolio.Id);
}
}
7 changes: 4 additions & 3 deletions RedPlus/Pages/Shared/_LayoutPortfolio.cshtml
Expand Up @@ -9,7 +9,8 @@
<title>@ViewBag.Title</title>
<base href="~/" />
<!-- Bootstrap core CSS -->
<link href="~/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
@*<link href="~/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">*@
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<!-- Custom styles for this template -->
<link href="~/css/modern-business.css" rel="stylesheet">
<link href="~/css/portfolio.css" rel="stylesheet" />
Expand Down Expand Up @@ -88,8 +89,8 @@

<!-- Bootstrap core JavaScript -->
<script src="~/vendor/jquery/jquery.min.js"></script>
<script src="~/vendor/bootstrap/js/bootstrap.bundle.min.js"></script>

@*<script src="~/vendor/bootstrap/js/bootstrap.bundle.min.js"></script>*@
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
<script src="/_framework/blazor.server.js"></script>

@await RenderSectionAsync("Scripts", required: false)
Expand Down

0 comments on commit b7b5b6c

Please sign in to comment.