437 lines
11 KiB
TypeScript
437 lines
11 KiB
TypeScript
import { DeesElement, customElement, html, css, property, cssManager } from '@design.estate/dees-element';
|
|
|
|
@customElement('view-settings')
|
|
export class ViewSettings extends DeesElement {
|
|
public static demo = [
|
|
() => html`<view-settings></view-settings>`,
|
|
() => html`<view-settings activeTab="notifications"></view-settings>`,
|
|
() => html`<view-settings activeTab="security"></view-settings>`,
|
|
];
|
|
|
|
@property()
|
|
accessor activeTab: 'profile' | 'notifications' | 'security' = 'profile';
|
|
|
|
@property()
|
|
accessor userName: string = 'John Doe';
|
|
|
|
@property()
|
|
accessor userEmail: string = 'john@example.com';
|
|
|
|
public static styles = [
|
|
cssManager.defaultStyles,
|
|
css`
|
|
:host {
|
|
display: block;
|
|
min-height: 100%;
|
|
background: ${cssManager.bdTheme('#f5f5f5', '#0a0a0a')};
|
|
color: ${cssManager.bdTheme('#1a1a1a', '#e5e5e5')};
|
|
font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
|
|
}
|
|
|
|
.settings-layout {
|
|
max-width: 1000px;
|
|
margin: 0 auto;
|
|
padding: 40px 24px;
|
|
}
|
|
|
|
.settings-header {
|
|
margin-bottom: 32px;
|
|
}
|
|
|
|
.settings-header h1 {
|
|
font-size: 28px;
|
|
font-weight: 700;
|
|
margin: 0 0 8px 0;
|
|
}
|
|
|
|
.settings-header p {
|
|
color: ${cssManager.bdTheme('#666', '#888')};
|
|
margin: 0;
|
|
}
|
|
|
|
.settings-content {
|
|
display: grid;
|
|
grid-template-columns: 200px 1fr;
|
|
gap: 32px;
|
|
}
|
|
|
|
.settings-nav {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 4px;
|
|
}
|
|
|
|
.nav-item {
|
|
padding: 12px 16px;
|
|
border-radius: 6px;
|
|
cursor: pointer;
|
|
transition: all 0.15s ease;
|
|
color: ${cssManager.bdTheme('#666', '#999')};
|
|
}
|
|
|
|
.nav-item:hover {
|
|
background: ${cssManager.bdTheme('#e5e5e5', '#1a1a1a')};
|
|
color: ${cssManager.bdTheme('#1a1a1a', '#fff')};
|
|
}
|
|
|
|
.nav-item.active {
|
|
background: ${cssManager.bdTheme('#1a1a1a', '#3b82f6')};
|
|
color: #fff;
|
|
}
|
|
|
|
.settings-panel {
|
|
background: ${cssManager.bdTheme('#fff', '#111')};
|
|
border: 1px solid ${cssManager.bdTheme('#e5e5e5', '#222')};
|
|
border-radius: 12px;
|
|
padding: 24px;
|
|
}
|
|
|
|
.panel-header {
|
|
margin-bottom: 24px;
|
|
padding-bottom: 16px;
|
|
border-bottom: 1px solid ${cssManager.bdTheme('#e5e5e5', '#222')};
|
|
}
|
|
|
|
.panel-header h2 {
|
|
font-size: 18px;
|
|
font-weight: 600;
|
|
margin: 0 0 4px 0;
|
|
}
|
|
|
|
.panel-header p {
|
|
font-size: 14px;
|
|
color: ${cssManager.bdTheme('#666', '#888')};
|
|
margin: 0;
|
|
}
|
|
|
|
.form-group {
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
.form-group label {
|
|
display: block;
|
|
font-size: 14px;
|
|
font-weight: 500;
|
|
margin-bottom: 8px;
|
|
}
|
|
|
|
.form-group input {
|
|
width: 100%;
|
|
padding: 10px 14px;
|
|
border: 1px solid ${cssManager.bdTheme('#ddd', '#333')};
|
|
border-radius: 6px;
|
|
font-size: 14px;
|
|
background: ${cssManager.bdTheme('#fff', '#0a0a0a')};
|
|
color: ${cssManager.bdTheme('#1a1a1a', '#e5e5e5')};
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
.form-group input:focus {
|
|
outline: none;
|
|
border-color: #3b82f6;
|
|
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
|
|
}
|
|
|
|
.form-row {
|
|
display: grid;
|
|
grid-template-columns: 1fr 1fr;
|
|
gap: 16px;
|
|
}
|
|
|
|
.toggle-group {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
padding: 16px 0;
|
|
border-bottom: 1px solid ${cssManager.bdTheme('#f0f0f0', '#1a1a1a')};
|
|
}
|
|
|
|
.toggle-group:last-child {
|
|
border-bottom: none;
|
|
}
|
|
|
|
.toggle-label {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 4px;
|
|
}
|
|
|
|
.toggle-label .title {
|
|
font-weight: 500;
|
|
}
|
|
|
|
.toggle-label .description {
|
|
font-size: 13px;
|
|
color: ${cssManager.bdTheme('#666', '#888')};
|
|
}
|
|
|
|
.toggle {
|
|
width: 44px;
|
|
height: 24px;
|
|
background: ${cssManager.bdTheme('#ddd', '#333')};
|
|
border-radius: 12px;
|
|
position: relative;
|
|
cursor: pointer;
|
|
transition: background 0.2s ease;
|
|
}
|
|
|
|
.toggle.active {
|
|
background: #3b82f6;
|
|
}
|
|
|
|
.toggle::after {
|
|
content: '';
|
|
position: absolute;
|
|
top: 2px;
|
|
left: 2px;
|
|
width: 20px;
|
|
height: 20px;
|
|
background: white;
|
|
border-radius: 50%;
|
|
transition: transform 0.2s ease;
|
|
}
|
|
|
|
.toggle.active::after {
|
|
transform: translateX(20px);
|
|
}
|
|
|
|
.button-group {
|
|
display: flex;
|
|
gap: 12px;
|
|
margin-top: 24px;
|
|
padding-top: 24px;
|
|
border-top: 1px solid ${cssManager.bdTheme('#e5e5e5', '#222')};
|
|
}
|
|
|
|
.btn {
|
|
padding: 10px 20px;
|
|
border-radius: 6px;
|
|
font-size: 14px;
|
|
font-weight: 500;
|
|
cursor: pointer;
|
|
transition: all 0.15s ease;
|
|
}
|
|
|
|
.btn-primary {
|
|
background: #3b82f6;
|
|
color: white;
|
|
border: none;
|
|
}
|
|
|
|
.btn-primary:hover {
|
|
background: #2563eb;
|
|
}
|
|
|
|
.btn-secondary {
|
|
background: transparent;
|
|
color: ${cssManager.bdTheme('#666', '#999')};
|
|
border: 1px solid ${cssManager.bdTheme('#ddd', '#333')};
|
|
}
|
|
|
|
.btn-secondary:hover {
|
|
background: ${cssManager.bdTheme('#f5f5f5', '#1a1a1a')};
|
|
}
|
|
|
|
.btn-danger {
|
|
background: #ef4444;
|
|
color: white;
|
|
border: none;
|
|
}
|
|
|
|
.btn-danger:hover {
|
|
background: #dc2626;
|
|
}
|
|
|
|
.security-item {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
padding: 16px;
|
|
background: ${cssManager.bdTheme('#f9f9f9', '#0a0a0a')};
|
|
border-radius: 8px;
|
|
margin-bottom: 12px;
|
|
}
|
|
|
|
.security-item .info {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 4px;
|
|
}
|
|
|
|
.security-item .title {
|
|
font-weight: 500;
|
|
}
|
|
|
|
.security-item .status {
|
|
font-size: 13px;
|
|
color: ${cssManager.bdTheme('#666', '#888')};
|
|
}
|
|
|
|
.security-item .status.enabled {
|
|
color: #22c55e;
|
|
}
|
|
`,
|
|
];
|
|
|
|
private handleTabClick(tab: 'profile' | 'notifications' | 'security') {
|
|
this.activeTab = tab;
|
|
}
|
|
|
|
public render() {
|
|
return html`
|
|
<div class="settings-layout">
|
|
<div class="settings-header">
|
|
<h1>Settings</h1>
|
|
<p>Manage your account settings and preferences</p>
|
|
</div>
|
|
|
|
<div class="settings-content">
|
|
<nav class="settings-nav">
|
|
<div
|
|
class="nav-item ${this.activeTab === 'profile' ? 'active' : ''}"
|
|
@click=${() => this.handleTabClick('profile')}
|
|
>
|
|
Profile
|
|
</div>
|
|
<div
|
|
class="nav-item ${this.activeTab === 'notifications' ? 'active' : ''}"
|
|
@click=${() => this.handleTabClick('notifications')}
|
|
>
|
|
Notifications
|
|
</div>
|
|
<div
|
|
class="nav-item ${this.activeTab === 'security' ? 'active' : ''}"
|
|
@click=${() => this.handleTabClick('security')}
|
|
>
|
|
Security
|
|
</div>
|
|
</nav>
|
|
|
|
<div class="settings-panel">
|
|
${this.activeTab === 'profile' ? this.renderProfile() : null}
|
|
${this.activeTab === 'notifications' ? this.renderNotifications() : null}
|
|
${this.activeTab === 'security' ? this.renderSecurity() : null}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
`;
|
|
}
|
|
|
|
private renderProfile() {
|
|
return html`
|
|
<div class="panel-header">
|
|
<h2>Profile Information</h2>
|
|
<p>Update your personal details and email address</p>
|
|
</div>
|
|
|
|
<div class="form-row">
|
|
<div class="form-group">
|
|
<label>First Name</label>
|
|
<input type="text" value="John" />
|
|
</div>
|
|
<div class="form-group">
|
|
<label>Last Name</label>
|
|
<input type="text" value="Doe" />
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label>Email Address</label>
|
|
<input type="email" value="${this.userEmail}" />
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label>Bio</label>
|
|
<input type="text" placeholder="Tell us about yourself..." />
|
|
</div>
|
|
|
|
<div class="button-group">
|
|
<button class="btn btn-primary">Save Changes</button>
|
|
<button class="btn btn-secondary">Cancel</button>
|
|
</div>
|
|
`;
|
|
}
|
|
|
|
private renderNotifications() {
|
|
return html`
|
|
<div class="panel-header">
|
|
<h2>Notification Preferences</h2>
|
|
<p>Choose what notifications you want to receive</p>
|
|
</div>
|
|
|
|
<div class="toggle-group">
|
|
<div class="toggle-label">
|
|
<span class="title">Email Notifications</span>
|
|
<span class="description">Receive email updates about your account activity</span>
|
|
</div>
|
|
<div class="toggle active"></div>
|
|
</div>
|
|
|
|
<div class="toggle-group">
|
|
<div class="toggle-label">
|
|
<span class="title">Push Notifications</span>
|
|
<span class="description">Receive push notifications on your device</span>
|
|
</div>
|
|
<div class="toggle active"></div>
|
|
</div>
|
|
|
|
<div class="toggle-group">
|
|
<div class="toggle-label">
|
|
<span class="title">Weekly Digest</span>
|
|
<span class="description">Get a weekly summary of your activity</span>
|
|
</div>
|
|
<div class="toggle"></div>
|
|
</div>
|
|
|
|
<div class="toggle-group">
|
|
<div class="toggle-label">
|
|
<span class="title">Marketing Emails</span>
|
|
<span class="description">Receive tips, updates, and promotions</span>
|
|
</div>
|
|
<div class="toggle"></div>
|
|
</div>
|
|
|
|
<div class="button-group">
|
|
<button class="btn btn-primary">Save Preferences</button>
|
|
</div>
|
|
`;
|
|
}
|
|
|
|
private renderSecurity() {
|
|
return html`
|
|
<div class="panel-header">
|
|
<h2>Security Settings</h2>
|
|
<p>Manage your password and security options</p>
|
|
</div>
|
|
|
|
<div class="security-item">
|
|
<div class="info">
|
|
<span class="title">Password</span>
|
|
<span class="status">Last changed 30 days ago</span>
|
|
</div>
|
|
<button class="btn btn-secondary">Change Password</button>
|
|
</div>
|
|
|
|
<div class="security-item">
|
|
<div class="info">
|
|
<span class="title">Two-Factor Authentication</span>
|
|
<span class="status enabled">Enabled</span>
|
|
</div>
|
|
<button class="btn btn-secondary">Manage</button>
|
|
</div>
|
|
|
|
<div class="security-item">
|
|
<div class="info">
|
|
<span class="title">Active Sessions</span>
|
|
<span class="status">3 devices</span>
|
|
</div>
|
|
<button class="btn btn-secondary">View All</button>
|
|
</div>
|
|
|
|
<div class="button-group">
|
|
<button class="btn btn-danger">Delete Account</button>
|
|
</div>
|
|
`;
|
|
}
|
|
}
|