From 5c126662cbe469b9cc9564b5b85d492c4bea7c1a Mon Sep 17 00:00:00 2001 From: KOSASIH Date: Tue, 3 Dec 2024 23:10:14 +0700 Subject: [PATCH] Create layoutCustomization.js --- src/customization/layoutCustomization.js | 48 ++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 src/customization/layoutCustomization.js diff --git a/src/customization/layoutCustomization.js b/src/customization/layoutCustomization.js new file mode 100644 index 000000000..98102d434 --- /dev/null +++ b/src/customization/layoutCustomization.js @@ -0,0 +1,48 @@ +// layoutCustomization.js + +class LayoutCustomization { + constructor() { + this.userLayouts = {}; // Store layout preferences by user ID + } + + // Set layout preferences for a user + setLayout(userId, layoutOptions) { + this.userLayouts[userId] = layoutOptions; + console.log(`Layout set for user ${userId}:`, layoutOptions); + return layoutOptions; + } + + // Get layout preferences for a user + getLayout(userId) { + return this.userLayouts[userId] || this.getDefaultLayout(); + } + + // Reset layout to default + resetLayout(userId) { + this.userLayouts[userId] = this.getDefaultLayout(); + console.log(`Layout reset to default for user ${userId}`); + return this.userLayouts[userId]; + } + + // Get default layout options + getDefaultLayout() { + return { + theme: 'light', + fontSize: 'medium', + layoutStyle: 'grid', + showSidebar: true, + }; + } +} + +// Example usage +const layoutManager = new LayoutCustomization(); +layoutManager.setLayout('user123', { theme: 'dark', fontSize: 'large', layoutStyle: 'list', showSidebar: false }); +const userLayout = layoutManager.getLayout('user123'); +console.log('User Layout for user123:', userLayout); + +layoutManager.resetLayout('user123'); +const defaultLayout = layoutManager.getLayout('user123'); +console.log('Default Layout for user123:', defaultLayout); + +export default LayoutCustomization;