mirror of
https://github.com/shoelace-style/webawesome.git
synced 2026-01-19 23:44:15 +00:00
Compare commits
2 Commits
native-cod
...
base
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9328feed19 | ||
|
|
2542354d5c |
@@ -1,14 +1,6 @@
|
|||||||
:host {
|
:host {
|
||||||
color: var(--wa-color-text-link);
|
color: var(--wa-color-text-link);
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
}
|
|
||||||
|
|
||||||
:host(:last-of-type) {
|
|
||||||
color: var(--wa-color-text-quiet);
|
|
||||||
}
|
|
||||||
|
|
||||||
.breadcrumb-item {
|
|
||||||
display: inline-flex;
|
|
||||||
align-items: center;
|
align-items: center;
|
||||||
font: inherit;
|
font: inherit;
|
||||||
font-weight: var(--wa-font-weight-action);
|
font-weight: var(--wa-font-weight-action);
|
||||||
@@ -16,6 +8,10 @@
|
|||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
:host(:last-of-type) {
|
||||||
|
color: var(--wa-color-text-quiet);
|
||||||
|
}
|
||||||
|
|
||||||
.label {
|
.label {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
font: inherit;
|
font: inherit;
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ import styles from './breadcrumb-item.css';
|
|||||||
* @slot separator - The separator to use for the breadcrumb item. This will only change the separator for this item. If
|
* @slot separator - The separator to use for the breadcrumb item. This will only change the separator for this item. If
|
||||||
* you want to change it for all items in the group, set the separator on `<wa-breadcrumb>` instead.
|
* you want to change it for all items in the group, set the separator on `<wa-breadcrumb>` instead.
|
||||||
*
|
*
|
||||||
* @csspart base - The component's base wrapper.
|
|
||||||
* @csspart label - The breadcrumb item's label.
|
* @csspart label - The breadcrumb item's label.
|
||||||
* @csspart prefix - The container that wraps the prefix.
|
* @csspart prefix - The container that wraps the prefix.
|
||||||
* @csspart suffix - The container that wraps the suffix.
|
* @csspart suffix - The container that wraps the suffix.
|
||||||
@@ -72,7 +71,6 @@ export default class WaBreadcrumbItem extends WebAwesomeElement {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
return html`
|
return html`
|
||||||
<div part="base" class="breadcrumb-item">
|
|
||||||
<span part="prefix" class="prefix">
|
<span part="prefix" class="prefix">
|
||||||
<slot name="prefix"></slot>
|
<slot name="prefix"></slot>
|
||||||
</span>
|
</span>
|
||||||
@@ -112,7 +110,6 @@ export default class WaBreadcrumbItem extends WebAwesomeElement {
|
|||||||
<span part="separator" class="separator" aria-hidden="true">
|
<span part="separator" class="separator" aria-hidden="true">
|
||||||
<slot name="separator"></slot>
|
<slot name="separator"></slot>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,9 +6,6 @@
|
|||||||
|
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
|
||||||
|
|
||||||
.image-comparer {
|
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
max-height: 100%;
|
max-height: 100%;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ import styles from './image-comparer.css';
|
|||||||
*
|
*
|
||||||
* @event change - Emitted when the position changes.
|
* @event change - Emitted when the position changes.
|
||||||
*
|
*
|
||||||
* @csspart base - The component's base wrapper.
|
|
||||||
* @csspart before - The container that wraps the before image.
|
* @csspart before - The container that wraps the before image.
|
||||||
* @csspart after - The container that wraps the after image.
|
* @csspart after - The container that wraps the after image.
|
||||||
* @csspart divider - The divider that separates the images.
|
* @csspart divider - The divider that separates the images.
|
||||||
@@ -40,19 +39,18 @@ export default class WaImageComparer extends WebAwesomeElement {
|
|||||||
|
|
||||||
private readonly localize = new LocalizeController(this);
|
private readonly localize = new LocalizeController(this);
|
||||||
|
|
||||||
@query('.image-comparer') base: HTMLElement;
|
|
||||||
@query('.handle') handle: HTMLElement;
|
@query('.handle') handle: HTMLElement;
|
||||||
|
|
||||||
/** The position of the divider as a percentage. */
|
/** The position of the divider as a percentage. */
|
||||||
@property({ type: Number, reflect: true }) position = 50;
|
@property({ type: Number, reflect: true }) position = 50;
|
||||||
|
|
||||||
private handleDrag(event: PointerEvent) {
|
private handleDrag(event: PointerEvent) {
|
||||||
const { width } = this.base.getBoundingClientRect();
|
const { width } = this.getBoundingClientRect();
|
||||||
const isRtl = this.localize.dir() === 'rtl';
|
const isRtl = this.localize.dir() === 'rtl';
|
||||||
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
drag(this.base, {
|
drag(this, {
|
||||||
onMove: x => {
|
onMove: x => {
|
||||||
this.position = parseFloat(clamp((x / width) * 100, 0, 100).toFixed(2));
|
this.position = parseFloat(clamp((x / width) * 100, 0, 100).toFixed(2));
|
||||||
if (isRtl) this.position = 100 - this.position;
|
if (isRtl) this.position = 100 - this.position;
|
||||||
@@ -98,7 +96,6 @@ export default class WaImageComparer extends WebAwesomeElement {
|
|||||||
const isRtl = this.hasUpdated ? this.localize.dir() === 'rtl' : this.dir === 'rtl';
|
const isRtl = this.hasUpdated ? this.localize.dir() === 'rtl' : this.dir === 'rtl';
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<div part="base" id="image-comparer" class="image-comparer" @keydown=${this.handleKeyDown}>
|
|
||||||
<div class="image">
|
<div class="image">
|
||||||
<div part="before" class="before">
|
<div part="before" class="before">
|
||||||
<slot name="before"></slot>
|
<slot name="before"></slot>
|
||||||
@@ -121,6 +118,7 @@ export default class WaImageComparer extends WebAwesomeElement {
|
|||||||
style=${styleMap({
|
style=${styleMap({
|
||||||
left: isRtl ? `${100 - this.position}%` : `${this.position}%`,
|
left: isRtl ? `${100 - this.position}%` : `${this.position}%`,
|
||||||
})}
|
})}
|
||||||
|
@keydown=${this.handleKeyDown}
|
||||||
@mousedown=${this.handleDrag}
|
@mousedown=${this.handleDrag}
|
||||||
@touchstart=${this.handleDrag}
|
@touchstart=${this.handleDrag}
|
||||||
>
|
>
|
||||||
@@ -139,7 +137,6 @@ export default class WaImageComparer extends WebAwesomeElement {
|
|||||||
</slot>
|
</slot>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user