Skip to content

Commit

Permalink
Create layoutCustomization.js
Browse files Browse the repository at this point in the history
  • Loading branch information
KOSASIH authored Dec 3, 2024
1 parent 7736f43 commit 5c12666
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions src/customization/layoutCustomization.js
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit 5c12666

Please sign in to comment.