| import { sidebarLayoutConfig } from "@/config";
|
|
|
| export interface ResponsiveSidebarConfig {
|
| isBothSidebars: boolean;
|
| hasLeftComponents: boolean;
|
| hasRightComponents: boolean;
|
| mobileShowSidebar: boolean;
|
| tabletShowSidebar: boolean;
|
| desktopShowSidebar: boolean;
|
| }
|
|
|
| |
| |
| |
| |
| |
| |
| |
|
|
| export function getResponsiveSidebarConfig(): ResponsiveSidebarConfig {
|
| const isBothSidebars =
|
| sidebarLayoutConfig.enable && sidebarLayoutConfig.position === "both";
|
|
|
| const hasLeftComponents =
|
| sidebarLayoutConfig.enable &&
|
| sidebarLayoutConfig.leftComponents.some((comp) => comp.enable);
|
|
|
|
|
| const hasRightComponents =
|
| sidebarLayoutConfig.enable &&
|
| sidebarLayoutConfig.position === "both" &&
|
| sidebarLayoutConfig.rightComponents.some((comp) => comp.enable);
|
|
|
|
|
| const mobileShowSidebar = false;
|
| const tabletShowSidebar = sidebarLayoutConfig.enable;
|
| const desktopShowSidebar = sidebarLayoutConfig.enable;
|
|
|
| return {
|
| isBothSidebars,
|
| hasLeftComponents,
|
| hasRightComponents,
|
| mobileShowSidebar,
|
| tabletShowSidebar,
|
| desktopShowSidebar,
|
| };
|
| }
|
|
|
| |
| |
| |
| |
| |
| |
| |
|
|
| export function generateGridClasses(config: ResponsiveSidebarConfig): {
|
| gridCols: string;
|
| } {
|
| let gridCols = "grid-cols-1";
|
|
|
| if (
|
| config.isBothSidebars &&
|
| config.hasLeftComponents &&
|
| config.hasRightComponents
|
| ) {
|
|
|
| gridCols =
|
| "grid-cols-1 md:grid-cols-[17.5rem_1fr] xl:grid-cols-[17.5rem_1fr_17.5rem]";
|
| } else if (config.hasLeftComponents && !config.hasRightComponents) {
|
|
|
| gridCols = "grid-cols-1 md:grid-cols-[17.5rem_1fr]";
|
| } else if (!config.hasLeftComponents && config.hasRightComponents) {
|
|
|
| gridCols = "grid-cols-1 xl:grid-cols-[1fr_17.5rem]";
|
| }
|
|
|
| return { gridCols };
|
| }
|
|
|
| |
| |
|
|
| export function generateSidebarClasses(): string {
|
| const classes = [
|
| "mb-4",
|
|
|
| "hidden",
|
| "md:block",
|
| "md:col-span-1",
|
| "md:max-w-70",
|
| "md:row-start-1",
|
| "md:row-end-2",
|
| "md:col-start-1",
|
| "onload-animation",
|
| ];
|
|
|
| return classes.join(" ");
|
| }
|
|
|
| |
| |
|
|
| export function generateRightSidebarClasses(): string {
|
| const classes = [
|
| "mb-4",
|
|
|
| "hidden",
|
| "xl:block",
|
| "xl:row-start-1",
|
| "xl:row-end-2",
|
| "xl:col-span-1",
|
| "xl:max-w-70",
|
| "onload-animation",
|
| "xl:col-start-3",
|
| ];
|
|
|
| return classes.join(" ");
|
| }
|
|
|
| |
| |
|
|
| export function generateMainContentClasses(
|
| config: ResponsiveSidebarConfig,
|
| ): string {
|
| const classes = [
|
| "transition-main",
|
|
|
| "col-span-1",
|
| ];
|
|
|
| if (
|
| config.isBothSidebars &&
|
| config.hasLeftComponents &&
|
| config.hasRightComponents
|
| ) {
|
|
|
| classes.push("md:col-span-1");
|
| classes.push("md:col-start-2");
|
| classes.push("xl:col-span-1");
|
| classes.push("xl:col-start-2");
|
| classes.push("xl:col-end-3");
|
| } else if (config.hasLeftComponents && !config.hasRightComponents) {
|
|
|
| classes.push("md:col-span-1");
|
| classes.push("md:col-start-2");
|
| } else if (!config.hasLeftComponents && config.hasRightComponents) {
|
|
|
| classes.push("xl:col-span-1");
|
| classes.push("xl:col-start-1");
|
| } else {
|
| classes.push("col-span-1");
|
| }
|
|
|
| classes.push("min-w-0");
|
| classes.push("overflow-hidden");
|
|
|
| return classes.join(" ");
|
| }
|
|
|