Skip to content

Commit

Permalink
2sxc 14 migration
Browse files Browse the repository at this point in the history
  • Loading branch information
getBlup committed Jul 4, 2022
1 parent 98e4b40 commit 10257fc
Show file tree
Hide file tree
Showing 12 changed files with 2,509 additions and 90 deletions.
6 changes: 3 additions & 3 deletions .data/app.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<SexyContent FileVersion="07.00.00" MinimumRequiredVersion="07.04.02" ModuleVersion="13.10.02" ExportDate="2022-05-10T13:22:30.7839886+02:00">
<SexyContent FileVersion="07.00.00" MinimumRequiredVersion="07.04.02" ModuleVersion="14.07.02" ExportDate="2022-07-04T09:38:39.0333261+02:00">
<Header>
<App Guid="8c3d9f27-4c23-4ac7-a9ea-c7d1551c5ba7" />
<Language Default="en-us" />
Expand Down Expand Up @@ -2278,13 +2278,13 @@
<Value Key="RequiredOqtaneVersion" Value="03.01.00" Type="String">
<Dimension DimensionID="159" ReadOnly="false" />
</Value>
<Value Key="RequiredVersion" Value="13.10.00" Type="String">
<Value Key="RequiredVersion" Value="14.07.00" Type="String">
<Dimension DimensionID="159" ReadOnly="false" />
</Value>
<Value Key="SupportsAjaxReload" Value="True" Type="Boolean">
<Dimension DimensionID="159" ReadOnly="false" />
</Value>
<Value Key="Version" Value="02.04.00" Type="String">
<Value Key="Version" Value="02.05.00" Type="String">
<Dimension DimensionID="159" ReadOnly="false" />
</Value>
</Entity>
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,8 @@ If you want to customize the CSS, you will usually follow the ["Create Custom St
* Removed the PictureTag helper
* Enabled image configuration
* Replaced data-enableoptimizations with pageSvc.AssetAttributes()

* 2022-06 Version 2.05.00
* Changed all base classes to their 2sxc 14 equivalents
* Replaced all GetService<> with the new ServiceKit14
* Changed all the toolbar configurations to use the IToolbarService
* Updated webpack
5 changes: 2 additions & 3 deletions bs4/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Linq;
using System;

public class Helpers: Custom.Hybrid.Code12
public class Helpers: Custom.Hybrid.Code14
{
/// <summary>
/// Generate bootstrap4 css class names for the overlay div, based on the settings of the slide
Expand All @@ -17,10 +17,9 @@ public dynamic OverlayAlignClasses(dynamic settingsStack) {
/// Generate bootstrap4 css class names for the overlay div, based on the settings of the slide
/// </summary>
public dynamic OverlayTextAlignClasses(dynamic settingsStack) {
var pageCss = GetService<Connect.Koi.ICss>(); // Service to get CSS information about the current Theme
var pos = settingsStack.TextPosition ?? "";
return (pos.EndsWith("c") ? "text-center" : "") // center: tc, cc, bc
+ " " + (pos.EndsWith("r") && pageCss.Is("bs4") ? "text-right" : pos.EndsWith("r") && pageCss.Is("bs5") ? "text-end" : ""); // right: tr, cr, br
+ " " + (pos.EndsWith("r") && Kit.Css.Is("bs4") ? "text-right" : pos.EndsWith("r") && Kit.Css.Is("bs5") ? "text-end" : ""); // right: tr, cr, br
}

/// <summary>
Expand Down
19 changes: 7 additions & 12 deletions bs4/_Swiper.PartAssets.cshtml
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
@inherits Custom.Hybrid.Razor12
@inherits Custom.Hybrid.Razor14
@using ToSic.Razor.Blade;
@using ToSic.Sxc.Services;
@{
// 1. Get Services for Css and Page
var pageCss = GetService<Connect.Koi.ICss>(); // Service to get CSS information about the current Theme
var pageSvc = GetService<IPageService>(); // Service to set titles etc. on the pageSvc
// 2. Include Bootstrap4 if the framework isn't known
if (pageCss.IsUnknown) {
pageSvc.Activate("Bootstrap4");
if (Kit.Css.IsUnknown) {
Kit.Page.Activate("Bootstrap4");
}

pageSvc.Activate("turnOn"); // see https://r.2sxc.org/turnon
Kit.Page.Activate("turnOn"); // see https://r.2sxc.org/turnon
var swiperSettings = DynamicModel.SwiperSettings;

Expand All @@ -26,6 +21,6 @@
}
};
}
<link rel="stylesheet" href="@App.Path/bs4/dist/styles.min.css" @pageSvc.AssetAttributes()>
<turnOn turn-on='{ "run": "window.appSwiper2.init()", "data": @Html.Raw(Convert.Json.ToJson(swiperData)) }'></turnOn>
<script src="@App.Path/bs4/dist/scripts.min.js" @pageSvc.AssetAttributes()></script>
<link rel="stylesheet" href="@App.Path/bs4/dist/styles.min.css" @Kit.Page.AssetAttributes()>
<turnOn turn-on='{ "run": "window.appSwiper2.init()", "data": @Html.Raw(Kit.Json.ToJson(swiperData)) }'></turnOn>
<script src="@App.Path/bs4/dist/scripts.min.js" @Kit.Page.AssetAttributes()></script>
2 changes: 1 addition & 1 deletion bs4/_Swiper.PartEmpty.cshtml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@inherits Custom.Hybrid.Razor12
@inherits Custom.Hybrid.Razor14
<div class="app-swiper2-empty-slides container" @Edit.TagToolbar(Content.Slides)>
<div class="arrow">
<div class="line"></div>
Expand Down
15 changes: 8 additions & 7 deletions bs4/_Swiper.cshtml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
@inherits Custom.Hybrid.Razor12
@inherits Custom.Hybrid.Razor14
@using ToSic.Razor.Blade;
@using ToSic.Sxc.Services;
@{
// Get some helper commands for later on
var helpers = CreateInstance("Helpers.cs");
Expand All @@ -17,10 +16,13 @@
var isRatio = sliderHeightOrRatio.IndexOf(":") > 0;
var aspectRatioStyle = isRatio ? "--aspect-ratio:calc(" + sliderHeightOrRatio.Replace(":", "/") + ")": "";
var swiperContainerHeight = isRatio ? "" : "height: " + sliderHeightOrRatio + ";";
var imgSvc = GetService<IImageService>();

var swiperToolbar = Kit.Toolbar.Default().Settings(hover:"left", autoAddMore:"start");

var slideToolbar = Kit.Toolbar.Default().Delete().Condition(!swiper.IsDemoItem);
}

<div class="app-swiper2" @Edit.TagToolbar(swiper, toolbar: new [] { "settings&hover=left&autoAddMore=start" }) style="@aspectRatioStyle">
<div class="app-swiper2" @swiperToolbar.For(swiper) style="@aspectRatioStyle">
@* Slider main container and wrapper *@
<div class="swiper [email protected]" style="width: @sliderWidth; @swiperContainerHeight">
<div class="swiper-wrapper">
Expand All @@ -36,12 +38,11 @@
var sldSettings = AsDynamic(slide, swiper, Settings);
var overlayEffect = sldSettings.OverlayEffect; // Positioning
var duration = sldSettings.ShowDuration; // time the slide will show if auto-playing
var toolbar = Edit.TagToolbar(slide, toolbar: new[] { "%delete&show=true" }, condition: !swiper.IsDemoItem );
<div class="swiper-slide" data-swiper-autoplay="@duration" @toolbar>
<div class="swiper-slide" data-swiper-autoplay="@duration" @slideToolbar.For(slide)>
<div class="image-wrapper @helpers.SlideWrapperClasses(sldSettings)">
@* Add the <picture> tag with all the sources *@
@imgSvc.Picture(slide.Field("Image"), settings: "Contnet", factor: sliderHeightOrRatio)
@Kit.Image.Picture(slide.Field("Image"), settings: "Contnet", factor: sliderHeightOrRatio)


@if (Text.Has(slide.Title) || Text.Has(slide.Text) || Text.Has(slide.LinkText)) {
Expand Down
5 changes: 2 additions & 3 deletions bs5/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Linq;
using System;

public class Helpers: Custom.Hybrid.Code12
public class Helpers: Custom.Hybrid.Code14
{
/// <summary>
/// Generate bootstrap4 css class names for the overlay div, based on the settings of the slide
Expand All @@ -17,10 +17,9 @@ public dynamic OverlayAlignClasses(dynamic settingsStack) {
/// Generate bootstrap4 css class names for the overlay div, based on the settings of the slide
/// </summary>
public dynamic OverlayTextAlignClasses(dynamic settingsStack) {
var pageCss = GetService<Connect.Koi.ICss>(); // Service to get CSS information about the current Theme
var pos = settingsStack.TextPosition ?? "";
return (pos.EndsWith("c") ? "text-center" : "") // center: tc, cc, bc
+ " " + (pos.EndsWith("r") && pageCss.Is("bs4") ? "text-right" : pos.EndsWith("r") && pageCss.Is("bs5") ? "text-end" : ""); // right: tr, cr, br
+ " " + (pos.EndsWith("r") && Kit.Css.Is("bs4") ? "text-right" : pos.EndsWith("r") && Kit.Css.Is("bs5") ? "text-end" : ""); // right: tr, cr, br
}

/// <summary>
Expand Down
19 changes: 7 additions & 12 deletions bs5/_Swiper.PartAssets.cshtml
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
@inherits Custom.Hybrid.Razor12
@inherits Custom.Hybrid.Razor14
@using ToSic.Razor.Blade;
@using ToSic.Sxc.Services;
@{
// 1. Get Services for Css and Page
var pageCss = GetService<Connect.Koi.ICss>(); // Service to get CSS information about the current Theme
var pageSvc = GetService<IPageService>(); // Service to set titles etc. on the pageSvc
// 2. Include Bootstrap4 if the framework isn't known
if (pageCss.IsUnknown) {
pageSvc.Activate("Bootstrap4");
if (Kit.Css.IsUnknown) {
Kit.Page.Activate("Bootstrap4");
}

pageSvc.Activate("turnOn"); // see https://r.2sxc.org/turnon
Kit.Page.Activate("turnOn"); // see https://r.2sxc.org/turnon
var swiperSettings = DynamicModel.SwiperSettings;

Expand All @@ -26,6 +21,6 @@
}
};
}
<link rel="stylesheet" href="@App.Path/bs5/dist/styles.min.css" @pageSvc.AssetAttributes()>
<turnOn turn-on='{ "run": "window.appSwiper2.init()", "data": @Html.Raw(Convert.Json.ToJson(swiperData)) }'></turnOn>
<script src="@App.Path/bs5/dist/scripts.min.js" @pageSvc.AssetAttributes()></script>
<link rel="stylesheet" href="@App.Path/bs5/dist/styles.min.css" @Kit.Page.AssetAttributes()>
<turnOn turn-on='{ "run": "window.appSwiper2.init()", "data": @Html.Raw(Kit.Json.ToJson(swiperData)) }'></turnOn>
<script src="@App.Path/bs5/dist/scripts.min.js" @Kit.Page.AssetAttributes()></script>
2 changes: 1 addition & 1 deletion bs5/_Swiper.PartEmpty.cshtml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@inherits Custom.Hybrid.Razor12
@inherits Custom.Hybrid.Razor14
<div class="app-swiper2-empty-slides container" @Edit.TagToolbar(Content.Slides)>
<div class="arrow">
<div class="line"></div>
Expand Down
15 changes: 8 additions & 7 deletions bs5/_Swiper.cshtml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
@inherits Custom.Hybrid.Razor12
@inherits Custom.Hybrid.Razor14
@using ToSic.Razor.Blade;
@using ToSic.Sxc.Services;
@{
// Get some helper commands for later on
var helpers = CreateInstance("Helpers.cs");
Expand All @@ -17,10 +16,13 @@
var isRatio = sliderHeightOrRatio.IndexOf(":") > 0;
var aspectRatioStyle = isRatio ? "--aspect-ratio:calc(" + sliderHeightOrRatio.Replace(":", "/") + ")": "";
var swiperContainerHeight = isRatio ? "" : "height: " + sliderHeightOrRatio + ";";
var imgSvc = GetService<IImageService>();

var swiperToolbar = Kit.Toolbar.Default().Settings(hover:"left", autoAddMore:"start");

var slideToolbar = Kit.Toolbar.Default().Delete().Condition(!swiper.IsDemoItem);
}

<div class="app-swiper2" @Edit.TagToolbar(swiper, toolbar: new [] { "settings&hover=left&autoAddMore=start" }) style="@aspectRatioStyle">
<div class="app-swiper2" @swiperToolbar.For(swiper) style="@aspectRatioStyle">
@* Slider main container and wrapper *@
<div class="swiper [email protected]" style="width: @sliderWidth; @swiperContainerHeight">
<div class="swiper-wrapper">
Expand All @@ -36,12 +38,11 @@
var sldSettings = AsDynamic(slide, swiper, Settings);
var overlayEffect = sldSettings.OverlayEffect; // Positioning
var duration = sldSettings.ShowDuration; // time the slide will show if auto-playing
var toolbar = Edit.TagToolbar(slide, toolbar: new[] { "%delete&show=true" }, condition: !swiper.IsDemoItem );
<div class="swiper-slide" data-swiper-autoplay="@duration" @toolbar>
<div class="swiper-slide" data-swiper-autoplay="@duration" @slideToolbar.For(slide)>
<div class="image-wrapper @helpers.SlideWrapperClasses(sldSettings)">
@* Add the <picture> tag with all the sources *@
@imgSvc.Picture(slide.Field("Image"), settings: "Content", factor: sliderHeightOrRatio)
@Kit.Image.Picture(slide.Field("Image"), settings: "Content", factor: sliderHeightOrRatio)

@if (Text.Has(slide.Title) || Text.Has(slide.Text) || Text.Has(slide.LinkText)) {
@* Show Overlay behind text *@
Expand Down
Loading

0 comments on commit 10257fc

Please sign in to comment.