ar-design
Version:
AR Design is a (react | nextjs) ui library.
33 lines (32 loc) • 1.17 kB
JavaScript
import "../../assets/css/components/layout/layout.css";
import Footer from "./Footer";
import Header from "./Header";
import LSider from "./LSider";
import Main from "./Main";
import React from "react";
import RSider from "./RSider";
import Section from "./Section";
const Layout = ({ children }) => {
const validOrder = ["Layout.LSider", "Layout.Main"]; // Doğru sıralama
React.Children.forEach(children, (child, index) => {
if (React.isValidElement(child)) {
const componentType = child.type;
if (validOrder[index] != componentType.displayName) {
throw new Error(`Layout içerisindeki bileşenler yanlış sırada. Beklenen sırada değil: ${componentType.displayName}`);
}
}
});
return (React.createElement("div", { className: "ar-layout" }, React.Children.map(children, (child) => {
if (!React.isValidElement(child))
return;
return child;
})));
};
Layout.Header = Header;
Layout.Main = Main;
Layout.LSider = LSider;
Layout.Section = Section;
Layout.RSider = RSider;
Layout.Footer = Footer;
Layout.displayName = "Layout";
export default Layout;