update
This commit is contained in:
@ -1,4 +1,4 @@
|
|||||||
import { html, css } from '@design.estate/dees-element';
|
import { html, css, cssManager } from '@design.estate/dees-element';
|
||||||
|
|
||||||
export const demoFunc = () => html`
|
export const demoFunc = () => html`
|
||||||
<dees-demowrapper>
|
<dees-demowrapper>
|
||||||
@ -7,10 +7,31 @@ export const demoFunc = () => html`
|
|||||||
.demo-container {
|
.demo-container {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 24px;
|
gap: 32px;
|
||||||
|
padding: 48px;
|
||||||
|
background: ${cssManager.bdTheme('#f8f9fa', '#0a0a0a')};
|
||||||
|
min-height: 100vh;
|
||||||
|
}
|
||||||
|
|
||||||
|
.section {
|
||||||
|
background: ${cssManager.bdTheme('#ffffff', '#18181b')};
|
||||||
|
border: 1px solid ${cssManager.bdTheme('#e5e7eb', '#27272a')};
|
||||||
|
border-radius: 8px;
|
||||||
padding: 24px;
|
padding: 24px;
|
||||||
max-width: 1200px;
|
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
||||||
margin: 0 auto;
|
}
|
||||||
|
|
||||||
|
.section-title {
|
||||||
|
font-size: 18px;
|
||||||
|
font-weight: 600;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
color: ${cssManager.bdTheme('#09090b', '#fafafa')};
|
||||||
|
}
|
||||||
|
|
||||||
|
.section-description {
|
||||||
|
font-size: 14px;
|
||||||
|
color: ${cssManager.bdTheme('#71717a', '#a1a1aa')};
|
||||||
|
margin-bottom: 24px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.settings-grid {
|
.settings-grid {
|
||||||
@ -28,7 +49,10 @@ export const demoFunc = () => html`
|
|||||||
</style>
|
</style>
|
||||||
|
|
||||||
<div class="demo-container">
|
<div class="demo-container">
|
||||||
<dees-panel .title=${'Multi-Option Toggle'} .subtitle=${'Select from multiple options with a sliding indicator'}>
|
<div class="section">
|
||||||
|
<div class="section-title">Multi-Option Toggle</div>
|
||||||
|
<div class="section-description">Select from multiple options with a smooth sliding indicator animation.</div>
|
||||||
|
|
||||||
<dees-input-multitoggle
|
<dees-input-multitoggle
|
||||||
.label=${'Display Mode'}
|
.label=${'Display Mode'}
|
||||||
.description=${'Choose how content is displayed'}
|
.description=${'Choose how content is displayed'}
|
||||||
@ -36,15 +60,20 @@ export const demoFunc = () => html`
|
|||||||
.selectedOption=${'Grid View'}
|
.selectedOption=${'Grid View'}
|
||||||
></dees-input-multitoggle>
|
></dees-input-multitoggle>
|
||||||
|
|
||||||
|
<br><br>
|
||||||
|
|
||||||
<dees-input-multitoggle
|
<dees-input-multitoggle
|
||||||
.label=${'T-Shirt Size'}
|
.label=${'T-Shirt Size'}
|
||||||
.description=${'Select your preferred size'}
|
.description=${'Select your preferred size'}
|
||||||
.options=${['XS', 'S', 'M', 'L', 'XL', 'XXL']}
|
.options=${['XS', 'S', 'M', 'L', 'XL', 'XXL']}
|
||||||
.selectedOption=${'M'}
|
.selectedOption=${'M'}
|
||||||
></dees-input-multitoggle>
|
></dees-input-multitoggle>
|
||||||
</dees-panel>
|
</div>
|
||||||
|
|
||||||
<dees-panel .title=${'Boolean Toggle'} .subtitle=${'Simple on/off switches with custom labels'}>
|
<div class="section">
|
||||||
|
<div class="section-title">Boolean Toggle</div>
|
||||||
|
<div class="section-description">Simple on/off switches with customizable labels for clearer context.</div>
|
||||||
|
|
||||||
<dees-input-multitoggle
|
<dees-input-multitoggle
|
||||||
.label=${'Notifications'}
|
.label=${'Notifications'}
|
||||||
.description=${'Enable or disable push notifications'}
|
.description=${'Enable or disable push notifications'}
|
||||||
@ -52,6 +81,8 @@ export const demoFunc = () => html`
|
|||||||
.selectedOption=${'true'}
|
.selectedOption=${'true'}
|
||||||
></dees-input-multitoggle>
|
></dees-input-multitoggle>
|
||||||
|
|
||||||
|
<br><br>
|
||||||
|
|
||||||
<dees-input-multitoggle
|
<dees-input-multitoggle
|
||||||
.label=${'Theme Mode'}
|
.label=${'Theme Mode'}
|
||||||
.description=${'Switch between light and dark theme'}
|
.description=${'Switch between light and dark theme'}
|
||||||
@ -60,13 +91,15 @@ export const demoFunc = () => html`
|
|||||||
.booleanFalseName=${'Light'}
|
.booleanFalseName=${'Light'}
|
||||||
.selectedOption=${'Dark'}
|
.selectedOption=${'Dark'}
|
||||||
></dees-input-multitoggle>
|
></dees-input-multitoggle>
|
||||||
</dees-panel>
|
</div>
|
||||||
|
|
||||||
<dees-panel .title=${'Settings Panel'} .subtitle=${'Configuration options in a horizontal layout'}>
|
<div class="section">
|
||||||
|
<div class="section-title">Settings Grid</div>
|
||||||
|
<div class="section-description">Configuration options arranged in a responsive grid layout.</div>
|
||||||
|
|
||||||
<div class="settings-grid">
|
<div class="settings-grid">
|
||||||
<dees-input-multitoggle
|
<dees-input-multitoggle
|
||||||
.label=${'Auto-Save'}
|
.label=${'Auto-Save'}
|
||||||
.layoutMode=${'horizontal'}
|
|
||||||
.type=${'boolean'}
|
.type=${'boolean'}
|
||||||
.booleanTrueName=${'Enabled'}
|
.booleanTrueName=${'Enabled'}
|
||||||
.booleanFalseName=${'Disabled'}
|
.booleanFalseName=${'Disabled'}
|
||||||
@ -75,30 +108,30 @@ export const demoFunc = () => html`
|
|||||||
|
|
||||||
<dees-input-multitoggle
|
<dees-input-multitoggle
|
||||||
.label=${'Language'}
|
.label=${'Language'}
|
||||||
.layoutMode=${'horizontal'}
|
|
||||||
.options=${['English', 'German', 'French', 'Spanish']}
|
.options=${['English', 'German', 'French', 'Spanish']}
|
||||||
.selectedOption=${'English'}
|
.selectedOption=${'English'}
|
||||||
></dees-input-multitoggle>
|
></dees-input-multitoggle>
|
||||||
|
|
||||||
<dees-input-multitoggle
|
<dees-input-multitoggle
|
||||||
.label=${'Quality'}
|
.label=${'Quality'}
|
||||||
.layoutMode=${'horizontal'}
|
|
||||||
.options=${['Low', 'Medium', 'High', 'Ultra']}
|
.options=${['Low', 'Medium', 'High', 'Ultra']}
|
||||||
.selectedOption=${'High'}
|
.selectedOption=${'High'}
|
||||||
></dees-input-multitoggle>
|
></dees-input-multitoggle>
|
||||||
|
|
||||||
<dees-input-multitoggle
|
<dees-input-multitoggle
|
||||||
.label=${'Privacy'}
|
.label=${'Privacy'}
|
||||||
.layoutMode=${'horizontal'}
|
|
||||||
.type=${'boolean'}
|
.type=${'boolean'}
|
||||||
.booleanTrueName=${'Private'}
|
.booleanTrueName=${'Private'}
|
||||||
.booleanFalseName=${'Public'}
|
.booleanFalseName=${'Public'}
|
||||||
.selectedOption=${'Private'}
|
.selectedOption=${'Private'}
|
||||||
></dees-input-multitoggle>
|
></dees-input-multitoggle>
|
||||||
</div>
|
</div>
|
||||||
</dees-panel>
|
</div>
|
||||||
|
|
||||||
<dees-panel .title=${'States & Form Integration'} .subtitle=${'Disabled states and form usage'}>
|
<div class="section">
|
||||||
|
<div class="section-title">States & Form Integration</div>
|
||||||
|
<div class="section-description">Examples of disabled states and integration within forms.</div>
|
||||||
|
|
||||||
<dees-input-multitoggle
|
<dees-input-multitoggle
|
||||||
.label=${'Account Type'}
|
.label=${'Account Type'}
|
||||||
.description=${'This setting is locked'}
|
.description=${'This setting is locked'}
|
||||||
@ -107,6 +140,8 @@ export const demoFunc = () => html`
|
|||||||
.disabled=${true}
|
.disabled=${true}
|
||||||
></dees-input-multitoggle>
|
></dees-input-multitoggle>
|
||||||
|
|
||||||
|
<br><br>
|
||||||
|
|
||||||
<dees-form>
|
<dees-form>
|
||||||
<dees-input-text .label=${'Project Name'} .required=${true}></dees-input-text>
|
<dees-input-text .label=${'Project Name'} .required=${true}></dees-input-text>
|
||||||
<dees-input-multitoggle
|
<dees-input-multitoggle
|
||||||
@ -122,7 +157,7 @@ export const demoFunc = () => html`
|
|||||||
.selectedOption=${'MIT'}
|
.selectedOption=${'MIT'}
|
||||||
></dees-input-multitoggle>
|
></dees-input-multitoggle>
|
||||||
</dees-form>
|
</dees-form>
|
||||||
</dees-panel>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</dees-demowrapper>
|
</dees-demowrapper>
|
||||||
`;
|
`;
|
@ -57,9 +57,12 @@ export class DeesInputMultitoggle extends DeesInputBase<DeesInputMultitoggle> {
|
|||||||
} else {
|
} else {
|
||||||
this.selectedOption = val as string;
|
this.selectedOption = val as string;
|
||||||
}
|
}
|
||||||
|
this.requestUpdate();
|
||||||
// Defer indicator update to next frame if component not yet updated
|
// Defer indicator update to next frame if component not yet updated
|
||||||
if (this.hasUpdated) {
|
if (this.hasUpdated) {
|
||||||
this.setIndicator();
|
requestAnimationFrame(() => {
|
||||||
|
this.setIndicator();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,59 +71,71 @@ export class DeesInputMultitoggle extends DeesInputBase<DeesInputMultitoggle> {
|
|||||||
cssManager.defaultStyles,
|
cssManager.defaultStyles,
|
||||||
css`
|
css`
|
||||||
:host {
|
:host {
|
||||||
color: ${cssManager.bdTheme('#333', '#ccc')};
|
color: ${cssManager.bdTheme('#09090b', '#fafafa')};
|
||||||
user-select: none;
|
user-select: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.selections {
|
.selections {
|
||||||
position: relative;
|
position: relative;
|
||||||
display: flex;
|
display: inline-flex;
|
||||||
flex-direction: row;
|
align-items: center;
|
||||||
flex-wrap: nowrap;
|
background: ${cssManager.bdTheme('#ffffff', '#18181b')};
|
||||||
background: ${cssManager.bdTheme('#fff', '#222')};
|
border: 1px solid ${cssManager.bdTheme('#e5e7eb', '#27272a')};
|
||||||
width: min-content;
|
padding: 4px;
|
||||||
border-radius: 20px;
|
border-radius: 8px;
|
||||||
height: 32px;
|
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
|
||||||
border-top: 1px solid ${cssManager.bdTheme('rgba(0,0,0,0.1)', 'rgba(255,255,255,0.1)')};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.option {
|
.option {
|
||||||
color: ${cssManager.bdTheme('#666', '#999')};
|
|
||||||
position: relative;
|
position: relative;
|
||||||
padding: 0px 16px;
|
padding: 8px 20px;
|
||||||
line-height: 32px;
|
border-radius: 6px;
|
||||||
cursor: default;
|
cursor: pointer;
|
||||||
width: min-content; /* Make the width as per the content */
|
white-space: nowrap;
|
||||||
white-space: nowrap; /* Prevent text wrapping */
|
transition: color 0.2s ease;
|
||||||
transition: all 0.1s;
|
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
transform: translateY(-1px);
|
font-weight: 500;
|
||||||
|
color: ${cssManager.bdTheme('#71717a', '#71717a')};
|
||||||
|
line-height: 1;
|
||||||
|
z-index: 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
.option:hover {
|
.option:hover {
|
||||||
color: ${cssManager.bdTheme('#333', '#fff')};
|
color: ${cssManager.bdTheme('#18181b', '#e4e4e7')};
|
||||||
}
|
}
|
||||||
|
|
||||||
.option.selected {
|
.option.selected {
|
||||||
color: ${cssManager.bdTheme('#fff', '#fff')};
|
color: ${cssManager.bdTheme('#3b82f6', '#60a5fa')};
|
||||||
}
|
}
|
||||||
|
|
||||||
.indicator {
|
.indicator {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
height: 24px;
|
height: calc(100% - 8px);
|
||||||
left: 4px;
|
top: 4px;
|
||||||
top: 3px;
|
border-radius: 6px;
|
||||||
border-radius: 16px;
|
background: ${cssManager.bdTheme('rgba(59, 130, 246, 0.15)', 'rgba(59, 130, 246, 0.15)')};
|
||||||
background: ${cssManager.bdTheme(colors.bright.blueActive, colors.dark.blueActive)};
|
transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
|
||||||
min-width: 24px;
|
z-index: 1;
|
||||||
transition: all 0.1s ease-in-out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.indicator.no-transition {
|
.indicator.no-transition {
|
||||||
transition: none;
|
transition: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
:host([disabled]) .selections {
|
||||||
|
opacity: 0.5;
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
|
||||||
|
:host([disabled]) .option {
|
||||||
|
cursor: not-allowed;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
:host([disabled]) .indicator {
|
||||||
|
background: ${cssManager.bdTheme('rgba(113, 113, 122, 0.15)', 'rgba(113, 113, 122, 0.15)')};
|
||||||
|
}
|
||||||
`,
|
`,
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -165,10 +180,14 @@ export class DeesInputMultitoggle extends DeesInputBase<DeesInputMultitoggle> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async handleSelection(optionArg: string) {
|
public async handleSelection(optionArg: string) {
|
||||||
|
if (this.disabled) return;
|
||||||
this.selectedOption = optionArg;
|
this.selectedOption = optionArg;
|
||||||
|
this.requestUpdate();
|
||||||
|
this.changeSubject.next(this);
|
||||||
|
await this.updateComplete;
|
||||||
this.setIndicator();
|
this.setIndicator();
|
||||||
}
|
}
|
||||||
|
|
||||||
private indicatorInitialized = false;
|
private indicatorInitialized = false;
|
||||||
|
|
||||||
public async setIndicator() {
|
public async setIndicator() {
|
||||||
@ -199,8 +218,8 @@ export class DeesInputMultitoggle extends DeesInputBase<DeesInputMultitoggle> {
|
|||||||
}, 50);
|
}, 50);
|
||||||
}
|
}
|
||||||
|
|
||||||
indicator.style.width = `${option.clientWidth - 8}px`;
|
indicator.style.width = `${option.clientWidth}px`;
|
||||||
indicator.style.left = `${option.offsetLeft + 4}px`;
|
indicator.style.left = `${option.offsetLeft}px`;
|
||||||
indicator.style.opacity = '1';
|
indicator.style.opacity = '1';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -218,8 +237,11 @@ export class DeesInputMultitoggle extends DeesInputBase<DeesInputMultitoggle> {
|
|||||||
} else {
|
} else {
|
||||||
this.selectedOption = value as string;
|
this.selectedOption = value as string;
|
||||||
}
|
}
|
||||||
|
this.requestUpdate();
|
||||||
if (this.hasUpdated) {
|
if (this.hasUpdated) {
|
||||||
this.setIndicator();
|
requestAnimationFrame(() => {
|
||||||
|
this.setIndicator();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user